diff --git a/src/plugins/condition/components/Criterion.vue b/src/plugins/condition/components/Criterion.vue
index 9a14ca6af3..2162e4af03 100644
--- a/src/plugins/condition/components/Criterion.vue
+++ b/src/plugins/condition/components/Criterion.vue
@@ -45,16 +45,32 @@
{{ option.text }}
-
-
+
- and
+
+ and
+
+
+
+
+
+
@@ -92,7 +108,8 @@ export default {
operations: OPERATIONS,
inputCount: 0,
rowLabel: '',
- operationFormat: ''
+ operationFormat: '',
+ enumerations: []
}
},
computed: {
@@ -123,11 +140,13 @@ export default {
},
methods: {
getOperationFormat() {
+ this.enumerations = [];
this.telemetryMetadata.valueMetadatas.forEach((value, index) => {
if (value.key === this.criterion.metadata) {
let valueMetadata = this.telemetryMetadataOptions[index];
if (valueMetadata.enumerations !== undefined) {
this.operationFormat = 'enum';
+ this.enumerations = valueMetadata.enumerations;
} else if (valueMetadata.hints.hasOwnProperty('range')) {
this.operationFormat = 'number';
} else if (valueMetadata.hints.hasOwnProperty('domain')) {
@@ -164,7 +183,7 @@ export default {
},
updateOperationInputVisibility(ev) {
if (ev) {
- this.criterion.input = [];
+ this.criterion.input = this.enumerations.length ? [this.enumerations[0].value.toString()] : [];
this.inputCount = 0;
}
for (let i = 0; i < this.filteredOps.length; i++) {
diff --git a/src/plugins/condition/criterion/TelemetryCriterion.js b/src/plugins/condition/criterion/TelemetryCriterion.js
index 0b71f8b8a1..233c8b7172 100644
--- a/src/plugins/condition/criterion/TelemetryCriterion.js
+++ b/src/plugins/condition/criterion/TelemetryCriterion.js
@@ -51,11 +51,15 @@ export default class TelemetryCriterion extends EventEmitter {
initialize(obj) {
this.telemetryObject = obj;
+ this.telemetryMetaData = this.openmct.telemetry.getMetadata(obj).valueMetadatas;
this.telemetryObjectIdAsString = this.objectAPI.makeKeyString(this.telemetryObject.identifier);
this.emitEvent('criterionUpdated', this);
}
handleSubscription(data) {
+ if (data) {
+ data = this.createNormalizedDatum(data);
+ }
const datum = {
result: this.computeResult(data)
};
@@ -69,6 +73,13 @@ export default class TelemetryCriterion extends EventEmitter {
this.emitEvent('criterionResultUpdated', datum);
}
+ createNormalizedDatum(telemetryDatum) {
+ return Object.values(this.telemetryMetaData).reduce((normalizedDatum, metadatum) => {
+ normalizedDatum[metadatum.key] = telemetryDatum[metadatum.source];
+ return normalizedDatum;
+ }, {});
+ }
+
findOperation(operation) {
for (let i=0, ii=OPERATIONS.length; i < ii; i++) {
if (operation === OPERATIONS[i].name) {
diff --git a/src/plugins/condition/criterion/TelemetryCriterionSpec.js b/src/plugins/condition/criterion/TelemetryCriterionSpec.js
index e68e7c5f9d..93ad86e164 100644
--- a/src/plugins/condition/criterion/TelemetryCriterionSpec.js
+++ b/src/plugins/condition/criterion/TelemetryCriterionSpec.js
@@ -37,18 +37,25 @@ describe("The telemetry criterion", function () {
type: "test-object",
name: "Test Object",
telemetry: {
- values: [{
- key: "some-key",
- name: "Some attribute",
+ valueMetadatas: [{
+ key: "value",
+ name: "Value",
+ hints: {
+ range: 2
+ }
+ },
+ {
+ key: "utc",
+ name: "Time",
+ format: "utc",
hints: {
domain: 1
}
}, {
- key: "some-other-key",
- name: "Another attribute",
- hints: {
- range: 1
- }
+ key: "testSource",
+ source: "value",
+ name: "Test",
+ format: "enum"
}]
}
};
@@ -60,7 +67,7 @@ describe("The telemetry criterion", function () {
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', "subscribe", "getMetadata"]);
openmct.telemetry.isTelemetryObject.and.returnValue(true);
openmct.telemetry.subscribe.and.returnValue(function () {});
- openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values);
+ openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry);
openmct.time = jasmine.createSpyObj('timeAPI',
['timeSystem', 'bounds', 'getAllTimeSystems']
@@ -101,11 +108,11 @@ describe("The telemetry criterion", function () {
});
it("emits update event on new data from telemetry providers", function () {
+ telemetryCriterion.initialize(testTelemetryObject);
spyOn(telemetryCriterion, 'emitEvent').and.callThrough();
telemetryCriterion.handleSubscription({
- key: 'some-key',
- source: 'testSource',
- testSource: 'Hello'
+ value: 'Hello',
+ utc: 'Hi'
});
expect(telemetryCriterion.emitEvent).toHaveBeenCalled();
expect(mockListener).toHaveBeenCalled();