mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 15:43:48 +00:00
[Telemetry] Subscribe from telemetry controller
Initiate subscriptions from telemetry controller. Allows plotting of streaming data from the WARP Server, WTD-644.
This commit is contained in:
@ -47,6 +47,9 @@ define(
|
|||||||
// is being issued.
|
// is being issued.
|
||||||
broadcasting: false,
|
broadcasting: false,
|
||||||
|
|
||||||
|
// Active subscriptions
|
||||||
|
subscriptions: [],
|
||||||
|
|
||||||
// Used for getTelemetryObjects; a reference is
|
// Used for getTelemetryObjects; a reference is
|
||||||
// stored so that this can be called in a watch
|
// stored so that this can be called in a watch
|
||||||
telemetryObjects: [],
|
telemetryObjects: [],
|
||||||
@ -183,6 +186,25 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subscribe to streaming telemetry updates
|
||||||
|
function subscribe(domainObject) {
|
||||||
|
var telemetryCapability =
|
||||||
|
domainObject.getCapability("telemetry");
|
||||||
|
return telemetryCapability.subscribe(function () {
|
||||||
|
requestTelemetryForId(
|
||||||
|
domainObject.getId(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop listening to active subscriptions
|
||||||
|
function unsubscribe() {
|
||||||
|
self.subscriptions.forEach(function (s) {
|
||||||
|
return s && s();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Build response containers (as above) for all
|
// Build response containers (as above) for all
|
||||||
// domain objects, and update some controller-internal
|
// domain objects, and update some controller-internal
|
||||||
// state to support subsequent calls.
|
// state to support subsequent calls.
|
||||||
@ -205,6 +227,9 @@ define(
|
|||||||
return self.response[id].metadata;
|
return self.response[id].metadata;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Subscribe to all telemetry objects
|
||||||
|
self.subscriptions = domainObjects.map(subscribe);
|
||||||
|
|
||||||
// Issue a request for the new objects, if we
|
// Issue a request for the new objects, if we
|
||||||
// know what our request looks like
|
// know what our request looks like
|
||||||
if (self.request) {
|
if (self.request) {
|
||||||
@ -217,6 +242,7 @@ define(
|
|||||||
// scope. This will be the domain object itself, or
|
// scope. This will be the domain object itself, or
|
||||||
// its telemetry delegates, or both.
|
// its telemetry delegates, or both.
|
||||||
function getTelemetryObjects(domainObject) {
|
function getTelemetryObjects(domainObject) {
|
||||||
|
unsubscribe();
|
||||||
promiseRelevantDomainObjects(domainObject)
|
promiseRelevantDomainObjects(domainObject)
|
||||||
.then(buildResponseContainers);
|
.then(buildResponseContainers);
|
||||||
}
|
}
|
||||||
@ -241,6 +267,7 @@ define(
|
|||||||
|
|
||||||
// Stop polling for changes
|
// Stop polling for changes
|
||||||
function deactivate() {
|
function deactivate() {
|
||||||
|
unsubscribe();
|
||||||
self.active = false;
|
self.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user