diff --git a/platform/features/plot/bundle.json b/platform/features/plot/bundle.json index 67c69d9e4b..ab8cf89b7c 100644 --- a/platform/features/plot/bundle.json +++ b/platform/features/plot/bundle.json @@ -22,7 +22,7 @@ { "key": "PlotController", "implementation": "PlotController.js", - "depends": [ "$scope", "telemetryFormatter", "telemetrySubscriber" ] + "depends": [ "$scope", "telemetryFormatter", "telemetryHandler" ] } ] } diff --git a/platform/features/plot/src/elements/PlotLine.js b/platform/features/plot/src/elements/PlotLine.js index d5bba0e320..00a65cbfac 100644 --- a/platform/features/plot/src/elements/PlotLine.js +++ b/platform/features/plot/src/elements/PlotLine.js @@ -13,8 +13,8 @@ define( var count = seriesWindow.getPointCount(); function doInsert() { - var firstTimestamp = buffer.getDomainValue(0), - lastTimestamp = buffer.getDomainValue(count - 1), + var firstTimestamp = seriesWindow.getDomainValue(0), + lastTimestamp = seriesWindow.getDomainValue(count - 1), startIndex = buffer.findInsertionIndex(firstTimestamp), endIndex = buffer.findInsertionIndex(lastTimestamp); @@ -51,8 +51,16 @@ define( * @param {number} rangeValue the range value */ addPoint: function (domainValue, rangeValue) { - var index = buffer.findInsertionIndex(domainValue); - if (index > -1) { + var index; + // Make sure we got real/useful values here... + if (domainValue !== undefined && rangeValue !== undefined) { + index = buffer.findInsertionIndex(domainValue); + + // Already in the buffer? Skip insertion + if (index < 0) { + return; + } + // Insert the point if (!buffer.insertPoint(domainValue, rangeValue, index)) { // If insertion failed, trim from the beginning... diff --git a/platform/features/plot/src/elements/PlotLineBuffer.js b/platform/features/plot/src/elements/PlotLineBuffer.js index 724347ed0c..7511ab4870 100644 --- a/platform/features/plot/src/elements/PlotLineBuffer.js +++ b/platform/features/plot/src/elements/PlotLineBuffer.js @@ -75,10 +75,8 @@ define( buffer[index * 2 + 1] = rangeValue; // Track min/max of range values (min/max for // domain values can be read directly from buffer) - rangeExtrema = [ - Math.min(rangeExtrema[0], rangeValue), - Math.max(rangeExtrema[1], rangeValue) - ]; + rangeExtrema[0] = Math.min(rangeExtrema[0], rangeValue); + rangeExtrema[1] = Math.max(rangeExtrema[1], rangeValue); } return { diff --git a/platform/features/plot/src/elements/PlotSeriesWindow.js b/platform/features/plot/src/elements/PlotSeriesWindow.js index 614c09b525..d8308eb3eb 100644 --- a/platform/features/plot/src/elements/PlotSeriesWindow.js +++ b/platform/features/plot/src/elements/PlotSeriesWindow.js @@ -41,5 +41,7 @@ define( } }; } + + return PlotSeriesWindow; } ); \ No newline at end of file diff --git a/platform/features/plot/src/elements/PlotUpdater.js b/platform/features/plot/src/elements/PlotUpdater.js index 3e155131e4..815b91b4e5 100644 --- a/platform/features/plot/src/elements/PlotUpdater.js +++ b/platform/features/plot/src/elements/PlotUpdater.js @@ -58,13 +58,14 @@ define( return; } - // Update list of ids in use - ids = nextIds; - // Built up a set of ids. Note that we can only // create plot lines after our domain offset has // been determined. if (domainOffset !== undefined) { + // Update list of ids in use + ids = nextIds; + + // Create buffers for these objects bufferArray = ids.map(function (id) { var buffer = new PlotLineBuffer( domainOffset, @@ -112,18 +113,31 @@ define( // Update dimensions and origin based on extrema of plots function updateExtrema() { - domainExtrema = bufferArray.map(function (lineBuffer) { - return lineBuffer.getDomainExtrema(); - }).reduce(reduceExtrema); + if (bufferArray.length > 0) { + domainExtrema = bufferArray.map(function (lineBuffer) { + return lineBuffer.getDomainExtrema(); + }).reduce(reduceExtrema); - rangeExtrema = bufferArray.map(function (lineBuffer) { - return lineBuffer.getRangeExtrema(); - }).reduce(reduceExtrema); + rangeExtrema = bufferArray.map(function (lineBuffer) { + return lineBuffer.getRangeExtrema(); + }).reduce(reduceExtrema); - dimensions = (rangeExtrema[0] === rangeExtrema[1]) ? - [dimensionsOf(domainExtrema), 2.0 ] : - [dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)]; - origin = [originOf(domainExtrema), originOf(rangeExtrema)]; + dimensions = (rangeExtrema[0] === rangeExtrema[1]) ? + [dimensionsOf(domainExtrema), 2.0 ] : + [dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)]; + origin = [originOf(domainExtrema), originOf(rangeExtrema)]; + } + } + + // Add latest data for this domain object + function addPointFor(domainObject) { + var line = lines[domainObject.getId()]; + if (line) { + line.addPoint( + handle.getDomainValue(domainObject, domain), + handle.getRangeValue(domainObject, range) + ); + } } // Handle new telemetry data @@ -134,6 +148,8 @@ define( if (domainOffset === undefined) { initializeDomainOffset(objects.map(function (obj) { return handle.getDomainValue(obj, domain); + }).filter(function (value) { + return typeof value === 'number'; })); } @@ -141,12 +157,7 @@ define( prepareLines(objects); // Add new data - objects.forEach(function (obj, index) { - lines[obj.getId()].addPoint( - handle.getDomainValue(obj, domain), - handle.getRangeValue(obj, range) - ); - }); + objects.forEach(addPointFor); // Finally, update extrema updateExtrema(); @@ -154,7 +165,7 @@ define( // Add historical data for this domain object function setHistorical(domainObject, series) { - var count = series.getPointCount(), + var count = series ? series.getPointCount() : 0, line; // Nothing to do if it's an empty series @@ -163,7 +174,7 @@ define( } // Initialize domain offset if necessary - if (domainOffset === undefined && series) { + if (domainOffset === undefined) { initializeDomainOffset([ series.getDomainValue(0, domain), series.getDomainValue(count - 1, domain) diff --git a/platform/telemetry/bundle.json b/platform/telemetry/bundle.json index f1500a67bf..a93c61bb02 100644 --- a/platform/telemetry/bundle.json +++ b/platform/telemetry/bundle.json @@ -43,6 +43,11 @@ "key": "telemetrySubscriber", "implementation": "TelemetrySubscriber.js", "depends": [ "$q", "$timeout" ] + }, + { + "key": "telemetryHandler", + "implementation": "TelemetryHandler.js", + "depends": [ "$q", "telemetrySubscriber" ] } ], "licenses": [