mirror of
https://github.com/nasa/openmct.git
synced 2025-03-23 04:25:27 +00:00
[Telemetry] Fix failing specs
Fix failing specs related to usage of subscriptions in the TelemetryController, introduced for WTD-644.
This commit is contained in:
parent
de57628b01
commit
12c4863feb
@ -123,6 +123,21 @@ define(
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subscribe to streaming telemetry updates
|
||||||
|
function subscribe(telemetryCapability, id) {
|
||||||
|
return telemetryCapability.subscribe(function () {
|
||||||
|
requestTelemetryForId(id, false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop listening to active subscriptions
|
||||||
|
function unsubscribe() {
|
||||||
|
self.subscriptions.forEach(function (s) {
|
||||||
|
return s && s();
|
||||||
|
});
|
||||||
|
self.subscriptions = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Look up domain objects which have telemetry capabilities.
|
// Look up domain objects which have telemetry capabilities.
|
||||||
// This will either be the object in view, or object that
|
// This will either be the object in view, or object that
|
||||||
// this object delegates its telemetry capability to.
|
// this object delegates its telemetry capability to.
|
||||||
@ -152,12 +167,17 @@ define(
|
|||||||
function buildResponseContainer(domainObject) {
|
function buildResponseContainer(domainObject) {
|
||||||
var telemetry = domainObject &&
|
var telemetry = domainObject &&
|
||||||
domainObject.getCapability("telemetry"),
|
domainObject.getCapability("telemetry"),
|
||||||
|
id,
|
||||||
metadata;
|
metadata;
|
||||||
|
|
||||||
if (telemetry) {
|
if (telemetry) {
|
||||||
|
id = domainObject.getId();
|
||||||
|
|
||||||
|
self.subscriptions.push(subscribe(telemetry, id));
|
||||||
|
|
||||||
metadata = telemetry.getMetadata();
|
metadata = telemetry.getMetadata();
|
||||||
|
|
||||||
self.response[domainObject.getId()] = {
|
self.response[id] = {
|
||||||
name: domainObject.getModel().name,
|
name: domainObject.getModel().name,
|
||||||
domainObject: domainObject,
|
domainObject: domainObject,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
@ -186,29 +206,13 @@ 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.
|
||||||
function buildResponseContainers(domainObjects) {
|
function buildResponseContainers(domainObjects) {
|
||||||
|
// Clear out any existing subscriptions
|
||||||
|
unsubscribe();
|
||||||
|
|
||||||
// Build the containers
|
// Build the containers
|
||||||
domainObjects.forEach(buildResponseContainer);
|
domainObjects.forEach(buildResponseContainer);
|
||||||
|
|
||||||
@ -227,9 +231,6 @@ 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) {
|
||||||
|
@ -12,6 +12,7 @@ define(
|
|||||||
mockLog,
|
mockLog,
|
||||||
mockDomainObject,
|
mockDomainObject,
|
||||||
mockTelemetry,
|
mockTelemetry,
|
||||||
|
mockUnsubscribe,
|
||||||
controller;
|
controller;
|
||||||
|
|
||||||
function mockPromise(value) {
|
function mockPromise(value) {
|
||||||
@ -44,8 +45,9 @@ define(
|
|||||||
|
|
||||||
mockTelemetry = jasmine.createSpyObj(
|
mockTelemetry = jasmine.createSpyObj(
|
||||||
"telemetry",
|
"telemetry",
|
||||||
[ "requestData", "getMetadata" ]
|
[ "requestData", "subscribe", "getMetadata" ]
|
||||||
);
|
);
|
||||||
|
mockUnsubscribe = jasmine.createSpy("unsubscribe");
|
||||||
|
|
||||||
mockQ.when.andCallFake(mockPromise);
|
mockQ.when.andCallFake(mockPromise);
|
||||||
mockQ.all.andReturn(mockPromise([mockDomainObject]));
|
mockQ.all.andReturn(mockPromise([mockDomainObject]));
|
||||||
@ -63,6 +65,7 @@ define(
|
|||||||
mockTelemetry.requestData.andReturn(mockPromise({
|
mockTelemetry.requestData.andReturn(mockPromise({
|
||||||
telemetryKey: "some value"
|
telemetryKey: "some value"
|
||||||
}));
|
}));
|
||||||
|
mockTelemetry.subscribe.andReturn(mockUnsubscribe);
|
||||||
|
|
||||||
controller = new TelemetryController(
|
controller = new TelemetryController(
|
||||||
mockScope,
|
mockScope,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user