mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
Added timestamp checking for individual criteria
This commit is contained in:
parent
bc6a828e9e
commit
4e89304d0c
@ -87,14 +87,16 @@ export default class Condition extends EventEmitter {
|
|||||||
|
|
||||||
// if all the criteria in this condition have no telemetry, we want to force the condition result to evaluate
|
// if all the criteria in this condition have no telemetry, we want to force the condition result to evaluate
|
||||||
if (this.hasNoTelemetry() || this.isTelemetryUsed(telemetryIdThatChanged)) {
|
if (this.hasNoTelemetry() || this.isTelemetryUsed(telemetryIdThatChanged)) {
|
||||||
|
const currentTimeSystemKey = this.openmct.time.getTimeSystem().key;
|
||||||
|
|
||||||
this.criteria.forEach((criterion) => {
|
this.criteria.forEach((criterion) => {
|
||||||
if (this.isAnyOrAllTelemetry(criterion)) {
|
if (this.isAnyOrAllTelemetry(criterion)) {
|
||||||
criterion.updateResult(latestDataTable, this.conditionManager.telemetryObjects);
|
criterion.updateResult(latestDataTable, this.conditionManager.telemetryObjects);
|
||||||
} else {
|
} else {
|
||||||
const relevantDatum = latestDataTable.get(criterion.telemetryObjectIdAsString);
|
const relevantDatum = latestDataTable.get(criterion.telemetryObjectIdAsString);
|
||||||
|
|
||||||
if (relevantDatum !== undefined) {
|
if (criterion.shouldUpdateResult(relevantDatum, currentTimeSystemKey)) {
|
||||||
criterion.updateResult(relevantDatum);
|
criterion.updateResult(relevantDatum, currentTimeSystemKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -29,16 +29,22 @@ import { getOperatorText, OPERATIONS } from '../utils/operations.js';
|
|||||||
import { checkIfOld } from '../utils/time.js';
|
import { checkIfOld } from '../utils/time.js';
|
||||||
|
|
||||||
export default class TelemetryCriterion extends EventEmitter {
|
export default class TelemetryCriterion extends EventEmitter {
|
||||||
|
#lastUpdated;
|
||||||
|
#lastTimeSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes/Unsubscribes to telemetry and emits the result
|
* Subscribes/Unsubscribes to telemetry and emits the result
|
||||||
* of operations performed on the telemetry data returned and a given input value.
|
* of operations performed on the telemetry data returned and a given input value.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param telemetryDomainObjectDefinition {id: uuid, operation: enum, input: Array, metadata: string, key: {domainObject.identifier} }
|
* @param telemetryDomainObjectDefinition {id: uuid, operation: enum, input: Array, metadata: string, key: {domainObject.identifier} }
|
||||||
* @param openmct
|
* @param {import('../../../MCT.js').OpenMCT} openmct
|
||||||
*/
|
*/
|
||||||
constructor(telemetryDomainObjectDefinition, openmct) {
|
constructor(telemetryDomainObjectDefinition, openmct) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {import('../../../MCT.js').MCT}
|
||||||
|
*/
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.telemetryDomainObjectDefinition = telemetryDomainObjectDefinition;
|
this.telemetryDomainObjectDefinition = telemetryDomainObjectDefinition;
|
||||||
this.id = telemetryDomainObjectDefinition.id;
|
this.id = telemetryDomainObjectDefinition.id;
|
||||||
@ -179,8 +185,15 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
|
|
||||||
return datum;
|
return datum;
|
||||||
}
|
}
|
||||||
|
shouldUpdateResult(datum, timesystem) {
|
||||||
|
const dataIsDefined = datum !== undefined;
|
||||||
|
const hasTimeSystemChanged =
|
||||||
|
this.#lastTimeSystem === undefined || this.#lastTimeSystem !== timesystem;
|
||||||
|
const isCacheStale = this.#lastUpdated === undefined || datum[timesystem] > this.#lastUpdated;
|
||||||
|
|
||||||
updateResult(data) {
|
return dataIsDefined && (hasTimeSystemChanged || isCacheStale);
|
||||||
|
}
|
||||||
|
updateResult(data, currentTimeSystemKey) {
|
||||||
const validatedData = this.isValid() ? data : {};
|
const validatedData = this.isValid() ? data : {};
|
||||||
|
|
||||||
if (!this.isStalenessCheck()) {
|
if (!this.isStalenessCheck()) {
|
||||||
@ -193,6 +206,8 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
} else {
|
} else {
|
||||||
this.result = this.computeResult(validatedData);
|
this.result = this.computeResult(validatedData);
|
||||||
}
|
}
|
||||||
|
this.#lastUpdated = data[currentTimeSystemKey];
|
||||||
|
this.#lastTimeSystem = currentTimeSystemKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user