Fixes error while getting metadata when telemetry is not yet available for a criterion

This commit is contained in:
Joshi 2020-03-25 13:44:26 -07:00
parent dc7f83754a
commit fcca8fa8d9
6 changed files with 19 additions and 19 deletions

View File

@ -9,8 +9,7 @@ define([
values: [ values: [
{ {
key: "name", key: "name",
name: "Name", name: "Name"
format: "string"
}, },
{ {
key: "utc", key: "utc",

View File

@ -81,15 +81,6 @@ define([
return printj.sprintf(formatString, baseFormat.call(this, value)); return printj.sprintf(formatString, baseFormat.call(this, value));
}; };
} }
if (valueMetadata.format === 'string') {
this.formatter.parse = function (value) {
if (typeof value === 'string') {
return value;
} else {
return value.toString();
}
};
}
} }
TelemetryValueFormatter.prototype.parse = function (datum) { TelemetryValueFormatter.prototype.parse = function (datum) {

View File

@ -193,6 +193,11 @@ export default class ConditionClass extends EventEmitter {
let found = this.findCriterion(criterion.id); let found = this.findCriterion(criterion.id);
if (found) { if (found) {
this.criteria[found.index] = criterion.data; this.criteria[found.index] = criterion.data;
// TODO nothing is listening to this
this.emitEvent('conditionUpdated', {
trigger: this.trigger,
criteria: this.criteria
});
} }
} }

View File

@ -25,6 +25,7 @@ import {TRIGGER} from "./utils/constants";
import TelemetryCriterion from "./criterion/TelemetryCriterion"; import TelemetryCriterion from "./criterion/TelemetryCriterion";
let openmct = {}, let openmct = {},
mockListener,
testConditionDefinition, testConditionDefinition,
testTelemetryObject, testTelemetryObject,
conditionObj, conditionObj,
@ -40,6 +41,7 @@ describe("The condition", function () {
mockBroadcastTelemetry = jasmine.createSpy('listener'); mockBroadcastTelemetry = jasmine.createSpy('listener');
conditionManager.on('broadcastTelemetry', mockBroadcastTelemetry); conditionManager.on('broadcastTelemetry', mockBroadcastTelemetry);
mockListener = jasmine.createSpy('listener');
testTelemetryObject = { testTelemetryObject = {
identifier:{ namespace: "", key: "test-object"}, identifier:{ namespace: "", key: "test-object"},
type: "test-object", type: "test-object",
@ -92,6 +94,8 @@ describe("The condition", function () {
openmct, openmct,
conditionManager conditionManager
); );
conditionObj.on('conditionUpdated', mockListener);
}); });
it("generates criteria with the correct properties", function () { it("generates criteria with the correct properties", function () {

View File

@ -40,6 +40,7 @@ export default class TelemetryCriterion extends EventEmitter {
this.telemetryAPI = this.openmct.telemetry; this.telemetryAPI = this.openmct.telemetry;
this.timeAPI = this.openmct.time; this.timeAPI = this.openmct.time;
this.id = telemetryDomainObjectDefinition.id; this.id = telemetryDomainObjectDefinition.id;
this.telemetry = telemetryDomainObjectDefinition.telemetry;
this.operation = telemetryDomainObjectDefinition.operation; this.operation = telemetryDomainObjectDefinition.operation;
this.input = telemetryDomainObjectDefinition.input; this.input = telemetryDomainObjectDefinition.input;
this.metadata = telemetryDomainObjectDefinition.metadata; this.metadata = telemetryDomainObjectDefinition.metadata;

View File

@ -2,7 +2,7 @@ export const OPERATIONS = [
{ {
name: 'equalTo', name: 'equalTo',
operation: function (input) { operation: function (input) {
return input[0] === parseInt(input[1]); return input[0] === input[1];
}, },
text: 'is equal to', text: 'is equal to',
appliesTo: ['number'], appliesTo: ['number'],
@ -14,7 +14,7 @@ export const OPERATIONS = [
{ {
name: 'notEqualTo', name: 'notEqualTo',
operation: function (input) { operation: function (input) {
return input[0] !== parseInt(input[1]); return input[0] !== input[1];
}, },
text: 'is not equal to', text: 'is not equal to',
appliesTo: ['number'], appliesTo: ['number'],
@ -26,7 +26,7 @@ export const OPERATIONS = [
{ {
name: 'greaterThan', name: 'greaterThan',
operation: function (input) { operation: function (input) {
return input[0] > parseInt(input[1]); return input[0] > input[1];
}, },
text: 'is greater than', text: 'is greater than',
appliesTo: ['number'], appliesTo: ['number'],
@ -38,7 +38,7 @@ export const OPERATIONS = [
{ {
name: 'lessThan', name: 'lessThan',
operation: function (input) { operation: function (input) {
return input[0] < parseInt(input[1]); return input[0] < input[1];
}, },
text: 'is less than', text: 'is less than',
appliesTo: ['number'], appliesTo: ['number'],
@ -50,7 +50,7 @@ export const OPERATIONS = [
{ {
name: 'greaterThanOrEq', name: 'greaterThanOrEq',
operation: function (input) { operation: function (input) {
return input[0] >= parseInt(input[1]); return input[0] >= input[1];
}, },
text: 'is greater than or equal to', text: 'is greater than or equal to',
appliesTo: ['number'], appliesTo: ['number'],
@ -62,7 +62,7 @@ export const OPERATIONS = [
{ {
name: 'lessThanOrEq', name: 'lessThanOrEq',
operation: function (input) { operation: function (input) {
return input[0] <= parseInt(input[1]); return input[0] <= input[1];
}, },
text: 'is less than or equal to', text: 'is less than or equal to',
appliesTo: ['number'], appliesTo: ['number'],
@ -74,7 +74,7 @@ export const OPERATIONS = [
{ {
name: 'between', name: 'between',
operation: function (input) { operation: function (input) {
return input[0] > parseInt(input[1]) && input[0] < parseInt(input[2]); return input[0] > input[1] && input[0] < input[2];
}, },
text: 'is between', text: 'is between',
appliesTo: ['number'], appliesTo: ['number'],
@ -86,7 +86,7 @@ export const OPERATIONS = [
{ {
name: 'notBetween', name: 'notBetween',
operation: function (input) { operation: function (input) {
return input[0] < parseInt(input[1]) || input[0] > parseInt(input[2]); return input[0] < input[1] || input[0] > input[2];
}, },
text: 'is not between', text: 'is not between',
appliesTo: ['number'], appliesTo: ['number'],