mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[Time Conductor] Addressing comments from code review
This commit is contained in:
@ -21,12 +21,12 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define([
|
define([
|
||||||
"./src/ui/TimeConductorViewService",
|
|
||||||
"./src/ui/TimeConductorController",
|
"./src/ui/TimeConductorController",
|
||||||
"./src/ui/ConductorAxisController",
|
"./src/ui/ConductorAxisController",
|
||||||
"./src/ui/ConductorTOIController",
|
"./src/ui/ConductorTOIController",
|
||||||
|
"./src/ui/ConductorTOIDirective",
|
||||||
"./src/ui/TimeOfInterestController",
|
"./src/ui/TimeOfInterestController",
|
||||||
"./src/ui/MctConductorAxis",
|
"./src/ui/ConductorAxisDirective",
|
||||||
"./src/ui/NumberFormat",
|
"./src/ui/NumberFormat",
|
||||||
"text!./res/templates/time-conductor.html",
|
"text!./res/templates/time-conductor.html",
|
||||||
"text!./res/templates/mode-selector/mode-selector.html",
|
"text!./res/templates/mode-selector/mode-selector.html",
|
||||||
@ -34,12 +34,12 @@ define([
|
|||||||
"text!./res/templates/time-of-interest.html",
|
"text!./res/templates/time-of-interest.html",
|
||||||
"legacyRegistry"
|
"legacyRegistry"
|
||||||
], function (
|
], function (
|
||||||
TimeConductorViewService,
|
|
||||||
TimeConductorController,
|
TimeConductorController,
|
||||||
ConductorAxisController,
|
ConductorAxisController,
|
||||||
ConductorTOIController,
|
ConductorTOIController,
|
||||||
|
ConductorTOIDirective,
|
||||||
TimeOfInterestController,
|
TimeOfInterestController,
|
||||||
MCTConductorAxis,
|
ConductorAxisDirective,
|
||||||
NumberFormat,
|
NumberFormat,
|
||||||
timeConductorTemplate,
|
timeConductorTemplate,
|
||||||
modeSelectorTemplate,
|
modeSelectorTemplate,
|
||||||
@ -50,16 +50,6 @@ define([
|
|||||||
|
|
||||||
legacyRegistry.register("platform/features/conductor/core", {
|
legacyRegistry.register("platform/features/conductor/core", {
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"services": [
|
|
||||||
{
|
|
||||||
"key": "timeConductorViewService",
|
|
||||||
"implementation": TimeConductorViewService,
|
|
||||||
"depends": [
|
|
||||||
"openmct",
|
|
||||||
"timeSystems[]"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"controllers": [
|
"controllers": [
|
||||||
{
|
{
|
||||||
"key": "TimeConductorController",
|
"key": "TimeConductorController",
|
||||||
@ -68,7 +58,6 @@ define([
|
|||||||
"$scope",
|
"$scope",
|
||||||
"$window",
|
"$window",
|
||||||
"openmct",
|
"openmct",
|
||||||
"timeConductorViewService",
|
|
||||||
"formatService",
|
"formatService",
|
||||||
"CONDUCTOR_CONFIG"
|
"CONDUCTOR_CONFIG"
|
||||||
]
|
]
|
||||||
@ -79,7 +68,6 @@ define([
|
|||||||
"depends": [
|
"depends": [
|
||||||
"$scope",
|
"$scope",
|
||||||
"openmct",
|
"openmct",
|
||||||
"timeConductorViewService",
|
|
||||||
"formatService"
|
"formatService"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -95,12 +83,16 @@ define([
|
|||||||
],
|
],
|
||||||
"directives": [
|
"directives": [
|
||||||
{
|
{
|
||||||
"key": "mctConductorAxis",
|
"key": "conductorAxis",
|
||||||
"implementation": MCTConductorAxis,
|
"implementation": ConductorAxisDirective,
|
||||||
"depends": [
|
"depends": [
|
||||||
"openmct",
|
"openmct",
|
||||||
"formatService"
|
"formatService"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "conductorTOI",
|
||||||
|
"implementation": ConductorTOIDirective
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stylesheets": [
|
"stylesheets": [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<!-- Parent holder for time conductor. follow-mode | fixed-mode -->
|
<!-- Parent holder for time conductor. follow-mode | fixed-mode -->
|
||||||
<div ng-controller="TimeConductorController as tcController"
|
<div ng-controller="TimeConductorController as tcController"
|
||||||
class="holder grows flex-elem l-flex-row l-time-conductor {{tcController.mode}}-mode {{timeSystemModel.selected.metadata.key}}-time-system"
|
class="holder grows flex-elem l-flex-row l-time-conductor {{tcController.isFixed ? 'fixed-mode' : 'realtime-mode'}} {{timeSystemModel.selected.metadata.key}}-time-system"
|
||||||
ng-class="{'status-panning': tcController.panning}">
|
ng-class="{'status-panning': tcController.panning}">
|
||||||
<div class="flex-elem holder time-conductor-icon">
|
<div class="flex-elem holder time-conductor-icon">
|
||||||
<div class="hand-little"></div>
|
<div class="hand-little"></div>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</mct-control>
|
</mct-control>
|
||||||
</span>
|
</span>
|
||||||
<span class="l-time-range-input-w time-delta start-delta"
|
<span class="l-time-range-input-w time-delta start-delta"
|
||||||
ng-class="{'hide':(tcController.mode === 'fixed')}">
|
ng-class="{'hide':tcController.isFixed}">
|
||||||
-
|
-
|
||||||
<mct-control key="'datetime-field'"
|
<mct-control key="'datetime-field'"
|
||||||
structure="{
|
structure="{
|
||||||
@ -55,13 +55,13 @@
|
|||||||
}"
|
}"
|
||||||
ng-model="boundsModel"
|
ng-model="boundsModel"
|
||||||
ng-blur="tcController.setBoundsFromView(boundsModel)"
|
ng-blur="tcController.setBoundsFromView(boundsModel)"
|
||||||
ng-disabled="tcController.mode !== 'fixed'"
|
ng-disabled="!tcController.isFixed"
|
||||||
field="'end'"
|
field="'end'"
|
||||||
class="time-range-input">
|
class="time-range-input">
|
||||||
</mct-control>
|
</mct-control>
|
||||||
</span>
|
</span>
|
||||||
<span class="l-time-range-input-w time-delta end-delta"
|
<span class="l-time-range-input-w time-delta end-delta"
|
||||||
ng-class="{'hide':(tcController.mode === 'fixed')}">
|
ng-class="{'hide': tcController.isFixed}">
|
||||||
+
|
+
|
||||||
<mct-control key="'datetime-field'"
|
<mct-control key="'datetime-field'"
|
||||||
structure="{
|
structure="{
|
||||||
@ -79,21 +79,11 @@
|
|||||||
|
|
||||||
<input type="submit" class="hidden">
|
<input type="submit" class="hidden">
|
||||||
</form>
|
</form>
|
||||||
<mct-conductor-axis></mct-conductor-axis>
|
<conductor-axis view-service="tcController.conductorViewService"></conductor-axis>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Holds data visualization, time of interest -->
|
<!-- Holds data visualization, time of interest -->
|
||||||
<div class="l-data-visualization-holder l-row-elem flex-elem"
|
<conductor-toi view-service="tcController.conductorViewService"></conductor-toi>
|
||||||
ng-controller="ConductorTOIController as toi">
|
|
||||||
<a class="l-page-button s-icon-button icon-pointer-left"></a>
|
|
||||||
<div class="l-data-visualization" ng-click="toi.setTOIFromPosition($event)">
|
|
||||||
<mct-include key="'time-of-interest'"
|
|
||||||
class="l-toi-holder show-val"
|
|
||||||
ng-class="{ pinned: toi.pinned, 'val-to-left': toi.left > 80 }"
|
|
||||||
ng-style="{'left': toi.left + '%'}"></mct-include>
|
|
||||||
</div>
|
|
||||||
<a class="l-page-button align-right s-icon-button icon-pointer-right"></a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Holds time system and session selectors, and zoom control -->
|
<!-- Holds time system and session selectors, and zoom control -->
|
||||||
<div class="l-time-conductor-controls l-row-elem l-flex-row flex-elem">
|
<div class="l-time-conductor-controls l-row-elem l-flex-row flex-elem">
|
||||||
|
@ -34,11 +34,10 @@ define(
|
|||||||
* Used by the mct-conductor-axis directive
|
* Used by the mct-conductor-axis directive
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function ConductorAxisController(openmct, formatService, conductorViewService, scope, element) {
|
function ConductorAxisController(openmct, formatService, scope, element) {
|
||||||
// Dependencies
|
// Dependencies
|
||||||
this.formatService = formatService;
|
this.formatService = formatService;
|
||||||
this.timeAPI = openmct.time;
|
this.timeAPI = openmct.time;
|
||||||
this.conductorViewService = conductorViewService;
|
|
||||||
|
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
|
|
||||||
@ -60,8 +59,8 @@ define(
|
|||||||
ConductorAxisController.prototype.destroy = function () {
|
ConductorAxisController.prototype.destroy = function () {
|
||||||
this.timeAPI.off('timeSystem', this.changeTimeSystem);
|
this.timeAPI.off('timeSystem', this.changeTimeSystem);
|
||||||
this.timeAPI.off('bounds', this.changeBounds);
|
this.timeAPI.off('bounds', this.changeBounds);
|
||||||
this.conductorViewService.off("zoom", this.onZoom);
|
this.viewService.off("zoom", this.onZoom);
|
||||||
this.conductorViewService.off("zoom-stop", this.onZoomStop);
|
this.viewService.off("zoom-stop", this.onZoomStop);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,8 +91,8 @@ define(
|
|||||||
|
|
||||||
this.scope.$on("$destroy", this.destroy);
|
this.scope.$on("$destroy", this.destroy);
|
||||||
|
|
||||||
this.conductorViewService.on("zoom", this.onZoom);
|
this.viewService.on("zoom", this.onZoom);
|
||||||
this.conductorViewService.on("zoom-stop", this.onZoomStop);
|
this.viewService.on("zoom-stop", this.onZoomStop);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,7 +174,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
ConductorAxisController.prototype.panStop = function () {
|
ConductorAxisController.prototype.panStop = function () {
|
||||||
//resync view bounds with time conductor bounds
|
//resync view bounds with time conductor bounds
|
||||||
this.conductorViewService.emit("pan-stop");
|
this.viewService.emit("pan-stop");
|
||||||
this.timeAPI.bounds(this.bounds);
|
this.timeAPI.bounds(this.bounds);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -222,7 +221,7 @@ define(
|
|||||||
end: end
|
end: end
|
||||||
};
|
};
|
||||||
this.setScale();
|
this.setScale();
|
||||||
this.conductorViewService.emit("pan", this.bounds);
|
this.viewService.emit("pan", this.bounds);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,23 +21,25 @@
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
define(['./ConductorAxisController'], function (ConductorAxisController) {
|
define(['./ConductorAxisController'], function (ConductorAxisController) {
|
||||||
function MctConductorAxis() {
|
function ConductorAxisDirective() {
|
||||||
/**
|
/**
|
||||||
* The mct-conductor-axis renders a horizontal axis with regular
|
* The mct-conductor-axis renders a horizontal axis with regular
|
||||||
* labelled 'ticks'. It requires 'start' and 'end' integer values to
|
* labelled 'ticks'. It requires 'start' and 'end' integer values to
|
||||||
* be specified as attributes.
|
* be specified as attributes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return {
|
return {
|
||||||
controller: [
|
controller: [
|
||||||
'openmct',
|
'openmct',
|
||||||
'formatService',
|
'formatService',
|
||||||
'timeConductorViewService',
|
|
||||||
'$scope',
|
'$scope',
|
||||||
'$element',
|
'$element',
|
||||||
ConductorAxisController
|
ConductorAxisController
|
||||||
],
|
],
|
||||||
controllerAs: 'axis',
|
controllerAs: 'axis',
|
||||||
|
scope: {
|
||||||
|
viewService: "="
|
||||||
|
},
|
||||||
|
bindToController: true,
|
||||||
|
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
priority: 1000,
|
priority: 1000,
|
||||||
@ -50,5 +52,5 @@ define(['./ConductorAxisController'], function (ConductorAxisController) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return MctConductorAxis;
|
return ConductorAxisDirective;
|
||||||
});
|
});
|
@ -29,9 +29,8 @@ define(
|
|||||||
* TOI indicator based on the current value of the TOI, and the width of the TOI conductor.
|
* TOI indicator based on the current value of the TOI, and the width of the TOI conductor.
|
||||||
* @memberof platform.features.conductor
|
* @memberof platform.features.conductor
|
||||||
*/
|
*/
|
||||||
function ConductorTOIController($scope, openmct, conductorViewService) {
|
function ConductorTOIController($scope, openmct) {
|
||||||
this.timeAPI = openmct.time;
|
this.timeAPI = openmct.time;
|
||||||
this.conductorViewService = conductorViewService;
|
|
||||||
|
|
||||||
//Bind all class functions to 'this'
|
//Bind all class functions to 'this'
|
||||||
Object.keys(ConductorTOIController.prototype).filter(function (key) {
|
Object.keys(ConductorTOIController.prototype).filter(function (key) {
|
||||||
|
@ -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:
|
||||||
|
'<div class="l-data-visualization-holder l-row-elem flex-elem">' +
|
||||||
|
' <a class="l-page-button s-icon-button icon-pointer-left"></a>' +
|
||||||
|
' <div class="l-data-visualization" ng-click="toi.setTOIFromPosition($event)">' +
|
||||||
|
' <mct-include key="\'time-of-interest\'" class="l-toi-holder show-val" ' +
|
||||||
|
' ng-class="{ pinned: toi.pinned, \'val-to-left\': toi.left > 80 }" ' +
|
||||||
|
' ng-style="{\'left\': toi.left + \'%\'}"></mct-include>' +
|
||||||
|
' </div>' +
|
||||||
|
' <a class="l-page-button align-right s-icon-button icon-pointer-right"></a>' +
|
||||||
|
'</div>'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConductorTOIDirective;
|
||||||
|
});
|
@ -24,9 +24,14 @@
|
|||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'moment',
|
'moment',
|
||||||
'./TimeConductorValidation'
|
'./TimeConductorValidation',
|
||||||
|
'./TimeConductorViewService'
|
||||||
],
|
],
|
||||||
function (moment, TimeConductorValidation) {
|
function (
|
||||||
|
moment,
|
||||||
|
TimeConductorValidation,
|
||||||
|
TimeConductorViewService
|
||||||
|
) {
|
||||||
|
|
||||||
var timeUnitsMegastructure = [
|
var timeUnitsMegastructure = [
|
||||||
["Decades", function (r) {
|
["Decades", function (r) {
|
||||||
@ -67,7 +72,6 @@ define(
|
|||||||
$scope,
|
$scope,
|
||||||
$window,
|
$window,
|
||||||
openmct,
|
openmct,
|
||||||
conductorViewService,
|
|
||||||
formatService,
|
formatService,
|
||||||
config
|
config
|
||||||
) {
|
) {
|
||||||
@ -89,8 +93,8 @@ define(
|
|||||||
|
|
||||||
this.$scope = $scope;
|
this.$scope = $scope;
|
||||||
this.$window = $window;
|
this.$window = $window;
|
||||||
this.conductorViewService = conductorViewService;
|
|
||||||
this.timeAPI = openmct.time;
|
this.timeAPI = openmct.time;
|
||||||
|
this.conductorViewService = new TimeConductorViewService(openmct);
|
||||||
this.validation = new TimeConductorValidation(this.timeAPI);
|
this.validation = new TimeConductorValidation(this.timeAPI);
|
||||||
this.formatService = formatService;
|
this.formatService = formatService;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@ -99,7 +103,12 @@ define(
|
|||||||
this.$scope.timeSystemModel = {};
|
this.$scope.timeSystemModel = {};
|
||||||
this.$scope.boundsModel = {};
|
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);
|
var options = this.optionsFromConfig(config);
|
||||||
this.menu = {
|
this.menu = {
|
||||||
@ -107,11 +116,6 @@ define(
|
|||||||
options: options
|
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
|
//Set the initial state of the UI from the conductor state
|
||||||
var timeSystem = this.timeAPI.timeSystem();
|
var timeSystem = this.timeAPI.timeSystem();
|
||||||
if (timeSystem) {
|
if (timeSystem) {
|
||||||
@ -224,7 +228,7 @@ define(
|
|||||||
var clock = this.getClock(menuOption.clock);
|
var clock = this.getClock(menuOption.clock);
|
||||||
var clockKey = menuOption.clock || 'fixed';
|
var clockKey = menuOption.clock || 'fixed';
|
||||||
|
|
||||||
var timeSystem = this.getTimeSystem(menuOption.timeSystem);
|
var timeSystem = this.timeSystems[menuOption.timeSystem];
|
||||||
if (timeSystem !== undefined) {
|
if (timeSystem !== undefined) {
|
||||||
if (clock !== undefined) {
|
if (clock !== undefined) {
|
||||||
// Use an associative array to built a set of unique
|
// 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) {
|
if (clock !== undefined) {
|
||||||
this.setViewFromOffsets(this.timeAPI.clockOffsets());
|
this.setViewFromOffsets(this.timeAPI.clockOffsets());
|
||||||
@ -423,7 +427,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
TimeConductorController.prototype.setTimeSystemFromView = function (key) {
|
TimeConductorController.prototype.setTimeSystemFromView = function (key) {
|
||||||
var clock = this.menu.selected.clock;
|
var clock = this.menu.selected.clock;
|
||||||
var timeSystem = this.getTimeSystem(key);
|
var timeSystem = this.timeSystems[key];
|
||||||
var config = this.getConfig(timeSystem, clock);
|
var config = this.getConfig(timeSystem, clock);
|
||||||
var bounds;
|
var bounds;
|
||||||
|
|
||||||
@ -445,7 +449,12 @@ define(
|
|||||||
this.timeAPI.timeSystem(timeSystem, bounds);
|
this.timeAPI.timeSystem(timeSystem, bounds);
|
||||||
var configOffsets = config.clockOffsets;
|
var configOffsets = config.clockOffsets;
|
||||||
var apiOffsets = this.timeAPI.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);
|
this.timeAPI.clockOffsets(configOffsets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
|
|
||||||
define(['EventEmitter'], function (EventEmitter) {
|
define(['EventEmitter'], function (EventEmitter) {
|
||||||
|
|
||||||
var tick;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The public API for setting and querying the temporal state of the
|
* 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
|
* 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.activeClock = undefined;
|
||||||
this.offsets = undefined;
|
this.offsets = undefined;
|
||||||
|
|
||||||
/**
|
this.tick = this.tick.bind(this);
|
||||||
* 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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +175,8 @@ define(['EventEmitter'], function (EventEmitter) {
|
|||||||
isNaN(offsets.end)
|
isNaN(offsets.end)
|
||||||
) {
|
) {
|
||||||
return "Start and end offsets must be specified as integer values";
|
return "Start and end offsets must be specified as integer values";
|
||||||
} else if (offsets.start >= 0) {
|
} else if (offsets.start >= offsets.end) {
|
||||||
return "Specified start offset must less than 0";
|
return "Specified start offset must be < end offset";
|
||||||
} else if (offsets.end < 0) {
|
|
||||||
return "Specified end offset must greater than or equal to 0";
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -330,6 +309,28 @@ define(['EventEmitter'], function (EventEmitter) {
|
|||||||
return this.toi;
|
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
|
* Set the active clock. Tick source will be immediately subscribed to
|
||||||
* and ticking will begin. Offsets from 'now' must also be provided. A clock
|
* 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;
|
var previousClock = this.activeClock;
|
||||||
if (previousClock !== undefined) {
|
if (previousClock !== undefined) {
|
||||||
previousClock.off("tick", tick);
|
previousClock.off("tick", this.tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.activeClock = clock;
|
this.activeClock = clock;
|
||||||
|
|
||||||
if (this.activeClock !== undefined) {
|
if (this.activeClock !== undefined) {
|
||||||
this.offsets = offsets;
|
this.offsets = offsets;
|
||||||
this.activeClock.on("tick", tick);
|
this.activeClock.on("tick", this.tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user