fix two timers bugs
This commit is contained in:
parent
1470a99665
commit
1660b06064
3 changed files with 9 additions and 3 deletions
|
|
@ -212,7 +212,7 @@ export function App() {
|
||||||
return () => {
|
return () => {
|
||||||
if (timeout) clearTimeout(timeout);
|
if (timeout) clearTimeout(timeout);
|
||||||
}
|
}
|
||||||
}, [time, trace]); // <-- todo: is this really efficient?
|
}, [time, currentTraceItem]); // <-- todo: is this really efficient?
|
||||||
|
|
||||||
function appendNewConfig(simtime: number, cause: string, computeNewState: () => [RaisedEvent[], CoupledState]) {
|
function appendNewConfig(simtime: number, cause: string, computeNewState: () => [RaisedEvent[], CoupledState]) {
|
||||||
let newItem: TraceItem;
|
let newItem: TraceItem;
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ function attemptSrcState(simtime: number, sourceState: AbstractState, event: RT_
|
||||||
else {
|
else {
|
||||||
// get transitions triggered by timeout
|
// get transitions triggered by timeout
|
||||||
triggered = labels.filter(([_t,l]) =>
|
triggered = labels.filter(([_t,l]) =>
|
||||||
l.trigger.kind === "after" && l.trigger.durationMs === event.timeDurMs);
|
l.trigger.kind === "after" && sourceState.uid === event.state && l.trigger.durationMs === event.timeDurMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,13 @@ export function statechartExecution(ast: Statechart): TimedReactive<BigStep> {
|
||||||
const bigstep = initialize(ast);
|
const bigstep = initialize(ast);
|
||||||
return [bigstep.outputEvents, bigstep];
|
return [bigstep.outputEvents, bigstep];
|
||||||
},
|
},
|
||||||
timeAdvance: (c: RT_Statechart) => (c.environment.get("_timers") as Timers)[0]?.[0] || Infinity,
|
timeAdvance: (c: RT_Statechart) => {
|
||||||
|
const timers = c.environment.get("_timers");
|
||||||
|
if (timers && timers[0]) {
|
||||||
|
return timers[0][0];
|
||||||
|
}
|
||||||
|
return Infinity;
|
||||||
|
},
|
||||||
intTransition: (c: RT_Statechart) => {
|
intTransition: (c: RT_Statechart) => {
|
||||||
const timers = c.environment.get("_timers") as Timers;
|
const timers = c.environment.get("_timers") as Timers;
|
||||||
if (timers.length === 0) {
|
if (timers.length === 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue