Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help needed with Object Provider and Object composer. #34

Open
rivermoon21 opened this issue Jan 25, 2019 · 0 comments
Open

Help needed with Object Provider and Object composer. #34

rivermoon21 opened this issue Jan 25, 2019 · 0 comments

Comments

@rivermoon21
Copy link

Hello, I am trying to build and display an object that has a root folder, subsystems, and the subsystem's data point. However, when I try in the code, the subsystems appear repeatedly every time [as shown in pic].
objectproviderinfinite

Can you guys help me figure out what I need to add to my Object Provider or Composition provider? I thought it would display it by adding the 'telemetry' argument

here is my json file (similar to tutorial found online):

 {
        "name": "Spacecraft",
        "type": 'folder',
        "namespace": "public.namespace",
        "key": "sc",
        "subsystems": [
             {
                 "name": "Propulsion",
                 "key": "prop",
                 "namespace": "public.namespace",
                 "measurements": [
                     {
                         "name": "Fuel",
                         "key": "prop.fuel",
                         "units": "kilograms",
                         "type": "float",
                     },
                     {
                         "name": "Thrusters",
                         "key": "prop.thrusters",
                         "units": "None",
                         "type": "string",
                     }
                 ]
             },
             {
                 "name": "Communications",
                 "key": "comms",
                 "namespace": "public.namespace",
                 "measurements": [
                     {
                         "name": "Received",
                         "key": "comms.recd",
                         "units": "bytes",
                         "type": "integer",
                     },
                     {
                         "name": "Sent",
                         "key": "comms.sent",
                         "units": "bytes",
                         "type": "integer",
                     }
                 ]
             },
             {
                 "name": "Power",
                 "key": "pwr",
                 "namespace": "public.namespace",
                 "measurements": [
                     {
                         "name": "Generator Temperature",
                         "key": "pwr.temp",
                         "units": "\u0080C",
                         "type": "float",
                     },
                     {
                         "name": "Generator Current",
                         "key": "pwr.c",
                         "units": "A",
                         "type": "float",
                     },
                     {
                         "name": "Generator Voltage",
                         "key": "pwr.v",
                         "units": "V",
                         "type": "float",
                     }
                 ]
             }
        ]
     }

And Object Provider:

        openmct.objects.addProvider('public.namespace', {
            get: function (identifier) {
                 return objectPromise.then(function(data) {
                    if(identifier.key === 'my-root-major-key')
                    {
                       return{
                          identifier: identifier,
                          name: data.name,
                          type: data.type,
                       }
                    }
                    else {
                       var measurement = data.subsystems.filter(function (m) {
                             return m.key === identifier.key;
                       })[0];
                       // include subsystem name
                       if (!measurement.key.toString().includes('.')) {
                          return {
                             identifier: identifier,
                             name: measurement.name,
                             type: 'folder',
                             telemetry: {
                                 values: measurement.measurements,
                                 type: 'example.telemetry',
                                 key: ''
                             },
                             location: 'public.namespace:my-root-major-key:'
                          };
                       }
                    }
                 });
            }
        });

And Composition Provider:

        openmct.composition.addProvider({
            appliesTo: function (domainObject) {
               return domainObject.identifier.namespace === 'public.namespace' &&
                    domainObject.type === 'folder';
            },
            load: function (domainObject) {
                return objectPromise.then(function (data) {
                        return data.subsystems.map(function (m) {
                            return {
                                namespace: 'public.namespace',
                                key: m.key,
                            };
                        });
                    });
            }
        });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant