mirror of
https://github.com/nasa/openmct.git
synced 2025-01-04 12:24:10 +00:00
subscriptions should use latest timestamp
This commit is contained in:
parent
24bb96cc90
commit
d41fc27b55
@ -253,7 +253,6 @@ export default class ConditionClass extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleConditionUpdated(datum) {
|
handleConditionUpdated(datum) {
|
||||||
console.log(datum);
|
|
||||||
// trigger an updated event so that consumers can react accordingly
|
// trigger an updated event so that consumers can react accordingly
|
||||||
this.result = this.evaluate(this.criteriaResults);
|
this.result = this.evaluate(this.criteriaResults);
|
||||||
this.emitEvent('conditionResultUpdated',
|
this.emitEvent('conditionResultUpdated',
|
||||||
|
@ -31,7 +31,6 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
this.conditionSetDomainObject = conditionSetDomainObject;
|
this.conditionSetDomainObject = conditionSetDomainObject;
|
||||||
this.timeAPI = this.openmct.time;
|
this.timeAPI = this.openmct.time;
|
||||||
this.latestTimestamp = {};
|
|
||||||
this.timeSystems = this.openmct.time.getAllTimeSystems();
|
this.timeSystems = this.openmct.time.getAllTimeSystems();
|
||||||
this.composition = this.openmct.composition.get(conditionSetDomainObject);
|
this.composition = this.openmct.composition.get(conditionSetDomainObject);
|
||||||
this.composition.on('add', this.subscribeToTelemetry, this);
|
this.composition.on('add', this.subscribeToTelemetry, this);
|
||||||
@ -203,7 +202,6 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateConditionResults(conditionResults, resultObj) {
|
updateConditionResults(conditionResults, resultObj) {
|
||||||
console.log(resultObj.data);
|
|
||||||
if (!resultObj) {
|
if (!resultObj) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,18 +211,14 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
if (this.findConditionById(id)) {
|
if (this.findConditionById(id)) {
|
||||||
conditionResults[id] = resultObj.data.result;
|
conditionResults[id] = resultObj.data.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.latestTimestamp = getLatestTimestamp(
|
|
||||||
this.latestTimestamp,
|
|
||||||
resultObj.data,
|
|
||||||
this.timeSystems
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleConditionResult(resultObj) {
|
handleConditionResult(resultObj) {
|
||||||
// update conditions results and then calculate the current condition
|
|
||||||
this.updateConditionResults(this.conditionResults, resultObj);
|
this.updateConditionResults(this.conditionResults, resultObj);
|
||||||
|
|
||||||
const currentCondition = this.getCurrentCondition(this.conditionResults);
|
const currentCondition = this.getCurrentCondition(this.conditionResults);
|
||||||
|
const timestamp = JSON.parse(JSON.stringify(resultObj.data))
|
||||||
|
delete timestamp.result
|
||||||
|
|
||||||
this.emit('conditionSetResultUpdated',
|
this.emit('conditionSetResultUpdated',
|
||||||
Object.assign(
|
Object.assign(
|
||||||
@ -233,7 +227,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
id: this.conditionSetDomainObject.identifier,
|
id: this.conditionSetDomainObject.identifier,
|
||||||
conditionId: currentCondition.id
|
conditionId: currentCondition.id
|
||||||
},
|
},
|
||||||
this.latestTimestamp
|
timestamp
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -252,6 +246,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
return Promise.all(conditionRequests)
|
return Promise.all(conditionRequests)
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
results.forEach(resultObj => {
|
results.forEach(resultObj => {
|
||||||
|
this.updateConditionResults(conditionResults, resultObj);
|
||||||
latestTimestamp = getLatestTimestamp(
|
latestTimestamp = getLatestTimestamp(
|
||||||
latestTimestamp,
|
latestTimestamp,
|
||||||
resultObj.data,
|
resultObj.data,
|
||||||
@ -309,7 +304,7 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
this.composition.off('add', this.subscribeToTelemetry, this);
|
this.composition.off('add', this.subscribeToTelemetry, this);
|
||||||
this.composition.off('remove', this.unsubscribeFromTelemetry, this);
|
this.composition.off('remove', this.unsubscribeFromTelemetry, this);
|
||||||
Object.values(this.subscriptions).forEach(unsubscribe => unsubscribe());
|
Object.values(this.subscriptions).forEach(unsubscribe => unsubscribe());
|
||||||
this.subscriptions = undefined;
|
delete this.subscriptions;
|
||||||
|
|
||||||
if(this.stopObservingForChanges) {
|
if(this.stopObservingForChanges) {
|
||||||
this.stopObservingForChanges();
|
this.stopObservingForChanges();
|
||||||
|
Loading…
Reference in New Issue
Block a user