[Time Conductor] #933 Fixed code style errors

This commit is contained in:
Henry 2016-09-06 10:04:29 -07:00
parent c6eaa3d528
commit 7af5875dd5
21 changed files with 124 additions and 113 deletions

View File

@ -56,7 +56,7 @@ define([
* the threshold required. * the threshold required.
* @private * @private
*/ */
function getScaledFormat (d) { function getScaledFormat(d) {
var momentified = moment.utc(d); var momentified = moment.utc(d);
/** /**
* Uses logic from d3 Time-Scales, v3 of the API. See * Uses logic from d3 Time-Scales, v3 of the API. See
@ -65,20 +65,32 @@ define([
* Licensed * Licensed
*/ */
return [ return [
[".SSS", function(m) { return m.milliseconds(); }], [".SSS", function (m) {
[":ss", function(m) { return m.seconds(); }], return m.milliseconds();
["HH:mm", function(m) { return m.minutes(); }], }],
["HH", function(m) { return m.hours(); }], [":ss", function (m) {
["ddd DD", function(m) { return m.seconds();
}],
["HH:mm", function (m) {
return m.minutes();
}],
["HH", function (m) {
return m.hours();
}],
["ddd DD", function (m) {
return m.days() && return m.days() &&
m.date() !== 1; m.date() !== 1;
}], }],
["MMM DD", function(m) { return m.date() !== 1; }], ["MMM DD", function (m) {
["MMMM", function(m) { return m.date() !== 1;
}],
["MMMM", function (m) {
return m.month(); return m.month();
}], }],
["YYYY", function() { return true; }] ["YYYY", function () {
].filter(function (row){ return true;
}]
].filter(function (row) {
return row[1](momentified); return row[1](momentified);
})[0][0]; })[0][0];
} }
@ -91,7 +103,7 @@ define([
* @returns {string} the formatted date * @returns {string} the formatted date
*/ */
UTCTimeFormat.prototype.format = function (value, scale) { UTCTimeFormat.prototype.format = function (value, scale) {
if (scale !== undefined){ if (scale !== undefined) {
var scaledFormat = getScaledFormat(value, scale); var scaledFormat = getScaledFormat(value, scale);
if (scaledFormat) { if (scaledFormat) {
return moment.utc(value).format(scaledFormat); return moment.utc(value).format(scaledFormat);

View File

@ -76,7 +76,7 @@ define(
} }
conductor.on('bounds', amendRequests); conductor.on('bounds', amendRequests);
return function() { return function () {
unsubscribeFunc(); unsubscribeFunc();
conductor.off('bounds', amendRequests); conductor.off('bounds', amendRequests);
}; };

View File

@ -112,7 +112,7 @@ define(['EventEmitter'], function (EventEmitter) {
TimeConductor.prototype.bounds = function (newBounds) { TimeConductor.prototype.bounds = function (newBounds) {
if (arguments.length > 0) { if (arguments.length > 0) {
var validationResult = this.validateBounds(newBounds); var validationResult = this.validateBounds(newBounds);
if (validationResult !== true){ if (validationResult !== true) {
throw new Error(validationResult); throw new Error(validationResult);
} }
//Create a copy to avoid direct mutation of conductor bounds //Create a copy to avoid direct mutation of conductor bounds

View File

@ -25,7 +25,7 @@ define(['./TickSource'], function (TickSource) {
* @implements TickSource * @implements TickSource
* @constructor * @constructor
*/ */
function LocalClock ($timeout, period) { function LocalClock($timeout, period) {
TickSource.call(this); TickSource.call(this);
this.metadata = { this.metadata = {
@ -56,7 +56,7 @@ define(['./TickSource'], function (TickSource) {
LocalClock.prototype.tick = function () { LocalClock.prototype.tick = function () {
var now = Date.now(); var now = Date.now();
this.listeners.forEach(function (listener){ this.listeners.forEach(function (listener) {
listener(now); listener(now);
}); });
this.timeoutHandle = this.$timeout(this.tick.bind(this), this.period); this.timeoutHandle = this.$timeout(this.tick.bind(this), this.period);
@ -73,7 +73,7 @@ define(['./TickSource'], function (TickSource) {
var listeners = this.listeners; var listeners = this.listeners;
listeners.push(listener); listeners.push(listener);
if (listeners.length === 1){ if (listeners.length === 1) {
this.start(); this.start();
} }

View File

@ -30,7 +30,7 @@ define([], function () {
* @interface * @interface
* @constructor * @constructor
*/ */
function TickSource () { function TickSource() {
this.listeners = []; this.listeners = [];
} }

View File

@ -25,7 +25,7 @@ define([], function () {
* @interface * @interface
* @constructor * @constructor
*/ */
function TimeSystem () { function TimeSystem() {
/** /**
* @typedef TimeSystemMetadata * @typedef TimeSystemMetadata
* @property {string} key * @property {string} key
@ -35,7 +35,6 @@ define([], function () {
* @type {TimeSystemMetadata} * @type {TimeSystemMetadata}
*/ */
this.metadata = undefined; this.metadata = undefined;
this._tickSources = [];
} }
/** /**

View File

@ -87,7 +87,7 @@ define(
//Define a custom format function //Define a custom format function
this.xAxis.tickFormat(function (tickValue) { this.xAxis.tickFormat(function (tickValue) {
// Normalize date representations to numbers // Normalize date representations to numbers
if (tickValue instanceof Date){ if (tickValue instanceof Date) {
tickValue = tickValue.getTime(); tickValue = tickValue.getTime();
} }
return format.format(tickValue, { return format.format(tickValue, {
@ -127,7 +127,7 @@ define(
} }
}; };
return function(conductor, formatService) { return function (conductor, formatService) {
return new MCTConductorAxis(conductor, formatService); return new MCTConductorAxis(conductor, formatService);
}; };
} }

View File

@ -71,7 +71,7 @@ define(['./MctConductorAxis'], function (MctConductorAxis) {
"range" "range"
]; ];
d3 = jasmine.createSpyObj("d3", d3Functions); d3 = jasmine.createSpyObj("d3", d3Functions);
d3Functions.forEach(function(func) { d3Functions.forEach(function (func) {
d3[func].andReturn(d3); d3[func].andReturn(d3);
}); });
@ -89,7 +89,7 @@ define(['./MctConductorAxis'], function (MctConductorAxis) {
var mockTimeSystem; var mockTimeSystem;
var mockFormat; var mockFormat;
beforeEach(function() { beforeEach(function () {
mockTimeSystem = jasmine.createSpyObj("timeSystem", [ mockTimeSystem = jasmine.createSpyObj("timeSystem", [
"formats", "formats",
"isUTCBased" "isUTCBased"

View File

@ -34,7 +34,7 @@ define([], function () {
} }
NumberFormat.prototype.format = function (value) { NumberFormat.prototype.format = function (value) {
if (isNaN(value)){ if (isNaN(value)) {
return ''; return '';
} else { } else {
return '' + value; return '' + value;

View File

@ -30,13 +30,13 @@ define(['./NumberFormat'], function (NumberFormat) {
it("The format function takes a string and produces a number", function () { it("The format function takes a string and produces a number", function () {
var text = format.format(1); var text = format.format(1);
expect(text).toBe("1"); expect(text).toBe("1");
expect(typeof(text)).toBe("string"); expect(typeof text).toBe("string");
}); });
it("The parse function takes a string and produces a number", function () { it("The parse function takes a string and produces a number", function () {
var number = format.parse("1"); var number = format.parse("1");
expect(number).toBe(1); expect(number).toBe(1);
expect(typeof(number)).toBe("number"); expect(typeof number).toBe("number");
}); });
it("validates that the input is a number", function () { it("validates that the input is a number", function () {

View File

@ -45,7 +45,7 @@ define(
this.validation = new TimeConductorValidation(this.conductor); this.validation = new TimeConductorValidation(this.conductor);
// Construct the provided time system definitions // Construct the provided time system definitions
this.timeSystems = timeSystems.map(function (timeSystemConstructor){ this.timeSystems = timeSystems.map(function (timeSystemConstructor) {
return timeSystemConstructor(); return timeSystemConstructor();
}); });
@ -53,7 +53,7 @@ define(
this.initializeScope(); this.initializeScope();
this.conductor.on('bounds', this.setFormFromBounds); this.conductor.on('bounds', this.setFormFromBounds);
this.conductor.on('follow', function (follow){ this.conductor.on('follow', function (follow) {
$scope.followMode = follow; $scope.followMode = follow;
}); });
this.conductor.on('timeSystem', this.changeTimeSystem); this.conductor.on('timeSystem', this.changeTimeSystem);
@ -67,7 +67,7 @@ define(
/** /**
* @private * @private
*/ */
TimeConductorController.prototype.initializeScope = function() { TimeConductorController.prototype.initializeScope = function () {
//Set time Conductor bounds in the form //Set time Conductor bounds in the form
this.$scope.boundsModel = this.conductor.bounds(); this.$scope.boundsModel = this.conductor.bounds();
@ -126,10 +126,11 @@ define(
TimeConductorController.prototype.setFormFromMode = function (mode) { TimeConductorController.prototype.setFormFromMode = function (mode) {
this.$scope.modeModel.selectedKey = mode; this.$scope.modeModel.selectedKey = mode;
//Synchronize scope with time system on mode //Synchronize scope with time system on mode
this.$scope.timeSystemModel.options = this.conductorViewService.availableTimeSystems() this.$scope.timeSystemModel.options =
this.conductorViewService.availableTimeSystems()
.map(function (t) { .map(function (t) {
return t.metadata; return t.metadata;
}); });
}; };
/** /**
@ -204,13 +205,13 @@ define(
* @param key * @param key
* @see TimeConductorController#setTimeSystem * @see TimeConductorController#setTimeSystem
*/ */
TimeConductorController.prototype.selectTimeSystemByKey = function(key){ TimeConductorController.prototype.selectTimeSystemByKey = function (key) {
var selected = this.timeSystems.filter(function (timeSystem){ var selected = this.timeSystems.filter(function (timeSystem) {
return timeSystem.metadata.key === key; return timeSystem.metadata.key === key;
})[0]; })[0];
this.conductor.timeSystem(selected, selected.defaults().bounds); this.conductor.timeSystem(selected, selected.defaults().bounds);
}; };
/** /**
* Handles time system change from time conductor * Handles time system change from time conductor
* *
@ -222,7 +223,7 @@ define(
*/ */
TimeConductorController.prototype.changeTimeSystem = function (newTimeSystem) { TimeConductorController.prototype.changeTimeSystem = function (newTimeSystem) {
if (newTimeSystem && (newTimeSystem !== this.$scope.timeSystemModel.selected)) { if (newTimeSystem && (newTimeSystem !== this.$scope.timeSystemModel.selected)) {
if (newTimeSystem.defaults()){ if (newTimeSystem.defaults()) {
var deltas = newTimeSystem.defaults().deltas || {start: 0, end: 0}; var deltas = newTimeSystem.defaults().deltas || {start: 0, end: 0};
var bounds = newTimeSystem.defaults().bounds || {start: 0, end: 0}; var bounds = newTimeSystem.defaults().bounds || {start: 0, end: 0};

View File

@ -58,13 +58,13 @@ define(['./TimeConductorController'], function (TimeConductorController) {
}); });
function getListener(name) { function getListener(name) {
return mockTimeConductor.on.calls.filter(function (call){ return mockTimeConductor.on.calls.filter(function (call) {
return call.args[0] === name; return call.args[0] === name;
})[0].args[1]; })[0].args[1];
} }
describe("", function (){ describe("", function () {
beforeEach(function() { beforeEach(function () {
controller = new TimeConductorController( controller = new TimeConductorController(
mockScope, mockScope,
mockWindow, mockWindow,
@ -183,7 +183,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
var ts2Metadata; var ts2Metadata;
var ts3Metadata; var ts3Metadata;
var mockTimeSystemConstructors; var mockTimeSystemConstructors;
beforeEach(function () { beforeEach(function () {
mode = "realtime"; mode = "realtime";
ts1Metadata = { ts1Metadata = {
@ -304,7 +304,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
metadata: { metadata: {
key: 'testTimeSystem' key: 'testTimeSystem'
}, },
defaults: function() { defaults: function () {
return { return {
bounds: defaultBounds bounds: defaultBounds
}; };
@ -313,7 +313,7 @@ define(['./TimeConductorController'], function (TimeConductorController) {
mockTimeSystems = [ mockTimeSystems = [
// Wrap as constructor function // Wrap as constructor function
function() { function () {
return timeSystem; return timeSystem;
} }
]; ];

View File

@ -33,12 +33,12 @@ define(
function TimeConductorMode(metadata, conductor, timeSystems) { function TimeConductorMode(metadata, conductor, timeSystems) {
this.conductor = conductor; this.conductor = conductor;
this._metadata = metadata; this.mdata = metadata;
this._deltas = undefined; this.dlts = undefined;
this._tickSource = undefined; this.source = undefined;
this._tickSourceUnlisten = undefined; this.sourceUnlisten = undefined;
this._timeSystems = timeSystems; this.systems = timeSystems;
this._availableTickSources = undefined; this.availableSources = undefined;
this.changeTimeSystem = this.changeTimeSystem.bind(this); this.changeTimeSystem = this.changeTimeSystem.bind(this);
this.tick = this.tick.bind(this); this.tick = this.tick.bind(this);
@ -52,9 +52,9 @@ define(
if (metadata.key === 'fixed') { if (metadata.key === 'fixed') {
//Fixed automatically supports all time systems //Fixed automatically supports all time systems
this._availableTimeSystems = timeSystems; this.availableSystems = timeSystems;
} else { } else {
this._availableTimeSystems = timeSystems.filter(function (timeSystem) { this.availableSystems = timeSystems.filter(function (timeSystem) {
//Only include time systems that have tick sources that //Only include time systems that have tick sources that
// support the current mode // support the current mode
return timeSystem.tickSources().some(function (tickSource) { return timeSystem.tickSources().some(function (tickSource) {
@ -86,10 +86,10 @@ define(
this.deltas(defaults.deltas); this.deltas(defaults.deltas);
// Tick sources are mode-specific, so restrict tick sources to only those supported by the current mode. // Tick sources are mode-specific, so restrict tick sources to only those supported by the current mode.
var key = this._metadata.key; var key = this.mdata.key;
var tickSources = timeSystem.tickSources(); var tickSources = timeSystem.tickSources();
if (tickSources) { if (tickSources) {
this._availableTickSources = tickSources.filter(function (source){ this.availableSources = tickSources.filter(function (source) {
return source.metadata.mode === key; return source.metadata.mode === key;
}); });
} }
@ -102,11 +102,11 @@ define(
* @returns {ModeMetadata} * @returns {ModeMetadata}
*/ */
TimeConductorMode.prototype.metadata = function () { TimeConductorMode.prototype.metadata = function () {
return this._metadata; return this.mdata;
}; };
TimeConductorMode.prototype.availableTimeSystems = function () { TimeConductorMode.prototype.availableTimeSystems = function () {
return this._availableTimeSystems; return this.availableSystems;
}; };
/** /**
@ -115,7 +115,7 @@ define(
* @returns {Array.<T>} * @returns {Array.<T>}
*/ */
TimeConductorMode.prototype.availableTickSources = function (timeSystem) { TimeConductorMode.prototype.availableTickSources = function (timeSystem) {
return this._availableTickSources; return this.availableSources;
}; };
/** /**
@ -126,26 +126,26 @@ define(
*/ */
TimeConductorMode.prototype.tickSource = function (tickSource) { TimeConductorMode.prototype.tickSource = function (tickSource) {
if (arguments.length > 0) { if (arguments.length > 0) {
if (this._tickSourceUnlisten) { if (this.sourceUnlisten) {
this._tickSourceUnlisten(); this.sourceUnlisten();
} }
this._tickSource = tickSource; this.source = tickSource;
if (tickSource) { if (tickSource) {
this._tickSourceUnlisten = tickSource.listen(this.tick); this.sourceUnlisten = tickSource.listen(this.tick);
//Now following a tick source //Now following a tick source
this.conductor.follow(true); this.conductor.follow(true);
} else { } else {
this.conductor.follow(false); this.conductor.follow(false);
} }
} }
return this._tickSource; return this.source;
}; };
TimeConductorMode.prototype.destroy = function () { TimeConductorMode.prototype.destroy = function () {
this.conductor.off('timeSystem', this.changeTimeSystem); this.conductor.off('timeSystem', this.changeTimeSystem);
if (this._tickSourceUnlisten) { if (this.sourceUnlisten) {
this._tickSourceUnlisten(); this.sourceUnlisten();
} }
}; };
@ -179,21 +179,21 @@ define(
if (arguments.length !== 0) { if (arguments.length !== 0) {
var oldEnd = this.conductor.bounds().end; var oldEnd = this.conductor.bounds().end;
if (this._deltas && this._deltas.end !== undefined){ if (this.dlts && this.dlts.end !== undefined) {
//Calculate the previous raw end value (without delta) //Calculate the previous raw end value (without delta)
oldEnd = oldEnd - this._deltas.end; oldEnd = oldEnd - this.dlts.end;
} }
this._deltas = deltas; this.dlts = deltas;
var newBounds = { var newBounds = {
start: oldEnd - this._deltas.start, start: oldEnd - this.dlts.start,
end: oldEnd + this._deltas.end end: oldEnd + this.dlts.end
}; };
this.conductor.bounds(newBounds); this.conductor.bounds(newBounds);
} }
return this._deltas; return this.dlts;
}; };
return TimeConductorMode; return TimeConductorMode;

View File

@ -118,7 +118,7 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
fixedTimeSystem.defaults.andReturn(defaults); fixedTimeSystem.defaults.andReturn(defaults);
}); });
it ("sets defaults from new time system", function() { it ("sets defaults from new time system", function () {
mode = new TimeConductorMode(fixedModeMetaData, mockTimeConductor, mockTimeSystems); mode = new TimeConductorMode(fixedModeMetaData, mockTimeConductor, mockTimeSystems);
spyOn(mode, "deltas"); spyOn(mode, "deltas");
mode.deltas.andCallThrough(); mode.deltas.andCallThrough();
@ -127,7 +127,7 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
expect(mockTimeConductor.bounds).toHaveBeenCalledWith(defaults.bounds); expect(mockTimeConductor.bounds).toHaveBeenCalledWith(defaults.bounds);
expect(mode.deltas).toHaveBeenCalledWith(defaults.deltas); expect(mode.deltas).toHaveBeenCalledWith(defaults.deltas);
}); });
it ("If a tick source is available, sets the tick source", function() { it ("If a tick source is available, sets the tick source", function () {
mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems); mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems);
mode.changeTimeSystem(realtimeTimeSystem); mode.changeTimeSystem(realtimeTimeSystem);
@ -139,7 +139,7 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
describe("Setting a tick source", function () { describe("Setting a tick source", function () {
var mockUnlistener; var mockUnlistener;
beforeEach(function() { beforeEach(function () {
mockUnlistener = jasmine.createSpy("unlistener"); mockUnlistener = jasmine.createSpy("unlistener");
mockTickSource.listen.andReturn(mockUnlistener); mockTickSource.listen.andReturn(mockUnlistener);
@ -147,31 +147,31 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
mode.tickSource(mockTickSource); mode.tickSource(mockTickSource);
}); });
it ("Unlistens from old tick source", function() { it ("Unlistens from old tick source", function () {
mode.tickSource(mockTickSource); mode.tickSource(mockTickSource);
expect(mockUnlistener).toHaveBeenCalled(); expect(mockUnlistener).toHaveBeenCalled();
}); });
it ("Listens to new tick source", function() { it ("Listens to new tick source", function () {
expect(mockTickSource.listen).toHaveBeenCalledWith(mode.tick); expect(mockTickSource.listen).toHaveBeenCalledWith(mode.tick);
}); });
it ("Sets 'follow' state on time conductor", function() { it ("Sets 'follow' state on time conductor", function () {
expect(mockTimeConductor.follow).toHaveBeenCalledWith(true); expect(mockTimeConductor.follow).toHaveBeenCalledWith(true);
}); });
it ("on destroy, unlistens from tick source", function() { it ("on destroy, unlistens from tick source", function () {
mode.destroy(); mode.destroy();
expect(mockUnlistener).toHaveBeenCalled(); expect(mockUnlistener).toHaveBeenCalled();
}); });
}); });
describe("setting deltas", function () { describe("setting deltas", function () {
beforeEach(function() { beforeEach(function () {
mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems); mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems);
}); });
it ("sets the bounds on the time conductor based on new delta" + it ("sets the bounds on the time conductor based on new delta" +
" values", function() { " values", function () {
var deltas = { var deltas = {
start: 20, start: 20,
end: 10 end: 10
@ -187,10 +187,10 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
}); });
describe("ticking", function () { describe("ticking", function () {
beforeEach(function() { beforeEach(function () {
mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems); mode = new TimeConductorMode(realtimeModeMetaData, mockTimeConductor, mockTimeSystems);
}); });
it ("sets bounds based on current delta values", function() { it ("sets bounds based on current delta values", function () {
var deltas = { var deltas = {
start: 20, start: 20,
end: 10 end: 10
@ -202,7 +202,7 @@ define(['./TimeConductorMode'], function (TimeConductorMode) {
expect(mockTimeConductor.bounds).toHaveBeenCalledWith({ expect(mockTimeConductor.bounds).toHaveBeenCalledWith({
start: time - deltas.start, start: time - deltas.start,
end:time + deltas.end end: time + deltas.end
}); });
}); });
}); });

View File

@ -34,7 +34,7 @@ define(['./TimeConductorValidation'], function (TimeConductorValidation) {
}); });
describe("Validates start and end values using Time Conductor", function () { describe("Validates start and end values using Time Conductor", function () {
beforeEach(function() { beforeEach(function () {
var mockBounds = { var mockBounds = {
start: 10, start: 10,
end: 20 end: 20

View File

@ -36,13 +36,12 @@ define(
* @constructor * @constructor
*/ */
function TimeConductorViewService(conductor, timeSystems) { function TimeConductorViewService(conductor, timeSystems) {
this._timeSystems = timeSystems.map( this.systems = timeSystems.map(function (timeSystemConstructor) {
function (timeSystemConstructor) { return timeSystemConstructor();
return timeSystemConstructor();
}); });
this._conductor = conductor; this.conductor = conductor;
this._mode = undefined; this.currentMode = undefined;
/** /**
* @typedef {object} ModeMetadata * @typedef {object} ModeMetadata
@ -53,7 +52,7 @@ define(
* @property {string} name A longer name for the mode * @property {string} name A longer name for the mode
* @property {string} description A description of the mode * @property {string} description A description of the mode
*/ */
this._availableModes = { this.availModes = {
'fixed': { 'fixed': {
key: 'fixed', key: 'fixed',
cssclass: 'icon-calendar', cssclass: 'icon-calendar',
@ -64,17 +63,17 @@ define(
}; };
function hasTickSource(sourceType, timeSystem) { function hasTickSource(sourceType, timeSystem) {
return timeSystem.tickSources().some(function (tickSource){ return timeSystem.tickSources().some(function (tickSource) {
return tickSource.metadata.mode === sourceType; return tickSource.metadata.mode === sourceType;
}); });
} }
var timeSystemsForMode = function (sourceType) { var timeSystemsForMode = function (sourceType) {
return this._timeSystems.filter(hasTickSource.bind(this, sourceType)); return this.systems.filter(hasTickSource.bind(this, sourceType));
}.bind(this); }.bind(this);
//Only show 'real-time mode' if appropriate time systems available //Only show 'real-time mode' if appropriate time systems available
if (timeSystemsForMode('realtime').length > 0 ) { if (timeSystemsForMode('realtime').length > 0) {
var realtimeMode = { var realtimeMode = {
key: 'realtime', key: 'realtime',
cssclass: 'icon-clock', cssclass: 'icon-clock',
@ -82,7 +81,7 @@ define(
name: 'Real-time Mode', 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.' 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._availableModes[realtimeMode.key] = realtimeMode; this.availModes[realtimeMode.key] = realtimeMode;
} }
//Only show 'LAD mode' if appropriate time systems available //Only show 'LAD mode' if appropriate time systems available
@ -94,7 +93,7 @@ define(
name: 'LAD Mode', name: 'LAD Mode',
description: 'Latest Available Data mode monitors real-time streaming data as it comes in. The Time Conductor and displays will only advance when data becomes available.' description: 'Latest Available Data mode monitors real-time streaming data as it comes in. The Time Conductor and displays will only advance when data becomes available.'
}; };
this._availableModes[ladMode.key] = ladMode; this.availModes[ladMode.key] = ladMode;
} }
} }
@ -125,23 +124,23 @@ define(
} }
if (arguments.length === 1) { if (arguments.length === 1) {
var timeSystem = this._conductor.timeSystem(); var timeSystem = this.conductor.timeSystem();
var modes = this.availableModes(); var modes = this.availableModes();
var modeMetaData = modes[newModeKey]; var modeMetaData = modes[newModeKey];
if (this._mode) { if (this.currentMode) {
this._mode.destroy(); this.currentMode.destroy();
} }
this._mode = new TimeConductorMode(modeMetaData, this._conductor, this._timeSystems); this.currentMode = new TimeConductorMode(modeMetaData, this.conductor, this.systems);
// If no time system set on time conductor, or the currently selected time system is not available in // If no time system set on time conductor, or the currently selected time system is not available in
// the new mode, default to first available time system // the new mode, default to first available time system
if (!timeSystem || !contains(this._mode.availableTimeSystems(), timeSystem)) { if (!timeSystem || !contains(this.currentMode.availableTimeSystems(), timeSystem)) {
timeSystem = this._mode.availableTimeSystems()[0]; timeSystem = this.currentMode.availableTimeSystems()[0];
this._conductor.timeSystem(timeSystem, timeSystem.defaults().bounds); this.conductor.timeSystem(timeSystem, timeSystem.defaults().bounds);
} }
} }
return this._mode ? this._mode.metadata().key : undefined; return this.currentMode ? this.currentMode.metadata().key : undefined;
}; };
/** /**
@ -176,7 +175,7 @@ define(
*/ */
TimeConductorViewService.prototype.deltas = function () { TimeConductorViewService.prototype.deltas = function () {
//Deltas stored on mode. Use .apply to preserve arguments //Deltas stored on mode. Use .apply to preserve arguments
return this._mode.deltas.apply(this._mode, arguments); return this.currentMode.deltas.apply(this.currentMode, arguments);
}; };
/** /**
@ -187,7 +186,7 @@ define(
* @returns {ModeMetadata[]} * @returns {ModeMetadata[]}
*/ */
TimeConductorViewService.prototype.availableModes = function () { TimeConductorViewService.prototype.availableModes = function () {
return this._availableModes; return this.availModes;
}; };
/** /**
@ -195,7 +194,7 @@ define(
* mode. Time systems and tick sources are mode dependent * mode. Time systems and tick sources are mode dependent
*/ */
TimeConductorViewService.prototype.availableTimeSystems = function () { TimeConductorViewService.prototype.availableTimeSystems = function () {
return this._mode.availableTimeSystems(); return this.currentMode.availableTimeSystems();
}; };
return TimeConductorViewService; return TimeConductorViewService;

View File

@ -133,7 +133,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
]); ]);
viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems); viewService = new TimeConductorViewService(mockTimeConductor, mockTimeSystems);
viewService._mode = oldMode; viewService.currentMode = oldMode;
viewService.mode('fixed'); viewService.mode('fixed');
expect(oldMode.destroy).toHaveBeenCalled(); expect(oldMode.destroy).toHaveBeenCalled();
}); });
@ -145,7 +145,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
metadata: { metadata: {
mode: 'realtime' mode: 'realtime'
}, },
listen: function() {} listen: function () {}
}; };
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]); tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);
@ -165,7 +165,7 @@ define(['./TimeConductorViewService'], function (TimeConductorViewService) {
metadata: { metadata: {
mode: 'realtime' mode: 'realtime'
}, },
listen: function() {} listen: function () {}
}; };
tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]); tickingTimeSystem.tickSources.andReturn([mockRealtimeTickSource]);

View File

@ -32,7 +32,7 @@ define([
* @implements TimeSystem * @implements TimeSystem
* @constructor * @constructor
*/ */
function UTCTimeSystem ($timeout) { function UTCTimeSystem($timeout) {
TimeSystem.call(this); TimeSystem.call(this);
/** /**
@ -46,14 +46,14 @@ define([
'cssclass': 'icon-clock' 'cssclass': 'icon-clock'
}; };
this._formats = ['utc']; this.fmts = ['utc'];
this._tickSources = [new LocalClock($timeout, DEFAULT_PERIOD)]; this.sources = [new LocalClock($timeout, DEFAULT_PERIOD)];
} }
UTCTimeSystem.prototype = Object.create(TimeSystem.prototype); UTCTimeSystem.prototype = Object.create(TimeSystem.prototype);
UTCTimeSystem.prototype.formats = function () { UTCTimeSystem.prototype.formats = function () {
return this._formats; return this.fmts;
}; };
UTCTimeSystem.prototype.deltaFormat = function () { UTCTimeSystem.prototype.deltaFormat = function () {
@ -61,7 +61,7 @@ define([
}; };
UTCTimeSystem.prototype.tickSources = function () { UTCTimeSystem.prototype.tickSources = function () {
return this._tickSources; return this.sources;
}; };
UTCTimeSystem.prototype.defaults = function (key) { UTCTimeSystem.prototype.defaults = function (key) {

View File

@ -229,7 +229,7 @@ define(
// Respond to a display bounds change (requery for data) // Respond to a display bounds change (requery for data)
function changeDisplayBounds(event, bounds, follow) { function changeDisplayBounds(event, bounds, follow) {
//'hack' for follow mode //'hack' for follow mode
if (follow === true){ if (follow === true) {
setBasePanZoom(bounds); setBasePanZoom(bounds);
} else { } else {
var domainAxis = $scope.axes[0]; var domainAxis = $scope.axes[0];

View File

@ -239,7 +239,7 @@ define(
it("sets status when plot becomes detached from time conductor", function () { it("sets status when plot becomes detached from time conductor", function () {
mockScope.$watch.mostRecentCall.args[1](mockDomainObject); mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
function boundsEvent(){ function boundsEvent() {
fireEvent("telemetry:display:bounds", [ fireEvent("telemetry:display:bounds", [
{}, {},
{ start: 10, end: 100 }, { start: 10, end: 100 },

View File

@ -80,7 +80,7 @@ define(
HistoricalTableController.prototype.boundsChange = function (event, bounds, follow) { HistoricalTableController.prototype.boundsChange = function (event, bounds, follow) {
// If in follow mode, don't bother re-subscribing, data will be // If in follow mode, don't bother re-subscribing, data will be
// received from existing subscription. // received from existing subscription.
if (follow!==true) { if (follow !== true) {
this.subscribe(); this.subscribe();
} }
}; };