diff --git a/platform/features/conductor/core/src/ui/ConductorAxisController.js b/platform/features/conductor/core/src/ui/ConductorAxisController.js
index 9b70e1ca66..6afa25331f 100644
--- a/platform/features/conductor/core/src/ui/ConductorAxisController.js
+++ b/platform/features/conductor/core/src/ui/ConductorAxisController.js
@@ -34,11 +34,10 @@ define(
* Used by the mct-conductor-axis directive
* @constructor
*/
- function ConductorAxisController(openmct, formatService, conductorViewService, scope, element) {
+ function ConductorAxisController(openmct, formatService, scope, element) {
// Dependencies
this.formatService = formatService;
this.timeAPI = openmct.time;
- this.conductorViewService = conductorViewService;
this.scope = scope;
@@ -60,8 +59,8 @@ define(
ConductorAxisController.prototype.destroy = function () {
this.timeAPI.off('timeSystem', this.changeTimeSystem);
this.timeAPI.off('bounds', this.changeBounds);
- this.conductorViewService.off("zoom", this.onZoom);
- this.conductorViewService.off("zoom-stop", this.onZoomStop);
+ this.viewService.off("zoom", this.onZoom);
+ this.viewService.off("zoom-stop", this.onZoomStop);
};
/**
@@ -92,8 +91,8 @@ define(
this.scope.$on("$destroy", this.destroy);
- this.conductorViewService.on("zoom", this.onZoom);
- this.conductorViewService.on("zoom-stop", this.onZoomStop);
+ this.viewService.on("zoom", this.onZoom);
+ this.viewService.on("zoom-stop", this.onZoomStop);
};
/**
@@ -175,7 +174,7 @@ define(
*/
ConductorAxisController.prototype.panStop = function () {
//resync view bounds with time conductor bounds
- this.conductorViewService.emit("pan-stop");
+ this.viewService.emit("pan-stop");
this.timeAPI.bounds(this.bounds);
};
@@ -222,7 +221,7 @@ define(
end: end
};
this.setScale();
- this.conductorViewService.emit("pan", this.bounds);
+ this.viewService.emit("pan", this.bounds);
}
};
diff --git a/platform/features/conductor/core/src/ui/MctConductorAxis.js b/platform/features/conductor/core/src/ui/ConductorAxisDirective.js
similarity index 92%
rename from platform/features/conductor/core/src/ui/MctConductorAxis.js
rename to platform/features/conductor/core/src/ui/ConductorAxisDirective.js
index 7484d6b35f..11dd3c31ed 100644
--- a/platform/features/conductor/core/src/ui/MctConductorAxis.js
+++ b/platform/features/conductor/core/src/ui/ConductorAxisDirective.js
@@ -21,23 +21,25 @@
*****************************************************************************/
define(['./ConductorAxisController'], function (ConductorAxisController) {
- function MctConductorAxis() {
+ function ConductorAxisDirective() {
/**
* The mct-conductor-axis renders a horizontal axis with regular
* labelled 'ticks'. It requires 'start' and 'end' integer values to
* be specified as attributes.
*/
-
return {
controller: [
'openmct',
'formatService',
- 'timeConductorViewService',
'$scope',
'$element',
ConductorAxisController
],
controllerAs: 'axis',
+ scope: {
+ viewService: "="
+ },
+ bindToController: true,
restrict: 'E',
priority: 1000,
@@ -50,5 +52,5 @@ define(['./ConductorAxisController'], function (ConductorAxisController) {
};
}
- return MctConductorAxis;
+ return ConductorAxisDirective;
});
diff --git a/platform/features/conductor/core/src/ui/ConductorTOIController.js b/platform/features/conductor/core/src/ui/ConductorTOIController.js
index 3d60de62d9..73f6128084 100644
--- a/platform/features/conductor/core/src/ui/ConductorTOIController.js
+++ b/platform/features/conductor/core/src/ui/ConductorTOIController.js
@@ -29,9 +29,8 @@ define(
* TOI indicator based on the current value of the TOI, and the width of the TOI conductor.
* @memberof platform.features.conductor
*/
- function ConductorTOIController($scope, openmct, conductorViewService) {
+ function ConductorTOIController($scope, openmct) {
this.timeAPI = openmct.time;
- this.conductorViewService = conductorViewService;
//Bind all class functions to 'this'
Object.keys(ConductorTOIController.prototype).filter(function (key) {
diff --git a/platform/features/conductor/core/src/ui/ConductorTOIDirective.js b/platform/features/conductor/core/src/ui/ConductorTOIDirective.js
new file mode 100644
index 0000000000..24e86200f1
--- /dev/null
+++ b/platform/features/conductor/core/src/ui/ConductorTOIDirective.js
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * 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.
+ *****************************************************************************/
+
+define(['./ConductorTOIController'], function (ConductorTOIController) {
+ /**
+ * A directive that encapsulates the TOI specific behavior of the Time Conductor UI.
+ * @constructor
+ */
+ function ConductorTOIDirective() {
+ /**
+ * The mct-conductor-axis renders a horizontal axis with regular
+ * labelled 'ticks'. It requires 'start' and 'end' integer values to
+ * be specified as attributes.
+ */
+ return {
+ controller: [
+ '$scope',
+ 'openmct',
+ ConductorTOIController
+ ],
+ controllerAs: 'toi',
+ scope: {
+ viewService: "="
+ },
+ bindToController: true,
+
+ restrict: 'E',
+ priority: 1000,
+
+ template:
+ '
' +
+ '
' +
+ '
' +
+ ' ' +
+ '
' +
+ '
' +
+ '
'
+ };
+ }
+
+ return ConductorTOIDirective;
+});
diff --git a/platform/features/conductor/core/src/ui/TimeConductorController.js b/platform/features/conductor/core/src/ui/TimeConductorController.js
index 5ee579f0f1..1c27d4518a 100644
--- a/platform/features/conductor/core/src/ui/TimeConductorController.js
+++ b/platform/features/conductor/core/src/ui/TimeConductorController.js
@@ -24,9 +24,14 @@
define(
[
'moment',
- './TimeConductorValidation'
+ './TimeConductorValidation',
+ './TimeConductorViewService'
],
- function (moment, TimeConductorValidation) {
+ function (
+ moment,
+ TimeConductorValidation,
+ TimeConductorViewService
+ ) {
var timeUnitsMegastructure = [
["Decades", function (r) {
@@ -67,7 +72,6 @@ define(
$scope,
$window,
openmct,
- conductorViewService,
formatService,
config
) {
@@ -89,8 +93,8 @@ define(
this.$scope = $scope;
this.$window = $window;
- this.conductorViewService = conductorViewService;
this.timeAPI = openmct.time;
+ this.conductorViewService = new TimeConductorViewService(openmct);
this.validation = new TimeConductorValidation(this.timeAPI);
this.formatService = formatService;
this.config = config;
@@ -99,7 +103,12 @@ define(
this.$scope.timeSystemModel = {};
this.$scope.boundsModel = {};
- this.mode = this.timeAPI.clock() === undefined ? 'fixed' : 'realtime';
+ this.timeSystems = this.timeAPI.getAllTimeSystems().reduce(function (map, timeSystem) {
+ map[timeSystem.key] = timeSystem;
+ return map;
+ }, {});
+
+ this.isFixed = this.timeAPI.clock() === undefined;
var options = this.optionsFromConfig(config);
this.menu = {
@@ -107,11 +116,6 @@ define(
options: options
};
- // Construct the provided time system definitions
- this.timeSystems = config.menuOptions.map(function (menuOption) {
- return this.getTimeSystem(menuOption.timeSystem);
- }.bind(this));
-
//Set the initial state of the UI from the conductor state
var timeSystem = this.timeAPI.timeSystem();
if (timeSystem) {
@@ -224,7 +228,7 @@ define(
var clock = this.getClock(menuOption.clock);
var clockKey = menuOption.clock || 'fixed';
- var timeSystem = this.getTimeSystem(menuOption.timeSystem);
+ var timeSystem = this.timeSystems[menuOption.timeSystem];
if (timeSystem !== undefined) {
if (clock !== undefined) {
// Use an associative array to built a set of unique
@@ -400,7 +404,7 @@ define(
}
}
- this.mode = clock === undefined ? 'fixed' : 'realtime';
+ this.isFixed = clock === undefined;
if (clock !== undefined) {
this.setViewFromOffsets(this.timeAPI.clockOffsets());
@@ -423,7 +427,7 @@ define(
*/
TimeConductorController.prototype.setTimeSystemFromView = function (key) {
var clock = this.menu.selected.clock;
- var timeSystem = this.getTimeSystem(key);
+ var timeSystem = this.timeSystems[key];
var config = this.getConfig(timeSystem, clock);
var bounds;
@@ -445,7 +449,12 @@ define(
this.timeAPI.timeSystem(timeSystem, bounds);
var configOffsets = config.clockOffsets;
var apiOffsets = this.timeAPI.clockOffsets();
- if (configOffsets.start !== apiOffsets.start || configOffsets.end !== apiOffsets.end) {
+
+ //Checking if a clock is actually set on the Time API before
+ // trying to set offsets.
+ if (this.timeAPI.clock() !== undefined &&
+ (configOffsets.start !== apiOffsets.start ||
+ configOffsets.end !== apiOffsets.end)) {
this.timeAPI.clockOffsets(configOffsets);
}
}
diff --git a/src/api/time/TimeAPI.js b/src/api/time/TimeAPI.js
index 136f5af0ef..aea887e756 100644
--- a/src/api/time/TimeAPI.js
+++ b/src/api/time/TimeAPI.js
@@ -22,8 +22,6 @@
define(['EventEmitter'], function (EventEmitter) {
- var tick;
-
/**
* The public API for setting and querying the temporal state of the
* application. The concept of time is integral to Open MCT, and at least
@@ -61,24 +59,7 @@ define(['EventEmitter'], function (EventEmitter) {
this.activeClock = undefined;
this.offsets = undefined;
- /**
- * Tick is private to avoid misuse.
- */
- tick = function (timestamp) {
- var newBounds = {
- start: timestamp + this.offsets.start,
- end: timestamp + this.offsets.end
- };
-
- this.boundsVal = newBounds;
- this.emit('bounds', this.boundsVal, true);
-
- // If a bounds change results in a TOI outside of the current
- // bounds, unset it
- if (this.toi < newBounds.start || this.toi > newBounds.end) {
- this.timeOfInterest(undefined);
- }
- }.bind(this);
+ this.tick = this.tick.bind(this);
}
@@ -194,10 +175,8 @@ define(['EventEmitter'], function (EventEmitter) {
isNaN(offsets.end)
) {
return "Start and end offsets must be specified as integer values";
- } else if (offsets.start >= 0) {
- return "Specified start offset must less than 0";
- } else if (offsets.end < 0) {
- return "Specified end offset must greater than or equal to 0";
+ } else if (offsets.start >= offsets.end) {
+ return "Specified start offset must be < end offset";
}
return true;
};
@@ -330,6 +309,28 @@ define(['EventEmitter'], function (EventEmitter) {
return this.toi;
};
+ /**
+ * Update bounds based on provided time and current offsets
+ * @private
+ * @param {number} timestamp A time from which boudns will be calculated
+ * using current offsets.
+ */
+ TimeAPI.prototype.tick = function (timestamp) {
+ var newBounds = {
+ start: timestamp + this.offsets.start,
+ end: timestamp + this.offsets.end
+ };
+
+ this.boundsVal = newBounds;
+ this.emit('bounds', this.boundsVal, true);
+
+ // If a bounds change results in a TOI outside of the current
+ // bounds, unset it
+ if (this.toi < newBounds.start || this.toi > newBounds.end) {
+ this.timeOfInterest(undefined);
+ }
+ };
+
/**
* Set the active clock. Tick source will be immediately subscribed to
* and ticking will begin. Offsets from 'now' must also be provided. A clock
@@ -360,14 +361,14 @@ define(['EventEmitter'], function (EventEmitter) {
var previousClock = this.activeClock;
if (previousClock !== undefined) {
- previousClock.off("tick", tick);
+ previousClock.off("tick", this.tick);
}
this.activeClock = clock;
if (this.activeClock !== undefined) {
this.offsets = offsets;
- this.activeClock.on("tick", tick);
+ this.activeClock.on("tick", this.tick);
}
/**