diff --git a/src/App/App.tsx b/src/App/App.tsx index 2d2a744..91e0daf 100644 --- a/src/App/App.tsx +++ b/src/App/App.tsx @@ -133,18 +133,25 @@ export function App() { }, 20); let timeout: NodeJS.Timeout | undefined; - if (time.kind === "realtime" && rtIdx !== null) { - console.log('checking timers...'); + if (rtIdx !== null) { const currentRt = rt[rtIdx]!; const timers = currentRt.environment.get("_timers") || []; if (timers.length > 0) { const [nextInterrupt, timeElapsedEvent] = timers[0]; - const wallclkDelay = getWallClkDelay(time, nextInterrupt, performance.now()); - console.log('scheduling timeout after', wallclkDelay); - timeout = setTimeout(() => { + const raiseTimeEvent = () => { const nextConfig = handleInputEvent(nextInterrupt, timeElapsedEvent, ast, currentRt); appendNewConfig('', nextInterrupt, nextConfig); - }, wallclkDelay); + } + if (time.kind === "realtime") { + const wallclkDelay = getWallClkDelay(time, nextInterrupt, performance.now()); + // console.log('scheduling timeout after', wallclkDelay); + timeout = setTimeout(raiseTimeEvent, wallclkDelay); + } + else if (time.kind === "paused") { + if (nextInterrupt <= time.simtime) { + raiseTimeEvent(); + } + } } } @@ -202,7 +209,7 @@ export function App() {   {ast.inputEvents && <>raise  - {[...ast.inputEvents].map(event => )} + {[...ast.inputEvents].map(event => )}   } onChangePaused(e.target.checked, performance.now())}/> @@ -211,19 +218,30 @@ export function App() {   - onTimeScaleChange(e.target.value, performance.now())}/> + onTimeScaleChange(e.target.value, performance.now())}/>     - + {nextTimedTransition && <>   - next timeout (s): - - +   + + } +