From 9bc4327c597261ead0c7becf35d3cebfbddc2752 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 22 Oct 2015 12:51:10 -0700 Subject: [PATCH] [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. --- example/generator/bundle.json | 10 ++++ example/generator/src/SinewaveDateProvider.js | 55 +++++++++++++++++++ .../generator/src/SinewaveTelemetrySeries.js | 3 + 3 files changed, 68 insertions(+) create mode 100644 example/generator/src/SinewaveDateProvider.js diff --git a/example/generator/bundle.json b/example/generator/bundle.json index cdb4736957..fc18f31193 100644 --- a/example/generator/bundle.json +++ b/example/generator/bundle.json @@ -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": [ diff --git a/example/generator/src/SinewaveDateProvider.js b/example/generator/src/SinewaveDateProvider.js new file mode 100644 index 0000000000..9b819a8796 --- /dev/null +++ b/example/generator/src/SinewaveDateProvider.js @@ -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; +}); diff --git a/example/generator/src/SinewaveTelemetrySeries.js b/example/generator/src/SinewaveTelemetrySeries.js index 1e84034766..17084a07da 100644 --- a/example/generator/src/SinewaveTelemetrySeries.js +++ b/example/generator/src/SinewaveTelemetrySeries.js @@ -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); };