mirror of
https://github.com/nasa/openmct.git
synced 2025-04-12 13:47:55 +00:00
[Time Conductor] Implement timeService in sinewave telemetry
Switch from initial dateService interface to more practical timeService interface.
This commit is contained in:
parent
5e9f38dadd
commit
1e71df5ce9
@ -10,9 +10,9 @@
|
||||
"depends": [ "$q", "$timeout" ]
|
||||
},
|
||||
{
|
||||
"implementation": "SinewaveDateProvider.js",
|
||||
"implementation": "SinewaveTimeProvider.js",
|
||||
"type": "provider",
|
||||
"provides": "dateService"
|
||||
"provides": "timeService"
|
||||
}
|
||||
],
|
||||
"capabilities": [
|
||||
|
@ -22,7 +22,9 @@
|
||||
/*global define*/
|
||||
|
||||
define([
|
||||
'./SinewaveTimeSystem'
|
||||
], function (
|
||||
SinewaveTimeSystem
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
@ -32,24 +34,19 @@ define([
|
||||
* not necessarily be formatted as UTC dates.
|
||||
* @memberof example/generator
|
||||
* @constructor
|
||||
* @implements {DateService}
|
||||
* @implements {TimeService}
|
||||
*/
|
||||
function SinewaveDateProvider() {
|
||||
function SinewaveTimeProvider() {
|
||||
this.indexTimeSystem = new SinewaveTimeSystem();
|
||||
}
|
||||
|
||||
SinewaveDateProvider.prototype.validate = function (text, key) {
|
||||
return key === 'generator.index' && /^#\d+$/.test(text);
|
||||
SinewaveTimeProvider.prototype.systems = function () {
|
||||
return [ 'generator.index' ];
|
||||
};
|
||||
|
||||
SinewaveDateProvider.prototype.format = function (value, key) {
|
||||
return key === 'generator.index' ?
|
||||
('#' + Math.floor(value)) :
|
||||
undefined;
|
||||
SinewaveTimeProvider.prototype.system = function (key) {
|
||||
return key === 'generator.index' ? this.indexTimeSystem : undefined;
|
||||
};
|
||||
|
||||
SinewaveDateProvider.prototype.parse = function (text, key) {
|
||||
return key === 'generator.index' && parseInt(key.substring(1), 10);
|
||||
};
|
||||
|
||||
return SinewaveDateProvider;
|
||||
return SinewaveTimeProvider;
|
||||
});
|
55
example/generator/src/SinewaveTimeSystem.js
Normal file
55
example/generator/src/SinewaveTimeSystem.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([
|
||||
'./SinewaveTelemetrySeries'
|
||||
], function (
|
||||
SinewaveTelemetrySeries
|
||||
) {
|
||||
"use strict";
|
||||
|
||||
function SinewaveTimeSystem(now) {
|
||||
}
|
||||
|
||||
SinewaveTimeSystem.prototype.format = function (value) {
|
||||
return ('#' + Math.floor(value));
|
||||
};
|
||||
|
||||
SinewaveTimeSystem.prototype.parse = function (text) {
|
||||
return parseInt(text.substring(1), 10);
|
||||
};
|
||||
|
||||
SinewaveTimeSystem.prototype.validate = function (text) {
|
||||
return (/^#\d+$/).test(text);
|
||||
};
|
||||
|
||||
SinewaveTimeSystem.prototype.now = function () {
|
||||
return new SinewaveTelemetrySeries().getPointCount();
|
||||
};
|
||||
|
||||
SinewaveTimeSystem.prototype.increment = function (scale) {
|
||||
return Math.pow(10, (scale || 0) + 1);
|
||||
};
|
||||
|
||||
return SinewaveTimeSystem;
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user