mirror of
https://github.com/nasa/openmct.git
synced 2024-12-21 14:07:50 +00:00
[Time Conductor] Add non-time-like domain
Add a non-time-like domain to sine wave generator telemetry, to support integration of custom domain formatting into time conductor.
This commit is contained in:
parent
c0fda5b572
commit
9bc4327c59
@ -8,6 +8,11 @@
|
||||
"type": "provider",
|
||||
"provides": "telemetryService",
|
||||
"depends": [ "$q", "$timeout" ]
|
||||
},
|
||||
{
|
||||
"implementation": "SinewaveDateProvider.js",
|
||||
"type": "provider",
|
||||
"provides": "dateService"
|
||||
}
|
||||
],
|
||||
"capabilities": [
|
||||
@ -38,6 +43,11 @@
|
||||
{
|
||||
"key": "yesterday",
|
||||
"name": "Yesterday"
|
||||
},
|
||||
{
|
||||
"key": "index",
|
||||
"name": "Index",
|
||||
"system": "generator.index"
|
||||
}
|
||||
],
|
||||
"ranges": [
|
||||
|
55
example/generator/src/SinewaveDateProvider.js
Normal file
55
example/generator/src/SinewaveDateProvider.js
Normal file
@ -0,0 +1,55 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web 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 Web 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([
|
||||
], function (
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Provides date-time formatting for the Sine Wave Generator's
|
||||
* `index` domain; demonstrates how to support domains which should
|
||||
* not necessarily be formatted as UTC dates.
|
||||
* @memberof example/generator
|
||||
* @constructor
|
||||
* @implements {DateService}
|
||||
*/
|
||||
function SinewaveDateProvider() {
|
||||
}
|
||||
|
||||
SinewaveDateProvider.prototype.validate = function (text, key) {
|
||||
return key === 'generator.index' && /^#\d+$/.test(text);
|
||||
};
|
||||
|
||||
SinewaveDateProvider.prototype.format = function (value, key) {
|
||||
return key === 'generator.index' ?
|
||||
('#' + Math.floor(value)) :
|
||||
undefined;
|
||||
};
|
||||
|
||||
SinewaveDateProvider.prototype.parse = function (text, key) {
|
||||
return key === 'generator.index' && parseInt(key.substring(1), 10);
|
||||
};
|
||||
|
||||
return SinewaveDateProvider;
|
||||
});
|
@ -58,6 +58,9 @@ define(
|
||||
};
|
||||
|
||||
generatorData.getDomainValue = function (i, domain) {
|
||||
if (domain === 'index') {
|
||||
return i;
|
||||
}
|
||||
return (i + offset) * 1000 + firstTime * 1000 -
|
||||
(domain === 'yesterday' ? ONE_DAY : 0);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user