Compare commits

...

2 Commits

Author SHA1 Message Date
a9df47abf6 WIP 2017-03-29 16:55:18 -07:00
f9c4247d01 WIP 2017-03-29 12:18:11 -07:00
2 changed files with 33 additions and 33 deletions

View File

@ -237,8 +237,7 @@ define([
"$scope", "$scope",
"$q", "$q",
"dialogService", "dialogService",
"telemetryHandler", "openmct",
"telemetryFormatter",
"throttle" "throttle"
] ]
} }

View File

@ -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);