[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:
Victor Woeltjen 2015-10-22 12:51:10 -07:00
parent c0fda5b572
commit 9bc4327c59
3 changed files with 68 additions and 0 deletions

View File

@ -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": [

View 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;
});

View File

@ -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);
};