keep track of latest timestamp

This commit is contained in:
David Tsay 2020-03-03 17:34:27 -08:00
parent 4c4b587d9c
commit 34a149661c

View File

@ -29,6 +29,8 @@ export default class ConditionManager extends EventEmitter {
super();
this.domainObject = domainObject;
this.openmct = openmct;
this.timeAPI = this.openmct.time;
this.latestTimestamp = {};
this.instantiate = this.openmct.$injector.get('instantiate');
this.initialize();
}
@ -213,6 +215,7 @@ export default class ConditionManager extends EventEmitter {
if (this.findConditionById(idAsString)) {
this.conditionResults[idAsString] = resultObj.data.result;
}
this.updateTimestamp(resultObj.data);
}
for (let i = 0; i < conditionCollection.length - 1; i++) {
@ -226,18 +229,28 @@ export default class ConditionManager extends EventEmitter {
this.openmct.objects.get(currentConditionIdentifier).then((obj) => {
this.emit('conditionSetResultUpdated',
Object.assign({},
resultObj ? resultObj.data : {},
Object.assign(
{
output: obj.configuration.output,
id: this.domainObject.identifier,
conditionId: currentConditionIdentifier
}
},
this.latestTimestamp
)
)
});
}
updateTimestamp(timestamp) {
this.timeAPI.getAllTimeSystems().forEach(timeSystem => {
if (!this.latestTimestamp[timeSystem.key]
|| timestamp[timeSystem.key] > this.latestTimestamp[timeSystem.key]
) {
this.latestTimestamp[timeSystem.key] = timestamp[timeSystem.key];
}
});
}
persist() {
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.domainObject.configuration.conditionCollection);
}