mirror of
https://github.com/nasa/openmct.git
synced 2025-01-01 19:06:40 +00:00
[Plot] Support fixed duration
Support a fixed duration for plots, WTD-1273.
This commit is contained in:
parent
a82fea2166
commit
fbf682d5fa
@ -99,7 +99,8 @@ define(
|
|||||||
updater = new PlotUpdater(
|
updater = new PlotUpdater(
|
||||||
handle,
|
handle,
|
||||||
($scope.axes[0].active || {}).key,
|
($scope.axes[0].active || {}).key,
|
||||||
($scope.axes[1].active || {}).key
|
($scope.axes[1].active || {}).key,
|
||||||
|
15000 // 15 seconds
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ define(
|
|||||||
|
|
||||||
// Unsubscribe when the plot is destroyed
|
// Unsubscribe when the plot is destroyed
|
||||||
$scope.$on("$destroy", releaseSubscription);
|
$scope.$on("$destroy", releaseSubscription);
|
||||||
|
|
||||||
// Create a throttled update function
|
// Create a throttled update function
|
||||||
scheduleUpdate = throttle(function () {
|
scheduleUpdate = throttle(function () {
|
||||||
modeOptions.getModeHandler().getSubPlots()
|
modeOptions.getModeHandler().getSubPlots()
|
||||||
@ -248,4 +249,4 @@ define(
|
|||||||
|
|
||||||
return PlotController;
|
return PlotController;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -43,9 +43,9 @@ define(
|
|||||||
var mid = Math.floor((min + max) / 2),
|
var mid = Math.floor((min + max) / 2),
|
||||||
found = buffer[mid * 2];
|
found = buffer[mid * 2];
|
||||||
|
|
||||||
// Collisions are not wanted
|
// On collisions, insert at same index
|
||||||
if (found === value) {
|
if (found === value) {
|
||||||
return -1;
|
return mid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, if we're down to a single index,
|
// Otherwise, if we're down to a single index,
|
||||||
@ -258,4 +258,4 @@ define(
|
|||||||
|
|
||||||
return PlotLineBuffer;
|
return PlotLineBuffer;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -42,8 +42,10 @@ define(
|
|||||||
* @param {TelemetryHandle} handle the handle to telemetry access
|
* @param {TelemetryHandle} handle the handle to telemetry access
|
||||||
* @param {string} domain the key to use when looking up domain values
|
* @param {string} domain the key to use when looking up domain values
|
||||||
* @param {string} range the key to use when looking up range values
|
* @param {string} range the key to use when looking up range values
|
||||||
|
* @param {number} maxDuration maximum plot duration to display
|
||||||
|
* @param {number} maxPoints maximum number of points to display
|
||||||
*/
|
*/
|
||||||
function PlotUpdater(handle, domain, range, maxPoints) {
|
function PlotUpdater(handle, domain, range, fixedDuration, maxPoints) {
|
||||||
var ids = [],
|
var ids = [],
|
||||||
lines = {},
|
lines = {},
|
||||||
dimensions = [0, 0],
|
dimensions = [0, 0],
|
||||||
@ -107,6 +109,7 @@ define(
|
|||||||
lines = next;
|
lines = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initialize the domain offset, based on these observed values
|
// Initialize the domain offset, based on these observed values
|
||||||
function initializeDomainOffset(values) {
|
function initializeDomainOffset(values) {
|
||||||
domainOffset =
|
domainOffset =
|
||||||
@ -147,6 +150,35 @@ define(
|
|||||||
[dimensionsOf(domainExtrema), 2.0 ] :
|
[dimensionsOf(domainExtrema), 2.0 ] :
|
||||||
[dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)];
|
[dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)];
|
||||||
origin = [originOf(domainExtrema), originOf(rangeExtrema)];
|
origin = [originOf(domainExtrema), originOf(rangeExtrema)];
|
||||||
|
|
||||||
|
if (fixedDuration !== undefined) {
|
||||||
|
origin[0] = Math.min(
|
||||||
|
origin[0],
|
||||||
|
origin[0] + dimensions[0] - fixedDuration
|
||||||
|
);
|
||||||
|
dimensions[0] = Math.max(dimensions[0], fixedDuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enforce maximum duration on all plot lines; not that
|
||||||
|
// domain extrema must be up-to-date for this to behave correctly.
|
||||||
|
function enforceDuration() {
|
||||||
|
var cutoff;
|
||||||
|
|
||||||
|
function enforceDurationForBuffer(plotLineBuffer) {
|
||||||
|
var index = plotLineBuffer.findInsertionIndex(cutoff);
|
||||||
|
if (index > 0) {
|
||||||
|
plotLineBuffer.trim(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fixedDuration !== undefined &&
|
||||||
|
domainExtrema !== undefined &&
|
||||||
|
(domainExtrema[1] - domainExtrema[0] > fixedDuration)) {
|
||||||
|
cutoff = domainExtrema[1] - fixedDuration;
|
||||||
|
bufferArray.forEach(enforceDurationForBuffer);
|
||||||
|
updateExtrema(); // Extrema may have changed now
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,6 +193,12 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update plot extremea and enforce maximum duration
|
||||||
|
function updateBounds() {
|
||||||
|
updateExtrema();
|
||||||
|
enforceDuration();
|
||||||
|
}
|
||||||
|
|
||||||
// Handle new telemetry data
|
// Handle new telemetry data
|
||||||
function update() {
|
function update() {
|
||||||
var objects = handle.getTelemetryObjects();
|
var objects = handle.getTelemetryObjects();
|
||||||
@ -180,8 +218,8 @@ define(
|
|||||||
// Add new data
|
// Add new data
|
||||||
objects.forEach(addPointFor);
|
objects.forEach(addPointFor);
|
||||||
|
|
||||||
// Finally, update extrema
|
// Then, update extrema
|
||||||
updateExtrema();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add historical data for this domain object
|
// Add historical data for this domain object
|
||||||
@ -213,12 +251,12 @@ define(
|
|||||||
line.addSeries(series, domain, range);
|
line.addSeries(series, domain, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, update extrema
|
// Update extrema
|
||||||
updateExtrema();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a default MAX_POINTS if none is provided
|
// Use a default MAX_POINTS if none is provided
|
||||||
maxPoints = maxPoints || MAX_POINTS;
|
maxPoints = maxPoints !== undefined ? maxPoints : MAX_POINTS;
|
||||||
|
|
||||||
// Initially prepare state for these objects.
|
// Initially prepare state for these objects.
|
||||||
// Note that this may be an empty array at this time,
|
// Note that this may be an empty array at this time,
|
||||||
@ -290,4 +328,4 @@ define(
|
|||||||
return PlotUpdater;
|
return PlotUpdater;
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user