mirror of
https://github.com/nasa/openmct.git
synced 2025-01-22 04:18:05 +00:00
Addresses comments - change function names, consolidate compute function
This commit is contained in:
parent
b3488c54cd
commit
e419149378
@ -24,7 +24,7 @@ import * as EventEmitter from 'eventemitter3';
|
||||
import uuid from 'uuid';
|
||||
import TelemetryCriterion from "@/plugins/condition/criterion/TelemetryCriterion";
|
||||
import { TRIGGER } from "@/plugins/condition/utils/constants";
|
||||
import {computeConditionForAll, computeConditionForAny} from "@/plugins/condition/utils/evaluator";
|
||||
import {computeCondition} from "@/plugins/condition/utils/evaluator";
|
||||
|
||||
/*
|
||||
* conditionDefinition = {
|
||||
@ -228,11 +228,7 @@ export default class ConditionClass extends EventEmitter {
|
||||
|
||||
//TODO: implement as part of the evaluator class task.
|
||||
evaluate() {
|
||||
if (this.trigger === TRIGGER.ANY) {
|
||||
this.result = computeConditionForAny(this.criteriaResults);
|
||||
} else if (this.trigger === TRIGGER.ALL) {
|
||||
this.result = computeConditionForAll(this.criteriaResults);
|
||||
}
|
||||
this.result = computeCondition(this.criteriaResults, this.trigger === TRIGGER.ALL);
|
||||
}
|
||||
|
||||
emitEvent(eventName, data) {
|
||||
|
@ -89,7 +89,7 @@
|
||||
<span class="t-configuration">
|
||||
<span class="controls">
|
||||
<select v-model="selectedTelemetryKey"
|
||||
@change="telemetryChange"
|
||||
@change="updateTelemetryMetaData"
|
||||
>
|
||||
<option value="">- Select Telemetry -</option>
|
||||
<option v-for="telemetryOption in telemetry"
|
||||
@ -113,7 +113,7 @@
|
||||
</span>
|
||||
<span class="controls">
|
||||
<select v-model="selectedOperationKey"
|
||||
@change="operationKeyChange"
|
||||
@change="setInputValueVisibility"
|
||||
>
|
||||
<option value="">- Select Comparison -</option>
|
||||
<option v-for="option in operations"
|
||||
@ -324,7 +324,7 @@ export default {
|
||||
this.condition.definition.output = this.selectedOutputKey;
|
||||
}
|
||||
},
|
||||
operationKeyChange(ev) {
|
||||
setInputValueVisibility(ev) {
|
||||
if (this.selectedOperationKey !== 'isUndefined' && this.selectedOperationKey !== 'isDefined') {
|
||||
this.comparisonValueField = true;
|
||||
} else {
|
||||
@ -332,7 +332,7 @@ export default {
|
||||
}
|
||||
//find the criterion being updated and set the operation property
|
||||
},
|
||||
telemetryChange() {
|
||||
updateTelemetryMetaData() {
|
||||
this.selectedMetaDataKey = '';
|
||||
this.updateConditionCriteria();
|
||||
this.updateTelemetry();
|
||||
|
@ -1,28 +1,13 @@
|
||||
/**
|
||||
* Returns true only if at least one of the results is true
|
||||
**/
|
||||
export const computeConditionForAny = (resultMap) => {
|
||||
export const computeCondition = (resultMap, allMustBeTrue) => {
|
||||
let result = false;
|
||||
for (let key in resultMap) {
|
||||
if (resultMap.hasOwnProperty(key)) {
|
||||
result = resultMap[key];
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true only if all the results are true
|
||||
**/
|
||||
export const computeConditionForAll = (resultMap) => {
|
||||
let result = false;
|
||||
for (let key in resultMap) {
|
||||
if (resultMap.hasOwnProperty(key)) {
|
||||
result = resultMap[key];
|
||||
if (!result) {
|
||||
if (allMustBeTrue && !result) {
|
||||
//If we want all conditions to be true, then even one negative result should break.
|
||||
break;
|
||||
} else if (!allMustBeTrue && result) {
|
||||
//If we want at least one condition to be true, then even one positive result should break.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user