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