From c026bfa17da75e29bc6d1dd073cd6769fa2872b8 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 8 Sep 2015 16:37:10 -0700 Subject: [PATCH] [Time Conductor] Begin adding support to fixed position Begin adding support for universal time controller to fixed position view, WTD-1515. --- platform/features/layout/bundle.json | 3 +- .../features/layout/src/FixedController.js | 39 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/platform/features/layout/bundle.json b/platform/features/layout/bundle.json index f1006d67e8..8a8d158e32 100644 --- a/platform/features/layout/bundle.json +++ b/platform/features/layout/bundle.json @@ -168,7 +168,8 @@ "$q", "dialogService", "telemetrySubscriber", - "telemetryFormatter" + "telemetryFormatter", + "throttle" ] } ], diff --git a/platform/features/layout/src/FixedController.js b/platform/features/layout/src/FixedController.js index 410c0d2f94..1fa057642a 100644 --- a/platform/features/layout/src/FixedController.js +++ b/platform/features/layout/src/FixedController.js @@ -38,9 +38,9 @@ define( * @constructor * @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, - subscription, + handle, names = {}, // Cache names by ID values = {}, // Cache values by ID elementProxiesById = {}; @@ -87,14 +87,14 @@ define( limit = telemetryObject && telemetryObject.getCapability('limit'), datum = telemetryObject && - subscription.getDatum(telemetryObject), + handle.getDatum(telemetryObject), alarm = limit && datum && limit.evaluate(datum); if (id) { (elementProxiesById[id] || []).forEach(function (element) { names[id] = telemetryObject.getModel().name; values[id] = telemetryFormatter.formatRangeValue( - subscription.getRangeValue(telemetryObject) + handle.getRangeValue(telemetryObject) ); element.name = names[id]; element.value = values[id]; @@ -115,8 +115,8 @@ define( // Update telemetry values based on new data available function updateValues() { - if (subscription) { - subscription.getTelemetryObjects().forEach(updateValue); + if (handle) { + handle.getTelemetryObjects().forEach(updateValue); } } @@ -178,22 +178,24 @@ define( // Free up subscription to telemetry function releaseSubscription() { - if (subscription) { - subscription.unsubscribe(); - subscription = undefined; + if (handle) { + handle.unsubscribe(); + handle = undefined; } } // Subscribe to telemetry updates for this domain object function subscribe(domainObject) { // Release existing subscription (if any) - if (subscription) { - subscription.unsubscribe(); + if (handle) { + handle.unsubscribe(); } // Make a new subscription - subscription = domainObject && - telemetrySubscriber.subscribe(domainObject, updateValues); + handle = domainObject && telemetryHandler.handle( + domainObject, + updateValues + ); } // Handle changes in the object's composition @@ -204,6 +206,11 @@ define( subscribe($scope.domainObject); } + // Trigger a new query for telemetry data + function requery() { + subscribe($scope.domainObject); + } + // Add an element to this view function addElement(element) { // Ensure that configuration field is populated @@ -277,6 +284,12 @@ define( // Position panes where they are dropped $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)); } /**