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