mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
Various Conditionals bug fixes (#3611)
* Don't apply styles on destroy as destroy should not have any side effects * Don't show undefined if trigger for condition is not available yet * Force recalculation of condition result if telemetry is removed Co-authored-by: Deep Tailor <deep.j.tailor@nasa.gov>
This commit is contained in:
parent
ac2034b243
commit
26b81345f2
@ -75,7 +75,8 @@ export default class Condition extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isTelemetryUsed(datum.id)) {
|
// if all the criteria in this condition have no telemetry, we want to force the condition result to evaluate
|
||||||
|
if (this.hasNoTelemetry() || this.isTelemetryUsed(datum.id)) {
|
||||||
|
|
||||||
this.criteria.forEach(criterion => {
|
this.criteria.forEach(criterion => {
|
||||||
if (this.isAnyOrAllTelemetry(criterion)) {
|
if (this.isAnyOrAllTelemetry(criterion)) {
|
||||||
@ -93,6 +94,12 @@ export default class Condition extends EventEmitter {
|
|||||||
return (criterion.telemetry && (criterion.telemetry === 'all' || criterion.telemetry === 'any'));
|
return (criterion.telemetry && (criterion.telemetry === 'all' || criterion.telemetry === 'any'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasNoTelemetry() {
|
||||||
|
return this.criteria.every((criterion) => {
|
||||||
|
return !this.isAnyOrAllTelemetry(criterion) && criterion.telemetry === '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
isTelemetryUsed(id) {
|
isTelemetryUsed(id) {
|
||||||
return this.criteria.some(criterion => {
|
return this.criteria.some(criterion => {
|
||||||
return this.isAnyOrAllTelemetry(criterion) || criterion.telemetryObjectIdAsString === id;
|
return this.isAnyOrAllTelemetry(criterion) || criterion.telemetryObjectIdAsString === id;
|
||||||
@ -250,10 +257,17 @@ export default class Condition extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTriggerDescription() {
|
getTriggerDescription() {
|
||||||
return {
|
if (this.trigger) {
|
||||||
conjunction: TRIGGER_CONJUNCTION[this.trigger],
|
return {
|
||||||
prefix: `${TRIGGER_LABEL[this.trigger]}: `
|
conjunction: TRIGGER_CONJUNCTION[this.trigger],
|
||||||
};
|
prefix: `${TRIGGER_LABEL[this.trigger]}: `
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
conjunction: '',
|
||||||
|
prefix: ''
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
requestLADConditionResult() {
|
requestLADConditionResult() {
|
||||||
|
@ -79,6 +79,17 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
delete this.subscriptions[id];
|
delete this.subscriptions[id];
|
||||||
delete this.telemetryObjects[id];
|
delete this.telemetryObjects[id];
|
||||||
this.removeConditionTelemetryObjects();
|
this.removeConditionTelemetryObjects();
|
||||||
|
|
||||||
|
//force re-computation of condition set result as we might be in a state where
|
||||||
|
// there is no telemetry datum coming in for a while or at all.
|
||||||
|
let latestTimestamp = getLatestTimestamp(
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
this.timeSystems,
|
||||||
|
this.openmct.time.timeSystem()
|
||||||
|
);
|
||||||
|
this.updateConditionResults({id: id});
|
||||||
|
this.updateCurrentCondition(latestTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
@ -336,14 +347,17 @@ export default class ConditionManager extends EventEmitter {
|
|||||||
let timestamp = {};
|
let timestamp = {};
|
||||||
timestamp[timeSystemKey] = normalizedDatum[timeSystemKey];
|
timestamp[timeSystemKey] = normalizedDatum[timeSystemKey];
|
||||||
|
|
||||||
|
this.updateConditionResults(normalizedDatum);
|
||||||
|
this.updateCurrentCondition(timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateConditionResults(normalizedDatum) {
|
||||||
//We want to stop when the first condition evaluates to true.
|
//We want to stop when the first condition evaluates to true.
|
||||||
this.conditions.some((condition) => {
|
this.conditions.some((condition) => {
|
||||||
condition.updateResult(normalizedDatum);
|
condition.updateResult(normalizedDatum);
|
||||||
|
|
||||||
return condition.result === true;
|
return condition.result === true;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateCurrentCondition(timestamp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateCurrentCondition(timestamp) {
|
updateCurrentCondition(timestamp) {
|
||||||
|
@ -86,6 +86,7 @@ export default class StyleRuleManager extends EventEmitter {
|
|||||||
updateObjectStyleConfig(styleConfiguration) {
|
updateObjectStyleConfig(styleConfiguration) {
|
||||||
if (!styleConfiguration || !styleConfiguration.conditionSetIdentifier) {
|
if (!styleConfiguration || !styleConfiguration.conditionSetIdentifier) {
|
||||||
this.initialize(styleConfiguration || {});
|
this.initialize(styleConfiguration || {});
|
||||||
|
this.applyStaticStyle();
|
||||||
this.destroy();
|
this.destroy();
|
||||||
} else {
|
} else {
|
||||||
let isNewConditionSet = !this.conditionSetIdentifier
|
let isNewConditionSet = !this.conditionSetIdentifier
|
||||||
@ -158,7 +159,6 @@ export default class StyleRuleManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.applyStaticStyle();
|
|
||||||
if (this.stopProvidingTelemetry) {
|
if (this.stopProvidingTelemetry) {
|
||||||
this.stopProvidingTelemetry();
|
this.stopProvidingTelemetry();
|
||||||
delete this.stopProvidingTelemetry;
|
delete this.stopProvidingTelemetry;
|
||||||
|
Loading…
Reference in New Issue
Block a user