mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 19:34:25 +00:00
Added support for new style telemetry providers from old screens. Converted SWG to new style data adapter
This commit is contained in:
parent
c74fdb816f
commit
b3cf7a5d93
@ -1,184 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
"./src/SinewaveTelemetryProvider",
|
||||
"./src/SinewaveLimitCapability",
|
||||
"./src/SinewaveDeltaFormat",
|
||||
'legacyRegistry'
|
||||
], function (
|
||||
SinewaveTelemetryProvider,
|
||||
SinewaveLimitCapability,
|
||||
SinewaveDeltaFormat,
|
||||
legacyRegistry
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
legacyRegistry.register("example/generator", {
|
||||
"name": "Sine Wave Generator",
|
||||
"description": "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
"extensions": {
|
||||
"components": [
|
||||
{
|
||||
"implementation": SinewaveTelemetryProvider,
|
||||
"type": "provider",
|
||||
"provides": "telemetryService",
|
||||
"depends": [
|
||||
"$q",
|
||||
"$timeout"
|
||||
]
|
||||
}
|
||||
],
|
||||
"capabilities": [
|
||||
{
|
||||
"key": "limit",
|
||||
"implementation": SinewaveLimitCapability
|
||||
}
|
||||
],
|
||||
"formats": [
|
||||
{
|
||||
"key": "example.delta",
|
||||
"implementation": SinewaveDeltaFormat
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"key": "TIME_CONDUCTOR_DOMAINS",
|
||||
"value": [
|
||||
{
|
||||
"key": "time",
|
||||
"name": "Time"
|
||||
},
|
||||
{
|
||||
"key": "yesterday",
|
||||
"name": "Yesterday"
|
||||
},
|
||||
{
|
||||
"key": "delta",
|
||||
"name": "Delta"
|
||||
}
|
||||
],
|
||||
"priority": -1
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
{
|
||||
"key": "generator",
|
||||
"name": "Sine Wave Generator",
|
||||
"cssClass": "icon-telemetry",
|
||||
"description": "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
"priority": 10,
|
||||
"features": "creation",
|
||||
"model": {
|
||||
"telemetry": {
|
||||
"period": 10,
|
||||
"amplitude": 1,
|
||||
"offset": 0,
|
||||
"dataRateInHz": 1
|
||||
}
|
||||
},
|
||||
"telemetry": {
|
||||
"source": "generator",
|
||||
"domains": [
|
||||
{
|
||||
"key": "utc",
|
||||
"name": "Time",
|
||||
"format": "utc"
|
||||
},
|
||||
{
|
||||
"key": "yesterday",
|
||||
"name": "Yesterday",
|
||||
"format": "utc"
|
||||
},
|
||||
{
|
||||
"key": "delta",
|
||||
"name": "Delta",
|
||||
"format": "example.delta"
|
||||
}
|
||||
],
|
||||
"ranges": [
|
||||
{
|
||||
"key": "sin",
|
||||
"name": "Sine"
|
||||
},
|
||||
{
|
||||
"key": "cos",
|
||||
"name": "Cosine"
|
||||
}
|
||||
]
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"name": "Period",
|
||||
"control": "textfield",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "period",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"period"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Amplitude",
|
||||
"control": "textfield",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "amplitude",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"amplitude"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Offset",
|
||||
"control": "textfield",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "offset",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"offset"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
"name": "Data Rate (hz)",
|
||||
"control": "textfield",
|
||||
"cssClass": "l-input-sm l-numeric",
|
||||
"key": "dataRateInHz",
|
||||
"required": true,
|
||||
"property": [
|
||||
"telemetry",
|
||||
"dataRateInHz"
|
||||
],
|
||||
"pattern": "^\\d*(\\.\\d*)?$"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
@ -118,7 +118,7 @@ define(
|
||||
formModel = this.createModel(formValue);
|
||||
|
||||
formModel.location = parent.getId();
|
||||
this.domainObject.useCapability("mutation", function () {
|
||||
this.domainObject.useCapability("mutation", function (model) {
|
||||
return formModel;
|
||||
});
|
||||
return this.domainObject;
|
||||
|
@ -79,6 +79,7 @@ define([
|
||||
"key": "telemetry",
|
||||
"implementation": TelemetryCapability,
|
||||
"depends": [
|
||||
"openmct",
|
||||
"$injector",
|
||||
"$q",
|
||||
"$log"
|
||||
|
@ -24,8 +24,12 @@
|
||||
* Module defining TelemetryCapability. Created by vwoeltje on 11/12/14.
|
||||
*/
|
||||
define(
|
||||
[],
|
||||
function () {
|
||||
[
|
||||
'../../../src/api/objects/object-utils'
|
||||
],
|
||||
function (
|
||||
objectUtils
|
||||
) {
|
||||
|
||||
var ZERO = function () {
|
||||
return 0;
|
||||
@ -103,7 +107,7 @@ define(
|
||||
* @implements {Capability}
|
||||
* @constructor
|
||||
*/
|
||||
function TelemetryCapability($injector, $q, $log, domainObject) {
|
||||
function TelemetryCapability(openmct, $injector, $q, $log, domainObject) {
|
||||
// We could depend on telemetryService directly, but
|
||||
// there isn't a platform implementation of this.
|
||||
this.initializeTelemetryService = function () {
|
||||
@ -118,7 +122,7 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.openmct = openmct;
|
||||
this.$q = $q;
|
||||
this.$log = $log;
|
||||
this.domainObject = domainObject;
|
||||
@ -160,6 +164,20 @@ define(
|
||||
};
|
||||
|
||||
|
||||
function asSeries(telemetry, defaultDomain, defaultRange) {
|
||||
return {
|
||||
getRangeValue: function (index, range) {
|
||||
return telemetry[index][range || defaultRange];
|
||||
},
|
||||
getDomainValue: function (index, domain) {
|
||||
return telemetry[index][domain || defaultDomain];
|
||||
},
|
||||
getPointCount: function () {
|
||||
return telemetry.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request telemetry data for this specific domain object.
|
||||
* @param {TelemetryRequest} [request] parameters for this
|
||||
@ -169,11 +187,21 @@ define(
|
||||
*/
|
||||
TelemetryCapability.prototype.requestData = function requestTelemetry(request) {
|
||||
// Bring in any defaults from the object model
|
||||
var fullRequest = this.buildRequest(request || {}),
|
||||
source = fullRequest.source,
|
||||
key = fullRequest.key,
|
||||
telemetryService = this.telemetryService ||
|
||||
this.initializeTelemetryService(); // Lazy initialization
|
||||
var fullRequest = this.buildRequest(request || {});
|
||||
var source = fullRequest.source;
|
||||
var key = fullRequest.key;
|
||||
var telemetryService = this.telemetryService ||
|
||||
this.initializeTelemetryService(); // Lazy initialization
|
||||
|
||||
var domainObject = objectUtils.toNewFormat(this.domainObject.getModel(), this.domainObject.getId());
|
||||
var telemetryAPI = this.openmct.telemetry;
|
||||
|
||||
var metadata = telemetryAPI.getMetadata(domainObject);
|
||||
var defaultDomain = (metadata.valuesForHints(['domain'])[0] || {}).key;
|
||||
var defaultRange = (metadata.valuesForHints(['range'])[0] || {}).key;
|
||||
|
||||
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject)
|
||||
=== telemetryAPI.legacyProvider;
|
||||
|
||||
// Pull out the relevant field from the larger,
|
||||
// structured response.
|
||||
@ -187,11 +215,18 @@ define(
|
||||
return telemetryService.requestTelemetry([fullRequest]);
|
||||
}
|
||||
|
||||
// If a telemetryService is not available,
|
||||
// getTelemetryService() should reject, and this should
|
||||
// bubble through subsequent then calls.
|
||||
return telemetryService &&
|
||||
requestTelemetryFromService().then(getRelevantResponse);
|
||||
// TODO: Adapt request / options?
|
||||
if (isLegacyProvider) {
|
||||
// If a telemetryService is not available,
|
||||
// getTelemetryService() should reject, and this should
|
||||
// bubble through subsequent then calls.
|
||||
return telemetryService &&
|
||||
requestTelemetryFromService().then(getRelevantResponse);
|
||||
} else {
|
||||
return telemetryAPI.request(domainObject, fullRequest).then(function (telemetry) {
|
||||
return asSeries(telemetry, defaultDomain, defaultRange);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -217,12 +252,26 @@ define(
|
||||
* subscription request
|
||||
*/
|
||||
TelemetryCapability.prototype.subscribe = function subscribe(callback, request) {
|
||||
var fullRequest = this.buildRequest(request || {}),
|
||||
telemetryService = this.telemetryService ||
|
||||
this.initializeTelemetryService(); // Lazy initialization
|
||||
var fullRequest = this.buildRequest(request || {});
|
||||
var telemetryService = this.telemetryService ||
|
||||
this.initializeTelemetryService(); // Lazy initialization
|
||||
|
||||
var domainObject = objectUtils.toNewFormat(this.domainObject.getModel(), this.domainObject.getId());
|
||||
var telemetryAPI = this.openmct.telemetry;
|
||||
|
||||
var metadata = telemetryAPI.getMetadata(domainObject);
|
||||
var defaultDomain = (metadata.valuesForHints(['domain'])[0] || {}).key;
|
||||
var defaultRange = (metadata.valuesForHints(['range'])[0] || {}).key;
|
||||
|
||||
var isLegacyProvider = telemetryAPI.findRequestProvider(domainObject)
|
||||
=== telemetryAPI.legacyProvider;
|
||||
|
||||
function update(telemetry) {
|
||||
callback(asSeries([telemetry], defaultDomain, defaultRange));
|
||||
}
|
||||
|
||||
// Unpack the relevant telemetry series
|
||||
function update(telemetries) {
|
||||
function updateLegacy(telemetries) {
|
||||
var source = fullRequest.source,
|
||||
key = fullRequest.key,
|
||||
result = ((telemetries || {})[source] || {})[key];
|
||||
@ -231,8 +280,13 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
return telemetryService &&
|
||||
telemetryService.subscribe(update, [fullRequest]);
|
||||
// Avoid a loop here...
|
||||
if (isLegacyProvider) {
|
||||
return telemetryService &&
|
||||
telemetryService.subscribe(updateLegacy, [fullRequest]);
|
||||
} else {
|
||||
return telemetryAPI.subscribe(domainObject, update, fullRequest);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -105,7 +105,6 @@ define([
|
||||
this.valueMetadatas = this.valueMetadatas.map(applyReasonableDefaults);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get value metadata for a single key.
|
||||
*/
|
||||
|
@ -33,7 +33,6 @@ define([
|
||||
'../example/export/bundle',
|
||||
'../example/extensions/bundle',
|
||||
'../example/forms/bundle',
|
||||
'../example/generator/bundle',
|
||||
'../example/identity/bundle',
|
||||
'../example/imagery/bundle',
|
||||
'../example/mobile/bundle',
|
||||
|
@ -41,6 +41,10 @@ define([
|
||||
return domainObject.type === 'generator';
|
||||
};
|
||||
|
||||
GeneratorProvider.prototype.supportsRequest =
|
||||
GeneratorProvider.prototype.supportsSubscribe =
|
||||
GeneratorProvider.prototype.canProvideTelemetry;
|
||||
|
||||
GeneratorProvider.prototype.makeWorkerRequest = function (domainObject, request) {
|
||||
var props = [
|
||||
'amplitude',
|
171
src/plugins/generator/plugin.js
Normal file
171
src/plugins/generator/plugin.js
Normal file
@ -0,0 +1,171 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT, Copyright (c) 2014-2016, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
"./GeneratorProvider",
|
||||
"./SinewaveLimitCapability",
|
||||
"./SinewaveDeltaFormat"
|
||||
], function (
|
||||
GeneratorProvider,
|
||||
SinewaveLimitCapability,
|
||||
SinewaveDeltaFormat
|
||||
) {
|
||||
|
||||
var legacyExtensions = {
|
||||
"capabilities": [
|
||||
{
|
||||
"key": "limit",
|
||||
"implementation": SinewaveLimitCapability
|
||||
}
|
||||
],
|
||||
"formats": [
|
||||
{
|
||||
"key": "example.delta",
|
||||
"implementation": SinewaveDeltaFormat
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
{
|
||||
"key": "TIME_CONDUCTOR_DOMAINS",
|
||||
"value": [
|
||||
{
|
||||
"key": "time",
|
||||
"name": "Time"
|
||||
},
|
||||
{
|
||||
"key": "yesterday",
|
||||
"name": "Yesterday"
|
||||
},
|
||||
{
|
||||
"key": "delta",
|
||||
"name": "Delta"
|
||||
}
|
||||
],
|
||||
"priority": -1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
return function(openmct){
|
||||
//Register legacy extensions for things not yet supported by the new API
|
||||
Object.keys(legacyExtensions).forEach(function (type){
|
||||
var extensionsOfType = legacyExtensions[type];
|
||||
extensionsOfType.forEach(function (extension) {
|
||||
openmct.legacyExtension(type, extension)
|
||||
})
|
||||
});
|
||||
openmct.types.register("generator", {
|
||||
label: "Sine Wave Generator",
|
||||
description: "For development use. Generates example streaming telemetry data using a simple sine wave algorithm.",
|
||||
cssClass: "icon-telemetry",
|
||||
creatable: true,
|
||||
form: [
|
||||
{
|
||||
name: "Period",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "period",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"period"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Amplitude",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "amplitude",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"amplitude"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Offset",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "offset",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"offset"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
},
|
||||
{
|
||||
name: "Data Rate (hz)",
|
||||
control: "textfield",
|
||||
cssClass: "l-input-sm l-numeric",
|
||||
key: "dataRateInHz",
|
||||
required: true,
|
||||
property: [
|
||||
"telemetry",
|
||||
"dataRateInHz"
|
||||
],
|
||||
pattern: "^\\d*(\\.\\d*)?$"
|
||||
}
|
||||
],
|
||||
initialize: function (object) {
|
||||
object.telemetry = {
|
||||
period: 10,
|
||||
amplitude: 1,
|
||||
offset: 0,
|
||||
dataRateInHz: 1,
|
||||
domains: [
|
||||
{
|
||||
key: "utc",
|
||||
name: "Time",
|
||||
format: "utc"
|
||||
},
|
||||
{
|
||||
key: "yesterday",
|
||||
name: "Yesterday",
|
||||
format: "utc"
|
||||
},
|
||||
{
|
||||
key: "delta",
|
||||
name: "Delta",
|
||||
format: "example.delta"
|
||||
}
|
||||
],
|
||||
ranges: [
|
||||
{
|
||||
key: "sin",
|
||||
name: "Sine"
|
||||
},
|
||||
{
|
||||
key: "cos",
|
||||
name: "Cosine"
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
});
|
||||
openmct.telemetry.addProvider(new GeneratorProvider());
|
||||
};
|
||||
|
||||
});
|
@ -21,16 +21,21 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define([
|
||||
'lodash'
|
||||
], function (_) {
|
||||
'lodash',
|
||||
'../../platform/features/conductor/utcTimeSystem/src/UTCTimeSystem',
|
||||
'./generator/plugin'
|
||||
], function (
|
||||
_,
|
||||
UTCTimeSystem,
|
||||
GeneratorPlugin
|
||||
) {
|
||||
var bundleMap = {
|
||||
couchDB: 'platform/persistence/couch',
|
||||
elasticsearch: 'platform/persistence/elastic',
|
||||
espresso: 'platform/commonUI/themes/espresso',
|
||||
localStorage: 'platform/persistence/local',
|
||||
myItems: 'platform/features/my-items',
|
||||
snow: 'platform/commonUI/themes/snow',
|
||||
utcTimeSystem: 'platform/features/conductor/utcTimeSystem'
|
||||
snow: 'platform/commonUI/themes/snow'
|
||||
};
|
||||
|
||||
var plugins = _.mapValues(bundleMap, function (bundleName, pluginName) {
|
||||
@ -39,6 +44,15 @@ define([
|
||||
};
|
||||
});
|
||||
|
||||
plugins.UTCTimeSystem = function () {
|
||||
return function (openmct) {
|
||||
openmct.legacyExtension("timeSystems", {
|
||||
"implementation": UTCTimeSystem,
|
||||
"depends": ["$timeout"]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
plugins.CouchDB = function (url) {
|
||||
return function (openmct) {
|
||||
if (url) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user