[Plot] Update PlotController

Update plot controller to request historical telemetry,
WTD-806.
This commit is contained in:
Victor Woeltjen
2015-04-17 14:09:39 -07:00
parent 9f390de213
commit 5cc89e7983
2 changed files with 23 additions and 15 deletions

View File

@ -30,13 +30,13 @@ define(
* *
* @constructor * @constructor
*/ */
function PlotController($scope, telemetryFormatter, telemetrySubscriber) { function PlotController($scope, telemetryFormatter, telemetryHandler) {
var subPlotFactory = new SubPlotFactory(telemetryFormatter), var subPlotFactory = new SubPlotFactory(telemetryFormatter),
modeOptions = new PlotModeOptions([], subPlotFactory), modeOptions = new PlotModeOptions([], subPlotFactory),
subplots = [], subplots = [],
cachedObjects = [], cachedObjects = [],
updater, updater,
subscription, handle,
domainOffset; domainOffset;
// Populate the scope with axis information (specifically, options // Populate the scope with axis information (specifically, options
@ -77,7 +77,7 @@ define(
// new subscription.) This will clear the plot. // new subscription.) This will clear the plot.
function recreateUpdater() { function recreateUpdater() {
updater = new PlotUpdater( updater = new PlotUpdater(
subscription, handle,
($scope.axes[0].active || {}).key, ($scope.axes[0].active || {}).key,
($scope.axes[1].active || {}).key ($scope.axes[1].active || {}).key
); );
@ -85,8 +85,8 @@ define(
// Handle new telemetry data in this plot // Handle new telemetry data in this plot
function updateValues() { function updateValues() {
if (subscription) { if (handle) {
setupModes(subscription.getTelemetryObjects()); setupModes(handle.getTelemetryObjects());
} }
if (updater) { if (updater) {
updater.update(); updater.update();
@ -95,29 +95,37 @@ define(
update(); update();
} }
// Issue a new request for historical telemetry
function requestTelemetry() {
if (handle && updater) {
handle.request({}, updater.addHistorical);
}
}
// Create a new subscription; telemetrySubscriber gets // Create a new subscription; telemetrySubscriber gets
// to do the meaningful work here. // to do the meaningful work here.
function subscribe(domainObject) { function subscribe(domainObject) {
if (subscription) { if (handle) {
subscription.unsubscribe(); handle.unsubscribe();
} }
subscription = domainObject && telemetrySubscriber.subscribe( handle = domainObject && telemetryHandler.handle(
domainObject, domainObject,
updateValues, updateValues,
true // Lossless true // Lossless
); );
if (subscription) { if (handle) {
setupModes(subscription.getTelemetryObjects()); setupModes(handle.getTelemetryObjects());
setupAxes(subscription.getMetadata()); setupAxes(handle.getMetadata());
recreateUpdater(); recreateUpdater();
requestTelemetry();
} }
} }
// Release the current subscription (called when scope is destroyed) // Release the current subscription (called when scope is destroyed)
function releaseSubscription() { function releaseSubscription() {
if (subscription) { if (handle) {
subscription.unsubscribe(); handle.unsubscribe();
subscription = undefined; handle = undefined;
} }
} }

View File

@ -251,7 +251,7 @@ define(
/** /**
* Fill in historical data. * Fill in historical data.
*/ */
setHistorical: setHistorical addHistorical: setHistorical
}; };
} }