mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 17:08:57 +00:00
[Telemetry] Add data structure specs
Add specs for data structures which will support resolution of WTD-784 by retaining all data not yet received by callbacks (instead of just the very latest) such that plots can ensure they do not miss streaming data.
This commit is contained in:
@ -1,8 +1,8 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
['./TelemetryQueue', './TelemetryTable'],
|
||||
function (TelemetryQueue, TelemetryTable) {
|
||||
"use strict";
|
||||
|
||||
|
||||
@ -25,11 +25,16 @@ define(
|
||||
* associated telemetry data is of interest
|
||||
* @param {Function} callback a function to invoke
|
||||
* when new data has become available.
|
||||
* @param {boolean} lossless true if callback should be invoked
|
||||
* once with every data point available; otherwise, multiple
|
||||
* data events in a short period of time will only invoke
|
||||
* the callback once, with access to the latest data
|
||||
*/
|
||||
function TelemetrySubscription($q, $timeout, domainObject, callback) {
|
||||
function TelemetrySubscription($q, $timeout, domainObject, callback, lossless) {
|
||||
var unsubscribePromise,
|
||||
latestValues = {},
|
||||
telemetryObjects = [],
|
||||
pool = lossless ? new TelemetryQueue() : new TelemetryTable(),
|
||||
metadatas,
|
||||
updatePending;
|
||||
|
||||
@ -56,10 +61,22 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
function updateValuesFromPool() {
|
||||
var values = pool.poll();
|
||||
Object.keys(values).forEach(function (k) {
|
||||
latestValues[k] = values[k];
|
||||
});
|
||||
}
|
||||
|
||||
// Invoke the observer callback to notify that new streaming
|
||||
// data has become available.
|
||||
function fireCallback() {
|
||||
callback();
|
||||
// Play back from queue if we are lossless
|
||||
while (!pool.isEmpty()) {
|
||||
updateValuesFromPool();
|
||||
callback();
|
||||
}
|
||||
|
||||
// Clear the pending flag so that future updates will
|
||||
// schedule this callback.
|
||||
updatePending = false;
|
||||
@ -80,10 +97,10 @@ define(
|
||||
|
||||
// Update the latest-value table
|
||||
if (count > 0) {
|
||||
latestValues[domainObject.getId()] = {
|
||||
pool.put(domainObject.getId(), {
|
||||
domain: telemetry.getDomainValue(count - 1),
|
||||
range: telemetry.getRangeValue(count - 1)
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user