mirror of
https://github.com/nasa/openmct.git
synced 2025-05-08 11:38:35 +00:00
[Telemetry] Provide latest telemetry datum
Provide latest telemetry as a datum to begin transitioning toward revised telemetry API, particularly as used from limits; WTD-1223.
This commit is contained in:
parent
4ab36bd421
commit
4544167b50
@ -26,7 +26,6 @@ define(
|
|||||||
function (TelemetryQueue, TelemetryTable, TelemetryDelegator) {
|
function (TelemetryQueue, TelemetryTable, TelemetryDelegator) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A TelemetrySubscription tracks latest values for streaming
|
* A TelemetrySubscription tracks latest values for streaming
|
||||||
* telemetry data and handles notifying interested observers.
|
* telemetry data and handles notifying interested observers.
|
||||||
@ -92,10 +91,38 @@ define(
|
|||||||
updatePending = false;
|
updatePending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Look up metadata associated with an object's telemetry
|
||||||
|
function lookupMetadata(domainObject) {
|
||||||
|
var telemetryCapability =
|
||||||
|
domainObject.getCapability("telemetry");
|
||||||
|
return telemetryCapability &&
|
||||||
|
telemetryCapability.getMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
// From a telemetry series, retrieve a single data point
|
||||||
|
// containing all fields for domains/ranges
|
||||||
|
function makeDatum(domainObject, series, index) {
|
||||||
|
var metadata = lookupMetadata(domainObject),
|
||||||
|
result = {};
|
||||||
|
|
||||||
|
(metadata.domains || []).forEach(function (domain) {
|
||||||
|
result[domain.key] =
|
||||||
|
series.getDomainValue(index, domain.key);
|
||||||
|
});
|
||||||
|
|
||||||
|
(metadata.ranges || []).forEach(function (range) {
|
||||||
|
result[range.key] =
|
||||||
|
series.getRangeValue(index, range.key);
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the latest telemetry data for a specific
|
// Update the latest telemetry data for a specific
|
||||||
// domain object. This will notify listeners.
|
// domain object. This will notify listeners.
|
||||||
function update(domainObject, telemetry) {
|
function update(domainObject, series) {
|
||||||
var count = telemetry && telemetry.getPointCount();
|
var count = series && series.getPointCount();
|
||||||
|
|
||||||
// Only schedule notification if there isn't already
|
// Only schedule notification if there isn't already
|
||||||
// a notification pending (and if we actually have
|
// a notification pending (and if we actually have
|
||||||
@ -108,8 +135,9 @@ define(
|
|||||||
// Update the latest-value table
|
// Update the latest-value table
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
pool.put(domainObject.getId(), {
|
pool.put(domainObject.getId(), {
|
||||||
domain: telemetry.getDomainValue(count - 1),
|
domain: series.getDomainValue(count - 1),
|
||||||
range: telemetry.getRangeValue(count - 1)
|
range: series.getRangeValue(count - 1),
|
||||||
|
datum: makeDatum(domainObject, series, count - 1)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,14 +152,6 @@ define(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look up metadata associated with an object's telemetry
|
|
||||||
function lookupMetadata(domainObject) {
|
|
||||||
var telemetryCapability =
|
|
||||||
domainObject.getCapability("telemetry");
|
|
||||||
return telemetryCapability &&
|
|
||||||
telemetryCapability.getMetadata();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare subscriptions to all relevant telemetry-providing
|
// Prepare subscriptions to all relevant telemetry-providing
|
||||||
// domain objects.
|
// domain objects.
|
||||||
function subscribeAll(domainObjects) {
|
function subscribeAll(domainObjects) {
|
||||||
@ -214,6 +234,16 @@ define(
|
|||||||
var id = domainObject.getId();
|
var id = domainObject.getId();
|
||||||
return (latestValues[id] || {}).range;
|
return (latestValues[id] || {}).range;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get the latest telemetry datum for this domain object.
|
||||||
|
*
|
||||||
|
* @param {DomainObject} domainObject the object of interest
|
||||||
|
* @returns {TelemetryDatum} the most recent datum
|
||||||
|
*/
|
||||||
|
getDatum: function (domainObject) {
|
||||||
|
var id = domainObject.getId();
|
||||||
|
return (latestValues[id] || {}).datum;
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Get all telemetry-providing domain objects which are
|
* Get all telemetry-providing domain objects which are
|
||||||
* being observed as part of this subscription.
|
* being observed as part of this subscription.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user