From 5cc89e798316bd9fa5b0f7be0e56a211bd2849ff Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 17 Apr 2015 14:09:39 -0700 Subject: [PATCH] [Plot] Update PlotController Update plot controller to request historical telemetry, WTD-806. --- platform/features/plot/src/PlotController.js | 36 +++++++++++-------- .../features/plot/src/elements/PlotUpdater.js | 2 +- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 6449e0f3a1..a2f5695f42 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -30,13 +30,13 @@ define( * * @constructor */ - function PlotController($scope, telemetryFormatter, telemetrySubscriber) { + function PlotController($scope, telemetryFormatter, telemetryHandler) { var subPlotFactory = new SubPlotFactory(telemetryFormatter), modeOptions = new PlotModeOptions([], subPlotFactory), subplots = [], cachedObjects = [], updater, - subscription, + handle, domainOffset; // Populate the scope with axis information (specifically, options @@ -77,7 +77,7 @@ define( // new subscription.) This will clear the plot. function recreateUpdater() { updater = new PlotUpdater( - subscription, + handle, ($scope.axes[0].active || {}).key, ($scope.axes[1].active || {}).key ); @@ -85,8 +85,8 @@ define( // Handle new telemetry data in this plot function updateValues() { - if (subscription) { - setupModes(subscription.getTelemetryObjects()); + if (handle) { + setupModes(handle.getTelemetryObjects()); } if (updater) { updater.update(); @@ -95,29 +95,37 @@ define( update(); } + // Issue a new request for historical telemetry + function requestTelemetry() { + if (handle && updater) { + handle.request({}, updater.addHistorical); + } + } + // Create a new subscription; telemetrySubscriber gets // to do the meaningful work here. function subscribe(domainObject) { - if (subscription) { - subscription.unsubscribe(); + if (handle) { + handle.unsubscribe(); } - subscription = domainObject && telemetrySubscriber.subscribe( + handle = domainObject && telemetryHandler.handle( domainObject, updateValues, true // Lossless ); - if (subscription) { - setupModes(subscription.getTelemetryObjects()); - setupAxes(subscription.getMetadata()); + if (handle) { + setupModes(handle.getTelemetryObjects()); + setupAxes(handle.getMetadata()); recreateUpdater(); + requestTelemetry(); } } // Release the current subscription (called when scope is destroyed) function releaseSubscription() { - if (subscription) { - subscription.unsubscribe(); - subscription = undefined; + if (handle) { + handle.unsubscribe(); + handle = undefined; } } diff --git a/platform/features/plot/src/elements/PlotUpdater.js b/platform/features/plot/src/elements/PlotUpdater.js index f39b77437b..3e155131e4 100644 --- a/platform/features/plot/src/elements/PlotUpdater.js +++ b/platform/features/plot/src/elements/PlotUpdater.js @@ -251,7 +251,7 @@ define( /** * Fill in historical data. */ - setHistorical: setHistorical + addHistorical: setHistorical }; }