Adds parse treatment for string format.

Adds format property to sine wave generator's name metadata
This commit is contained in:
Joshi 2020-03-25 12:05:24 -07:00
parent 6f500d0d0b
commit dc7f83754a
3 changed files with 12 additions and 4 deletions

View File

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

View File

@ -81,6 +81,15 @@ 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

@ -268,9 +268,7 @@ export default class ConditionManager extends EventEmitter {
createNormalizedDatum(telemetryDatum, id) {
return Object.values(this.telemetryObjects[id].telemetryMetaData).reduce((normalizedDatum, metadatum) => {
const formatter = this.openmct.telemetry.getValueFormatter(metadatum);
const data = telemetryDatum[metadatum.source];
const parsedValue = formatter.parse(data);
normalizedDatum[metadatum.key] = _.isNaN(parsedValue) ? data : parsedValue;
normalizedDatum[metadatum.key] = formatter.parse(telemetryDatum[metadatum.source]);
return normalizedDatum;
}, {});
}