Skip to content

Commit

Permalink
More refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Jul 14, 2016
1 parent 2baca65 commit 2f9fbfe
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 12 deletions.
19 changes: 19 additions & 0 deletions platform/features/conductor-v2/src/TimeConductorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ define(

$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 = {
selected: 'fixed',
options: {
Expand Down
32 changes: 24 additions & 8 deletions platform/features/conductor-v2/src/timeSystems/LocalClock.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,52 @@

define(['./TickSource'], function (TickSource) {
/**
* @interface
* @implements TickSource
* @constructor
*/
function PeriodicTickSource ($timeout, interval) {
function LocalClock ($timeout) {
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.$timeout = $timeout;
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);
};

PeriodicTickSource.prototype.stop = function () {
LocalClock.prototype.stop = function () {
if (this.timeoutHandle) {
this.$timeout.cancel(this.timeoutHandle);
}
};

PeriodicTickSource.prototype.tick = function () {
LocalClock.prototype.tick = function () {
var now = Date.now();
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);

if (this.listeners.length === 1){
Expand Down
13 changes: 9 additions & 4 deletions platform/features/conductor-v2/src/timeSystems/UTCTimeSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@
* 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;

/**
* @implements TimeSystem
* @constructor
*/
function UTCTimeSystem () {
function UTCTimeSystem ($timeout) {
TimeSystem.call(this);

this._formats = [];
this._tickSources = [];
this._formats = [new UTCTimeFormat()];
this._tickSources = [new LocalClock($timeout)];
}

UTCTimeSystem.prototype = Object.create(TimeSystem.prototype);
Expand Down

0 comments on commit 2f9fbfe

Please sign in to comment.