Update condition sets in fixed timespan mode if the datum's timestamp is valid (#3852)

This commit is contained in:
Shefali Joshi 2021-05-11 19:25:56 -07:00 committed by GitHub
parent 3ca133c782
commit dacec48aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 51 additions and 12 deletions

View File

@ -272,11 +272,11 @@ export default class Condition extends EventEmitter {
} }
} }
requestLADConditionResult() { requestLADConditionResult(options) {
let latestTimestamp; let latestTimestamp;
let criteriaResults = {}; let criteriaResults = {};
const criteriaRequests = this.criteria const criteriaRequests = this.criteria
.map(criterion => criterion.requestLAD(this.conditionManager.telemetryObjects)); .map(criterion => criterion.requestLAD(this.conditionManager.telemetryObjects, options));
return Promise.all(criteriaRequests) return Promise.all(criteriaRequests)
.then(results => { .then(results => {

View File

@ -282,7 +282,7 @@ export default class ConditionManager extends EventEmitter {
return currentCondition; return currentCondition;
} }
requestLADConditionSetOutput() { requestLADConditionSetOutput(options) {
if (!this.conditions.length) { if (!this.conditions.length) {
return Promise.resolve([]); return Promise.resolve([]);
} }
@ -291,7 +291,7 @@ export default class ConditionManager extends EventEmitter {
let latestTimestamp; let latestTimestamp;
let conditionResults = {}; let conditionResults = {};
const conditionRequests = this.conditions const conditionRequests = this.conditions
.map(condition => condition.requestLADConditionResult()); .map(condition => condition.requestLADConditionResult(options));
return Promise.all(conditionRequests) return Promise.all(conditionRequests)
.then((results) => { .then((results) => {

View File

@ -40,10 +40,10 @@ export default class ConditionSetTelemetryProvider {
return domainObject.type === 'conditionSet'; return domainObject.type === 'conditionSet';
} }
request(domainObject) { request(domainObject, options) {
let conditionManager = this.getConditionManager(domainObject); let conditionManager = this.getConditionManager(domainObject);
return conditionManager.requestLADConditionSetOutput() return conditionManager.requestLADConditionSetOutput(options)
.then(latestOutput => { .then(latestOutput => {
return latestOutput; return latestOutput;
}); });
@ -52,7 +52,9 @@ export default class ConditionSetTelemetryProvider {
subscribe(domainObject, callback) { subscribe(domainObject, callback) {
let conditionManager = this.getConditionManager(domainObject); let conditionManager = this.getConditionManager(domainObject);
conditionManager.on('conditionSetResultUpdated', callback); conditionManager.on('conditionSetResultUpdated', (data) => {
callback(data);
});
return this.destroyConditionManager.bind(this, this.openmct.objects.makeKeyString(domainObject.identifier)); return this.destroyConditionManager.bind(this, this.openmct.objects.makeKeyString(domainObject.identifier));
} }

View File

@ -35,6 +35,7 @@ export default class StyleRuleManager extends EventEmitter {
if (styleConfiguration) { if (styleConfiguration) {
this.initialize(styleConfiguration); this.initialize(styleConfiguration);
if (styleConfiguration.conditionSetIdentifier) { if (styleConfiguration.conditionSetIdentifier) {
this.openmct.time.on("bounds", this.refreshData.bind(this));
this.subscribeToConditionSet(); this.subscribeToConditionSet();
} else { } else {
this.applyStaticStyle(); this.applyStaticStyle();
@ -83,6 +84,25 @@ export default class StyleRuleManager extends EventEmitter {
}); });
} }
refreshData(bounds, isTick) {
if (!isTick) {
let options = {
start: bounds.start,
end: bounds.end,
size: 1,
strategy: 'latest'
};
this.openmct.objects.get(this.conditionSetIdentifier).then((conditionSetDomainObject) => {
this.openmct.telemetry.request(conditionSetDomainObject, options)
.then(output => {
if (output && output.length) {
this.handleConditionSetResultUpdated(output[0]);
}
});
});
}
}
updateObjectStyleConfig(styleConfiguration) { updateObjectStyleConfig(styleConfiguration) {
if (!styleConfiguration || !styleConfiguration.conditionSetIdentifier) { if (!styleConfiguration || !styleConfiguration.conditionSetIdentifier) {
this.initialize(styleConfiguration || {}); this.initialize(styleConfiguration || {});
@ -160,10 +180,14 @@ export default class StyleRuleManager extends EventEmitter {
destroy() { destroy() {
if (this.stopProvidingTelemetry) { if (this.stopProvidingTelemetry) {
this.stopProvidingTelemetry(); this.stopProvidingTelemetry();
delete this.stopProvidingTelemetry; delete this.stopProvidingTelemetry;
} }
this.openmct.time.off("bounds", this.refreshData);
this.openmct.editor.off('isEditing', this.toggleSubscription);
this.conditionSetIdentifier = undefined; this.conditionSetIdentifier = undefined;
} }

View File

@ -147,12 +147,16 @@ export default class AllTelemetryCriterion extends TelemetryCriterion {
this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry); this.result = evaluateResults(Object.values(this.telemetryDataCache), this.telemetry);
} }
requestLAD(telemetryObjects) { requestLAD(telemetryObjects, requestOptions) {
const options = { let options = {
strategy: 'latest', strategy: 'latest',
size: 1 size: 1
}; };
if (requestOptions !== undefined) {
options = Object.assign(options, requestOptions);
}
if (!this.isValid()) { if (!this.isValid()) {
return this.formatData({}, telemetryObjects); return this.formatData({}, telemetryObjects);
} }

View File

@ -137,12 +137,16 @@ export default class TelemetryCriterion extends EventEmitter {
} }
} }
requestLAD() { requestLAD(telemetryObjects, requestOptions) {
const options = { let options = {
strategy: 'latest', strategy: 'latest',
size: 1 size: 1
}; };
if (requestOptions !== undefined) {
options = Object.assign(options, requestOptions);
}
if (!this.isValid()) { if (!this.isValid()) {
return { return {
id: this.id, id: this.id,

View File

@ -269,7 +269,12 @@ export default {
}, },
subscribeToObject() { subscribeToObject() {
this.subscription = this.openmct.telemetry.subscribe(this.domainObject, function (datum) { this.subscription = this.openmct.telemetry.subscribe(this.domainObject, function (datum) {
if (this.openmct.time.clock() !== undefined) { const key = this.openmct.time.timeSystem().key;
const datumTimeStamp = datum[key];
if (this.openmct.time.clock() !== undefined
|| (datumTimeStamp
&& (this.openmct.time.bounds().end >= datumTimeStamp))
) {
this.updateView(datum); this.updateView(datum);
} }
}.bind(this)); }.bind(this));