mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +00:00
Some optimizations
This commit is contained in:
parent
4e89304d0c
commit
dc47dba403
@ -31,6 +31,7 @@ import { checkIfOld } from '../utils/time.js';
|
|||||||
export default class TelemetryCriterion extends EventEmitter {
|
export default class TelemetryCriterion extends EventEmitter {
|
||||||
#lastUpdated;
|
#lastUpdated;
|
||||||
#lastTimeSystem;
|
#lastTimeSystem;
|
||||||
|
#comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes/Unsubscribes to telemetry and emits the result
|
* Subscribes/Unsubscribes to telemetry and emits the result
|
||||||
@ -50,6 +51,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
this.id = telemetryDomainObjectDefinition.id;
|
this.id = telemetryDomainObjectDefinition.id;
|
||||||
this.telemetry = telemetryDomainObjectDefinition.telemetry;
|
this.telemetry = telemetryDomainObjectDefinition.telemetry;
|
||||||
this.operation = telemetryDomainObjectDefinition.operation;
|
this.operation = telemetryDomainObjectDefinition.operation;
|
||||||
|
this.#comparator = this.#findOperation(this.operation);
|
||||||
this.input = telemetryDomainObjectDefinition.input;
|
this.input = telemetryDomainObjectDefinition.input;
|
||||||
this.metadata = telemetryDomainObjectDefinition.metadata;
|
this.metadata = telemetryDomainObjectDefinition.metadata;
|
||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
@ -251,7 +253,7 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
findOperation(operation) {
|
#findOperation(operation) {
|
||||||
for (let i = 0, ii = OPERATIONS.length; i < ii; i++) {
|
for (let i = 0, ii = OPERATIONS.length; i < ii; i++) {
|
||||||
if (operation === OPERATIONS[i].name) {
|
if (operation === OPERATIONS[i].name) {
|
||||||
return OPERATIONS[i].operation;
|
return OPERATIONS[i].operation;
|
||||||
@ -264,15 +266,14 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
computeResult(data) {
|
computeResult(data) {
|
||||||
let result = false;
|
let result = false;
|
||||||
if (data) {
|
if (data) {
|
||||||
let comparator = this.findOperation(this.operation);
|
|
||||||
let params = [];
|
let params = [];
|
||||||
params.push(data[this.metadata]);
|
params.push(data[this.metadata]);
|
||||||
if (this.isValidInput()) {
|
if (this.isValidInput()) {
|
||||||
this.input.forEach((input) => params.push(input));
|
this.input.forEach((input) => params.push(input));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof comparator === 'function') {
|
if (typeof this.comparator === 'function') {
|
||||||
result = Boolean(comparator(params));
|
result = Boolean(this.comparator(params));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user