From 72a3248123e1e3b90c6ff0be1d5ce357d2b11d5e Mon Sep 17 00:00:00 2001 From: Joshi Date: Tue, 31 Mar 2020 16:48:59 -0700 Subject: [PATCH 1/2] Fix LAD requests for any/all telemetry --- .../criterion/AllTelemetryCriterion.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/condition/criterion/AllTelemetryCriterion.js b/src/plugins/condition/criterion/AllTelemetryCriterion.js index 8355975d50..bceb21c0dd 100644 --- a/src/plugins/condition/criterion/AllTelemetryCriterion.js +++ b/src/plugins/condition/criterion/AllTelemetryCriterion.js @@ -137,28 +137,28 @@ export default class TelemetryCriterion extends EventEmitter { return this.formatData({}, options.telemetryObjects); } - const telemetryRequests = options.telemetryObjects - .map(telemetryObject => this.telemetryAPI.request( - telemetryObject, + let keys = Object.keys(Object.assign({}, options.telemetryObjects)); + const telemetryRequests = keys + .map(key => this.telemetryAPI.request( + options.telemetryObjects[key], options )); return Promise.all(telemetryRequests) .then(telemetryRequestsResults => { + let latestDatum; telemetryRequestsResults.forEach((results, index) => { - const latestDatum = results.length ? results[results.length - 1] : {}; - if (index === telemetryRequestsResults.length-1) { - //when the last result is computed, we return the result - return { - id: this.id, - data: this.formatData(latestDatum, options.telemetryObjects) - }; - } else { + latestDatum = results.length ? results[results.length - 1] : {}; + if (index < telemetryRequestsResults.length-1) { if (latestDatum) { this.telemetryDataCache[latestDatum.id] = this.computeResult(latestDatum); } } }); + return { + id: this.id, + data: this.formatData(latestDatum, options.telemetryObjects) + }; }); } From b9ab599c350e54bf1b80ae590b1bee0225ca52bb Mon Sep 17 00:00:00 2001 From: Joshi Date: Wed, 1 Apr 2020 10:10:31 -0700 Subject: [PATCH 2/2] Fix description and errors for all/any telemetry --- .../components/ConditionDescription.vue | 59 +++++++++++-------- .../condition/components/ConditionError.vue | 21 +++++-- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/src/plugins/condition/components/ConditionDescription.vue b/src/plugins/condition/components/ConditionDescription.vue index f80db911f1..3bfd121e6b 100644 --- a/src/plugins/condition/components/ConditionDescription.vue +++ b/src/plugins/condition/components/ConditionDescription.vue @@ -105,36 +105,45 @@ export default { } }, getCriterionDescription(criterion, index) { - this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { - if (telemetryObject.type === 'unknown') { - let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`; - this.criterionDescriptions.splice(index, 0, description); - } else { - let metadataValue = criterion.metadata; - let inputValue = criterion.input; - if (criterion.metadata) { - this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject); + if (!criterion.telemetry) { + let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`; + this.criterionDescriptions.splice(index, 0, description); + } else if (criterion.telemetry === 'all' || criterion.telemetry === 'any') { + const telemetryDescription = criterion.telemetry === 'all' ? 'All telemetry' : 'Any telemetry'; + let description = `${telemetryDescription} ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`; + this.criterionDescriptions.splice(index, 0, description); + } else { + this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { + if (telemetryObject.type === 'unknown') { + let description = `Unknown ${criterion.metadata} ${this.getOperatorText(criterion.operation, criterion.input)}`; + this.criterionDescriptions.splice(index, 0, description); + } else { + let metadataValue = criterion.metadata; + let inputValue = criterion.input; + if (criterion.metadata) { + this.telemetryMetadata = this.openmct.telemetry.getMetadata(telemetryObject); - const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata); - if (metadataObj) { - if (metadataObj.name) { - metadataValue = metadataObj.name; - } - if(metadataObj.enumerations && inputValue.length) { - if (metadataObj.enumerations[inputValue[0]] && metadataObj.enumerations[inputValue[0]].string) { - inputValue = [metadataObj.enumerations[inputValue[0]].string]; + const metadataObj = this.telemetryMetadata.valueMetadatas.find((metadata) => metadata.key === criterion.metadata); + if (metadataObj) { + if (metadataObj.name) { + metadataValue = metadataObj.name; + } + if(metadataObj.enumerations && inputValue.length) { + if (metadataObj.enumerations[inputValue[0]] && metadataObj.enumerations[inputValue[0]].string) { + inputValue = [metadataObj.enumerations[inputValue[0]].string]; + } } } } + let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, inputValue)}`; + if (this.criterionDescriptions[index]) { + this.criterionDescriptions[index] = description; + } else { + this.criterionDescriptions.splice(index, 0, description); + } } - let description = `${telemetryObject.name} ${metadataValue} ${this.getOperatorText(criterion.operation, inputValue)}`; - if (this.criterionDescriptions[index]) { - this.criterionDescriptions[index] = description; - } else { - this.criterionDescriptions.splice(index, 0, description); - } - } - }); + }); + } }, getOperatorText(operationName, values) { const found = OPERATIONS.find((operation) => operation.name === operationName); diff --git a/src/plugins/condition/components/ConditionError.vue b/src/plugins/condition/components/ConditionError.vue index 98f0e523d1..8a23c4a15b 100644 --- a/src/plugins/condition/components/ConditionError.vue +++ b/src/plugins/condition/components/ConditionError.vue @@ -66,14 +66,23 @@ export default { } }, getCriterionErrors(criterion, index) { - this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { - if (telemetryObject.type === 'unknown') { - this.conditionErrors.push({ - message: ERROR.TELEMETRY_NOT_FOUND, - additionalInfo: criterion.telemetry ? `Key: ${this.openmct.objects.makeKeyString(criterion.telemetry)}` : '' + if (!criterion.telemetry) { + this.conditionErrors.push({ + message: ERROR.TELEMETRY_NOT_FOUND, + additionalInfo: '' + }); + } else { + if (criterion.telemetry !== 'all' && criterion.telemetry !== 'any') { + this.openmct.objects.get(criterion.telemetry).then((telemetryObject) => { + if (telemetryObject.type === 'unknown') { + this.conditionErrors.push({ + message: ERROR.TELEMETRY_NOT_FOUND, + additionalInfo: criterion.telemetry ? `Key: ${this.openmct.objects.makeKeyString(criterion.telemetry)}` : '' + }); + } }); } - }); + } } } }