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: [
{
key: "name",
name: "Name",
format: "string"
name: "Name"
},
{
key: "utc",

View File

@ -81,15 +81,6 @@ define([
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) {

View File

@ -193,6 +193,11 @@ export default class ConditionClass extends EventEmitter {
let found = this.findCriterion(criterion.id);
if (found) {
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";
let openmct = {},
mockListener,
testConditionDefinition,
testTelemetryObject,
conditionObj,
@ -40,6 +41,7 @@ describe("The condition", function () {
mockBroadcastTelemetry = jasmine.createSpy('listener');
conditionManager.on('broadcastTelemetry', mockBroadcastTelemetry);
mockListener = jasmine.createSpy('listener');
testTelemetryObject = {
identifier:{ namespace: "", key: "test-object"},
type: "test-object",
@ -92,6 +94,8 @@ describe("The condition", function () {
openmct,
conditionManager
);
conditionObj.on('conditionUpdated', mockListener);
});
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.timeAPI = this.openmct.time;
this.id = telemetryDomainObjectDefinition.id;
this.telemetry = telemetryDomainObjectDefinition.telemetry;
this.operation = telemetryDomainObjectDefinition.operation;
this.input = telemetryDomainObjectDefinition.input;
this.metadata = telemetryDomainObjectDefinition.metadata;

View File

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