More refactoring

This commit is contained in:
Henry
2016-07-13 20:33:47 -07:00
parent 2baca659ca
commit 2f9fbfef7f
3 changed files with 52 additions and 12 deletions

View File

@ -66,6 +66,25 @@ define(
$scope.$watch('modeModel.selected', this.switchMode); $scope.$watch('modeModel.selected', this.switchMode);
$scope.$watch('timeSystem', function (newTimeSystem, oldTimeSystem) {
$scope.modeModel = {
selected: 'fixed',
options: {
'fixed': {
glyph: '\ue604',
label: 'Fixed',
name: 'Fixed Timespan Mode',
description: 'Query and explore data that falls between two fixed datetimes.'
},
}
}
newTimeSystem.tickSources().forEach(function (tickSource) {
var option = {};
$scope.modeModel.options.push({
});
});
});
$scope.modeModel = { $scope.modeModel = {
selected: 'fixed', selected: 'fixed',
options: { options: {

View File

@ -22,36 +22,52 @@
define(['./TickSource'], function (TickSource) { define(['./TickSource'], function (TickSource) {
/** /**
* @interface * @implements TickSource
* @constructor * @constructor
*/ */
function PeriodicTickSource ($timeout, interval) { function LocalClock ($timeout) {
TickSource.call(this); TickSource.call(this);
this.metadata = {
key: 'real-time',
glyph: '\u0043',
label: 'Real-time',
name: 'Real-time Mode',
description: 'Monitor real-time streaming data as it comes in. The Time Conductor and displays will automatically advance themselves based on a UTC clock.'
};
this.interval = interval; this.interval = interval;
this.$timeout = $timeout; this.$timeout = $timeout;
this.timeoutHandle = undefined; this.timeoutHandle = undefined;
} }
PeriodicTickSource.prototype = Object.create(TickSource.prototype); LocalClock.prototype = Object.create(TickSource.prototype);
PeriodicTickSource.prototype.start = function () { LocalClock.prototype.start = function () {
this.timeoutHandle = this.$timeout(this.tick.bind(this), this.interval); this.timeoutHandle = this.$timeout(this.tick.bind(this), this.interval);
}; };
PeriodicTickSource.prototype.stop = function () { LocalClock.prototype.stop = function () {
if (this.timeoutHandle) { if (this.timeoutHandle) {
this.$timeout.cancel(this.timeoutHandle); this.$timeout.cancel(this.timeoutHandle);
} }
}; };
PeriodicTickSource.prototype.tick = function () { LocalClock.prototype.tick = function () {
var now = Date.now();
this.listeners.forEach(function (listener){ this.listeners.forEach(function (listener){
listener(); listener(now);
}); });
}; };
PeriodicTickSource.prototype.listen = function (listener) { /**
* Register a listener for the local clock. When it ticks, the local
* clock will provide the current local system time
*
* @param listener
* @returns {function} a function for deregistering the provided listener
*/
LocalClock.prototype.listen = function (listener) {
this.listeners.push(listener); this.listeners.push(listener);
if (this.listeners.length === 1){ if (this.listeners.length === 1){

View File

@ -20,17 +20,22 @@
* at runtime from the About dialog for additional information. * at runtime from the About dialog for additional information.
*****************************************************************************/ *****************************************************************************/
define(['./TimeSystem'], function (TimeSystem) { define([
'./TimeSystem',
'./LocalClock',
'../../../../commonUI/formats/src/UTCTimeFormat'
], function (TimeSystem, LocalClock, UTCTimeFormat) {
var FIFTEEN_MINUTES = 15 * 60 * 1000; var FIFTEEN_MINUTES = 15 * 60 * 1000;
/** /**
* @implements TimeSystem * @implements TimeSystem
* @constructor * @constructor
*/ */
function UTCTimeSystem () { function UTCTimeSystem ($timeout) {
TimeSystem.call(this); TimeSystem.call(this);
this._formats = []; this._formats = [new UTCTimeFormat()];
this._tickSources = []; this._tickSources = [new LocalClock($timeout)];
} }
UTCTimeSystem.prototype = Object.create(TimeSystem.prototype); UTCTimeSystem.prototype = Object.create(TimeSystem.prototype);