Skip to content

SKAJohanVenter/tangomct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tangomct

Plugin for OpenMCT to monitor a Tango Controls system

Development

Start a tango controls test environment

cd docker-compose
docker network create tango
docker compose -f tango-db.yml  -f  tango-test.yml -f tangogql.yml  up

GraphiQL

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
    }
  }
}

Subscribe to a Tango attribute

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" }

Open MCT (TODO)

Follow the instructions from https://github.com/nasa/openmct.

Install the plugins

Update index.html

Add the following lines

...
+openmct.install(openmct.plugins.TangoTree());
+openmct.install(openmct.plugins.TangoData());
document.addEventListener('DOMContentLoaded', function () {
  openmct.start();
});
...

Update src/plugins/plugins.js

...
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;

Run the server

npm start

Browse to http://localhost:8080/

About

Plugin for OpenMCT to graph Tango Controls

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •