Compare commits
2 Commits
itc-mode-d
...
open1494
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9df47abf6 | ||
|
|
f9c4247d01 |
@@ -237,8 +237,7 @@ define([
|
|||||||
"$scope",
|
"$scope",
|
||||||
"$q",
|
"$q",
|
||||||
"dialogService",
|
"dialogService",
|
||||||
"telemetryHandler",
|
"openmct",
|
||||||
"telemetryFormatter",
|
|
||||||
"throttle"
|
"throttle"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,13 +35,15 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param {Scope} $scope the controller's Angular scope
|
* @param {Scope} $scope the controller's Angular scope
|
||||||
*/
|
*/
|
||||||
function FixedController($scope, $q, dialogService, telemetryHandler, telemetryFormatter) {
|
function FixedController($scope, $q, dialogService, openmct) {
|
||||||
var self = this,
|
var self = this,
|
||||||
handle,
|
handle,
|
||||||
names = {}, // Cache names by ID
|
names = {}, // Cache names by ID
|
||||||
values = {}, // Cache values by ID
|
values = {}, // Cache values by ID
|
||||||
elementProxiesById = {},
|
elementProxiesById = {},
|
||||||
maxDomainValue = Number.POSITIVE_INFINITY;
|
maxDomainValue = Number.POSITIVE_INFINITY;
|
||||||
|
var subscriptions = [];
|
||||||
|
var limitEvaluators = {};
|
||||||
|
|
||||||
// Convert from element x/y/width/height to an
|
// Convert from element x/y/width/height to an
|
||||||
// appropriate ng-style argument, to position elements.
|
// appropriate ng-style argument, to position elements.
|
||||||
@@ -112,18 +114,20 @@ define(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the displayed value for this object
|
// Update the displayed value for this object
|
||||||
function updateValue(telemetryObject) {
|
function updateValue(telemetryObject, datum) {
|
||||||
var limit = telemetryObject &&
|
var limitEvaluator = limitEvaluators[telemetryObject];
|
||||||
telemetryObject.getCapability('limit'),
|
var timeSystem = openmct.conductor.timeSystem();
|
||||||
datum = telemetryObject &&
|
var metadata = openmct.telemetry.getMetadata(telemetryObject);
|
||||||
handle.getDatum(telemetryObject);
|
var domain = timeSystem && openmct.conductor.timeSystem().metadata.key;
|
||||||
|
var domainValue = timeSystem && datum[domain];
|
||||||
|
var rangeField =
|
||||||
|
var rangeValue =
|
||||||
|
|
||||||
if (telemetryObject &&
|
if (timeSystem && domainValue < maxDomainValue) {
|
||||||
(handle.getDomainValue(telemetryObject) < maxDomainValue)) {
|
|
||||||
setDisplayedValue(
|
setDisplayedValue(
|
||||||
telemetryObject,
|
telemetryObject,
|
||||||
handle.getRangeValue(telemetryObject),
|
handle.getRangeValue(telemetryObject),
|
||||||
limit && datum && limit.evaluate(datum)
|
limitEvaluator && limitEvaluator.evaluate(datum)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -197,35 +201,32 @@ define(
|
|||||||
elementProxiesById[id].push(elementProxy);
|
elementProxiesById[id].push(elementProxy);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Ensure elements for all domain objects?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free up subscription to telemetry
|
function unsubscribe() {
|
||||||
function releaseSubscription() {
|
subscriptions.forEach(function (unsubscribe) {
|
||||||
if (handle) {
|
unsubscribe();
|
||||||
handle.unsubscribe();
|
})
|
||||||
handle = undefined;
|
subscriptions = [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to telemetry updates for this domain object
|
// Subscribe to telemetry updates for this domain object
|
||||||
function subscribe(domainObject) {
|
function subscribe(domainObject) {
|
||||||
// Release existing subscription (if any)
|
var newObject = domainObject.getCapability('adapter');
|
||||||
if (handle) {
|
|
||||||
handle.unsubscribe();
|
if (subscriptions.length > 0) {
|
||||||
|
unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a new subscription
|
if (openmct.telemetry.canProvideTelemetry(newObject)){
|
||||||
handle = domainObject && telemetryHandler.handle(
|
subscriptions = [openmct.telemetry.subscribe(newObject)];
|
||||||
domainObject,
|
} else {
|
||||||
updateValues
|
openmct.composition.get(newObject).load().then(function (composees) {
|
||||||
);
|
subscriptions = composees.filter(openmct.telemetry.canProvideTelemetry).map(function(object) {
|
||||||
// Request an initial historical telemetry value
|
return openmct.telemetry.subscribe(object, updateValue.bind(object));
|
||||||
handle.request(
|
});
|
||||||
{ size: 1 }, // Only need a single data point
|
});
|
||||||
updateValueFromSeries
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle changes in the object's composition
|
// Handle changes in the object's composition
|
||||||
@@ -321,7 +322,7 @@ define(
|
|||||||
$scope.$watch("domainObject", subscribe);
|
$scope.$watch("domainObject", subscribe);
|
||||||
|
|
||||||
// Free up subscription on destroy
|
// Free up subscription on destroy
|
||||||
$scope.$on("$destroy", releaseSubscription);
|
$scope.$on("$destroy", unsubscribe);
|
||||||
|
|
||||||
// Position panes where they are dropped
|
// Position panes where they are dropped
|
||||||
$scope.$on("mctDrop", handleDrop);
|
$scope.$on("mctDrop", handleDrop);
|
||||||
|
|||||||
Reference in New Issue
Block a user