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