mirror of
https://github.com/nasa/openmct.git
synced 2025-05-12 13:33:14 +00:00
WIP receive criterion results and compute condition results
This commit is contained in:
parent
7f32d196e4
commit
cf9336dae9
@ -59,6 +59,7 @@ export default class ConditionClass extends EventEmitter {
|
|||||||
this.criteria = [];
|
this.criteria = [];
|
||||||
this.criteriaResults = {};
|
this.criteriaResults = {};
|
||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
|
this.latestTimestamp = {};
|
||||||
if (conditionConfiguration.configuration.criteria) {
|
if (conditionConfiguration.configuration.criteria) {
|
||||||
this.createCriteria(conditionConfiguration.configuration.criteria);
|
this.createCriteria(conditionConfiguration.configuration.criteria);
|
||||||
}
|
}
|
||||||
@ -203,21 +204,18 @@ export default class ConditionClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
requestLADConditionResult() {
|
requestLADConditionResult() {
|
||||||
const criteriaResults = [];
|
const criteriaResults = this.criteria.map(criterion =>
|
||||||
|
criterion.requestLAD()
|
||||||
this.criteria.forEach(criterion => {
|
);
|
||||||
criteriaResults.push(
|
|
||||||
criterion.requestLAD()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
return Promise.all(criteriaResults)
|
return Promise.all(criteriaResults)
|
||||||
.then(results => {
|
.then(results => {
|
||||||
results.forEach(result => {
|
results.forEach(result => {
|
||||||
this.updateCriteriaResults(result);
|
this.updateCriteriaResults(result);
|
||||||
|
this.latestTimestamp = this.getLatestTimestamp(this.latestTimestamp, result)
|
||||||
});
|
});
|
||||||
|
console.log(Object.assign({}, this.latestTimestamp, { result: this.result }));
|
||||||
return Object.assign({}, /*datum,*/ { result: this.result });
|
return Object.assign({}, this.latestTimestamp, { result: this.result });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +251,20 @@ export default class ConditionClass extends EventEmitter {
|
|||||||
this.result = computeCondition(this.criteriaResults, this.trigger === TRIGGER.ALL);
|
this.result = computeCondition(this.criteriaResults, this.trigger === TRIGGER.ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLatestTimestamp(current, compare) {
|
||||||
|
const timestamp = Object.assign({}, current);
|
||||||
|
|
||||||
|
this.openmct.time.getAllTimeSystems().forEach(timeSystem => {
|
||||||
|
if (!timestamp[timeSystem.key]
|
||||||
|
|| compare[timeSystem.key] > timestamp[timeSystem.key]
|
||||||
|
) {
|
||||||
|
timestamp[timeSystem.key] = compare[timeSystem.key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
emitEvent(eventName, data) {
|
emitEvent(eventName, data) {
|
||||||
this.emit(eventName, {
|
this.emit(eventName, {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
@ -128,8 +128,8 @@ export default class TelemetryCriterion extends EventEmitter {
|
|||||||
obj,
|
obj,
|
||||||
options
|
options
|
||||||
).then(results => {
|
).then(results => {
|
||||||
const datum = results.length ? results[results.length - 1] : {};
|
const latestDatum = results.length ? results[results.length - 1] : {};
|
||||||
return this.formatData(datum);
|
return this.formatData(latestDatum);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user