Simulation Lifecycle Events
The following events control the lifecycle of the simulation. They govern the starting, initializing, pausing, resuming, and stopping of the simulation as well as the associated state transitions.
State Model
The simulation passes through the following states:
[START] → INITIALIZING → RUNNING ⇄ PAUSED → STOPPED
State transitions are triggered by command events and confirmed by simulation:state notification events.
Event Overview and Lifecycle
| Event | Category | Type | Description |
|---|---|---|---|
start |
simulation |
Command | Starts the simulation |
reset |
simulation |
Command | Resets the simulation to its initial state |
initialize-world |
simulation |
Command (internal) | Initializes the simulation world |
initialize |
simulation |
Command | Requests all clients to initialize |
initialized |
client |
Response | Confirms that a client has completed initialization |
state |
simulation |
Notification | Informs about state changes |
pause |
simulation |
Command | Pauses the simulation |
continue |
simulation |
Command | Resumes a paused simulation |
stop |
simulation |
Command | Stops the simulation |
OPTIMIZER/VISUALIZATION SIMULATION ALL CLIENTS
| | |
|--- simulation:start -----> | |
| |-- simulation:state -------> | (INITIALIZING)
| |-- simulation:reset -------> |
| |-- simulation:init-world (internal)
| |-- simulation:initialize --> |
| | |
| |<-- client:initialized ----- | (per client)
| |<-- client:initialized ----- |
| | |
| |-- simulation:state -------> | (RUNNING)
| | |
|--- simulation:pause -----> | |
| |-- simulation:state -------> | (PAUSED)
| | |
|--- simulation:continue --> | |
| |-- simulation:state -------> | (RUNNING)
| | |
|--- simulation:stop ------> | |
| |-- simulation:state -------> | (STOPPED)
Events in Detail
simulation:start
Starts the simulation. This event triggers the initialization process of the simulation.
Senders
OPTIMIZER,VISUALIZATION
Receivers
SIMULATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "start",
"data": {}
}
Flow after Triggering
- The simulation receives
simulation:start. - The simulation sends
simulation:statewithstate: "INITIALIZING". - The simulation sends
simulation:reset. - The simulation sends
simulation:initialize-worldinternally. - The simulation sends
simulation:initialize. - All clients respond with
client:initialized. - Once all clients have confirmed, the simulation sends
simulation:statewithstate: "RUNNING".
simulation:state
Informs all participants about a state change of the simulation. This event is sent exclusively by the simulation and serves as confirmation of a completed state transition.
Senders
SIMULATION
Receivers
OPTIMIZER,SIMULATION,VISUALIZATION
Data Fields
| Field | Type | Required | Description |
|---|---|---|---|
state |
string |
Yes | The new state of the simulation. Possible values: INITIALIZING, RUNNING, PAUSED, STOPPED |
Example
{
"category": "simulation",
"name": "state",
"data": {
"state": "INITIALIZING"
}
}
Valid State Transitions
| Previous State | New State | Triggering Event |
|---|---|---|
STOPPED |
INITIALIZING |
simulation:start |
INITIALIZING |
RUNNING |
All client:initialized received |
RUNNING |
PAUSED |
simulation:pause |
PAUSED |
RUNNING |
simulation:continue |
RUNNING |
STOPPED |
simulation:stop |
PAUSED |
STOPPED |
simulation:stop |
simulation:reset
Resets the simulation to its initial state. This event is sent by the simulation during the initialization process and signals all participants to reset their internal state.
Senders
SIMULATION
Receivers
OPTIMIZERSIMULATIONVISUALIZATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "reset",
"data": {}
}
simulation:initialize-world
Initializes the simulation world. This is a simulation-internal event and is processed exclusively within the simulation. It is used to build the world structure (e.g., terrain, objects, entities) before the clients are initialized.
Senders
SIMULATION
Receivers
SIMULATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "initialize-world",
"data": {}
}
simulation:initialize
Requests all clients to initialize themselves. This event is sent after the simulation world has been built. Each receiving client must respond with a client:initialized event upon completion of its initialization.
Senders
SIMULATION
Receivers
OPTIMIZERSIMULATIONVISUALIZATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "initialize",
"data": {}
}
Expected Receiver Behaviour
Each receiver must send a client:initialized event to the simulation after successful initialization. The simulation waits for confirmation from all clients before transitioning to the RUNNING state.
client:initialized
Confirms that a client has completed its initialization. This event is sent in response to simulation:initialize. The simulation waits for a client:initialized event from each registered client before transitioning to the RUNNING state.
Senders
OPTIMIZERSIMULATIONVISUALIZATION
Receivers
SIMULATION
Data Fields
- This event contains no data fields.
Example
{
"category": "client",
"name": "initialized",
"data": {}
}
simulation:pause
Pauses the running simulation. The simulation transitions to the PAUSED state and confirms this by sending a simulation:state event.
Senders
VISUALIZATION
Receivers
OPTIMIZERSIMULATIONVISUALIZATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "pause",
"data": {}
}
Flow after Triggering
- The visualization sends
simulation:pause. - The simulation receives the event and transitions to the
PAUSEDstate. - The simulation sends
simulation:statewithstate: "PAUSED".
simulation:continue
Resumes a paused simulation. The simulation transitions back to the RUNNING state and confirms this by sending a simulation:state event.
Senders
VISUALIZATION
Receivers
OPTIMIZERSIMULATIONVISUALIZATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "continue",
"data": {}
}
Flow after Triggering
- The visualization sends
simulation:continue. - The simulation receives the event and transitions back to the
RUNNINGstate. - The simulation sends
simulation:statewithstate: "RUNNING".
simulation:stop
Stops the simulation. The simulation is terminated and transitions to the STOPPED state.
Senders
OPTIMIZERVISUALIZATION
####Receivers
OPTIMIZERSIMULATIONVISUALIZATION
Data Fields
- This event contains no data fields.
Example
{
"category": "simulation",
"name": "stop",
"data": {}
}
Flow after Triggering
- The optimizer or the visualization sends
simulation:stop. - The simulation receives the event and transitions to the
STOPPEDstate. - The simulation sends
simulation:statewithstate: "STOPPED".