[Time Conductor] Begin adding support to fixed position

Begin adding support for universal time controller to
fixed position view, WTD-1515.
This commit is contained in:
Victor Woeltjen
2015-09-08 16:37:10 -07:00
parent 47b97a504e
commit c026bfa17d
2 changed files with 28 additions and 14 deletions

View File

@ -168,7 +168,8 @@
"$q", "$q",
"dialogService", "dialogService",
"telemetrySubscriber", "telemetrySubscriber",
"telemetryFormatter" "telemetryFormatter",
"throttle"
] ]
} }
], ],

View File

@ -38,9 +38,9 @@ define(
* @constructor * @constructor
* @param {Scope} $scope the controller's Angular scope * @param {Scope} $scope the controller's Angular scope
*/ */
function FixedController($scope, $q, dialogService, telemetrySubscriber, telemetryFormatter) { function FixedController($scope, $q, dialogService, telemetryHandler, telemetryFormatter, throttle) {
var self = this, var self = this,
subscription, handle,
names = {}, // Cache names by ID names = {}, // Cache names by ID
values = {}, // Cache values by ID values = {}, // Cache values by ID
elementProxiesById = {}; elementProxiesById = {};
@ -87,14 +87,14 @@ define(
limit = telemetryObject && limit = telemetryObject &&
telemetryObject.getCapability('limit'), telemetryObject.getCapability('limit'),
datum = telemetryObject && datum = telemetryObject &&
subscription.getDatum(telemetryObject), handle.getDatum(telemetryObject),
alarm = limit && datum && limit.evaluate(datum); alarm = limit && datum && limit.evaluate(datum);
if (id) { if (id) {
(elementProxiesById[id] || []).forEach(function (element) { (elementProxiesById[id] || []).forEach(function (element) {
names[id] = telemetryObject.getModel().name; names[id] = telemetryObject.getModel().name;
values[id] = telemetryFormatter.formatRangeValue( values[id] = telemetryFormatter.formatRangeValue(
subscription.getRangeValue(telemetryObject) handle.getRangeValue(telemetryObject)
); );
element.name = names[id]; element.name = names[id];
element.value = values[id]; element.value = values[id];
@ -115,8 +115,8 @@ define(
// Update telemetry values based on new data available // Update telemetry values based on new data available
function updateValues() { function updateValues() {
if (subscription) { if (handle) {
subscription.getTelemetryObjects().forEach(updateValue); handle.getTelemetryObjects().forEach(updateValue);
} }
} }
@ -178,22 +178,24 @@ define(
// Free up subscription to telemetry // Free up subscription to telemetry
function releaseSubscription() { function releaseSubscription() {
if (subscription) { if (handle) {
subscription.unsubscribe(); handle.unsubscribe();
subscription = undefined; handle = undefined;
} }
} }
// 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) // Release existing subscription (if any)
if (subscription) { if (handle) {
subscription.unsubscribe(); handle.unsubscribe();
} }
// Make a new subscription // Make a new subscription
subscription = domainObject && handle = domainObject && telemetryHandler.handle(
telemetrySubscriber.subscribe(domainObject, updateValues); domainObject,
updateValues
);
} }
// Handle changes in the object's composition // Handle changes in the object's composition
@ -204,6 +206,11 @@ define(
subscribe($scope.domainObject); subscribe($scope.domainObject);
} }
// Trigger a new query for telemetry data
function requery() {
subscribe($scope.domainObject);
}
// Add an element to this view // Add an element to this view
function addElement(element) { function addElement(element) {
// Ensure that configuration field is populated // Ensure that configuration field is populated
@ -277,6 +284,12 @@ define(
// Position panes where they are dropped // Position panes where they are dropped
$scope.$on("mctDrop", handleDrop); $scope.$on("mctDrop", handleDrop);
// Respond to external bounds changes
$scope.$on("telemetry:display:bounds", throttle(requery, 250));
// Respond to external query range changes
$scope.$on("telemetry:query:bounds", throttle(requery, 250));
} }
/** /**