mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 13:17:53 +00:00
8db75bf41e
* [API] Support dynamic telemetry metadata Add support for dynamic telemetry metadata via custom telemetry metadata providers. The metadata provider API should be considered unstable in it's current invocation. * Perform deprecation checking at runtime * SWG uses telemetry metadata provider * Don't throw with no matched metadata provider * Update API docs * Add license header * Combine metadata providers with general telemetry providers * Replace `TelemetryAPI.canProvideTelemetry` with `TelemetryAPI.isTelemetryObject`. * CanProvideTelemetry is deprecated * Change SWG inputs to numberfield
109 lines
2.7 KiB
JavaScript
109 lines
2.7 KiB
JavaScript
define([
|
|
'lodash'
|
|
], function (
|
|
_
|
|
) {
|
|
|
|
var METADATA_BY_TYPE = {
|
|
'generator': {
|
|
values: [
|
|
{
|
|
key: "name",
|
|
name: "Name"
|
|
},
|
|
{
|
|
key: "utc",
|
|
name: "Time",
|
|
format: "utc",
|
|
hints: {
|
|
domain: 1
|
|
}
|
|
},
|
|
{
|
|
key: "yesterday",
|
|
name: "Yesterday",
|
|
format: "utc",
|
|
hints: {
|
|
domain: 2
|
|
}
|
|
},
|
|
{
|
|
key: "sin",
|
|
name: "Sine",
|
|
hints: {
|
|
range: 1
|
|
}
|
|
},
|
|
{
|
|
key: "cos",
|
|
name: "Cosine",
|
|
hints: {
|
|
range: 2
|
|
}
|
|
}
|
|
]
|
|
},
|
|
'example.state-generator': {
|
|
values: [
|
|
{
|
|
key: "name",
|
|
name: "Name"
|
|
},
|
|
{
|
|
key: "utc",
|
|
name: "Time",
|
|
format: "utc",
|
|
hints: {
|
|
domain: 1
|
|
}
|
|
},
|
|
{
|
|
key: "state",
|
|
source: "value",
|
|
name: "State",
|
|
format: "enum",
|
|
enumerations: [
|
|
{
|
|
value: 0,
|
|
string: "OFF"
|
|
},
|
|
{
|
|
value: 1,
|
|
string: "ON"
|
|
}
|
|
],
|
|
hints: {
|
|
range: 1
|
|
}
|
|
},
|
|
{
|
|
key: "value",
|
|
name: "Value",
|
|
hints: {
|
|
range: 2
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
|
|
function GeneratorMetadataProvider() {
|
|
|
|
}
|
|
|
|
GeneratorMetadataProvider.prototype.supportsMetadata = function (domainObject) {
|
|
return METADATA_BY_TYPE.hasOwnProperty(domainObject.type);
|
|
};
|
|
|
|
GeneratorMetadataProvider.prototype.getMetadata = function (domainObject) {
|
|
return _.extend(
|
|
{},
|
|
domainObject.telemetry,
|
|
METADATA_BY_TYPE[domainObject.type]
|
|
);
|
|
};
|
|
|
|
return GeneratorMetadataProvider;
|
|
|
|
});
|