diff --git a/src/plugins/condition/ConditionManager.js b/src/plugins/condition/ConditionManager.js index 67d71405ed..25a3512155 100644 --- a/src/plugins/condition/ConditionManager.js +++ b/src/plugins/condition/ConditionManager.js @@ -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); }