Closed nunoguedelha closed 2 years ago
On the installed plugins...
telemetry.fixed
object types only.Time Systems are JavaScript objects that provide some information about the current time reference frame, typically the time display format and the time zone: UTC/GMT, ETC, ...
The example below defines/registers a UTC based time system:
openmct.time.addTimeSystem({
key: 'utc',
name: 'UTC Time',
cssClass = 'icon-clock',
timeFormat = 'utc',
durationFormat = 'duration',
isUTCBased = true
});
Note: 'utc'
and 'duration'
are formats defined in the utcTimeSystem
plugin module.
The TimeAPI provides a getter/setter for querying and setting time bounds. Time bounds are simply an object with a start
and an end
end attribute, delimiting the period displayed by time-responsive telemetry views in the active Time System.
const ONE_HOUR = 60 * 60 * 1000;
let now = Date.now();
openmct.time.bounds({start: now - ONE_HOUR, now);
Clocks can tick on anything. For example, a clock could be defined to provide the timestamp of any new data received via a telemetry subscription. This would have the effect of advancing the bounds of views automatically whenever data is received. A clock could also be defined to tick on some remote timing source.
var someClock = {
key: 'someClock',
cssClass: 'icon-clock',
name: 'Some clock',
description: "Presumably does something useful",
on: function (event, callback) {
// Some function that registers listeners, and updates them on a tick
},
off: function (event, callback) {
// Some function that unregisters listeners.
},
currentValue: function () {
// A function that returns the last ticked value for the clock
}
}
openmct.time.addClock(someClock);
Unlike bounds, which represent absolute time values, clock offsets represent relative time spans, start
(<0) and end
(>0), used to update the start and stop bons on each clock tick.
The DefaultClock
class is implemented in src/utils/clock/DefaultClock.js
and extends an EventEmitter
. It provides the methods depicted earlier in the someClock
example.
The class LocalClock
implemented in src/plugins/utcTimeSystem/LocalClock.j
extends the DefaultClock
class, providing the additional start
and stop
methods used by the openmct
Time API.
The utcTimeSystem
installation instantiates a UTCTimeSystem
Time System and a LocalClock
and registers them: https://github.com/nasa/openmct/blob/ab7e2c57470d3c6076459ad7e3eaa1883cc3b8b0/src/plugins/utcTimeSystem/plugin.js#L34-L40
return function () {
return function (openmct) {
const timeSystem = new UTCTimeSystem();
openmct.time.addTimeSystem(timeSystem);
openmct.time.addClock(new LocalClock.default(100));
};
};
The clock and Time System are activated in the openmctStaticServer/index.html
visualizer client installation file. The clockOffsets
are passed in the clock activation:
https://github.com/ami-iit/yarp-openmct/blob/0a9bd9b5aeae631227e665ca2d0a0b2d28cbc18d/openmctStaticServer/index.html#L35-L36
timeSystem
event.clockOffsets
event, and then a bounds
event as the offsets are applied to the clock's currentValue()
.clock.on
.The Time Conductor plugin provides a user interface for selecting pre-defined configurations of combined clocks, time systems and time bounds or offsets in Open MCT. The Time Conductor configuration in https://github.com/ami-iit/yarp-openmct/blob/feature/improve-time-range-zone-management/openmctStaticServer/index.html specifies the combinations made available in the GUI. The whole configuration is provided as an array of menu options. Each entry defines...
the used clock
: [string] Active Clock ("Local Clock") or Fixed Time Mode (no active clock, "Fixed Timespan"),
the available timeSystem
: [string] the key for the time system that this configuration relates to,
some default bounds
(for the "Fixed Timespan" configuration) or clockOffsets
(for the "Local Clock" configuration): [object] with start and
end` properties,
presets
: array of bounds (start|end) or clockOffsets, setting available entries in the history drop down menu,
records
: [number] maximum recent bounds to retain in conductor history,
Unused options so far:
The Time Conductor handles by itself the clock and system activation, so we can discard the lines: https://github.com/ami-iit/yarp-openmct/blob/0a9bd9b5aeae631227e665ca2d0a0b2d28cbc18d/openmctStaticServer/index.html#L35-L36
I'm still analysing how to integrate the Clock
plugin in the Time Conductor. The Clock
plugin alone can be added to "My Items" and allows set different time zones.
I will add this improvement eventually, along with the remoteClock
in a future PR.
The measurements timestamp is fixed to the UTC timezone. The measurements time span is also fixed. We should be able to change both from the web GUI.