mirror of
https://github.com/nasa/openmct.git
synced 2025-06-26 19:12:02 +00:00
Compare commits
1 Commits
eval-sourc
...
open1425
Author | SHA1 | Date | |
---|---|---|---|
b5332c0df9 |
@ -191,12 +191,13 @@ has been finalized.
|
|||||||
[
|
[
|
||||||
'example/imagery',
|
'example/imagery',
|
||||||
'example/eventGenerator',
|
'example/eventGenerator',
|
||||||
'example/generator',
|
'example/generator'
|
||||||
'platform/features/my-items',
|
|
||||||
'platform/persistence/local'
|
|
||||||
].forEach(
|
].forEach(
|
||||||
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
||||||
);
|
);
|
||||||
|
openmct.install(openmct.plugins.myItems);
|
||||||
|
openmct.install(openmct.plugins.localStorage);
|
||||||
|
openmct.install(openmct.plugins.espresso);
|
||||||
openmct.start();
|
openmct.start();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -214,6 +215,7 @@ has been finalized.
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
__index.html__
|
__index.html__
|
||||||
|
|
||||||
@ -258,12 +260,13 @@ __index.html__
|
|||||||
'example/imagery',
|
'example/imagery',
|
||||||
'example/eventGenerator',
|
'example/eventGenerator',
|
||||||
'example/generator',
|
'example/generator',
|
||||||
'platform/features/my-items',
|
|
||||||
'platform/persistence/local',
|
|
||||||
+ 'tutorials/todo'
|
+ 'tutorials/todo'
|
||||||
].forEach(
|
].forEach(
|
||||||
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
||||||
);
|
);
|
||||||
|
openmct.install(openmct.plugins.myItems);
|
||||||
|
openmct.install(openmct.plugins.localStorage);
|
||||||
|
openmct.install(openmct.plugins.espresso);
|
||||||
openmct.start();
|
openmct.start();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -280,7 +283,6 @@ __index.html__
|
|||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
```
|
```
|
||||||
__index.html__
|
__index.html__
|
||||||
|
|
||||||
@ -2392,12 +2394,13 @@ If we include this in our set of active bundles:
|
|||||||
'example/imagery',
|
'example/imagery',
|
||||||
'example/eventGenerator',
|
'example/eventGenerator',
|
||||||
'example/generator',
|
'example/generator',
|
||||||
'platform/features/my-items',
|
|
||||||
'platform/persistence/local',
|
|
||||||
'tutorials/telemetry'
|
'tutorials/telemetry'
|
||||||
].forEach(
|
].forEach(
|
||||||
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
|
||||||
);
|
);
|
||||||
|
openmct.install(openmct.plugins.myItems);
|
||||||
|
openmct.install(openmct.plugins.localStorage);
|
||||||
|
openmct.install(openmct.plugins.espresso);
|
||||||
openmct.start();
|
openmct.start();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -2415,6 +2418,7 @@ If we include this in our set of active bundles:
|
|||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
__index.html__
|
__index.html__
|
||||||
|
|
||||||
@ -2618,69 +2622,65 @@ again later in Steps 3 and 4.
|
|||||||
|
|
||||||
This allows our telemetry dictionary to be expressed as domain object models
|
This allows our telemetry dictionary to be expressed as domain object models
|
||||||
(and, in turn, as domain objects), but these objects still aren't reachable. To
|
(and, in turn, as domain objects), but these objects still aren't reachable. To
|
||||||
fix this, we will need another script which will add these subsystems to the
|
fix this, we will need another script which will expose these subsystems from the
|
||||||
root-level object we added in Step 1.
|
root-level object we added in Step 1.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
function () {
|
[
|
||||||
"use strict";
|
'../../../src/api/composition/DefaultCompositionProvider',
|
||||||
|
'../../../src/api/objects/object-utils'
|
||||||
|
],
|
||||||
|
function (
|
||||||
|
DefaultCompositionProvider,
|
||||||
|
objectUtils
|
||||||
|
) {
|
||||||
|
var TAXONOMY_SPACE = "example",
|
||||||
|
TAXONOMY_KEY = "sc",
|
||||||
|
SUBSYSTEM_SPACE = "example_tlm";
|
||||||
|
|
||||||
var TAXONOMY_ID = "example:sc",
|
function ExampleTelemetryCompositionProvider(openmct) {
|
||||||
PREFIX = "example_tlm:";
|
this.openmct = openmct;
|
||||||
|
DefaultCompositionProvider.call(this, openmct);
|
||||||
function ExampleTelemetryInitializer(adapter, objectService) {
|
|
||||||
// Generate a domain object identifier for a dictionary element
|
|
||||||
function makeId(element) {
|
|
||||||
return PREFIX + element.identifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// When the dictionary is available, add all subsystems
|
ExampleTelemetryCompositionProvider.prototype = Object.create(DefaultCompositionProvider.prototype);
|
||||||
// to the composition of My Spacecraft
|
|
||||||
function initializeTaxonomy(dictionary) {
|
|
||||||
// Get the top-level container for dictionary objects
|
|
||||||
// from a group of domain objects.
|
|
||||||
function getTaxonomyObject(domainObjects) {
|
|
||||||
return domainObjects[TAXONOMY_ID];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate
|
ExampleTelemetryCompositionProvider.prototype.appliesTo = function (domainObject) {
|
||||||
function populateModel(taxonomyObject) {
|
return domainObject.identifier &&
|
||||||
return taxonomyObject.useCapability(
|
domainObject.identifier.namespace === TAXONOMY_SPACE &&
|
||||||
"mutation",
|
domainObject.identifier.key === TAXONOMY_KEY;
|
||||||
function (model) {
|
};
|
||||||
model.name =
|
|
||||||
dictionary.name;
|
|
||||||
model.composition =
|
|
||||||
dictionary.subsystems.map(makeId);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look up My Spacecraft, and populate it accordingly.
|
ExampleTelemetryCompositionProvider.prototype.load = function (domainObject) {
|
||||||
objectService.getObjects([TAXONOMY_ID])
|
var adapter = this.openmct.$injector.get('example.adapter');
|
||||||
.then(getTaxonomyObject)
|
function makeId(subsystem) {
|
||||||
.then(populateModel);
|
return objectUtils.parseKeyString(SUBSYSTEM_SPACE + ":" + subsystem.identifier);
|
||||||
}
|
}
|
||||||
|
return adapter.dictionary().then(function (dictionary) {
|
||||||
|
return dictionary.subsystems.map(makeId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
adapter.dictionary().then(initializeTaxonomy);
|
return ExampleTelemetryCompositionProvider;
|
||||||
}
|
|
||||||
|
|
||||||
return ExampleTelemetryInitializer;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
```
|
|
||||||
__tutorials/telemetry/src/ExampleTelemetryInitializer.js__
|
|
||||||
|
|
||||||
At the conclusion of Step 1, the top-level My Spacecraft object was empty. This
|
```
|
||||||
script will wait for the dictionary to be loaded, then load My Spacecraft (by
|
__tutorials/telemetry/src/ExampleTelemetryCompositionProvider.js__
|
||||||
its identifier), and "mutate" it. The `mutation` capability allows changes to be
|
|
||||||
made to a domain object's model. Here, we take this top-level object, update its
|
At the conclusion of Step 1, the top-level My Spacecraft object was empty. Here
|
||||||
name to match what was in the dictionary, and set its `composition` to an array
|
we define a composition provider that allows an object to provide a list of
|
||||||
of domain object identifiers for all subsystems contained in the dictionary
|
its children asynchronously. The children are represented with an array of their
|
||||||
(using the same identifier prefix as before.)
|
identifiers.
|
||||||
|
|
||||||
|
You may notice that the code snippet below, the method of registering a composition
|
||||||
|
provider is a little different to the other components defined in these tutorials.
|
||||||
|
The registration mechanism for Composition Providers reflects [changes to our API that are currently underway](https://github.com/nasa/openmct#new-api).
|
||||||
|
More details will be available about Composition Providers and other aspects of
|
||||||
|
our new API in the near future.
|
||||||
|
|
||||||
Finally, we wire in these changes by modifying our plugin's `bundle.js` to
|
Finally, we wire in these changes by modifying our plugin's `bundle.js` to
|
||||||
provide metadata about how these pieces interact (both with each other, and
|
provide metadata about how these pieces interact (both with each other, and
|
||||||
@ -2690,12 +2690,12 @@ with the platform):
|
|||||||
define([
|
define([
|
||||||
'openmct',
|
'openmct',
|
||||||
+ './src/ExampleTelemetryServerAdapter',
|
+ './src/ExampleTelemetryServerAdapter',
|
||||||
+ './src/ExampleTelemetryInitializer',
|
+ './src/ExampleTelemetryCompositionProvider',
|
||||||
+ './src/ExampleTelemetryModelProvider'
|
+ './src/ExampleTelemetryModelProvider'
|
||||||
], function (
|
], function (
|
||||||
openmct,
|
openmct,
|
||||||
+ ExampleTelemetryServerAdapter,
|
+ ExampleTelemetryServerAdapter,
|
||||||
+ ExampleTelemetryInitializer,
|
+ ExampleTelemetryCompositionProvider,
|
||||||
+ ExampleTelemetryModelProvider
|
+ ExampleTelemetryModelProvider
|
||||||
) {
|
) {
|
||||||
openmct.legacyRegistry.register("tutorials/telemetry", {
|
openmct.legacyRegistry.register("tutorials/telemetry", {
|
||||||
@ -2760,12 +2760,6 @@ define([
|
|||||||
+ "value": "ws://localhost:8081"
|
+ "value": "ws://localhost:8081"
|
||||||
+ }
|
+ }
|
||||||
+ ],
|
+ ],
|
||||||
+ "runs": [
|
|
||||||
+ {
|
|
||||||
+ "implementation": ExampleTelemetryInitializer,
|
|
||||||
+ "depends": [ "example.adapter", "objectService" ]
|
|
||||||
+ }
|
|
||||||
+ ],
|
|
||||||
+ "components": [
|
+ "components": [
|
||||||
+ {
|
+ {
|
||||||
+ "provides": "modelService",
|
+ "provides": "modelService",
|
||||||
@ -2776,6 +2770,7 @@ define([
|
|||||||
+ ]
|
+ ]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
+ openmct.composition.addProvider(new ExampleTelemetryCompositionProvider(openmct));
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
__tutorials/telemetry/bundle.js__
|
__tutorials/telemetry/bundle.js__
|
||||||
@ -2801,16 +2796,15 @@ plugin.
|
|||||||
`example.server`. Setting `priority` to `fallback` means this constant will be
|
`example.server`. Setting `priority` to `fallback` means this constant will be
|
||||||
overridden if defined anywhere else, allowing configuration bundles to specify
|
overridden if defined anywhere else, allowing configuration bundles to specify
|
||||||
different URLs for the WebSocket connection.
|
different URLs for the WebSocket connection.
|
||||||
* The initializer script is registered using the `runs` category of extension,
|
* A Composition Provider is defined, which will expose the spacecraft's
|
||||||
to ensure that this executes (and populates the contents of the top-level My
|
subsystems and telemetry as objects in the tree.
|
||||||
Spacecraft object) once Open MCT is started.
|
|
||||||
* This depends upon the `example.adapter` service we exposed above, as well
|
* This depends upon the `example.adapter` service we exposed above, as well
|
||||||
as Angular's `$q`; these services will be made available in the constructor
|
as Angular's `$q`; these services will be made available in the constructor
|
||||||
call.
|
call.
|
||||||
* Finally, the `modelService` provider which presents dictionary elements as
|
* Finally, the `modelService` provider which presents dictionary elements as
|
||||||
domain object models is exposed. Since `modelService` is a composite service,
|
domain object models is exposed. Since `modelService` is a composite service,
|
||||||
this is registered under the extension category `components`.
|
this is registered under the extension category `components`.
|
||||||
* As with the initializer, this depends upon the `example.adapter` service
|
* As with the composition provider, this depends upon the `example.adapter` service
|
||||||
we exposed above, as well as Angular's `$q`; these services will be made
|
we exposed above, as well as Angular's `$q`; these services will be made
|
||||||
available in the constructor call.
|
available in the constructor call.
|
||||||
|
|
||||||
@ -3015,12 +3009,12 @@ Finally, we expose this `telemetryService` provider declaratively:
|
|||||||
define([
|
define([
|
||||||
'openmct',
|
'openmct',
|
||||||
'./src/ExampleTelemetryServerAdapter',
|
'./src/ExampleTelemetryServerAdapter',
|
||||||
'./src/ExampleTelemetryInitializer',
|
'./src/ExampleTelemetryCompositionProvider',
|
||||||
'./src/ExampleTelemetryModelProvider'
|
'./src/ExampleTelemetryModelProvider'
|
||||||
], function (
|
], function (
|
||||||
openmct,
|
openmct,
|
||||||
ExampleTelemetryServerAdapter,
|
ExampleTelemetryServerAdapter,
|
||||||
ExampleTelemetryInitializer,
|
ExampleTelemetryCompositionProvider,
|
||||||
ExampleTelemetryModelProvider
|
ExampleTelemetryModelProvider
|
||||||
) {
|
) {
|
||||||
openmct.legacyRegistry.register("tutorials/telemetry", {
|
openmct.legacyRegistry.register("tutorials/telemetry", {
|
||||||
@ -3085,12 +3079,6 @@ define([
|
|||||||
"value": "ws://localhost:8081"
|
"value": "ws://localhost:8081"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"runs": [
|
|
||||||
{
|
|
||||||
"implementation": "ExampleTelemetryInitializer.js",
|
|
||||||
"depends": [ "example.adapter", "objectService" ]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"components": [
|
"components": [
|
||||||
{
|
{
|
||||||
"provides": "modelService",
|
"provides": "modelService",
|
||||||
@ -3107,6 +3095,7 @@ define([
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
openmct.composition.addProvider(new ExampleTelemetryCompositionProvider(openmct));
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
__tutorials/telemetry/bundle.js__
|
__tutorials/telemetry/bundle.js__
|
||||||
|
Reference in New Issue
Block a user