mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 02:39:56 +00:00
[Telemetry] Added 'name' as a telemetry datum attribute. Fixes #1099
This commit is contained in:
parent
09e79d38ff
commit
6936ab6100
@ -14,7 +14,8 @@
|
||||
"nonew": true,
|
||||
"predef": [
|
||||
"define",
|
||||
"Promise"
|
||||
"Promise",
|
||||
"WeakMap"
|
||||
],
|
||||
"shadow": "outer",
|
||||
"strict": "implied",
|
||||
|
@ -44,25 +44,29 @@ define([
|
||||
utils.makeKeyString(domainObject.identifier)).hasCapability("telemetry");
|
||||
};
|
||||
|
||||
function createDatum(metadata, legacySeries, i) {
|
||||
function createDatum(domainObject, metadata, legacySeries, i) {
|
||||
var datum = {};
|
||||
|
||||
metadata.domains.reduce(function (telemetryObject, domain) {
|
||||
datum[domain.key] = legacySeries.getDomainValue(i, domain.key);
|
||||
metadata.domains.reduce(function (d, domain) {
|
||||
d[domain.key] = legacySeries.getDomainValue(i, domain.key);
|
||||
return d;
|
||||
}, datum);
|
||||
|
||||
metadata.ranges.reduce(function (telemetryObject, range) {
|
||||
datum[range.key] = legacySeries.getRangeValue(i, range.key);
|
||||
metadata.ranges.reduce(function (d, range) {
|
||||
d[range.key] = legacySeries.getRangeValue(i, range.key);
|
||||
return d;
|
||||
}, datum);
|
||||
|
||||
datum.name = domainObject.name;
|
||||
|
||||
return datum;
|
||||
}
|
||||
|
||||
function adaptSeries(metadata, legacySeries) {
|
||||
function adaptSeries(domainObject, metadata, legacySeries) {
|
||||
var series = [];
|
||||
|
||||
for (var i=0; i < legacySeries.getPointCount(); i++) {
|
||||
series.push(createDatum(metadata, legacySeries, i));
|
||||
for (var i = 0; i < legacySeries.getPointCount(); i++) {
|
||||
series.push(createDatum(domainObject, metadata, legacySeries, i));
|
||||
}
|
||||
|
||||
return series;
|
||||
@ -90,7 +94,7 @@ define([
|
||||
var capability = oldObject.getCapability("telemetry");
|
||||
|
||||
return capability.requestData(request).then(function (telemetrySeries) {
|
||||
return Promise.resolve(adaptSeries(capability.getMetadata(), telemetrySeries));
|
||||
return Promise.resolve(adaptSeries(domainObject, capability.getMetadata(), telemetrySeries));
|
||||
}).catch(function (error) {
|
||||
return Promise.reject(error);
|
||||
});
|
||||
@ -114,8 +118,8 @@ define([
|
||||
var oldObject = this.instantiate(utils.toOldFormat(domainObject), utils.makeKeyString(domainObject.identifier));
|
||||
var capability = oldObject.getCapability("telemetry");
|
||||
|
||||
function callbackWrapper(series){
|
||||
callback(createDatum(capability.getMetadata(), series, series.getPointCount()-1));
|
||||
function callbackWrapper(series) {
|
||||
callback(createDatum(domainObject, capability.getMetadata(), series, series.getPointCount() - 1));
|
||||
}
|
||||
|
||||
return capability.subscribe(callbackWrapper, request);
|
||||
@ -125,13 +129,13 @@ define([
|
||||
var oldObject = this.instantiate(
|
||||
utils.toOldFormat(domainObject),
|
||||
utils.makeKeyString(domainObject.identifier));
|
||||
var limitEvaluator = oldObject.getCapability('limit');
|
||||
var limitEvaluator = oldObject.getCapability("limit");
|
||||
|
||||
return {
|
||||
evaluate: function (datum, property) {
|
||||
return limitEvaluator.evaluate(datum, property.key);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return function (openmct, instantiate) {
|
||||
@ -141,4 +145,4 @@ define([
|
||||
new LegacyTelemetryProvider(instantiate));
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -286,7 +286,9 @@ define([
|
||||
});
|
||||
return results;
|
||||
});
|
||||
var sortKeys = hints.map(function (h) { return 'hints.' + h; });
|
||||
var sortKeys = hints.map(function (h) {
|
||||
return 'hints.' + h;
|
||||
});
|
||||
return _.sortByAll(options, sortKeys);
|
||||
};
|
||||
|
||||
|
@ -30,11 +30,16 @@ define([
|
||||
function valueMetadatasFromOldFormat(metadata) {
|
||||
var valueMetadatas = [];
|
||||
|
||||
valueMetadatas.push({
|
||||
key: 'name',
|
||||
name: 'Name'
|
||||
});
|
||||
|
||||
metadata.domains.forEach(function (domain, index) {
|
||||
var valueMetadata = _.clone(domain);
|
||||
valueMetadata.hints = {
|
||||
x: index,
|
||||
domain: index
|
||||
x: index + 1,
|
||||
domain: index + 1
|
||||
};
|
||||
valueMetadatas.push(valueMetadata);
|
||||
});
|
||||
@ -44,7 +49,7 @@ define([
|
||||
valueMetadata.hints = {
|
||||
y: index,
|
||||
range: index,
|
||||
priority: index + metadata.domains.length
|
||||
priority: index + metadata.domains.length + 1
|
||||
};
|
||||
|
||||
if (valueMetadata.type === 'enum') {
|
||||
@ -61,7 +66,7 @@ define([
|
||||
valueMetadata.values = _.pluck(valueMetadata.enumerations, 'value');
|
||||
valueMetadata.max = _.max(valueMetadata.values);
|
||||
valueMetadata.min = _.min(valueMetadata.values);
|
||||
};
|
||||
}
|
||||
|
||||
valueMetadatas.push(valueMetadata);
|
||||
});
|
||||
@ -106,7 +111,7 @@ define([
|
||||
*/
|
||||
TelemetryMetadataManager.prototype.value = function (key) {
|
||||
return this.valueMetadatas.filter(function (metadata) {
|
||||
return metadata.key === key
|
||||
return metadata.key === key;
|
||||
})[0];
|
||||
};
|
||||
|
||||
@ -126,6 +131,7 @@ define([
|
||||
hints
|
||||
) {
|
||||
function hasHint(hint) {
|
||||
/*jshint validthis: true */
|
||||
return this.hints.hasOwnProperty(hint);
|
||||
}
|
||||
function hasHints(metadata) {
|
||||
|
@ -37,9 +37,15 @@ define([
|
||||
} catch (e) {
|
||||
// TODO: Better formatting
|
||||
this.formatter = {
|
||||
parse: function (x) { return Number(x); },
|
||||
format: function (x) { return x; },
|
||||
validate: function (x) { return true; }
|
||||
parse: function (x) {
|
||||
return Number(x);
|
||||
},
|
||||
format: function (x) {
|
||||
return x;
|
||||
},
|
||||
validate: function (x) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user