diff --git a/src/api/time/GlobalTimeContext.js b/src/api/time/GlobalTimeContext.js index 9031989ebb..8c2fea6780 100644 --- a/src/api/time/GlobalTimeContext.js +++ b/src/api/time/GlobalTimeContext.js @@ -22,6 +22,10 @@ import TimeContext from './TimeContext.js'; +/** + * @typedef {import('./TimeAPI').TimeConductorBounds} TimeConductorBounds + */ + /** * The GlobalContext handles getting and setting time of the openmct application in general. * Views will use this context unless they specify an alternate/independent time context @@ -38,12 +42,10 @@ class GlobalTimeContext extends TimeContext { * Get or set the start and end time of the time conductor. Basic validation * of bounds is performed. * - * @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds + * @param {TimeConductorBounds} newBounds * @throws {Error} Validation error - * @fires module:openmct.TimeAPI~bounds - * @returns {module:openmct.TimeAPI~TimeConductorBounds} - * @memberof module:openmct.TimeAPI# - * @method bounds + * @returns {TimeConductorBounds} + * @override */ bounds(newBounds) { if (arguments.length > 0) { @@ -61,9 +63,9 @@ class GlobalTimeContext extends TimeContext { /** * Update bounds based on provided time and current offsets - * @private * @param {number} timestamp A time from which bounds will be calculated * using current offsets. + * @override */ tick(timestamp) { super.tick.call(this, ...arguments); @@ -81,11 +83,8 @@ class GlobalTimeContext extends TimeContext { * be manipulated by the user from the time conductor or from other views. * The time of interest can effectively be unset by assigning a value of * 'undefined'. - * @fires module:openmct.TimeAPI~timeOfInterest * @param newTOI * @returns {number} the current time of interest - * @memberof module:openmct.TimeAPI# - * @method timeOfInterest */ timeOfInterest(newTOI) { if (arguments.length > 0) { @@ -93,8 +92,7 @@ class GlobalTimeContext extends TimeContext { /** * The Time of Interest has moved. * @event timeOfInterest - * @memberof module:openmct.TimeAPI~ - * @property {number} Current time of interest + * @property {number} timeOfInterest time of interest */ this.emit('timeOfInterest', this.toi); } diff --git a/src/api/time/IndependentTimeContext.js b/src/api/time/IndependentTimeContext.js index 885a02c215..ead0eb2f50 100644 --- a/src/api/time/IndependentTimeContext.js +++ b/src/api/time/IndependentTimeContext.js @@ -23,19 +23,36 @@ import { MODES, REALTIME_MODE_KEY, TIME_CONTEXT_EVENTS } from './constants.js'; import TimeContext from './TimeContext.js'; +/** + * @typedef {import('./TimeAPI.js').default} TimeAPI + * @typedef {import('./GlobalTimeContext.js').default} GlobalTimeContext + * @typedef {import('./TimeAPI.js').TimeSystem} TimeSystem + * @typedef {import('./TimeContext.js').Mode} Mode + * @typedef {import('./TimeContext.js').TimeConductorBounds} TimeConductorBounds + * @typedef {import('./TimeAPI.js').ClockOffsets} ClockOffsets + */ + /** * The IndependentTimeContext handles getting and setting time of the openmct application in general. * Views will use the GlobalTimeContext unless they specify an alternate/independent time context here. */ class IndependentTimeContext extends TimeContext { + /** + * @param {import('openmct').OpenMCT} openmct - The Open MCT application instance. + * @param {TimeAPI & GlobalTimeContext} globalTimeContext - The global time context. + * @param {import('openmct').ObjectPath} objectPath - The path of objects. + */ constructor(openmct, globalTimeContext, objectPath) { super(); + /** @type {any} */ this.openmct = openmct; + /** @type {Function[]} */ this.unlisteners = []; + /** @type {TimeAPI & GlobalTimeContext | undefined} */ this.globalTimeContext = globalTimeContext; - // We always start with the global time context. - // This upstream context will be undefined when an independent time context is added later. + /** @type {TimeAPI & GlobalTimeContext | undefined} */ this.upstreamTimeContext = this.globalTimeContext; + /** @type {Array} */ this.objectPath = objectPath; this.refreshContext = this.refreshContext.bind(this); this.resetContext = this.resetContext.bind(this); @@ -47,6 +64,10 @@ class IndependentTimeContext extends TimeContext { this.globalTimeContext.on('removeOwnContext', this.removeIndependentContext); } + /** + * @deprecated + * @override + */ bounds() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.bounds(...arguments); @@ -55,6 +76,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ getBounds() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.getBounds(); @@ -63,6 +87,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ setBounds() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.setBounds(...arguments); @@ -71,6 +98,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ tick() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.tick(...arguments); @@ -79,6 +109,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ clockOffsets() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.clockOffsets(...arguments); @@ -87,6 +120,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ getClockOffsets() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.getClockOffsets(); @@ -95,6 +131,9 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @override + */ setClockOffsets() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.setClockOffsets(...arguments); @@ -103,12 +142,24 @@ class IndependentTimeContext extends TimeContext { } } + /** + * + * @param {number} newTOI + * @returns {number} + */ timeOfInterest(newTOI) { return this.globalTimeContext.timeOfInterest(...arguments); } + /** + * + * @param {TimeSystem | string} timeSystemOrKey + * @param {TimeConductorBounds} bounds + * @returns {TimeSystem} + * @override + */ timeSystem(timeSystemOrKey, bounds) { - return this.globalTimeContext.timeSystem(...arguments); + return this.globalTimeContext.setTimeSystem(...arguments); } /** @@ -116,6 +167,7 @@ class IndependentTimeContext extends TimeContext { * @returns {TimeSystem} The currently applied time system * @memberof module:openmct.TimeAPI# * @method getTimeSystem + * @override */ getTimeSystem() { return this.globalTimeContext.getTimeSystem(); @@ -246,6 +298,7 @@ class IndependentTimeContext extends TimeContext { /** * Get the current mode. * @return {Mode} the current mode; + * @override */ getMode() { if (this.upstreamTimeContext) { @@ -259,9 +312,8 @@ class IndependentTimeContext extends TimeContext { * Set the mode to either fixed or realtime. * * @param {Mode} mode The mode to activate - * @param {TimeBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width - * @fires module:openmct.TimeAPI~clock - * @return {Mode} the currently active mode; + * @param {TimeConductorBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width + * @return {Mode | undefined} the currently active mode; */ setMode(mode, offsetsOrBounds) { if (!mode) { @@ -299,6 +351,10 @@ class IndependentTimeContext extends TimeContext { return this.mode; } + /** + * @returns {boolean} + * @override + */ isRealTime() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.isRealTime(...arguments); @@ -307,6 +363,10 @@ class IndependentTimeContext extends TimeContext { } } + /** + * @returns {number} + * @override + */ now() { if (this.upstreamTimeContext) { return this.upstreamTimeContext.now(...arguments); @@ -343,6 +403,9 @@ class IndependentTimeContext extends TimeContext { this.unlisteners = []; } + /** + * Reset the time context to the global time context + */ resetContext() { if (this.upstreamTimeContext) { this.stopFollowingTimeContext(); @@ -352,6 +415,7 @@ class IndependentTimeContext extends TimeContext { /** * Refresh the time context, following any upstream time contexts as necessary + * @param {string} [viewKey] The key of the view to refresh */ refreshContext(viewKey) { const key = this.openmct.objects.makeKeyString(this.objectPath[0].identifier); @@ -370,10 +434,17 @@ class IndependentTimeContext extends TimeContext { this.emit(TIME_CONTEXT_EVENTS.boundsChanged, this.getBounds()); } + /** + * @returns {boolean} True if this time context has an independent context, false otherwise + */ hasOwnContext() { return this.upstreamTimeContext === undefined; } + /** + * Get the upstream time context of this time context + * @returns {TimeAPI & GlobalTimeContext | undefined} The upstream time context + */ getUpstreamContext() { // If a view has an independent context, don't return an upstream context // Be aware that when a new independent time context is created, we assign the global context as default diff --git a/src/api/time/TimeAPI.js b/src/api/time/TimeAPI.js index 02cd19425c..b85bafc1ca 100644 --- a/src/api/time/TimeAPI.js +++ b/src/api/time/TimeAPI.js @@ -25,6 +25,41 @@ import IndependentTimeContext from '@/api/time/IndependentTimeContext'; import GlobalTimeContext from './GlobalTimeContext.js'; +/** + * @typedef {import('./TimeContext.js').default} TimeContext + */ + +/** + * @typedef {import('./TimeContext.js').TimeConductorBounds} TimeConductorBounds + */ + +/** + * @typedef {import('./TimeContext.js').ClockOffsets} ClockOffsets + */ + +/** + * A TimeSystem provides meaning to the values returned by the TimeAPI. Open + * MCT supports multiple different types of time values, although all are + * intrinsically represented by numbers, the meaning of those numbers can + * differ depending on context. + * + * A default time system is provided by Open MCT in the form of the {@link UTCTimeSystem}, + * which represents integer values as ms in the Unix epoch. An example of + * another time system might be "sols" for a Martian mission. TimeSystems do + * not address the issue of converting between time systems. + * + * @typedef {Object} TimeSystem + * @property {string} key A unique identifier + * @property {string} name A human-readable descriptor + * @property {string} [cssClass] Specify a css class defining an icon for + * this time system. This will be visible next to the time system in the + * menu in the Time Conductor + * @property {string} timeFormat The key of a format to use when displaying + * discrete timestamps from this time system + * @property {string} [durationFormat] The key of a format to use when + * displaying a duration or relative span of time in this time system. + */ + /** * 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 @@ -41,8 +76,8 @@ import GlobalTimeContext from './GlobalTimeContext.js'; * fired when properties of the time conductor change, which are documented * below. * - * @interface - * @memberof module:openmct + * @class + * @extends {GlobalTimeContext} */ class TimeAPI extends GlobalTimeContext { constructor(openmct) { @@ -51,33 +86,9 @@ class TimeAPI extends GlobalTimeContext { this.independentContexts = new Map(); } - /** - * A TimeSystem provides meaning to the values returned by the TimeAPI. Open - * MCT supports multiple different types of time values, although all are - * intrinsically represented by numbers, the meaning of those numbers can - * differ depending on context. - * - * A default time system is provided by Open MCT in the form of the {@link UTCTimeSystem}, - * which represents integer values as ms in the Unix epoch. An example of - * another time system might be "sols" for a Martian mission. TimeSystems do - * not address the issue of converting between time systems. - * - * @typedef {Object} TimeSystem - * @property {string} key A unique identifier - * @property {string} name A human-readable descriptor - * @property {string} [cssClass] Specify a css class defining an icon for - * this time system. This will be visible next to the time system in the - * menu in the Time Conductor - * @property {string} timeFormat The key of a format to use when displaying - * discrete timestamps from this time system - * @property {string} [durationFormat] The key of a format to use when - * displaying a duration or relative span of time in this time system. - */ - /** * Register a new time system. Once registered it can activated using * {@link TimeAPI.timeSystem}, and can be referenced via its key in [Time Conductor configuration](@link https://github.com/nasa/openmct/blob/master/API.md#time-conductor). - * @memberof module:openmct.TimeAPI# * @param {TimeSystem} timeSystem A time system object. */ addTimeSystem(timeSystem) { @@ -109,7 +120,6 @@ class TimeAPI extends GlobalTimeContext { /** * Register a new Clock. - * @memberof module:openmct.TimeAPI# * @param {Clock} clock */ addClock(clock) { @@ -117,9 +127,7 @@ class TimeAPI extends GlobalTimeContext { } /** - * @memberof module:openmct.TimeAPI# * @returns {Clock[]} - * @memberof module:openmct.TimeAPI# */ getAllClocks() { return Array.from(this.clocks.values()); @@ -128,11 +136,9 @@ class TimeAPI extends GlobalTimeContext { /** * Get or set an independent time context which follows the TimeAPI timeSystem, * but with different offsets for a given domain object - * @param {key | string} key The identifier key of the domain object these offsets are set for - * @param {ClockOffsets | TimeBounds} value This maintains a sliding time window of a fixed width that automatically updates + * @param {string} key The identifier key of the domain object these offsets are set for + * @param {ClockOffsets | TimeConductorBounds} value This maintains a sliding time window of a fixed width that automatically updates * @param {key | string} clockKey the real time clock key currently in use - * @memberof module:openmct.TimeAPI# - * @method addIndependentTimeContext */ addIndependentContext(key, value, clockKey) { let timeContext = this.getIndependentContext(key); @@ -159,9 +165,8 @@ class TimeAPI extends GlobalTimeContext { /** * Get the independent time context which follows the TimeAPI timeSystem, * but with different offsets. - * @param {key | string} key The identifier key of the domain object these offsets - * @memberof module:openmct.TimeAPI# - * @method getIndependentTimeContext + * @param {string} key The identifier key of the domain object these offsets + * @returns {IndependentTimeContext} The independent time context */ getIndependentContext(key) { return this.independentContexts.get(key); @@ -170,9 +175,8 @@ class TimeAPI extends GlobalTimeContext { /** * Get the a timeContext for a view based on it's objectPath. If there is any object in the objectPath with an independent time context, it will be returned. * Otherwise, the global time context will be returned. - * @param { Array } objectPath The view's objectPath - * @memberof module:openmct.TimeAPI# - * @method getContextForView + * @param {Array} objectPath The view's objectPath + * @returns {TimeContext | GlobalTimeContext} The time context */ getContextForView(objectPath) { if (!objectPath || !Array.isArray(objectPath)) { diff --git a/src/api/time/TimeContext.js b/src/api/time/TimeContext.js index ba85b41715..9fd5c84820 100644 --- a/src/api/time/TimeContext.js +++ b/src/api/time/TimeContext.js @@ -24,22 +24,85 @@ import EventEmitter from 'EventEmitter'; import { FIXED_MODE_KEY, MODES, REALTIME_MODE_KEY, TIME_CONTEXT_EVENTS } from './constants.js'; +/** + * @typedef {import('../../utils/clock/DefaultClock.js').default} Clock + */ + +/** + * @typedef {import('./TimeAPI.js').TimeSystem} TimeSystem + */ + +/** + * @typedef {Object} TimeConductorBounds + * @property {number } start The start time displayed by the time conductor + * in ms since epoch. Epoch determined by currently active time system + * @property {number} end The end time displayed by the time conductor in ms + * since epoch. + */ + +/** + * Clock offsets are used to calculate temporal bounds when the system is + * ticking on a clock source. + * + * @typedef {Object} ClockOffsets + * @property {number} start A time span relative to the current value of the + * ticking clock, from which start bounds will be calculated. This value must + * be < 0. When a clock is active, bounds will be calculated automatically + * based on the value provided by the clock, and the defined clock offsets. + * @property {number} end A time span relative to the current value of the + * ticking clock, from which end bounds will be calculated. This value must + * be >= 0. + */ + +/** + * @typedef {Object} ValidationResult + * @property {boolean} valid Result of the validation - true or false. + * @property {string} message An error message if valid is false. + */ + +/** + * @typedef {'fixed' | 'realtime'} Mode The time conductor mode. + */ + +/** + * @class TimeContext + * @extends EventEmitter + */ class TimeContext extends EventEmitter { constructor() { super(); - //The Time System + /** + * The time systems available to the TimeAPI. + * @type {Map} + */ this.timeSystems = new Map(); + /** + * The currently applied time system. + * @type {TimeSystem | undefined} + */ this.system = undefined; + /** + * The clocks available to the TimeAPI. + * @type {Map} + */ this.clocks = new Map(); + /** + * The current bounds of the time conductor. + * @type {TimeConductorBounds} + */ this.boundsVal = { start: undefined, end: undefined }; + /** + * The currently active clock. + * @type {Clock | undefined} + */ this.activeClock = undefined; this.offsets = undefined; this.mode = undefined; @@ -51,11 +114,9 @@ class TimeContext extends EventEmitter { /** * Get or set the time system of the TimeAPI. * @param {TimeSystem | string} timeSystemOrKey - * @param {module:openmct.TimeAPI~TimeConductorBounds} bounds - * @fires module:openmct.TimeAPI~timeSystem + * @param {TimeConductorBounds} bounds * @returns {TimeSystem} The currently applied time system - * @memberof module:openmct.TimeAPI# - * @method timeSystem + * @deprecated This method is deprecated. Use "getTimeSystem" and "setTimeSystem" instead. */ timeSystem(timeSystemOrKey, bounds) { this.#warnMethodDeprecated('"timeSystem"', '"getTimeSystem" and "setTimeSystem"'); @@ -101,11 +162,8 @@ class TimeContext extends EventEmitter { * The time system used by the time * conductor has changed. A change in Time System will always be * followed by a bounds event specifying new query bounds. - * - * @event module:openmct.TimeAPI~timeSystem - * @property {TimeSystem} The value of the currently applied - * Time System - * */ + * @type {TimeSystem} + */ const system = this.#copy(this.system); this.emit('timeSystem', system); this.emit(TIME_CONTEXT_EVENTS.timeSystemChanged, system); @@ -118,21 +176,11 @@ class TimeContext extends EventEmitter { return this.system; } - /** - * Clock offsets are used to calculate temporal bounds when the system is - * ticking on a clock source. - * - * @typedef {Object} ValidationResult - * @property {boolean} valid Result of the validation - true or false. - * @property {string} message An error message if valid is false. - */ /** * Validate the given bounds. This can be used for pre-validation of bounds, * for example by views validating user inputs. - * @param {TimeBounds} bounds The start and end time of the conductor. + * @param {TimeConductorBounds} bounds The start and end time of the conductor. * @returns {ValidationResult} A validation error, or true if valid - * @memberof module:openmct.TimeAPI# - * @method validateBounds */ validateBounds(bounds) { if ( @@ -162,12 +210,10 @@ class TimeContext extends EventEmitter { * Get or set the start and end time of the time conductor. Basic validation * of bounds is performed. * - * @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds + * @param {TimeConductorBounds} [newBounds] The new bounds to set. If not provided, current bounds will be returned. * @throws {Error} Validation error - * @fires module:openmct.TimeAPI~bounds - * @returns {module:openmct.TimeAPI~TimeConductorBounds} - * @memberof module:openmct.TimeAPI# - * @method bounds + * @returns {TimeConductorBounds} The current bounds of the time conductor. + * @deprecated This method is deprecated. Use "getBounds" and "setBounds" instead. */ bounds(newBounds) { this.#warnMethodDeprecated('"bounds"', '"getBounds" and "setBounds"'); @@ -183,7 +229,6 @@ class TimeContext extends EventEmitter { /** * The start time, end time, or both have been updated. * @event bounds - * @memberof module:openmct.TimeAPI~ * @property {TimeConductorBounds} bounds The newly updated bounds * @property {boolean} [tick] `true` if the bounds update was due to * a "tick" event (ie. was an automatic update), false otherwise. @@ -200,9 +245,7 @@ class TimeContext extends EventEmitter { * Validate the given offsets. This can be used for pre-validation of * offsets, for example by views validating user inputs. * @param {ClockOffsets} offsets The start and end offsets from a 'now' value. - * @returns { ValidationResult } A validation error, and true/false if valid or not - * @memberof module:openmct.TimeAPI# - * @method validateOffsets + * @returns {ValidationResult} A validation error, and true/false if valid or not */ validateOffsets(offsets) { if ( @@ -228,34 +271,13 @@ class TimeContext extends EventEmitter { }; } - /** - * @typedef {Object} TimeBounds - * @property {number} start The start time displayed by the time conductor - * in ms since epoch. Epoch determined by currently active time system - * @property {number} end The end time displayed by the time conductor in ms - * since epoch. - * @memberof module:openmct.TimeAPI~ - */ - - /** - * Clock offsets are used to calculate temporal bounds when the system is - * ticking on a clock source. - * - * @typedef {Object} ClockOffsets - * @property {number} start A time span relative to the current value of the - * ticking clock, from which start bounds will be calculated. This value must - * be < 0. When a clock is active, bounds will be calculated automatically - * based on the value provided by the clock, and the defined clock offsets. - * @property {number} end A time span relative to the current value of the - * ticking clock, from which end bounds will be calculated. This value must - * be >= 0. - */ /** * Get or set the currently applied clock offsets. If no parameter is provided, * the current value will be returned. If provided, the new value will be * used as the new clock offsets. - * @param {ClockOffsets} offsets - * @returns {ClockOffsets} + * @param {ClockOffsets} [offsets] The new clock offsets to set. If not provided, current offsets will be returned. + * @returns {ClockOffsets} The current clock offsets. + * @deprecated This method is deprecated. Use "getClockOffsets" and "setClockOffsets" instead. */ clockOffsets(offsets) { this.#warnMethodDeprecated('"clockOffsets"', '"getClockOffsets" and "setClockOffsets"'); @@ -293,6 +315,7 @@ class TimeContext extends EventEmitter { * Stop following the currently active clock. This will * revert all views to showing a static time frame defined by the current * bounds. + * @deprecated This method is deprecated. */ stopClock() { this.#warnMethodDeprecated('"stopClock"'); @@ -304,12 +327,14 @@ class TimeContext extends EventEmitter { * Set the active clock. Tick source will be immediately subscribed to * and ticking will begin. Offsets from 'now' must also be provided. * - * @param {Clock || string} keyOrClock The clock to activate, or its key + * @param {string|Clock} keyOrClock The clock to activate, or its key * @param {ClockOffsets} offsets on each tick these will be used to calculate * the start and end bounds. This maintains a sliding time window of a fixed * width that automatically updates. - * @fires module:openmct.TimeAPI~clock - * @return {Clock} the currently active clock; + * (Legacy) Emits a "clock" event with the new clock. + * Emits a "clockChanged" event with the new clock. + * @return {Clock|undefined} the currently active clock; undefined if in fixed mode + * @deprecated This method is deprecated. Use "getClock" and "setClock" instead. */ clock(keyOrClock, offsets) { this.#warnMethodDeprecated('"clock"', '"getClock" and "setClock"'); @@ -339,7 +364,6 @@ class TimeContext extends EventEmitter { /** * The active clock has changed. * @event clock - * @memberof module:openmct.TimeAPI~ * @property {Clock} clock The newly activated clock, or undefined * if the system is no longer following a clock source */ @@ -361,7 +385,7 @@ class TimeContext extends EventEmitter { } /** - * Update bounds based on provided time and current offsets + * Update bounds based on provided time and current offsets. * @param {number} timestamp A time from which bounds will be calculated * using current offsets. */ @@ -385,8 +409,6 @@ class TimeContext extends EventEmitter { /** * Get the timestamp of the current clock * @returns {number} current timestamp of current clock regardless of mode - * @memberof module:openmct.TimeAPI# - * @method now */ now() { @@ -396,8 +418,6 @@ class TimeContext extends EventEmitter { /** * Get the time system of the TimeAPI. * @returns {TimeSystem} The currently applied time system - * @memberof module:openmct.TimeAPI# - * @method getTimeSystem */ getTimeSystem() { return this.system; @@ -405,12 +425,9 @@ class TimeContext extends EventEmitter { /** * Set the time system of the TimeAPI. + * Emits a "timeSystem" event with the new time system. * @param {TimeSystem | string} timeSystemOrKey - * @param {module:openmct.TimeAPI~TimeConductorBounds} bounds - * @fires module:openmct.TimeAPI~timeSystem - * @returns {TimeSystem} The currently applied time system - * @memberof module:openmct.TimeAPI# - * @method setTimeSystem + * @param {TimeConductorBounds} bounds */ setTimeSystem(timeSystemOrKey, bounds) { if (timeSystemOrKey === undefined) { @@ -441,7 +458,6 @@ class TimeContext extends EventEmitter { * conductor has changed. A change in Time System will always be * followed by a bounds event specifying new query bounds. * - * @event module:openmct.TimeAPI~timeSystem * @property {TimeSystem} The value of the currently applied * Time System * */ @@ -456,9 +472,7 @@ class TimeContext extends EventEmitter { /** * Get the start and end time of the time conductor. Basic validation * of bounds is performed. - * @returns {module:openmct.TimeAPI~TimeConductorBounds} - * @memberof module:openmct.TimeAPI# - * @method bounds + * @returns {TimeConductorBounds} The current bounds of the time conductor. */ getBounds() { //Return a copy to prevent direct mutation of time conductor bounds. @@ -469,12 +483,8 @@ class TimeContext extends EventEmitter { * Set the start and end time of the time conductor. Basic validation * of bounds is performed. * - * @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds - * @throws {Error} Validation error - * @fires module:openmct.TimeAPI~bounds - * @returns {module:openmct.TimeAPI~TimeConductorBounds} - * @memberof module:openmct.TimeAPI# - * @method bounds + * @param {TimeConductorBounds} newBounds The new bounds to set. + * @throws {Error} Validation error if bounds are invalid */ setBounds(newBounds) { const validationResult = this.validateBounds(newBounds); @@ -487,7 +497,6 @@ class TimeContext extends EventEmitter { /** * The start time, end time, or both have been updated. * @event bounds - * @memberof module:openmct.TimeAPI~ * @property {TimeConductorBounds} bounds The newly updated bounds * @property {boolean} [tick] `true` if the bounds update was due to * a "tick" event (i.e. was an automatic update), false otherwise. @@ -498,7 +507,7 @@ class TimeContext extends EventEmitter { /** * Get the active clock. - * @return {Clock} the currently active clock; + * @return {Clock|undefined} the currently active clock; undefined if in fixed mode. */ getClock() { return this.activeClock; @@ -509,9 +518,7 @@ class TimeContext extends EventEmitter { * and the currently ticking will begin. * Offsets from 'now', if provided, will be used to set realtime mode offsets * - * @param {Clock || string} keyOrClock The clock to activate, or its key - * @fires module:openmct.TimeAPI~clock - * @return {Clock} the currently active clock; + * @param {string|Clock} keyOrClock The clock to activate, or its key */ setClock(keyOrClock) { let clock; @@ -540,7 +547,7 @@ class TimeContext extends EventEmitter { * The active clock has changed. * @event clock * @memberof module:openmct.TimeAPI~ - * @property {Clock} clock The newly activated clock, or undefined + * @property {TimeContext} clock The newly activated clock, or undefined * if the system is no longer following a clock source */ this.emit(TIME_CONTEXT_EVENTS.clockChanged, this.activeClock); @@ -549,7 +556,7 @@ class TimeContext extends EventEmitter { /** * Get the current mode. - * @return {Mode} the current mode; + * @return {Mode} the current mode */ getMode() { return this.mode; @@ -559,9 +566,9 @@ class TimeContext extends EventEmitter { * Set the mode to either fixed or realtime. * * @param {Mode} mode The mode to activate - * @param {TimeBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width + * @param {TimeConductorBounds|ClockOffsets} offsetsOrBounds A time window of a fixed width * @fires module:openmct.TimeAPI~clock - * @return {Mode} the currently active mode; + * @return {Mode | undefined} the currently active mode */ setMode(mode, offsetsOrBounds) { if (!mode) { @@ -577,7 +584,6 @@ class TimeContext extends EventEmitter { /** * The active mode has changed. * @event modeChanged - * @memberof module:openmct.TimeAPI~ * @property {Mode} mode The newly activated mode */ this.emit(TIME_CONTEXT_EVENTS.modeChanged, this.#copy(this.mode)); @@ -610,18 +616,15 @@ class TimeContext extends EventEmitter { /** * Get the currently applied clock offsets. - * @returns {ClockOffsets} + * @returns {ClockOffsets} The current clock offsets. */ getClockOffsets() { return this.offsets; } /** - * Set the currently applied clock offsets. If no parameter is provided, - * the current value will be returned. If provided, the new value will be - * used as the new clock offsets. - * @param {ClockOffsets} offsets - * @returns {ClockOffsets} + * Set the currently applied clock offsets. + * @param {ClockOffsets} offsets The new clock offsets to set. */ setClockOffsets(offsets) { const validationResult = this.validateOffsets(offsets); @@ -642,13 +645,20 @@ class TimeContext extends EventEmitter { /** * Event that is triggered when clock offsets change. * @event clockOffsets - * @memberof module:openmct.TimeAPI~ * @property {ClockOffsets} clockOffsets The newly activated clock * offsets. */ this.emit(TIME_CONTEXT_EVENTS.clockOffsetsChanged, this.#copy(offsets)); } + /** + * Prints a warning to the console when a deprecated method is used. Limits + * the number of times a warning is printed per unique method and newMethod + * combination. + * @param {string} method the deprecated method + * @param {string} [newMethod] the new method to use instead + * @returns + */ #warnMethodDeprecated(method, newMethod) { const MAX_CALLS = 1; // Only warn once per unique method and newMethod combination @@ -673,6 +683,11 @@ class TimeContext extends EventEmitter { console.warn(message); } + /** + * Deep copy an object. + * @param {object} object The object to copy + * @returns {object} The copied object + */ #copy(object) { return JSON.parse(JSON.stringify(object)); } diff --git a/src/plugins/LADTable/components/LadRow.vue b/src/plugins/LADTable/components/LadRow.vue index d6df918968..1936e49637 100644 --- a/src/plugins/LADTable/components/LadRow.vue +++ b/src/plugins/LADTable/components/LadRow.vue @@ -212,7 +212,7 @@ export default { this.openmct.time.on('timeSystem', this.updateTimeSystem); - this.timestampKey = this.openmct.time.timeSystem().key; + this.timestampKey = this.openmct.time.getTimeSystem().key; this.valueMetadata = undefined; diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index d065a4461b..7ada369b0f 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -253,7 +253,7 @@ export default { }; }, getOptions() { - const { start, end } = this.timeContext.bounds(); + const { start, end } = this.timeContext.getBounds(); return { end, @@ -372,13 +372,13 @@ export default { this.setTrace(key, telemetryObject.name, axisMetadata, xValues, yValues); }, isDataInTimeRange(datum, key, telemetryObject) { - const timeSystemKey = this.timeContext.timeSystem().key; + const timeSystemKey = this.timeContext.getTimeSystem().key; const metadata = this.openmct.telemetry.getMetadata(telemetryObject); let metadataValue = metadata.value(timeSystemKey) || { key: timeSystemKey }; let currentTimestamp = this.parse(key, metadataValue.key, datum); - return currentTimestamp && this.timeContext.bounds().end >= currentTimestamp; + return currentTimestamp && this.timeContext.getBounds().end >= currentTimestamp; }, format(telemetryObjectKey, metadataKey, data) { const formats = this.telemetryObjectFormats[telemetryObjectKey]; diff --git a/src/plugins/charts/scatter/ScatterPlotView.vue b/src/plugins/charts/scatter/ScatterPlotView.vue index 5431acf2f9..fe96cc9d63 100644 --- a/src/plugins/charts/scatter/ScatterPlotView.vue +++ b/src/plugins/charts/scatter/ScatterPlotView.vue @@ -306,7 +306,7 @@ export default { this.trace = [trace]; }, getTimestampForDatum(datum, key, telemetryObject) { - const timeSystemKey = this.timeContext.timeSystem().key; + const timeSystemKey = this.timeContext.getTimeSystem().key; const metadata = this.openmct.telemetry.getMetadata(telemetryObject); let metadataValue = metadata.value(timeSystemKey) || { format: timeSystemKey }; @@ -327,7 +327,7 @@ export default { return formats[metadataKey].parse(datum); }, getOptions() { - const { start, end } = this.timeContext.bounds(); + const { start, end } = this.timeContext.getBounds(); return { end, diff --git a/src/plugins/condition/Condition.js b/src/plugins/condition/Condition.js index 3b4999fe6b..81e7f22614 100644 --- a/src/plugins/condition/Condition.js +++ b/src/plugins/condition/Condition.js @@ -245,7 +245,7 @@ export default class Condition extends EventEmitter { latestTimestamp, updatedCriterion.data, this.timeSystems, - this.openmct.time.timeSystem() + this.openmct.time.getTimeSystem() ); this.conditionManager.updateCurrentCondition(latestTimestamp); } @@ -309,7 +309,7 @@ export default class Condition extends EventEmitter { latestTimestamp, data, this.timeSystems, - this.openmct.time.timeSystem() + this.openmct.time.getTimeSystem() ); }); diff --git a/src/plugins/condition/ConditionManager.js b/src/plugins/condition/ConditionManager.js index be51360300..7d10dee642 100644 --- a/src/plugins/condition/ConditionManager.js +++ b/src/plugins/condition/ConditionManager.js @@ -113,7 +113,7 @@ export default class ConditionManager extends EventEmitter { {}, {}, this.timeSystems, - this.openmct.time.timeSystem() + this.openmct.time.getTimeSystem() ); this.updateConditionResults({ id: id }); this.updateCurrentCondition(latestTimestamp); @@ -383,7 +383,7 @@ export default class ConditionManager extends EventEmitter { latestTimestamp, data, this.timeSystems, - this.openmct.time.timeSystem() + this.openmct.time.getTimeSystem() ); }); diff --git a/src/plugins/condition/criterion/AllTelemetryCriterion.js b/src/plugins/condition/criterion/AllTelemetryCriterion.js index 5e8573ea7e..3dc497dd07 100644 --- a/src/plugins/condition/criterion/AllTelemetryCriterion.js +++ b/src/plugins/condition/criterion/AllTelemetryCriterion.js @@ -227,7 +227,7 @@ export default class AllTelemetryCriterion extends TelemetryCriterion { return Promise.all(telemetryRequests).then((telemetryRequestsResults) => { let latestTimestamp; const timeSystems = this.openmct.time.getAllTimeSystems(); - const timeSystem = this.openmct.time.timeSystem(); + const timeSystem = this.openmct.time.getTimeSystem(); telemetryRequestsResults.forEach((results, index) => { const latestDatum = diff --git a/src/plugins/displayLayout/components/TelemetryView.vue b/src/plugins/displayLayout/components/TelemetryView.vue index 3a65ae0cdb..bc75d29e99 100644 --- a/src/plugins/displayLayout/components/TelemetryView.vue +++ b/src/plugins/displayLayout/components/TelemetryView.vue @@ -280,7 +280,7 @@ export default { await this.$nextTick(); }, formattedValueForCopy() { - const timeFormatterKey = this.openmct.time.timeSystem().key; + const timeFormatterKey = this.openmct.time.getTimeSystem().key; const timeFormatter = this.formats[timeFormatterKey]; const unit = this.unit ? ` ${this.unit}` : ''; diff --git a/src/plugins/gauge/components/GaugeComponent.vue b/src/plugins/gauge/components/GaugeComponent.vue index 4d00a05af9..5486b0eed3 100644 --- a/src/plugins/gauge/components/GaugeComponent.vue +++ b/src/plugins/gauge/components/GaugeComponent.vue @@ -363,7 +363,7 @@ export default { rangeLow: gaugeController.min, gaugeType: gaugeController.gaugeType, showUnits: gaugeController.showUnits, - activeTimeSystem: this.openmct.time.timeSystem(), + activeTimeSystem: this.openmct.time.getTimeSystem(), units: '' }; }, @@ -726,7 +726,7 @@ export default { return; } - const { start, end } = this.openmct.time.bounds(); + const { start, end } = this.openmct.time.getBounds(); const parsedValue = this.timeFormatter.parse(this.datum); const beforeStartOfBounds = parsedValue < start; diff --git a/src/plugins/imagery/components/ImageryTimeView.vue b/src/plugins/imagery/components/ImageryTimeView.vue index f3fe87249d..04cd172a98 100644 --- a/src/plugins/imagery/components/ImageryTimeView.vue +++ b/src/plugins/imagery/components/ImageryTimeView.vue @@ -49,7 +49,7 @@ export default { mixins: [imageryData], inject: ['openmct', 'domainObject', 'objectPath'], data() { - let timeSystem = this.openmct.time.timeSystem(); + let timeSystem = this.openmct.time.getTimeSystem(); this.metadata = {}; this.requestCount = 0; @@ -148,10 +148,10 @@ export default { return clientWidth; }, updateViewBounds(bounds, isTick) { - this.viewBounds = this.timeContext.bounds(); + this.viewBounds = this.timeContext.getBounds(); if (this.timeSystem === undefined) { - this.timeSystem = this.timeContext.timeSystem(); + this.timeSystem = this.timeContext.getTimeSystem(); } this.setScaleAndPlotImagery(this.timeSystem, !isTick); @@ -216,7 +216,7 @@ export default { } if (timeSystem === undefined) { - timeSystem = this.timeContext.timeSystem(); + timeSystem = this.timeContext.getTimeSystem(); } if (timeSystem.isUTCBased) { diff --git a/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js b/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js index ccba3b59b5..cbc9f3e8a9 100644 --- a/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js +++ b/src/plugins/imagery/components/RelatedTelemetry/RelatedTelemetry.js @@ -44,7 +44,7 @@ export default class RelatedTelemetry { this.keys = telemetryKeys; this._timeFormatter = undefined; - this._timeSystemChange(this.timeContext.timeSystem()); + this._timeSystemChange(this.timeContext.getTimeSystem()); // grab related telemetry metadata for (let key of this.keys) { @@ -110,10 +110,10 @@ export default class RelatedTelemetry { // and set bounds. ephemeralContext.resetContext(); const newBounds = { - start: this.timeContext.bounds().start, + start: this.timeContext.getBounds().start, end: this._parseTime(datum) }; - ephemeralContext.bounds(newBounds); + ephemeralContext.setBounds(newBounds); const options = { start: newBounds.start, diff --git a/src/plugins/imagery/mixins/imageryData.js b/src/plugins/imagery/mixins/imageryData.js index 0242b66748..804d06f4e3 100644 --- a/src/plugins/imagery/mixins/imageryData.js +++ b/src/plugins/imagery/mixins/imageryData.js @@ -171,7 +171,7 @@ export default { this.bounds = bounds; // setting bounds for ImageryView watcher }, timeSystemChanged() { - this.timeSystem = this.timeContext.timeSystem(); + this.timeSystem = this.timeContext.getTimeSystem(); this.timeKey = this.timeSystem.key; this.timeFormatter = this.getFormatter(this.timeKey); this.durationFormatter = this.getFormatter( diff --git a/src/plugins/localTimeSystem/pluginSpec.js b/src/plugins/localTimeSystem/pluginSpec.js index af27504d55..33ccbff6cf 100644 --- a/src/plugins/localTimeSystem/pluginSpec.js +++ b/src/plugins/localTimeSystem/pluginSpec.js @@ -61,7 +61,7 @@ describe('The local time', () => { }); it('can be set to be the main time system', () => { - expect(openmct.time.timeSystem().key).toBe(LOCAL_SYSTEM_KEY); + expect(openmct.time.getTimeSystem().key).toBe(LOCAL_SYSTEM_KEY); }); it('uses the local-format time format', () => { diff --git a/src/plugins/notebook/components/NotebookComponent.vue b/src/plugins/notebook/components/NotebookComponent.vue index 4c2d7a4c02..37e7e4d102 100644 --- a/src/plugins/notebook/components/NotebookComponent.vue +++ b/src/plugins/notebook/components/NotebookComponent.vue @@ -680,7 +680,7 @@ export default { } else if (domainObjectData) { // plain domain object const objectPath = JSON.parse(domainObjectData); - const bounds = this.openmct.time.bounds(); + const bounds = this.openmct.time.getBounds(); const snapshotMeta = { bounds, link: null, diff --git a/src/plugins/notebook/components/NotebookEmbed.vue b/src/plugins/notebook/components/NotebookEmbed.vue index 696d628db2..a651750e1d 100644 --- a/src/plugins/notebook/components/NotebookEmbed.vue +++ b/src/plugins/notebook/components/NotebookEmbed.vue @@ -275,7 +275,7 @@ export default { } const hash = this.embed.historicLink; - const bounds = this.openmct.time.bounds(); + const bounds = this.openmct.time.getBounds(); const isTimeBoundChanged = this.embed.bounds.start !== bounds.start || this.embed.bounds.end !== bounds.end; const isFixedTimespanMode = !this.openmct.time.clock(); diff --git a/src/plugins/notebook/components/NotebookEntry.vue b/src/plugins/notebook/components/NotebookEntry.vue index 9e43528d46..b3bba5d45d 100644 --- a/src/plugins/notebook/components/NotebookEntry.vue +++ b/src/plugins/notebook/components/NotebookEntry.vue @@ -369,7 +369,7 @@ export default { }, methods: { async addNewEmbed(objectPath) { - const bounds = this.openmct.time.bounds(); + const bounds = this.openmct.time.getBounds(); const snapshotMeta = { bounds, link: null, diff --git a/src/plugins/notebook/components/NotebookMenuSwitcher.vue b/src/plugins/notebook/components/NotebookMenuSwitcher.vue index aaa7cbe57b..bfa349543f 100644 --- a/src/plugins/notebook/components/NotebookMenuSwitcher.vue +++ b/src/plugins/notebook/components/NotebookMenuSwitcher.vue @@ -123,7 +123,7 @@ export default { const objectPath = this.objectPath || this.openmct.router.path; const link = this.isPreview ? this.getPreviewObjectLink() : window.location.hash; const snapshotMeta = { - bounds: this.openmct.time.bounds(), + bounds: this.openmct.time.getBounds(), link, objectPath, openmct: this.openmct diff --git a/src/plugins/notebook/utils/notebook-entries.js b/src/plugins/notebook/utils/notebook-entries.js index 093af45f49..ea7d9d7639 100644 --- a/src/plugins/notebook/utils/notebook-entries.js +++ b/src/plugins/notebook/utils/notebook-entries.js @@ -140,7 +140,7 @@ export function createNewImageEmbed(image, openmct, imageName = '') { }; const embedMetaData = { - bounds: openmct.time.bounds(), + bounds: openmct.time.getBounds(), link: null, objectPath: null, openmct, diff --git a/src/plugins/plan/components/PlanView.vue b/src/plugins/plan/components/PlanView.vue index 7bd2550827..4ddec85f13 100644 --- a/src/plugins/plan/components/PlanView.vue +++ b/src/plugins/plan/components/PlanView.vue @@ -196,7 +196,7 @@ export default { this.followTimeContext(); }, followTimeContext() { - this.updateViewBounds(this.timeContext.bounds()); + this.updateViewBounds(this.timeContext.getBounds()); this.timeContext.on('timeSystem', this.setScaleAndGenerateActivities); this.timeContext.on('bounds', this.updateViewBounds); @@ -319,7 +319,7 @@ export default { } if (this.timeSystem === null) { - this.timeSystem = this.openmct.time.timeSystem(); + this.timeSystem = this.openmct.time.getTimeSystem(); } this.setScaleAndGenerateActivities(); @@ -344,7 +344,7 @@ export default { } if (!timeSystem) { - timeSystem = this.openmct.time.timeSystem(); + timeSystem = this.openmct.time.getTimeSystem(); } if (timeSystem.isUTCBased) { diff --git a/src/plugins/plan/inspector/components/PlanActivitiesView.vue b/src/plugins/plan/inspector/components/PlanActivitiesView.vue index 22c473da0e..13e98e41a8 100644 --- a/src/plugins/plan/inspector/components/PlanActivitiesView.vue +++ b/src/plugins/plan/inspector/components/PlanActivitiesView.vue @@ -116,7 +116,7 @@ export default { } }, setFormatters() { - let timeSystem = this.openmct.time.timeSystem(); + let timeSystem = this.openmct.time.getTimeSystem(); this.timeFormatter = this.openmct.telemetry.getValueFormatter({ format: timeSystem.timeFormat }).formatter; diff --git a/src/plugins/plot/MctPlot.vue b/src/plugins/plot/MctPlot.vue index a09abaa35d..cd4aca2ad9 100644 --- a/src/plugins/plot/MctPlot.vue +++ b/src/plugins/plot/MctPlot.vue @@ -661,7 +661,7 @@ export default { this.offsetWidth = this.$parent.$refs.plotWrapper.offsetWidth; this.startLoading(); - const bounds = this.timeContext.bounds(); + const bounds = this.timeContext.getBounds(); const options = { size: this.$parent.$refs.plotWrapper.offsetWidth, domain: this.config.xAxis.get('key'), diff --git a/src/plugins/plot/chart/MctChart.vue b/src/plugins/plot/chart/MctChart.vue index 3af51ac03c..c92cc18596 100644 --- a/src/plugins/plot/chart/MctChart.vue +++ b/src/plugins/plot/chart/MctChart.vue @@ -614,7 +614,7 @@ export default { const yAxisId = series.get('yAxisId') || mainYAxisId; let offset = this.offset[yAxisId]; - return new MCTChartAlarmLineSet(series, this, offset, this.openmct.time.bounds()); + return new MCTChartAlarmLineSet(series, this, offset, this.openmct.time.getBounds()); }, pointSetForSeries(series) { const mainYAxisId = this.config.yAxis.get('id'); diff --git a/src/plugins/plot/configuration/XAxisModel.js b/src/plugins/plot/configuration/XAxisModel.js index ff1b2b088b..183da855f9 100644 --- a/src/plugins/plot/configuration/XAxisModel.js +++ b/src/plugins/plot/configuration/XAxisModel.js @@ -93,7 +93,7 @@ export default class XAxisModel extends Model { * @override */ defaultModel(options) { - const bounds = options.openmct.time.bounds(); + const bounds = options.openmct.time.getBounds(); const timeSystem = options.openmct.time.getTimeSystem(); const format = options.openmct.telemetry.getFormatter(timeSystem.timeFormat); diff --git a/src/plugins/remoteClock/RemoteClock.js b/src/plugins/remoteClock/RemoteClock.js index db50e4b2e2..b97ae8d027 100644 --- a/src/plugins/remoteClock/RemoteClock.js +++ b/src/plugins/remoteClock/RemoteClock.js @@ -134,7 +134,7 @@ export default class RemoteClock extends DefaultClock { * @private */ _timeSystemChange() { - let timeSystem = this.openmct.time.timeSystem(); + let timeSystem = this.openmct.time.getTimeSystem(); let timeKey = timeSystem.key; let metadataValue = this.metadata.value(timeKey); let timeFormatter = this.openmct.telemetry.getValueFormatter(metadataValue); @@ -149,13 +149,11 @@ export default class RemoteClock extends DefaultClock { /** * Waits for the clock to have a non-default tick value. - * - * @private */ #waitForReady() { const waitForInitialTick = (resolve) => { if (this.lastTick > 0) { - const offsets = this.openmct.time.clockOffsets(); + const offsets = this.openmct.time.getClockOffsets(); resolve({ start: this.lastTick + offsets.start, end: this.lastTick + offsets.end diff --git a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js index 0e61202f67..239753034f 100644 --- a/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js +++ b/src/plugins/summaryWidget/src/telemetry/SummaryWidgetEvaluator.js @@ -62,7 +62,7 @@ SummaryWidgetEvaluator.prototype.subscribe = function (callback) { } const updateCallback = function () { - const datum = this.evaluateState(realtimeStates, this.openmct.time.timeSystem().key); + const datum = this.evaluateState(realtimeStates, this.openmct.time.getTimeSystem().key); if (datum) { callback(datum); } diff --git a/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js b/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js index d5ceff97ed..6e3936b049 100644 --- a/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js +++ b/src/plugins/telemetryMean/src/MeanTelemetryProviderSpec.js @@ -611,11 +611,11 @@ describe('The Mean Telemetry Provider', function () { } function createMockTimeApi() { - return jasmine.createSpyObj('timeApi', ['timeSystem']); + return jasmine.createSpyObj('timeApi', ['getTimeSystem', 'setTimeSystem']); } function setTimeSystemTo(timeSystemKey) { - mockApi.time.timeSystem.and.returnValue({ + mockApi.time.getTimeSystem.and.returnValue({ key: timeSystemKey }); } diff --git a/src/plugins/telemetryMean/src/TelemetryAverager.js b/src/plugins/telemetryMean/src/TelemetryAverager.js index 5274819b18..486c24ec2f 100644 --- a/src/plugins/telemetryMean/src/TelemetryAverager.js +++ b/src/plugins/telemetryMean/src/TelemetryAverager.js @@ -92,7 +92,7 @@ TelemetryAverager.prototype.calculateMean = function () { * @private */ TelemetryAverager.prototype.setDomainKeyAndFormatter = function () { - const domainKey = this.timeAPI.timeSystem().key; + const domainKey = this.timeAPI.getTimeSystem().key; if (domainKey !== this.domainKey) { this.domainKey = domainKey; this.domainFormatter = this.getFormatter(domainKey); diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index 3d4d91ae92..766b4e9e57 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -134,7 +134,7 @@ export default class TelemetryTable extends EventEmitter { //If no persisted sort order, default to sorting by time system, descending. sortOptions = sortOptions || { - key: this.openmct.time.timeSystem().key, + key: this.openmct.time.getTimeSystem().key, direction: 'desc' }; diff --git a/src/plugins/timeConductor/ConductorPopUp.vue b/src/plugins/timeConductor/ConductorPopUp.vue index e6a6b8ce97..739db4be77 100644 --- a/src/plugins/timeConductor/ConductorPopUp.vue +++ b/src/plugins/timeConductor/ConductorPopUp.vue @@ -141,7 +141,6 @@ export default { data() { const bounds = this.openmct.time.getBounds(); const timeSystem = this.openmct.time.getTimeSystem(); - // const isFixed = this.openmct.time.isFixed(); return { timeSystem, diff --git a/src/plugins/timeline/TimelineViewLayout.vue b/src/plugins/timeline/TimelineViewLayout.vue index a7500bd543..1f51ab464a 100644 --- a/src/plugins/timeline/TimelineViewLayout.vue +++ b/src/plugins/timeline/TimelineViewLayout.vue @@ -173,16 +173,16 @@ export default { }); }, getBoundsForTimeSystem(timeSystem) { - const currentBounds = this.timeContext.bounds(); + const currentBounds = this.timeContext.getBounds(); //TODO: Some kind of translation via an offset? of current bounds to target timeSystem return currentBounds; }, updateViewBounds() { - const bounds = this.timeContext.bounds(); + const bounds = this.timeContext.getBounds(); this.updateContentHeight(); let currentTimeSystemIndex = this.timeSystems.findIndex( - (item) => item.timeSystem.key === this.openmct.time.timeSystem().key + (item) => item.timeSystem.key === this.openmct.time.getTimeSystem().key ); if (currentTimeSystemIndex > -1) { let currentTimeSystem = { diff --git a/src/plugins/timelist/TimelistComponent.vue b/src/plugins/timelist/TimelistComponent.vue index ac0d8adef5..400920a7b3 100644 --- a/src/plugins/timelist/TimelistComponent.vue +++ b/src/plugins/timelist/TimelistComponent.vue @@ -97,7 +97,7 @@ const headerItems = [ property: 'start', name: 'Start Time', format: function (value, object, key, openmct, options = {}) { - const timeFormat = openmct.time.timeSystem().timeFormat; + const timeFormat = openmct.time.getTimeSystem().timeFormat; const timeFormatter = openmct.telemetry.getValueFormatter({ format: timeFormat }).formatter; if (options.skipDateForToday) { return timeFormatter.format(value, SAME_DAY_PRECISION_SECONDS); @@ -112,7 +112,7 @@ const headerItems = [ property: 'end', name: 'End Time', format: function (value, object, key, openmct, options = {}) { - const timeFormat = openmct.time.timeSystem().timeFormat; + const timeFormat = openmct.time.getTimeSystem().timeFormat; const timeFormatter = openmct.telemetry.getValueFormatter({ format: timeFormat }).formatter; if (options.skipDateForToday) { return timeFormatter.format(value, SAME_DAY_PRECISION_SECONDS); @@ -425,14 +425,14 @@ export default { }, isActivityInBounds(activity) { const startInBounds = - activity.start >= this.timeContext.bounds()?.start && - activity.start <= this.timeContext.bounds()?.end; + activity.start >= this.timeContext.getBounds()?.start && + activity.start <= this.timeContext.getBounds()?.end; const endInBounds = - activity.end >= this.timeContext.bounds()?.start && - activity.end <= this.timeContext.bounds()?.end; + activity.end >= this.timeContext.getBounds()?.start && + activity.end <= this.timeContext.getBounds()?.end; const middleInBounds = - activity.start <= this.timeContext.bounds()?.start && - activity.end >= this.timeContext.bounds()?.end; + activity.start <= this.timeContext.getBounds()?.start && + activity.end >= this.timeContext.getBounds()?.end; return startInBounds || endInBounds || middleInBounds; }, diff --git a/src/utils/staleness.js b/src/utils/staleness.js index 7527a6b62c..06c3b17734 100644 --- a/src/utils/staleness.js +++ b/src/utils/staleness.js @@ -33,7 +33,7 @@ export default class StalenessUtils { shouldUpdateStaleness(stalenessResponse, id) { const stalenessResponseTime = this.parseTime(stalenessResponse); - const { start } = this.openmct.time.bounds(); + const { start } = this.openmct.time.getBounds(); const isStalenessInCurrentClock = stalenessResponseTime > start; if (stalenessResponseTime > this.lastStalenessResponseTime && isStalenessInCurrentClock) {