timestamps visible in execution history
This commit is contained in:
parent
3f095bb419
commit
446829c8ec
4 changed files with 55 additions and 31 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import { evalExpr } from "./actionlang_interpreter";
|
||||
import { computeArena, ConcreteState, getDescendants, isAncestorOf, isOverlapping, OrState, Statechart, stateDescription, Transition } from "./ast";
|
||||
import { Action } from "./label_ast";
|
||||
import { Environment, RaisedEvents, Mode, RT_Statechart, initialRaised, BigStep } from "./runtime_types";
|
||||
import { Environment, RaisedEvents, Mode, RT_Statechart, initialRaised, BigStepOutput } from "./runtime_types";
|
||||
|
||||
export function initialize(ast: Statechart): BigStep {
|
||||
export function initialize(ast: Statechart): BigStepOutput {
|
||||
let {enteredStates, environment, ...raised} = enterDefault(ast.root, {
|
||||
environment: new Map(),
|
||||
...initialRaised,
|
||||
|
|
@ -204,7 +204,7 @@ export function handleEvent(event: string, statechart: Statechart, activeParent:
|
|||
return {environment, mode, ...raised};
|
||||
}
|
||||
|
||||
export function handleInputEvent(event: string, statechart: Statechart, {mode, environment}: {mode: Mode, environment: Environment}): BigStep {
|
||||
export function handleInputEvent(event: string, statechart: Statechart, {mode, environment}: {mode: Mode, environment: Environment}): BigStepOutput {
|
||||
let raised = initialRaised;
|
||||
|
||||
({mode, environment, ...raised} = handleEvent(event, statechart, statechart.root, {mode, environment, ...raised}));
|
||||
|
|
@ -212,7 +212,7 @@ export function handleInputEvent(event: string, statechart: Statechart, {mode, e
|
|||
return handleInternalEvents(statechart, {mode, environment, ...raised});
|
||||
}
|
||||
|
||||
export function handleInternalEvents(statechart: Statechart, {mode, environment, ...raised}: RT_Statechart & RaisedEvents): BigStep {
|
||||
export function handleInternalEvents(statechart: Statechart, {mode, environment, ...raised}: RT_Statechart & RaisedEvents): BigStepOutput {
|
||||
while (raised.internalEvents.length > 0) {
|
||||
const [internalEvent, ...rest] = raised.internalEvents;
|
||||
({mode, environment, ...raised} = handleEvent(internalEvent, statechart, statechart.root, {mode, environment, internalEvents: rest, outputEvents: raised.outputEvents}));
|
||||
|
|
|
|||
|
|
@ -12,7 +12,15 @@ export type RT_Statechart = {
|
|||
// history: // TODO
|
||||
}
|
||||
|
||||
export type BigStep = RT_Statechart & {outputEvents: string[]};
|
||||
export type BigStepOutput = RT_Statechart & {
|
||||
outputEvents: string[],
|
||||
};
|
||||
|
||||
export type BigStep = {
|
||||
inputEvent: string | null, // null if initialization
|
||||
simtime: number,
|
||||
} & BigStepOutput;
|
||||
|
||||
|
||||
export type RaisedEvents = {
|
||||
internalEvents: string[];
|
||||
|
|
@ -24,4 +32,4 @@ export type Timers = Map<string, number>; // transition uid -> timestamp
|
|||
export const initialRaised: RaisedEvents = {
|
||||
internalEvents: [],
|
||||
outputEvents: [],
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
|
||||
export type TimeMode = TimePaused | TimeRealTime;
|
||||
|
||||
// When the simulation is paused, we only need to know the current simulated time.
|
||||
export type TimePaused = {
|
||||
kind: "paused",
|
||||
simtime: number, // the current simulated time
|
||||
}
|
||||
|
||||
// When the simulation is running in real time, we need to know the time when the simulation was set to real time (both in simulated and wall-clock time), and the time scale. This allows us to compute the simulated time of every future event.
|
||||
// Such a 'future event' may be:
|
||||
// - raising an input event
|
||||
// - changing of the time scale parameter
|
||||
// - pausing the simulation
|
||||
export type TimeRealTime = {
|
||||
kind: "realtime",
|
||||
scale: number, // time scale relative to wall-clock time
|
||||
since: {
|
||||
simtime: number, // the simulated time at which the time was set to realtime
|
||||
wallclktime: number, // the wall-clock time at which the time was set to realtime
|
||||
}
|
||||
scale: number, // time scale relative to wall-clock time
|
||||
}
|
||||
|
||||
export function getSimTime(currentMode: TimeMode, wallclktime: number): number {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue