Open Telemetry Provider
Simple and easy telemetry provider write in Go to use with NASA OpenMCT
Install
go get -u github.com/crgimenes/otp
OpenMPT is undergoing many changes. At the moment our code works with the last version before the API change.
git clone https://github.com/nasa/openmct.git
git checkout 156ba832f2da3c219f65f86198fb228557566449
Example
Taxonomy dictionary file dictionary.json
{
"name": "OTP",
"identifier": "board",
"subsystems": [
{
"name": "Power",
"identifier": "pwr",
"measurements": [
{
"name": "Voltage",
"identifier": "pwr.v",
"units": "V",
"type": "float"
}
]
}
]
}
App example
package main
import (
"fmt"
"log"
"math"
"os"
"os/signal"
otp "github.com/crgimenes/otp"
)
func main() {
go func() {
sc := make(chan os.Signal, 1)
signal.Notify(sc, os.Interrupt)
<-sc
// close all connections
otp.CloseAll()
fmt.Print("\n")
log.Println("Have a nice day!")
os.Exit(0)
}()
otp.LoadTaxonomyDictionaryFromFile("./dictionary.json")
otp.SubsystemHandleFunc("pwr.v", pwrvFunc)
otp.ListenAndServe(8081, 1000)
}
var x float64
func pwrvFunc() {
x += 0.01
y := math.Sin(x) * (x / 2.0 * math.Pi)
otp.SetDataValue("pwr.v", otp.MakeTimestamp(), y)
}
Contributing
- Fork the repo on GitHub
- Clone the project to your own machine
- Create a branch with your modifications
git checkout -b fantastic-feature
. - Then commit your changes
git commit -m 'Implementation of new fantastic feature'
- Make a push to your branch
git push origin fantastic-feature
. - Submit a Pull Request so that we can review your changes