From e4a14b7603a9fe6266e9b04f18cd27e95bbf8b6f Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 30 Oct 2015 14:56:52 -0700 Subject: [PATCH 1/5] [Time Conductor] Consistently throttle broadcast Consistently throttle broadcast of bounds to minimize redundant broadcasts, nasa/openmctweb#229 --- platform/features/conductor/src/ConductorRepresenter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 2d1bec36d8..8f893c4fb8 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -103,7 +103,7 @@ define( var newDomain = conductor.domain(value); conductorScope.parameters.format = newDomain && newDomain.format; - repScope.$broadcast('telemetry:display:bounds', bounds()); + broadcastBounds(); } // telemetry domain metadata -> option for a select control @@ -141,7 +141,7 @@ define( conductorScope .$watch('ngModel.domain', updateDomain); - repScope.$on('telemetry:view', updateConductorInner); + repScope.$on('telemetry:view', broadcastBounds); }; ConductorRepresenter.prototype.conductorScope = function (s) { From f7f6b8d61281013b5563730fc82d8411c29fb36a Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Fri, 30 Oct 2015 14:59:32 -0700 Subject: [PATCH 2/5] [Time Conductor] Don't broadcast on telemetry:view Instead, use delay from throttling initial bounds broadcast to avoid broadcasting bounds prematurely. --- platform/features/conductor/src/ConductorRepresenter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/platform/features/conductor/src/ConductorRepresenter.js b/platform/features/conductor/src/ConductorRepresenter.js index 8f893c4fb8..4b8e848a48 100644 --- a/platform/features/conductor/src/ConductorRepresenter.js +++ b/platform/features/conductor/src/ConductorRepresenter.js @@ -140,8 +140,6 @@ define( .$watch('ngModel.conductor.inner.end', updateConductorInner); conductorScope .$watch('ngModel.domain', updateDomain); - - repScope.$on('telemetry:view', broadcastBounds); }; ConductorRepresenter.prototype.conductorScope = function (s) { From 5940f946441df9b22299b2239206406c96552645 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 3 Nov 2015 15:24:38 -0800 Subject: [PATCH 3/5] [Time Conductor] Cancel requests Don't callback for any telemetry requests from a TelemetryHandle if the handle has been destroyed. --- platform/telemetry/src/TelemetryHandle.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/telemetry/src/TelemetryHandle.js b/platform/telemetry/src/TelemetryHandle.js index ff77d7b9e0..11fd05bb90 100644 --- a/platform/telemetry/src/TelemetryHandle.js +++ b/platform/telemetry/src/TelemetryHandle.js @@ -39,6 +39,7 @@ define( */ function TelemetryHandle($q, subscription) { var seriesMap = {}, + active = true, self = Object.create(subscription); // Request a telemetry series for this specific object @@ -50,7 +51,7 @@ define( // Store it for subsequent lookup seriesMap[id] = series; // Notify callback of new series data, if there is one - if (callback) { + if (callback && active) { callback(telemetryObject, series); } // Pass it along for promise-chaining @@ -61,6 +62,10 @@ define( return telemetry.requestData(request).then(receiveSeries); } + self.unsubscribe = function () { + active = false; + return subscription.unsubscribe(); + }; /** * Get the most recently obtained telemetry data series associated From df484c18008becf57601eaf2eae7d3a37d52b15b Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 3 Nov 2015 15:27:08 -0800 Subject: [PATCH 4/5] [Time Conductor] Update TelemetryHandler spec --- platform/telemetry/test/TelemetryHandleSpec.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/telemetry/test/TelemetryHandleSpec.js b/platform/telemetry/test/TelemetryHandleSpec.js index 2e34b8dcd3..8e543d21dd 100644 --- a/platform/telemetry/test/TelemetryHandleSpec.js +++ b/platform/telemetry/test/TelemetryHandleSpec.js @@ -85,10 +85,18 @@ define( it("exposes subscription API", function () { // Should still expose methods from the provided subscription - expect(handle.unsubscribe) - .toBe(mockSubscription.unsubscribe); - expect(handle.getTelemetryObjects) - .toBe(mockSubscription.getTelemetryObjects); + // (though these may have been wrapped) + expect(mockSubscription.getTelemetryObjects) + .not.toHaveBeenCalled(); + handle.getTelemetryObjects(); + expect(mockSubscription.getTelemetryObjects) + .toHaveBeenCalled(); + + expect(mockSubscription.unsubscribe) + .not.toHaveBeenCalled(); + handle.unsubscribe(); + expect(mockSubscription.unsubscribe) + .toHaveBeenCalled(); }); it("provides an interface for historical requests", function () { From ac529be55c88c9afb0fecf861ee69df39daed511 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Tue, 3 Nov 2015 17:01:22 -0800 Subject: [PATCH 5/5] [Time Conductor] Don't emit view event Don't emit an event when plot is instantiated; this is no longer needed, as time conductor broadcasts its bounds whenever views change. --- platform/features/plot/src/PlotController.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index d6acdb6a5c..cf6bfcf581 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -245,9 +245,6 @@ define( // Unsubscribe when the plot is destroyed $scope.$on("$destroy", releaseSubscription); - - // Notify any external observers that a new telemetry view is here - $scope.$emit("telemetry:view"); } /**