Handle string states (#2019)

* State generator realtime uses strings

Change the state generator's realtime data to return string values
instead of number values.  This exercises an edge case where
enumerations could be a string instead of a number.  Exposes #2018.

* [Telemetry] handle string enumeration value

Don't treat all strings as properly formatted enumeration values.

Instead, check any input value against known enumerations and if
one matches, return it.  Otherwise, return input.

Fixes #2018
This commit is contained in:
Pete Richards 2018-05-02 11:42:42 -07:00 committed by Pegah Sarram
parent ec8b4db2e5
commit 865b99f445
2 changed files with 5 additions and 3 deletions

View File

@ -47,7 +47,9 @@ define([
var interval = setInterval(function () {
var now = Date.now();
callback(pointForTimestamp(now, duration, domainObject.name));
var datum = pointForTimestamp(now, duration, domainObject.name);
datum.value += "";
callback(datum);
}, duration);
return function () {

View File

@ -57,8 +57,8 @@ define([
return vm;
}, {byValue: {}, byString: {}});
this.formatter.format = function (value) {
if (typeof value === "number") {
return this.enumerations.byValue[value] || value;
if (this.enumerations.byValue.hasOwnProperty(value)) {
return this.enumerations.byValue[value];
}
return value;
}.bind(this);