Plugin for OpenMCT to monitor a Tango Controls system
cd docker-compose
docker network create tango
docker compose -f tango-db.yml -f tango-test.yml -f tangogql.yml up
The Graphql endpoint should be available at: http://localhost:5004/db.
# Query a device
query {
devices(pattern: "sys/tg_test/1") {
attributes(pattern: "*") {
name
}
name
state
connected
alias
deviceClass
pid
startedDate
stoppedDate
exported
}
}
# .. Or explore the schema and types
query {
schema: __schema {
types {
name
}
}
subscriptionFields: __type(name: "Subscription") {
fields {
name
}
}
queryFields: __type(name: "Query") {
fields {
name
}
}
}
For example, to consume the GraphQL API open a website and in the console:
const socket = new WebSocket('ws://127.0.0.1:5004/socket', "graphql-ws")
socket.onmessage = function (event) {
const parsed_data = JSON.parse(event.data)
const point = {
value: parsed_data.payload.data.attributes.value,
timestamp: parsed_data.payload.data.attributes.timestamp * 1000,
id: 'sys.tg_test.1.double_scalar',
}
console.log(point)
}
const gqlSubscriptionQuery =
'{ "type": "start", "payload": { "query": "subscription Attributes($fullNames: [String]!) { attributes(fullNames: $fullNames) { device attribute value writeValue timestamp }}", "variables": { "fullNames": ["sys/tg_test/1/double_scalar"] } } }'
socket.onopen = () => socket.send(gqlSubscriptionQuery)
// You should see logs something like
{ "value": 232.01497690132726, "timestamp": 1715785846038.907, "id": "sys.tg_test.1.double_scalar" }
Follow the instructions from https://github.com/nasa/openmct.
Add the following lines
...
+openmct.install(openmct.plugins.TangoTree());
+openmct.install(openmct.plugins.TangoData());
document.addEventListener('DOMContentLoaded', function () {
openmct.start();
});
...
...
import WebPagePlugin from './webPage/plugin.js';
+import TangoTreePlugin from '../../../tango_plugin/TangoTreePlugin.js';
+import TangoDataPlugin from '../../../tango_plugin/TangoDataPlugin.js';
const plugins = {};
...
+plugins.TangoTree = TangoTreePlugin;
+plugins.TangoData = TangoDataPlugin
export default plugins;
npm start
Browse to http://localhost:8080/