mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 10:53:51 +00:00
Relative run mode (#1512)
* inti relative mode * send imediat update on mode change * add relative to test * don't persist offset mode * add test relative and update calc function * pass data from ssocket * add dev guard * spelling and comments * show relative in offset overview * remove comments * refactor: move totalDelay to _rundown * update clear naming and comments * remove old testing values
This commit is contained in:
committed by
GitHub
parent
a94b10cb0f
commit
dce87c3a81
@@ -156,6 +156,23 @@ export function getRuntimeOffset(state: RuntimeState): number {
|
||||
return startOffset - addedTime - pausedTime + overtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates relative offset
|
||||
* should always be calculated after the absolute offset
|
||||
*/
|
||||
export function getRelativeOffset(state: RuntimeState): number {
|
||||
const { actualStart, plannedStart, offset } = state.runtime;
|
||||
// eslint-disable-next-line no-unused-labels -- dev code path
|
||||
DEV: {
|
||||
// we know actualStart and plannedStart exists as long as a timer is running
|
||||
if (actualStart === null || plannedStart === null) {
|
||||
throw new Error('timerUtils.calculate: actualStart and plannedStart must be set');
|
||||
}
|
||||
}
|
||||
const relativeStartOffset = actualStart - plannedStart;
|
||||
return offset + relativeStartOffset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the expected end of the rundown
|
||||
*/
|
||||
@@ -164,7 +181,7 @@ export function getExpectedEnd(state: RuntimeState): MaybeNumber {
|
||||
if (state.runtime.actualStart === null || state.runtime.plannedEnd === null) {
|
||||
return null;
|
||||
}
|
||||
return state.runtime.plannedEnd - state.runtime.offset + state._timer.totalDelay;
|
||||
return state.runtime.plannedEnd - state.runtime.offset + state._rundown.totalDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user