mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 19:34:25 +00:00
Merged mode-specific defaults, with some refactoring
This commit is contained in:
commit
6b482d487b
@ -38,16 +38,6 @@ define(['../../../platform/features/conductor-v2/conductor/src/timeSystems/Local
|
||||
}
|
||||
LADTickSource.prototype = Object.create(LocalClock.prototype);
|
||||
|
||||
LADTickSource.prototype.tick = function () {
|
||||
console.log('data tick');
|
||||
var now = Date.now();
|
||||
this.listeners.forEach(function (listener){
|
||||
listener(now);
|
||||
});
|
||||
this.timeoutHandle = this.$timeout(this.tick.bind(this), this.period);
|
||||
};
|
||||
|
||||
|
||||
LADTickSource.prototype.type = function () {
|
||||
return 'data';
|
||||
};
|
||||
|
@ -26,6 +26,7 @@ define([
|
||||
'./LADTickSource'
|
||||
], function (TimeSystem, LocalClock, LADTickSource) {
|
||||
var FIFTEEN_MINUTES = 15 * 60 * 1000,
|
||||
THIRTY_MINUTES = 30 * 60 * 1000,
|
||||
DEFAULT_PERIOD = 1000;
|
||||
|
||||
/**
|
||||
@ -71,8 +72,16 @@ define([
|
||||
{
|
||||
key: 'local-default',
|
||||
name: 'Local 12 hour time system defaults',
|
||||
mode: 'fixed',
|
||||
deltas: {start: FIFTEEN_MINUTES, end: 0},
|
||||
bounds: {start: now - FIFTEEN_MINUTES, end: now}
|
||||
},
|
||||
{
|
||||
key: 'local-default',
|
||||
name: 'Local 12 hour time system defaults',
|
||||
mode: 'follow',
|
||||
deltas: {start: THIRTY_MINUTES, end: 0},
|
||||
bounds: {start: now - THIRTY_MINUTES, end: now}
|
||||
}
|
||||
];
|
||||
};
|
||||
|
@ -54,7 +54,6 @@ define(['./TickSource'], function (TickSource) {
|
||||
};
|
||||
|
||||
LocalClock.prototype.tick = function () {
|
||||
console.log('clock tick');
|
||||
var now = Date.now();
|
||||
this.listeners.forEach(function (listener){
|
||||
listener(now);
|
||||
|
@ -253,8 +253,8 @@ define(
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
TimeConductorController.prototype.setDeltasFromTimeSystem = function (timeSystem) {
|
||||
var defaults = timeSystem.defaults()[0];
|
||||
TimeConductorController.prototype.setDeltasFromMode = function (mode) {
|
||||
var defaults = mode.defaults();
|
||||
var deltas = defaults.deltas;
|
||||
|
||||
/*
|
||||
@ -295,7 +295,7 @@ define(
|
||||
this.$scope.timeSystemModel.deltaFormat = newTimeSystem.deltaFormat();
|
||||
var mode = this.conductorService.mode();
|
||||
mode.timeSystem(newTimeSystem);
|
||||
this.setDeltasFromTimeSystem(newTimeSystem);
|
||||
this.setDeltasFromMode(mode);
|
||||
|
||||
// If current mode supports ticking, set an appropriate tick
|
||||
// source from the new time system
|
||||
|
@ -43,6 +43,16 @@ define(
|
||||
this.conductor.follow(false);
|
||||
};
|
||||
|
||||
FixedMode.prototype.defaults = function () {
|
||||
var timeSystem = this.timeSystem();
|
||||
|
||||
if (timeSystem){
|
||||
return timeSystem.defaults().filter(function (d) {
|
||||
return d.mode === 'fixed';
|
||||
})[0];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Defines behavior to occur when selected time system changes. In
|
||||
* this case, sets default bounds on the time conductor.
|
||||
@ -53,7 +63,7 @@ define(
|
||||
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
|
||||
|
||||
if (timeSystem) {
|
||||
var defaults = timeSystem.defaults()[0];
|
||||
var defaults = this.defaults();
|
||||
|
||||
var bounds = {
|
||||
start: defaults.bounds.start,
|
||||
|
@ -64,7 +64,7 @@ define(
|
||||
* Get or set tick source. Setting tick source will also start
|
||||
* listening to it and unlisten from any existing tick source
|
||||
* @param tickSource
|
||||
* @returns {undefined|*}
|
||||
* @returns {TickSource}
|
||||
*/
|
||||
FollowMode.prototype.tickSource = function (tickSource) {
|
||||
if (tickSource) {
|
||||
@ -77,6 +77,16 @@ define(
|
||||
return this._tickSource;
|
||||
};
|
||||
|
||||
FollowMode.prototype.defaults = function () {
|
||||
var timeSystem = this.timeSystem();
|
||||
|
||||
if (timeSystem){
|
||||
return timeSystem.defaults().filter(function (d) {
|
||||
return d.mode === 'follow';
|
||||
})[0];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* On time system change, default the bounds values in the time
|
||||
* conductor, using the deltas associated with this mode.
|
||||
@ -87,7 +97,7 @@ define(
|
||||
TimeConductorMode.prototype.timeSystem.apply(this, arguments);
|
||||
|
||||
if (timeSystem) {
|
||||
var defaults = timeSystem.defaults()[0];
|
||||
var defaults = this.defaults();
|
||||
|
||||
if (arguments.length > 0) {
|
||||
var bounds = {
|
||||
|
@ -62,6 +62,10 @@ define(
|
||||
return this._key;
|
||||
};
|
||||
|
||||
TimeConductorMode.prototype.defaults = function () {
|
||||
throw new Error("Not implemented");
|
||||
};
|
||||
|
||||
TimeConductorMode.prototype.destroy = function () {
|
||||
};
|
||||
|
||||
|
@ -70,6 +70,14 @@ define([
|
||||
{
|
||||
key: 'utc-default',
|
||||
name: 'UTC time system defaults',
|
||||
mode: 'follow',
|
||||
deltas: {start: FIFTEEN_MINUTES, end: 0},
|
||||
bounds: {start: now - FIFTEEN_MINUTES, end: now}
|
||||
},
|
||||
{
|
||||
key: 'utc-default',
|
||||
name: 'UTC time system defaults',
|
||||
mode: 'fixed',
|
||||
deltas: {start: FIFTEEN_MINUTES, end: 0},
|
||||
bounds: {start: now - FIFTEEN_MINUTES, end: now}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user