Compare commits
12 Commits
master
...
time-condu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e624821ab1 | ||
|
|
15126fd550 | ||
|
|
5adc86c71e | ||
|
|
a11fcc3231 | ||
|
|
d0a77637c0 | ||
|
|
eeda4c62fc | ||
|
|
10457a583e | ||
|
|
ff605a0a0d | ||
|
|
f56a8a1f5d | ||
|
|
c8f8a098f2 | ||
|
|
31be2cba3d | ||
|
|
eeb4f995a4 |
@@ -74,6 +74,7 @@
|
||||
|
||||
<script>
|
||||
import _ from 'lodash';
|
||||
import { inject, onMounted, provide } from 'vue';
|
||||
|
||||
import {
|
||||
FIXED_MODE_KEY,
|
||||
@@ -90,6 +91,7 @@ import ConductorModeIcon from './ConductorModeIcon.vue';
|
||||
import ConductorPopUp from './ConductorPopUp.vue';
|
||||
import conductorPopUpManager from './conductorPopUpManager.js';
|
||||
import ConductorTimeSystem from './ConductorTimeSystem.vue';
|
||||
import { useTimeSystem } from './useTimeSystem.js';
|
||||
|
||||
const DEFAULT_DURATION_FORMATTER = 'duration';
|
||||
|
||||
@@ -106,6 +108,16 @@ export default {
|
||||
},
|
||||
mixins: [conductorPopUpManager],
|
||||
inject: ['openmct', 'configuration'],
|
||||
setup() {
|
||||
const openmct = inject('openmct');
|
||||
const { observeTimeSystem, timeSystemKey } = useTimeSystem(openmct);
|
||||
|
||||
onMounted(() => observeTimeSystem());
|
||||
|
||||
provide('timeSystemKey', timeSystemKey);
|
||||
|
||||
return { timeSystemKey };
|
||||
},
|
||||
data() {
|
||||
const isFixed = this.openmct.time.isFixed();
|
||||
const bounds = this.openmct.time.getBounds();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
<template>
|
||||
<time-popup-fixed
|
||||
<TimePopupFixed
|
||||
v-if="readOnly === false"
|
||||
:input-bounds="bounds"
|
||||
:input-time-system="timeSystem"
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2024, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<form ref="fixedDeltaInput">
|
||||
<div class="c-tc-input-popup__input-grid">
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
<!--
|
||||
Open MCT, Copyright (c) 2014-2024, United States Government
|
||||
as represented by the Administrator of the National Aeronautics and Space
|
||||
Administration. All rights reserved.
|
||||
|
||||
Open MCT is licensed under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
Open MCT includes source code licensed under additional open source
|
||||
licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
this source code distribution or the Licensing information page available
|
||||
at runtime from the About dialog for additional information.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<form ref="deltaInput">
|
||||
<div class="c-tc-input-popup__input-grid">
|
||||
|
||||
59
src/plugins/timeConductor/useClockOffsets.js
Normal file
59
src/plugins/timeConductor/useClockOffsets.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2024, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { onBeforeUnmount, shallowRef } from 'vue';
|
||||
|
||||
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
|
||||
|
||||
/**
|
||||
* Provides reactive `offsets`,
|
||||
* as well as a function to observe and update offsets changes,
|
||||
* which automatically stops observing when the component is unmounted.
|
||||
*
|
||||
* @param {OpenMCT} openmct the Open MCT API
|
||||
* @returns {{
|
||||
* observeClockOffsets: () => void,
|
||||
* offsets: import('vue').Ref<object>,
|
||||
* }}
|
||||
*/
|
||||
export function useClockOffsets(openmct, options) {
|
||||
let stopObservingClockOffsets;
|
||||
|
||||
const offsets = shallowRef(openmct.time.getClockOffsets());
|
||||
|
||||
onBeforeUnmount(() => stopObservingClockOffsets?.());
|
||||
|
||||
function observeClockOffsets() {
|
||||
openmct.time.on(TIME_CONTEXT_EVENTS.clockOffsetsChanged, updateClockOffsets);
|
||||
stopObservingClockOffsets = () =>
|
||||
openmct.time.off(TIME_CONTEXT_EVENTS.clockOffsetsChanged, updateClockOffsets);
|
||||
}
|
||||
|
||||
function updateClockOffsets(_offsets) {
|
||||
offsets.value = _offsets;
|
||||
}
|
||||
|
||||
return {
|
||||
observeClockOffsets,
|
||||
offsets
|
||||
};
|
||||
}
|
||||
64
src/plugins/timeConductor/useTimeBounds.js
Normal file
64
src/plugins/timeConductor/useTimeBounds.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2024, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { onBeforeUnmount, ref, shallowRef } from 'vue';
|
||||
|
||||
import { TIME_CONTEXT_EVENTS } from '../../api/time/constants.js';
|
||||
import throttle from '../../utils/throttle.js';
|
||||
|
||||
/**
|
||||
* Provides reactive `bounds`,
|
||||
* as well as a function to observe and update bounds changes,
|
||||
* which automatically stops observing when the component is unmounted.
|
||||
*
|
||||
* @param {OpenMCT} openmct the Open MCT API
|
||||
* @returns {{
|
||||
* observeTimeBounds: () => void,
|
||||
* bounds: import('vue').Ref<object>,
|
||||
* isTick: import('vue').Ref<boolean>
|
||||
* }}
|
||||
*/
|
||||
export function useTimeBounds(openmct, options) {
|
||||
let stopObservingTimeBounds;
|
||||
|
||||
const bounds = shallowRef(openmct.time.getBounds());
|
||||
const isTick = ref(false);
|
||||
|
||||
onBeforeUnmount(() => stopObservingTimeBounds?.());
|
||||
|
||||
function observeTimeBounds(milliseconds = 300) {
|
||||
openmct.time.on(TIME_CONTEXT_EVENTS.boundsChanged, throttle(updateTimeBounds), milliseconds);
|
||||
stopObservingTimeBounds = () =>
|
||||
openmct.time.off(TIME_CONTEXT_EVENTS.boundsChanged, throttle(updateTimeBounds), milliseconds);
|
||||
}
|
||||
|
||||
function updateTimeBounds(_timeBounds, _isTick) {
|
||||
bounds.value = _timeBounds;
|
||||
isTick.value = _isTick;
|
||||
}
|
||||
|
||||
return {
|
||||
observeTimeBounds,
|
||||
isTick,
|
||||
bounds
|
||||
};
|
||||
}
|
||||
66
src/plugins/timeConductor/useTimeMode.js
Normal file
66
src/plugins/timeConductor/useTimeMode.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2024, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
import {
|
||||
FIXED_MODE_KEY,
|
||||
REALTIME_MODE_KEY,
|
||||
TIME_CONTEXT_EVENTS
|
||||
} from '../../api/time/constants.js';
|
||||
|
||||
/**
|
||||
* Provides reactive `isFixedTimeMode` and `isRealTimeMode`,
|
||||
* as well as a function to observe and update the component's time mode,
|
||||
* which automatically stops observing when the component is unmounted.
|
||||
*
|
||||
* @param {OpenMCT} openmct the Open MCT API
|
||||
* @returns {{
|
||||
* observeTimeMode: () => void,
|
||||
* isFixedTimeMode: import('vue').Ref<boolean>,
|
||||
* isRealTimeMode: import('vue').Ref<boolean>
|
||||
* }}
|
||||
*/
|
||||
export function useTimeMode(openmct, options) {
|
||||
let stopObservingTimeMode;
|
||||
|
||||
const timeMode = ref(openmct.time.getMode());
|
||||
const isFixedTimeMode = computed(() => timeMode.value === FIXED_MODE_KEY);
|
||||
const isRealTimeMode = computed(() => timeMode.value === REALTIME_MODE_KEY);
|
||||
|
||||
onBeforeUnmount(() => stopObservingTimeMode?.());
|
||||
|
||||
function observeTimeMode() {
|
||||
openmct.time.on(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
|
||||
stopObservingTimeMode = () => openmct.time.off(TIME_CONTEXT_EVENTS.modeChanged, updateTimeMode);
|
||||
}
|
||||
|
||||
function updateTimeMode(_timeMode) {
|
||||
timeMode.value = _timeMode;
|
||||
}
|
||||
|
||||
return {
|
||||
observeTimeMode,
|
||||
isFixedTimeMode,
|
||||
isRealTimeMode
|
||||
};
|
||||
}
|
||||
83
src/plugins/timeConductor/useTimeSystem.js
Normal file
83
src/plugins/timeConductor/useTimeSystem.js
Normal file
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2024, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
import { onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
const DEFAULT_DURATION_FORMATTER = 'duration';
|
||||
|
||||
/**
|
||||
* Provides a reactive destructuring of the component's current time system,
|
||||
* as well as a function to observe and update the component's time system,
|
||||
* which automatically stops observing when the component is unmounted.
|
||||
*
|
||||
* @param {OpenMCT} openmct the Open MCT API
|
||||
* @returns {{
|
||||
* observeTimeSystem: () => void,
|
||||
* timeSystemKey: import('vue').Ref<string>,
|
||||
* timeSystemFormatter: import('vue').Ref<() => void>,
|
||||
* timeSystemDurationFormatter: import('vue').Ref<() => void>,
|
||||
* isTimeSystemUTCBased: import('vue').Ref<boolean>
|
||||
* }}
|
||||
*/
|
||||
export function useTimeSystem(openmct, options) {
|
||||
let stopObservingTimeSystem;
|
||||
|
||||
const currentTimeSystem = openmct.time.getTimeSystem();
|
||||
|
||||
const timeSystemKey = ref(currentTimeSystem.key);
|
||||
const timeSystemFormatter = ref(getFormatter(openmct, currentTimeSystem.timeFormat));
|
||||
const timeSystemDurationFormatter = ref(
|
||||
getFormatter(openmct, currentTimeSystem.durationFormat || DEFAULT_DURATION_FORMATTER)
|
||||
);
|
||||
const isTimeSystemUTCBased = ref(currentTimeSystem.isUTCBased);
|
||||
|
||||
onBeforeUnmount(() => stopObservingTimeSystem?.());
|
||||
|
||||
function observeTimeSystem() {
|
||||
openmct.time.on('timeSystemChanged', updateTimeSystem);
|
||||
stopObservingTimeSystem = () => openmct.time.off('timeSystemChanged', updateTimeSystem);
|
||||
}
|
||||
|
||||
function updateTimeSystem(timeSystem) {
|
||||
timeSystemKey.value = timeSystem.key;
|
||||
timeSystemFormatter.value = getFormatter(openmct, timeSystem.timeFormat);
|
||||
timeSystemDurationFormatter.value = getFormatter(
|
||||
openmct,
|
||||
timeSystem.durationFormat || DEFAULT_DURATION_FORMATTER
|
||||
);
|
||||
isTimeSystemUTCBased.value = timeSystem.isUTCBased;
|
||||
}
|
||||
|
||||
return {
|
||||
observeTimeSystem,
|
||||
timeSystemKey,
|
||||
timeSystemFormatter,
|
||||
timeSystemDurationFormatter,
|
||||
isTimeSystemUTCBased
|
||||
};
|
||||
}
|
||||
|
||||
function getFormatter(openmct, key) {
|
||||
return openmct.telemetry.getValueFormatter({
|
||||
format: key
|
||||
}).formatter;
|
||||
}
|
||||
Reference in New Issue
Block a user