Compare commits
7 Commits
remove-dep
...
update-wor
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
088c563efc | ||
|
|
e2e76ce989 | ||
|
|
662630586d | ||
|
|
83301a3d71 | ||
|
|
833a3cf075 | ||
|
|
2d98260864 | ||
|
|
aa5b93aaa8 |
@@ -129,8 +129,6 @@ const config = {
|
||||
'array-callback-return': 'error',
|
||||
// https://eslint.org/docs/rules/no-invalid-this
|
||||
'no-invalid-this': 'error', // Believe this one actually surfaces some bugs
|
||||
// https://eslint.org/docs/rules/func-style
|
||||
'func-style': ['error', 'declaration'],
|
||||
// https://eslint.org/docs/rules/no-unused-expressions
|
||||
'no-unused-expressions': 'error',
|
||||
// https://eslint.org/docs/rules/no-useless-concat
|
||||
|
||||
@@ -45,9 +45,6 @@ const config = {
|
||||
},
|
||||
entry: {
|
||||
openmct: './openmct.js',
|
||||
generatorWorker: './example/generator/generatorWorker.js',
|
||||
couchDBChangesFeed: './src/plugins/persistence/couch/CouchChangesFeed.js',
|
||||
inMemorySearchWorker: './src/api/objects/InMemorySearchWorker.js',
|
||||
espressoTheme: './src/plugins/themes/espresso-theme.scss',
|
||||
snowTheme: './src/plugins/themes/snow-theme.scss'
|
||||
},
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
export default function WorkerInterface(openmct, StalenessProvider) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const workerUrl = `${openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}generatorWorker.js`;
|
||||
this.StalenessProvider = StalenessProvider;
|
||||
this.worker = new Worker(workerUrl);
|
||||
this.worker = new Worker(
|
||||
/* webpackChunkName: "generatorWorker" */ new URL('./generatorWorker.js', import.meta.url)
|
||||
);
|
||||
this.worker.onmessage = this.onMessage.bind(this);
|
||||
this.callbacks = {};
|
||||
this.staleTelemetryIds = {};
|
||||
|
||||
@@ -20,29 +20,24 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
(function () {
|
||||
var FIFTEEN_MINUTES = 15 * 60 * 1000;
|
||||
(() => {
|
||||
const FIFTEEN_MINUTES = 15 * 60 * 1000;
|
||||
|
||||
var handlers = {
|
||||
const handlers = {
|
||||
subscribe: onSubscribe,
|
||||
unsubscribe: onUnsubscribe,
|
||||
request: onRequest
|
||||
};
|
||||
|
||||
var subscriptions = {};
|
||||
const subscriptions = new Map();
|
||||
|
||||
function workSubscriptions(timestamp) {
|
||||
var now = Date.now();
|
||||
var nextWork = Math.min.apply(
|
||||
Math,
|
||||
Object.values(subscriptions).map(function (subscription) {
|
||||
return subscription(now);
|
||||
})
|
||||
const now = Date.now();
|
||||
const nextWork = Math.min(
|
||||
...Array.from(subscriptions.values()).map((subscription) => subscription(now))
|
||||
);
|
||||
var wait = nextWork - now;
|
||||
if (wait < 0) {
|
||||
wait = 0;
|
||||
}
|
||||
let wait = nextWork - now;
|
||||
wait = wait < 0 ? 0 : wait;
|
||||
|
||||
if (Number.isFinite(wait)) {
|
||||
setTimeout(workSubscriptions, wait);
|
||||
@@ -50,19 +45,18 @@
|
||||
}
|
||||
|
||||
function onSubscribe(message) {
|
||||
var data = message.data;
|
||||
const { data } = message;
|
||||
|
||||
// Keep
|
||||
var start = Date.now();
|
||||
var step = 1000 / data.dataRateInHz;
|
||||
var nextStep = start - (start % step) + step;
|
||||
const start = Date.now();
|
||||
const step = 1000 / data.dataRateInHz;
|
||||
let nextStep = start - (start % step) + step;
|
||||
let work;
|
||||
if (data.spectra) {
|
||||
work = function (now) {
|
||||
work = (now) => {
|
||||
while (nextStep < now) {
|
||||
const messageCopy = Object.create(message);
|
||||
message.data.start = nextStep - 60 * 1000;
|
||||
message.data.end = nextStep;
|
||||
const messageCopy = { ...message };
|
||||
messageCopy.data.start = nextStep - 60 * 1000;
|
||||
messageCopy.data.end = nextStep;
|
||||
onRequest(messageCopy);
|
||||
nextStep += step;
|
||||
}
|
||||
@@ -70,7 +64,7 @@
|
||||
return nextStep;
|
||||
};
|
||||
} else {
|
||||
work = function (now) {
|
||||
work = (now) => {
|
||||
while (nextStep < now) {
|
||||
self.postMessage({
|
||||
id: message.id,
|
||||
@@ -78,28 +72,10 @@
|
||||
name: data.name,
|
||||
utc: nextStep,
|
||||
yesterday: nextStep - 60 * 60 * 24 * 1000,
|
||||
sin: sin(
|
||||
nextStep,
|
||||
data.period,
|
||||
data.amplitude,
|
||||
data.offset,
|
||||
data.phase,
|
||||
data.randomness,
|
||||
data.infinityValues,
|
||||
data.exceedFloat32
|
||||
),
|
||||
sin: sin(nextStep, data),
|
||||
wavelengths: wavelengths(),
|
||||
intensities: intensities(),
|
||||
cos: cos(
|
||||
nextStep,
|
||||
data.period,
|
||||
data.amplitude,
|
||||
data.offset,
|
||||
data.phase,
|
||||
data.randomness,
|
||||
data.infinityValues,
|
||||
data.exceedFloat32
|
||||
)
|
||||
cos: cos(nextStep, data)
|
||||
}
|
||||
});
|
||||
nextStep += step;
|
||||
@@ -109,47 +85,36 @@
|
||||
};
|
||||
}
|
||||
|
||||
subscriptions[message.id] = work;
|
||||
subscriptions.set(message.id, work);
|
||||
workSubscriptions();
|
||||
}
|
||||
|
||||
function onUnsubscribe(message) {
|
||||
delete subscriptions[message.data.id];
|
||||
subscriptions.delete(message.data.id);
|
||||
}
|
||||
|
||||
function onRequest(message) {
|
||||
var request = message.data;
|
||||
if (request.end === undefined) {
|
||||
request.end = Date.now();
|
||||
}
|
||||
const request = message.data;
|
||||
request.end = request.end ?? Date.now();
|
||||
request.start = request.start ?? request.end - FIFTEEN_MINUTES;
|
||||
|
||||
if (request.start === undefined) {
|
||||
request.start = request.end - FIFTEEN_MINUTES;
|
||||
}
|
||||
const now = Date.now();
|
||||
const { start, end: requestEnd, period, dataRateInHz, loadDelay = 0, size } = request;
|
||||
const end = requestEnd > now ? now : requestEnd;
|
||||
const duration = end - start;
|
||||
const step = 1000 / dataRateInHz;
|
||||
const maxPoints = Math.floor(duration / step);
|
||||
let nextStep = start - (start % step) + step;
|
||||
|
||||
var now = Date.now();
|
||||
var start = request.start;
|
||||
var end = request.end > now ? now : request.end;
|
||||
var period = request.period;
|
||||
var dataRateInHz = request.dataRateInHz;
|
||||
var loadDelay = Math.max(request.loadDelay, 0);
|
||||
var size = request.size;
|
||||
var duration = end - start;
|
||||
var step = 1000 / dataRateInHz;
|
||||
var maxPoints = Math.floor(duration / step);
|
||||
var nextStep = start - (start % step) + step;
|
||||
|
||||
var data = [];
|
||||
let data = [];
|
||||
|
||||
if (request.strategy === 'minmax' && size) {
|
||||
// Calculate the number of cycles to include based on size (2 points per cycle)
|
||||
var totalCycles = Math.min(Math.floor(size / 2), Math.floor(duration / period));
|
||||
const totalCycles = Math.min(Math.floor(size / 2), Math.floor(duration / period));
|
||||
|
||||
for (let cycle = 0; cycle < totalCycles; cycle++) {
|
||||
// Distribute cycles evenly across the time range
|
||||
let cycleStart = start + (duration / totalCycles) * cycle;
|
||||
let minPointTime = cycleStart; // Assuming min at the start of the cycle
|
||||
let maxPointTime = cycleStart + period / 2; // Assuming max at the halfway of the cycle
|
||||
let minPointTime = cycleStart;
|
||||
let maxPointTime = cycleStart + period / 2;
|
||||
|
||||
data.push(createDataPoint(minPointTime, request), createDataPoint(maxPointTime, request));
|
||||
}
|
||||
@@ -174,28 +139,10 @@
|
||||
return {
|
||||
utc: time,
|
||||
yesterday: time - 60 * 60 * 24 * 1000,
|
||||
sin: sin(
|
||||
time,
|
||||
request.period,
|
||||
request.amplitude,
|
||||
request.offset,
|
||||
request.phase,
|
||||
request.randomness,
|
||||
request.infinityValues,
|
||||
request.exceedFloat32
|
||||
),
|
||||
sin: sin(time, request),
|
||||
wavelengths: wavelengths(),
|
||||
intensities: intensities(),
|
||||
cos: cos(
|
||||
time,
|
||||
request.period,
|
||||
request.amplitude,
|
||||
request.offset,
|
||||
request.phase,
|
||||
request.randomness,
|
||||
request.infinityValues,
|
||||
request.exceedFloat32
|
||||
)
|
||||
cos: cos(time, request)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -204,12 +151,8 @@
|
||||
id: message.id,
|
||||
data: request.spectra
|
||||
? {
|
||||
wavelength: data.map((item) => {
|
||||
return item.wavelength;
|
||||
}),
|
||||
cos: data.map((item) => {
|
||||
return item.cos;
|
||||
})
|
||||
wavelength: data.map((item) => item.wavelength),
|
||||
cos: data.map((item) => item.cos)
|
||||
}
|
||||
: data
|
||||
});
|
||||
@@ -217,42 +160,38 @@
|
||||
|
||||
function cos(
|
||||
timestamp,
|
||||
period,
|
||||
amplitude,
|
||||
offset,
|
||||
phase,
|
||||
randomness,
|
||||
infinityValues,
|
||||
exceedFloat32
|
||||
{ period, amplitude, offset, phase, randomness, infinityValues, exceedFloat32 }
|
||||
) {
|
||||
if (infinityValues && exceedFloat32) {
|
||||
if (Math.random() > 0.5) {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else if (Math.random() < 0.01) {
|
||||
return getRandomFloat32OverflowValue();
|
||||
}
|
||||
} else if (infinityValues && Math.random() > 0.5) {
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else if (exceedFloat32 && Math.random() < 0.01) {
|
||||
return getRandomFloat32OverflowValue();
|
||||
}
|
||||
|
||||
return (
|
||||
amplitude * Math.cos(phase + (timestamp / period / 1000) * Math.PI * 2) +
|
||||
amplitude * Math.random() * randomness +
|
||||
offset
|
||||
);
|
||||
return calculateWaveform('cos', timestamp, {
|
||||
period,
|
||||
amplitude,
|
||||
offset,
|
||||
phase,
|
||||
randomness,
|
||||
infinityValues,
|
||||
exceedFloat32
|
||||
});
|
||||
}
|
||||
|
||||
function sin(
|
||||
timestamp,
|
||||
period,
|
||||
amplitude,
|
||||
offset,
|
||||
phase,
|
||||
randomness,
|
||||
infinityValues,
|
||||
exceedFloat32
|
||||
{ period, amplitude, offset, phase, randomness, infinityValues, exceedFloat32 }
|
||||
) {
|
||||
return calculateWaveform('sin', timestamp, {
|
||||
period,
|
||||
amplitude,
|
||||
offset,
|
||||
phase,
|
||||
randomness,
|
||||
infinityValues,
|
||||
exceedFloat32
|
||||
});
|
||||
}
|
||||
|
||||
function calculateWaveform(
|
||||
type,
|
||||
timestamp,
|
||||
{ period, amplitude, offset, phase, randomness, infinityValues, exceedFloat32 }
|
||||
) {
|
||||
if (infinityValues && exceedFloat32) {
|
||||
if (Math.random() > 0.5) {
|
||||
@@ -266,8 +205,9 @@
|
||||
return getRandomFloat32OverflowValue();
|
||||
}
|
||||
|
||||
const waveFunction = type === 'sin' ? Math.sin : Math.cos;
|
||||
return (
|
||||
amplitude * Math.sin(phase + (timestamp / period / 1000) * Math.PI * 2) +
|
||||
amplitude * waveFunction(phase + (timestamp / period / 1000) * Math.PI * 2) +
|
||||
amplitude * Math.random() * randomness +
|
||||
offset
|
||||
);
|
||||
@@ -276,45 +216,28 @@
|
||||
// Values exceeding float32 range (Positive: 3.4+38, Negative: -3.4+38)
|
||||
function getRandomFloat32OverflowValue() {
|
||||
const sign = Math.random() > 0.5 ? 1 : -1;
|
||||
|
||||
return sign * 3.4e39;
|
||||
}
|
||||
|
||||
function wavelengths() {
|
||||
let values = [];
|
||||
while (values.length < 5) {
|
||||
const randomValue = Math.random() * 100;
|
||||
if (!values.includes(randomValue)) {
|
||||
values.push(String(randomValue));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
return Array.from({ length: 5 }, () => String(Math.random() * 100));
|
||||
}
|
||||
|
||||
function intensities() {
|
||||
let values = [];
|
||||
while (values.length < 5) {
|
||||
const randomValue = Math.random() * 10;
|
||||
if (!values.includes(randomValue)) {
|
||||
values.push(String(randomValue));
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
return Array.from({ length: 5 }, () => String(Math.random() * 10));
|
||||
}
|
||||
|
||||
function sendError(error, message) {
|
||||
self.postMessage({
|
||||
error: error.name + ': ' + error.message,
|
||||
message: message,
|
||||
error: `${error.name}: ${error.message}`,
|
||||
message,
|
||||
id: message.id
|
||||
});
|
||||
}
|
||||
|
||||
self.onmessage = function handleMessage(event) {
|
||||
var message = event.data;
|
||||
var handler = handlers[message.request];
|
||||
self.onmessage = (event) => {
|
||||
const { data: message } = event;
|
||||
const handler = handlers[message.request];
|
||||
|
||||
if (!handler) {
|
||||
sendError(new Error('unknown message type'), message);
|
||||
|
||||
@@ -222,10 +222,13 @@ class InMemorySearchProvider {
|
||||
* @private
|
||||
*/
|
||||
startSharedWorker() {
|
||||
// eslint-disable-next-line no-undef
|
||||
const sharedWorkerURL = `${this.openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}inMemorySearchWorker.js`;
|
||||
|
||||
const sharedWorker = new SharedWorker(sharedWorkerURL, 'InMemorySearch Shared Worker');
|
||||
const sharedWorker = new SharedWorker(
|
||||
/* webpackChunkName: "in-memory-search-worker" */ new URL(
|
||||
'./InMemorySearchWorker.js',
|
||||
import.meta.url
|
||||
),
|
||||
'InMemorySearch Shared Worker'
|
||||
);
|
||||
sharedWorker.onerror = this.onWorkerError;
|
||||
sharedWorker.port.onmessage = this.onWorkerMessage;
|
||||
sharedWorker.port.onmessageerror = this.onWorkerMessageError;
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
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
|
||||
@@ -42,10 +38,12 @@ class GlobalTimeContext extends TimeContext {
|
||||
* Get or set the start and end time of the time conductor. Basic validation
|
||||
* of bounds is performed.
|
||||
*
|
||||
* @param {TimeConductorBounds} newBounds
|
||||
* @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds
|
||||
* @throws {Error} Validation error
|
||||
* @returns {TimeConductorBounds}
|
||||
* @override
|
||||
* @fires module:openmct.TimeAPI~bounds
|
||||
* @returns {module:openmct.TimeAPI~TimeConductorBounds}
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method bounds
|
||||
*/
|
||||
bounds(newBounds) {
|
||||
if (arguments.length > 0) {
|
||||
@@ -63,9 +61,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);
|
||||
@@ -83,8 +81,11 @@ 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) {
|
||||
@@ -92,7 +93,8 @@ class GlobalTimeContext extends TimeContext {
|
||||
/**
|
||||
* The Time of Interest has moved.
|
||||
* @event timeOfInterest
|
||||
* @property {number} timeOfInterest time of interest
|
||||
* @memberof module:openmct.TimeAPI~
|
||||
* @property {number} Current time of interest
|
||||
*/
|
||||
this.emit('timeOfInterest', this.toi);
|
||||
}
|
||||
|
||||
@@ -23,36 +23,19 @@
|
||||
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;
|
||||
/** @type {TimeAPI & GlobalTimeContext | undefined} */
|
||||
// We always start with the global time context.
|
||||
// This upstream context will be undefined when an independent time context is added later.
|
||||
this.upstreamTimeContext = this.globalTimeContext;
|
||||
/** @type {Array<any>} */
|
||||
this.objectPath = objectPath;
|
||||
this.refreshContext = this.refreshContext.bind(this);
|
||||
this.resetContext = this.resetContext.bind(this);
|
||||
@@ -64,10 +47,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
this.globalTimeContext.on('removeOwnContext', this.removeIndependentContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @override
|
||||
*/
|
||||
bounds() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.bounds(...arguments);
|
||||
@@ -76,9 +55,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
getBounds() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.getBounds();
|
||||
@@ -87,9 +63,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
setBounds() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.setBounds(...arguments);
|
||||
@@ -98,9 +71,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
tick() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.tick(...arguments);
|
||||
@@ -109,9 +79,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
clockOffsets() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.clockOffsets(...arguments);
|
||||
@@ -120,9 +87,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
getClockOffsets() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.getClockOffsets();
|
||||
@@ -131,9 +95,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
setClockOffsets() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.setClockOffsets(...arguments);
|
||||
@@ -142,24 +103,12 @@ 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.setTimeSystem(...arguments);
|
||||
return this.globalTimeContext.timeSystem(...arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +116,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
* @returns {TimeSystem} The currently applied time system
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method getTimeSystem
|
||||
* @override
|
||||
*/
|
||||
getTimeSystem() {
|
||||
return this.globalTimeContext.getTimeSystem();
|
||||
@@ -298,7 +246,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
/**
|
||||
* Get the current mode.
|
||||
* @return {Mode} the current mode;
|
||||
* @override
|
||||
*/
|
||||
getMode() {
|
||||
if (this.upstreamTimeContext) {
|
||||
@@ -312,8 +259,9 @@ class IndependentTimeContext extends TimeContext {
|
||||
* Set the mode to either fixed or realtime.
|
||||
*
|
||||
* @param {Mode} mode The mode to activate
|
||||
* @param {TimeConductorBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width
|
||||
* @return {Mode | undefined} the currently active mode;
|
||||
* @param {TimeBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width
|
||||
* @fires module:openmct.TimeAPI~clock
|
||||
* @return {Mode} the currently active mode;
|
||||
*/
|
||||
setMode(mode, offsetsOrBounds) {
|
||||
if (!mode) {
|
||||
@@ -351,10 +299,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
* @override
|
||||
*/
|
||||
isRealTime() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.isRealTime(...arguments);
|
||||
@@ -363,10 +307,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {number}
|
||||
* @override
|
||||
*/
|
||||
now() {
|
||||
if (this.upstreamTimeContext) {
|
||||
return this.upstreamTimeContext.now(...arguments);
|
||||
@@ -403,9 +343,6 @@ class IndependentTimeContext extends TimeContext {
|
||||
this.unlisteners = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the time context to the global time context
|
||||
*/
|
||||
resetContext() {
|
||||
if (this.upstreamTimeContext) {
|
||||
this.stopFollowingTimeContext();
|
||||
@@ -415,7 +352,6 @@ 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);
|
||||
@@ -434,17 +370,10 @@ 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
|
||||
|
||||
@@ -25,41 +25,6 @@ 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
|
||||
@@ -76,8 +41,8 @@ import GlobalTimeContext from './GlobalTimeContext.js';
|
||||
* fired when properties of the time conductor change, which are documented
|
||||
* below.
|
||||
*
|
||||
* @class
|
||||
* @extends {GlobalTimeContext}
|
||||
* @interface
|
||||
* @memberof module:openmct
|
||||
*/
|
||||
class TimeAPI extends GlobalTimeContext {
|
||||
constructor(openmct) {
|
||||
@@ -86,9 +51,33 @@ 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) {
|
||||
@@ -120,6 +109,7 @@ class TimeAPI extends GlobalTimeContext {
|
||||
|
||||
/**
|
||||
* Register a new Clock.
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @param {Clock} clock
|
||||
*/
|
||||
addClock(clock) {
|
||||
@@ -127,7 +117,9 @@ class TimeAPI extends GlobalTimeContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @returns {Clock[]}
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
*/
|
||||
getAllClocks() {
|
||||
return Array.from(this.clocks.values());
|
||||
@@ -136,9 +128,11 @@ 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 {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} 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 {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);
|
||||
@@ -165,8 +159,9 @@ class TimeAPI extends GlobalTimeContext {
|
||||
/**
|
||||
* Get the independent time context which follows the TimeAPI timeSystem,
|
||||
* but with different offsets.
|
||||
* @param {string} key The identifier key of the domain object these offsets
|
||||
* @returns {IndependentTimeContext} The independent time context
|
||||
* @param {key | string} key The identifier key of the domain object these offsets
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method getIndependentTimeContext
|
||||
*/
|
||||
getIndependentContext(key) {
|
||||
return this.independentContexts.get(key);
|
||||
@@ -175,8 +170,9 @@ 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
|
||||
* @returns {TimeContext | GlobalTimeContext} The time context
|
||||
* @param { Array } objectPath The view's objectPath
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method getContextForView
|
||||
*/
|
||||
getContextForView(objectPath) {
|
||||
if (!objectPath || !Array.isArray(objectPath)) {
|
||||
|
||||
@@ -24,85 +24,22 @@ 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 systems available to the TimeAPI.
|
||||
* @type {Map<string, TimeSystem>}
|
||||
*/
|
||||
//The Time System
|
||||
this.timeSystems = new Map();
|
||||
|
||||
/**
|
||||
* The currently applied time system.
|
||||
* @type {TimeSystem | undefined}
|
||||
*/
|
||||
this.system = undefined;
|
||||
|
||||
/**
|
||||
* The clocks available to the TimeAPI.
|
||||
* @type {Map<string, import('../../utils/clock/DefaultClock.js').default>}
|
||||
*/
|
||||
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;
|
||||
@@ -114,9 +51,11 @@ class TimeContext extends EventEmitter {
|
||||
/**
|
||||
* Get or set the time system of the TimeAPI.
|
||||
* @param {TimeSystem | string} timeSystemOrKey
|
||||
* @param {TimeConductorBounds} bounds
|
||||
* @param {module:openmct.TimeAPI~TimeConductorBounds} bounds
|
||||
* @fires module:openmct.TimeAPI~timeSystem
|
||||
* @returns {TimeSystem} The currently applied time system
|
||||
* @deprecated This method is deprecated. Use "getTimeSystem" and "setTimeSystem" instead.
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method timeSystem
|
||||
*/
|
||||
timeSystem(timeSystemOrKey, bounds) {
|
||||
this.#warnMethodDeprecated('"timeSystem"', '"getTimeSystem" and "setTimeSystem"');
|
||||
@@ -162,8 +101,11 @@ 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.
|
||||
* @type {TimeSystem}
|
||||
*/
|
||||
*
|
||||
* @event module:openmct.TimeAPI~timeSystem
|
||||
* @property {TimeSystem} The value of the currently applied
|
||||
* Time System
|
||||
* */
|
||||
const system = this.#copy(this.system);
|
||||
this.emit('timeSystem', system);
|
||||
this.emit(TIME_CONTEXT_EVENTS.timeSystemChanged, system);
|
||||
@@ -176,11 +118,21 @@ 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 {TimeConductorBounds} bounds The start and end time of the conductor.
|
||||
* @param {TimeBounds} 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 (
|
||||
@@ -210,10 +162,12 @@ class TimeContext extends EventEmitter {
|
||||
* Get or set the start and end time of the time conductor. Basic validation
|
||||
* of bounds is performed.
|
||||
*
|
||||
* @param {TimeConductorBounds} [newBounds] The new bounds to set. If not provided, current bounds will be returned.
|
||||
* @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds
|
||||
* @throws {Error} Validation error
|
||||
* @returns {TimeConductorBounds} The current bounds of the time conductor.
|
||||
* @deprecated This method is deprecated. Use "getBounds" and "setBounds" instead.
|
||||
* @fires module:openmct.TimeAPI~bounds
|
||||
* @returns {module:openmct.TimeAPI~TimeConductorBounds}
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method bounds
|
||||
*/
|
||||
bounds(newBounds) {
|
||||
this.#warnMethodDeprecated('"bounds"', '"getBounds" and "setBounds"');
|
||||
@@ -229,6 +183,7 @@ 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.
|
||||
@@ -245,7 +200,9 @@ 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
|
||||
* @returns { ValidationResult } A validation error, and true/false if valid or not
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method validateOffsets
|
||||
*/
|
||||
validateOffsets(offsets) {
|
||||
if (
|
||||
@@ -271,13 +228,34 @@ 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] 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.
|
||||
* @param {ClockOffsets} offsets
|
||||
* @returns {ClockOffsets}
|
||||
*/
|
||||
clockOffsets(offsets) {
|
||||
this.#warnMethodDeprecated('"clockOffsets"', '"getClockOffsets" and "setClockOffsets"');
|
||||
@@ -315,7 +293,6 @@ 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"');
|
||||
@@ -327,14 +304,12 @@ 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 {string|Clock} keyOrClock The clock to activate, or its key
|
||||
* @param {Clock || string} 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.
|
||||
* (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.
|
||||
* @fires module:openmct.TimeAPI~clock
|
||||
* @return {Clock} the currently active clock;
|
||||
*/
|
||||
clock(keyOrClock, offsets) {
|
||||
this.#warnMethodDeprecated('"clock"', '"getClock" and "setClock"');
|
||||
@@ -364,6 +339,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
|
||||
* if the system is no longer following a clock source
|
||||
*/
|
||||
@@ -385,7 +361,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.
|
||||
*/
|
||||
@@ -409,6 +385,8 @@ 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() {
|
||||
@@ -418,6 +396,8 @@ 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;
|
||||
@@ -425,9 +405,12 @@ 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 {TimeConductorBounds} bounds
|
||||
* @param {module:openmct.TimeAPI~TimeConductorBounds} bounds
|
||||
* @fires module:openmct.TimeAPI~timeSystem
|
||||
* @returns {TimeSystem} The currently applied time system
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method setTimeSystem
|
||||
*/
|
||||
setTimeSystem(timeSystemOrKey, bounds) {
|
||||
if (timeSystemOrKey === undefined) {
|
||||
@@ -458,6 +441,7 @@ 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
|
||||
* */
|
||||
@@ -472,7 +456,9 @@ class TimeContext extends EventEmitter {
|
||||
/**
|
||||
* Get the start and end time of the time conductor. Basic validation
|
||||
* of bounds is performed.
|
||||
* @returns {TimeConductorBounds} The current bounds of the time conductor.
|
||||
* @returns {module:openmct.TimeAPI~TimeConductorBounds}
|
||||
* @memberof module:openmct.TimeAPI#
|
||||
* @method bounds
|
||||
*/
|
||||
getBounds() {
|
||||
//Return a copy to prevent direct mutation of time conductor bounds.
|
||||
@@ -483,8 +469,12 @@ class TimeContext extends EventEmitter {
|
||||
* Set the start and end time of the time conductor. Basic validation
|
||||
* of bounds is performed.
|
||||
*
|
||||
* @param {TimeConductorBounds} newBounds The new bounds to set.
|
||||
* @throws {Error} Validation error if bounds are invalid
|
||||
* @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
|
||||
*/
|
||||
setBounds(newBounds) {
|
||||
const validationResult = this.validateBounds(newBounds);
|
||||
@@ -497,6 +487,7 @@ 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.
|
||||
@@ -507,7 +498,7 @@ class TimeContext extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Get the active clock.
|
||||
* @return {Clock|undefined} the currently active clock; undefined if in fixed mode.
|
||||
* @return {Clock} the currently active clock;
|
||||
*/
|
||||
getClock() {
|
||||
return this.activeClock;
|
||||
@@ -518,7 +509,9 @@ class TimeContext extends EventEmitter {
|
||||
* and the currently ticking will begin.
|
||||
* Offsets from 'now', if provided, will be used to set realtime mode offsets
|
||||
*
|
||||
* @param {string|Clock} keyOrClock The clock to activate, or its key
|
||||
* @param {Clock || string} keyOrClock The clock to activate, or its key
|
||||
* @fires module:openmct.TimeAPI~clock
|
||||
* @return {Clock} the currently active clock;
|
||||
*/
|
||||
setClock(keyOrClock) {
|
||||
let clock;
|
||||
@@ -547,7 +540,7 @@ class TimeContext extends EventEmitter {
|
||||
* The active clock has changed.
|
||||
* @event clock
|
||||
* @memberof module:openmct.TimeAPI~
|
||||
* @property {TimeContext} clock The newly activated clock, or undefined
|
||||
* @property {Clock} 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);
|
||||
@@ -556,7 +549,7 @@ class TimeContext extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Get the current mode.
|
||||
* @return {Mode} the current mode
|
||||
* @return {Mode} the current mode;
|
||||
*/
|
||||
getMode() {
|
||||
return this.mode;
|
||||
@@ -566,9 +559,9 @@ class TimeContext extends EventEmitter {
|
||||
* Set the mode to either fixed or realtime.
|
||||
*
|
||||
* @param {Mode} mode The mode to activate
|
||||
* @param {TimeConductorBounds|ClockOffsets} offsetsOrBounds A time window of a fixed width
|
||||
* @param {TimeBounds | ClockOffsets} offsetsOrBounds A time window of a fixed width
|
||||
* @fires module:openmct.TimeAPI~clock
|
||||
* @return {Mode | undefined} the currently active mode
|
||||
* @return {Mode} the currently active mode;
|
||||
*/
|
||||
setMode(mode, offsetsOrBounds) {
|
||||
if (!mode) {
|
||||
@@ -584,6 +577,7 @@ 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));
|
||||
@@ -616,15 +610,18 @@ class TimeContext extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Get the currently applied clock offsets.
|
||||
* @returns {ClockOffsets} The current clock offsets.
|
||||
* @returns {ClockOffsets}
|
||||
*/
|
||||
getClockOffsets() {
|
||||
return this.offsets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the currently applied clock offsets.
|
||||
* @param {ClockOffsets} offsets The new clock offsets to set.
|
||||
* 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}
|
||||
*/
|
||||
setClockOffsets(offsets) {
|
||||
const validationResult = this.validateOffsets(offsets);
|
||||
@@ -645,20 +642,13 @@ 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
|
||||
|
||||
@@ -683,11 +673,6 @@ 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));
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ export default {
|
||||
|
||||
this.openmct.time.on('timeSystem', this.updateTimeSystem);
|
||||
|
||||
this.timestampKey = this.openmct.time.getTimeSystem().key;
|
||||
this.timestampKey = this.openmct.time.timeSystem().key;
|
||||
|
||||
this.valueMetadata = undefined;
|
||||
|
||||
|
||||
@@ -253,7 +253,7 @@ export default {
|
||||
};
|
||||
},
|
||||
getOptions() {
|
||||
const { start, end } = this.timeContext.getBounds();
|
||||
const { start, end } = this.timeContext.bounds();
|
||||
|
||||
return {
|
||||
end,
|
||||
@@ -372,13 +372,13 @@ export default {
|
||||
this.setTrace(key, telemetryObject.name, axisMetadata, xValues, yValues);
|
||||
},
|
||||
isDataInTimeRange(datum, key, telemetryObject) {
|
||||
const timeSystemKey = this.timeContext.getTimeSystem().key;
|
||||
const timeSystemKey = this.timeContext.timeSystem().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.getBounds().end >= currentTimestamp;
|
||||
return currentTimestamp && this.timeContext.bounds().end >= currentTimestamp;
|
||||
},
|
||||
format(telemetryObjectKey, metadataKey, data) {
|
||||
const formats = this.telemetryObjectFormats[telemetryObjectKey];
|
||||
|
||||
@@ -306,7 +306,7 @@ export default {
|
||||
this.trace = [trace];
|
||||
},
|
||||
getTimestampForDatum(datum, key, telemetryObject) {
|
||||
const timeSystemKey = this.timeContext.getTimeSystem().key;
|
||||
const timeSystemKey = this.timeContext.timeSystem().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.getBounds();
|
||||
const { start, end } = this.timeContext.bounds();
|
||||
|
||||
return {
|
||||
end,
|
||||
|
||||
@@ -245,7 +245,7 @@ export default class Condition extends EventEmitter {
|
||||
latestTimestamp,
|
||||
updatedCriterion.data,
|
||||
this.timeSystems,
|
||||
this.openmct.time.getTimeSystem()
|
||||
this.openmct.time.timeSystem()
|
||||
);
|
||||
this.conditionManager.updateCurrentCondition(latestTimestamp);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ export default class Condition extends EventEmitter {
|
||||
latestTimestamp,
|
||||
data,
|
||||
this.timeSystems,
|
||||
this.openmct.time.getTimeSystem()
|
||||
this.openmct.time.timeSystem()
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
{},
|
||||
{},
|
||||
this.timeSystems,
|
||||
this.openmct.time.getTimeSystem()
|
||||
this.openmct.time.timeSystem()
|
||||
);
|
||||
this.updateConditionResults({ id: id });
|
||||
this.updateCurrentCondition(latestTimestamp);
|
||||
@@ -383,7 +383,7 @@ export default class ConditionManager extends EventEmitter {
|
||||
latestTimestamp,
|
||||
data,
|
||||
this.timeSystems,
|
||||
this.openmct.time.getTimeSystem()
|
||||
this.openmct.time.timeSystem()
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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.getTimeSystem();
|
||||
const timeSystem = this.openmct.time.timeSystem();
|
||||
|
||||
telemetryRequestsResults.forEach((results, index) => {
|
||||
const latestDatum =
|
||||
|
||||
@@ -280,7 +280,7 @@ export default {
|
||||
await this.$nextTick();
|
||||
},
|
||||
formattedValueForCopy() {
|
||||
const timeFormatterKey = this.openmct.time.getTimeSystem().key;
|
||||
const timeFormatterKey = this.openmct.time.timeSystem().key;
|
||||
const timeFormatter = this.formats[timeFormatterKey];
|
||||
const unit = this.unit ? ` ${this.unit}` : '';
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ export default {
|
||||
rangeLow: gaugeController.min,
|
||||
gaugeType: gaugeController.gaugeType,
|
||||
showUnits: gaugeController.showUnits,
|
||||
activeTimeSystem: this.openmct.time.getTimeSystem(),
|
||||
activeTimeSystem: this.openmct.time.timeSystem(),
|
||||
units: ''
|
||||
};
|
||||
},
|
||||
@@ -726,7 +726,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
const { start, end } = this.openmct.time.getBounds();
|
||||
const { start, end } = this.openmct.time.bounds();
|
||||
const parsedValue = this.timeFormatter.parse(this.datum);
|
||||
|
||||
const beforeStartOfBounds = parsedValue < start;
|
||||
|
||||
@@ -49,7 +49,7 @@ export default {
|
||||
mixins: [imageryData],
|
||||
inject: ['openmct', 'domainObject', 'objectPath'],
|
||||
data() {
|
||||
let timeSystem = this.openmct.time.getTimeSystem();
|
||||
let timeSystem = this.openmct.time.timeSystem();
|
||||
this.metadata = {};
|
||||
this.requestCount = 0;
|
||||
|
||||
@@ -148,10 +148,10 @@ export default {
|
||||
return clientWidth;
|
||||
},
|
||||
updateViewBounds(bounds, isTick) {
|
||||
this.viewBounds = this.timeContext.getBounds();
|
||||
this.viewBounds = this.timeContext.bounds();
|
||||
|
||||
if (this.timeSystem === undefined) {
|
||||
this.timeSystem = this.timeContext.getTimeSystem();
|
||||
this.timeSystem = this.timeContext.timeSystem();
|
||||
}
|
||||
|
||||
this.setScaleAndPlotImagery(this.timeSystem, !isTick);
|
||||
@@ -216,7 +216,7 @@ export default {
|
||||
}
|
||||
|
||||
if (timeSystem === undefined) {
|
||||
timeSystem = this.timeContext.getTimeSystem();
|
||||
timeSystem = this.timeContext.timeSystem();
|
||||
}
|
||||
|
||||
if (timeSystem.isUTCBased) {
|
||||
|
||||
@@ -44,7 +44,7 @@ export default class RelatedTelemetry {
|
||||
this.keys = telemetryKeys;
|
||||
|
||||
this._timeFormatter = undefined;
|
||||
this._timeSystemChange(this.timeContext.getTimeSystem());
|
||||
this._timeSystemChange(this.timeContext.timeSystem());
|
||||
|
||||
// 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.getBounds().start,
|
||||
start: this.timeContext.bounds().start,
|
||||
end: this._parseTime(datum)
|
||||
};
|
||||
ephemeralContext.setBounds(newBounds);
|
||||
ephemeralContext.bounds(newBounds);
|
||||
|
||||
const options = {
|
||||
start: newBounds.start,
|
||||
|
||||
@@ -171,7 +171,7 @@ export default {
|
||||
this.bounds = bounds; // setting bounds for ImageryView watcher
|
||||
},
|
||||
timeSystemChanged() {
|
||||
this.timeSystem = this.timeContext.getTimeSystem();
|
||||
this.timeSystem = this.timeContext.timeSystem();
|
||||
this.timeKey = this.timeSystem.key;
|
||||
this.timeFormatter = this.getFormatter(this.timeKey);
|
||||
this.durationFormatter = this.getFormatter(
|
||||
|
||||
@@ -61,7 +61,7 @@ describe('The local time', () => {
|
||||
});
|
||||
|
||||
it('can be set to be the main time system', () => {
|
||||
expect(openmct.time.getTimeSystem().key).toBe(LOCAL_SYSTEM_KEY);
|
||||
expect(openmct.time.timeSystem().key).toBe(LOCAL_SYSTEM_KEY);
|
||||
});
|
||||
|
||||
it('uses the local-format time format', () => {
|
||||
|
||||
@@ -680,7 +680,7 @@ export default {
|
||||
} else if (domainObjectData) {
|
||||
// plain domain object
|
||||
const objectPath = JSON.parse(domainObjectData);
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
const bounds = this.openmct.time.bounds();
|
||||
const snapshotMeta = {
|
||||
bounds,
|
||||
link: null,
|
||||
|
||||
@@ -275,7 +275,7 @@ export default {
|
||||
}
|
||||
const hash = this.embed.historicLink;
|
||||
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
const bounds = this.openmct.time.bounds();
|
||||
const isTimeBoundChanged =
|
||||
this.embed.bounds.start !== bounds.start || this.embed.bounds.end !== bounds.end;
|
||||
const isFixedTimespanMode = !this.openmct.time.clock();
|
||||
|
||||
@@ -369,7 +369,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
async addNewEmbed(objectPath) {
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
const bounds = this.openmct.time.bounds();
|
||||
const snapshotMeta = {
|
||||
bounds,
|
||||
link: null,
|
||||
|
||||
@@ -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.getBounds(),
|
||||
bounds: this.openmct.time.bounds(),
|
||||
link,
|
||||
objectPath,
|
||||
openmct: this.openmct
|
||||
|
||||
@@ -140,7 +140,7 @@ export function createNewImageEmbed(image, openmct, imageName = '') {
|
||||
};
|
||||
|
||||
const embedMetaData = {
|
||||
bounds: openmct.time.getBounds(),
|
||||
bounds: openmct.time.bounds(),
|
||||
link: null,
|
||||
objectPath: null,
|
||||
openmct,
|
||||
|
||||
@@ -57,11 +57,11 @@ class CouchObjectProvider {
|
||||
let provider = this;
|
||||
let sharedWorker;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const sharedWorkerURL = `${this.openmct.getAssetPath()}${__OPENMCT_ROOT_RELATIVE__}couchDBChangesFeed.js`;
|
||||
|
||||
sharedWorker = new SharedWorker(
|
||||
sharedWorkerURL,
|
||||
/* webpackChunkName: "couchDBChangesFeed" */ new URL(
|
||||
'./CouchChangesFeed.js',
|
||||
import.meta.url
|
||||
),
|
||||
`CouchDB SSE Shared Worker for ${this.namespace}`
|
||||
);
|
||||
sharedWorker.port.onmessage = provider.onSharedWorkerMessage.bind(this);
|
||||
|
||||
@@ -196,7 +196,7 @@ export default {
|
||||
this.followTimeContext();
|
||||
},
|
||||
followTimeContext() {
|
||||
this.updateViewBounds(this.timeContext.getBounds());
|
||||
this.updateViewBounds(this.timeContext.bounds());
|
||||
|
||||
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.getTimeSystem();
|
||||
this.timeSystem = this.openmct.time.timeSystem();
|
||||
}
|
||||
|
||||
this.setScaleAndGenerateActivities();
|
||||
@@ -344,7 +344,7 @@ export default {
|
||||
}
|
||||
|
||||
if (!timeSystem) {
|
||||
timeSystem = this.openmct.time.getTimeSystem();
|
||||
timeSystem = this.openmct.time.timeSystem();
|
||||
}
|
||||
|
||||
if (timeSystem.isUTCBased) {
|
||||
|
||||
@@ -116,7 +116,7 @@ export default {
|
||||
}
|
||||
},
|
||||
setFormatters() {
|
||||
let timeSystem = this.openmct.time.getTimeSystem();
|
||||
let timeSystem = this.openmct.time.timeSystem();
|
||||
this.timeFormatter = this.openmct.telemetry.getValueFormatter({
|
||||
format: timeSystem.timeFormat
|
||||
}).formatter;
|
||||
|
||||
@@ -661,7 +661,7 @@ export default {
|
||||
this.offsetWidth = this.$parent.$refs.plotWrapper.offsetWidth;
|
||||
|
||||
this.startLoading();
|
||||
const bounds = this.timeContext.getBounds();
|
||||
const bounds = this.timeContext.bounds();
|
||||
const options = {
|
||||
size: this.$parent.$refs.plotWrapper.offsetWidth,
|
||||
domain: this.config.xAxis.get('key'),
|
||||
|
||||
@@ -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.getBounds());
|
||||
return new MCTChartAlarmLineSet(series, this, offset, this.openmct.time.bounds());
|
||||
},
|
||||
pointSetForSeries(series) {
|
||||
const mainYAxisId = this.config.yAxis.get('id');
|
||||
|
||||
@@ -93,7 +93,7 @@ export default class XAxisModel extends Model {
|
||||
* @override
|
||||
*/
|
||||
defaultModel(options) {
|
||||
const bounds = options.openmct.time.getBounds();
|
||||
const bounds = options.openmct.time.bounds();
|
||||
const timeSystem = options.openmct.time.getTimeSystem();
|
||||
const format = options.openmct.telemetry.getFormatter(timeSystem.timeFormat);
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ export default class RemoteClock extends DefaultClock {
|
||||
* @private
|
||||
*/
|
||||
_timeSystemChange() {
|
||||
let timeSystem = this.openmct.time.getTimeSystem();
|
||||
let timeSystem = this.openmct.time.timeSystem();
|
||||
let timeKey = timeSystem.key;
|
||||
let metadataValue = this.metadata.value(timeKey);
|
||||
let timeFormatter = this.openmct.telemetry.getValueFormatter(metadataValue);
|
||||
@@ -149,11 +149,13 @@ 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.getClockOffsets();
|
||||
const offsets = this.openmct.time.clockOffsets();
|
||||
resolve({
|
||||
start: this.lastTick + offsets.start,
|
||||
end: this.lastTick + offsets.end
|
||||
|
||||
@@ -62,7 +62,7 @@ SummaryWidgetEvaluator.prototype.subscribe = function (callback) {
|
||||
}
|
||||
|
||||
const updateCallback = function () {
|
||||
const datum = this.evaluateState(realtimeStates, this.openmct.time.getTimeSystem().key);
|
||||
const datum = this.evaluateState(realtimeStates, this.openmct.time.timeSystem().key);
|
||||
if (datum) {
|
||||
callback(datum);
|
||||
}
|
||||
|
||||
@@ -611,11 +611,11 @@ describe('The Mean Telemetry Provider', function () {
|
||||
}
|
||||
|
||||
function createMockTimeApi() {
|
||||
return jasmine.createSpyObj('timeApi', ['getTimeSystem', 'setTimeSystem']);
|
||||
return jasmine.createSpyObj('timeApi', ['timeSystem']);
|
||||
}
|
||||
|
||||
function setTimeSystemTo(timeSystemKey) {
|
||||
mockApi.time.getTimeSystem.and.returnValue({
|
||||
mockApi.time.timeSystem.and.returnValue({
|
||||
key: timeSystemKey
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ TelemetryAverager.prototype.calculateMean = function () {
|
||||
* @private
|
||||
*/
|
||||
TelemetryAverager.prototype.setDomainKeyAndFormatter = function () {
|
||||
const domainKey = this.timeAPI.getTimeSystem().key;
|
||||
const domainKey = this.timeAPI.timeSystem().key;
|
||||
if (domainKey !== this.domainKey) {
|
||||
this.domainKey = domainKey;
|
||||
this.domainFormatter = this.getFormatter(domainKey);
|
||||
|
||||
@@ -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.getTimeSystem().key,
|
||||
key: this.openmct.time.timeSystem().key,
|
||||
direction: 'desc'
|
||||
};
|
||||
|
||||
|
||||
@@ -141,6 +141,7 @@ export default {
|
||||
data() {
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
const timeSystem = this.openmct.time.getTimeSystem();
|
||||
// const isFixed = this.openmct.time.isFixed();
|
||||
|
||||
return {
|
||||
timeSystem,
|
||||
|
||||
@@ -173,16 +173,16 @@ export default {
|
||||
});
|
||||
},
|
||||
getBoundsForTimeSystem(timeSystem) {
|
||||
const currentBounds = this.timeContext.getBounds();
|
||||
const currentBounds = this.timeContext.bounds();
|
||||
|
||||
//TODO: Some kind of translation via an offset? of current bounds to target timeSystem
|
||||
return currentBounds;
|
||||
},
|
||||
updateViewBounds() {
|
||||
const bounds = this.timeContext.getBounds();
|
||||
const bounds = this.timeContext.bounds();
|
||||
this.updateContentHeight();
|
||||
let currentTimeSystemIndex = this.timeSystems.findIndex(
|
||||
(item) => item.timeSystem.key === this.openmct.time.getTimeSystem().key
|
||||
(item) => item.timeSystem.key === this.openmct.time.timeSystem().key
|
||||
);
|
||||
if (currentTimeSystemIndex > -1) {
|
||||
let currentTimeSystem = {
|
||||
|
||||
@@ -97,7 +97,7 @@ const headerItems = [
|
||||
property: 'start',
|
||||
name: 'Start Time',
|
||||
format: function (value, object, key, openmct, options = {}) {
|
||||
const timeFormat = openmct.time.getTimeSystem().timeFormat;
|
||||
const timeFormat = openmct.time.timeSystem().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.getTimeSystem().timeFormat;
|
||||
const timeFormat = openmct.time.timeSystem().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.getBounds()?.start &&
|
||||
activity.start <= this.timeContext.getBounds()?.end;
|
||||
activity.start >= this.timeContext.bounds()?.start &&
|
||||
activity.start <= this.timeContext.bounds()?.end;
|
||||
const endInBounds =
|
||||
activity.end >= this.timeContext.getBounds()?.start &&
|
||||
activity.end <= this.timeContext.getBounds()?.end;
|
||||
activity.end >= this.timeContext.bounds()?.start &&
|
||||
activity.end <= this.timeContext.bounds()?.end;
|
||||
const middleInBounds =
|
||||
activity.start <= this.timeContext.getBounds()?.start &&
|
||||
activity.end >= this.timeContext.getBounds()?.end;
|
||||
activity.start <= this.timeContext.bounds()?.start &&
|
||||
activity.end >= this.timeContext.bounds()?.end;
|
||||
|
||||
return startInBounds || endInBounds || middleInBounds;
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ export default class StalenessUtils {
|
||||
|
||||
shouldUpdateStaleness(stalenessResponse, id) {
|
||||
const stalenessResponseTime = this.parseTime(stalenessResponse);
|
||||
const { start } = this.openmct.time.getBounds();
|
||||
const { start } = this.openmct.time.bounds();
|
||||
const isStalenessInCurrentClock = stalenessResponseTime > start;
|
||||
|
||||
if (stalenessResponseTime > this.lastStalenessResponseTime && isStalenessInCurrentClock) {
|
||||
|
||||
Reference in New Issue
Block a user