$darkmode
engine::SimulationMachine Class Reference

#include <simulation_machine.hpp>

Inheritance diagram for engine::SimulationMachine:
Collaboration diagram for engine::SimulationMachine:

Public Member Functions

void run (SimulationContext &ctx)
 
void run_machine (StateId initial, SimulationContext &ctx)
 
StateId run_state_async (StateId id, SimulationContext &ctx)
 
void pause ()
 
void resume ()
 
void stop ()
 
void succeed ()
 
void fail ()
 
void reset ()
 
void abort ()
 
StateId handle_interrupt (StateId nominal, StateId interrupt, SimulationContext &ctx) override
 
 DEFINE_STATE (CONNECT, Connect)
 
 DEFINE_STATE (PROBE, Probe)
 
 DEFINE_STATE (START, Start)
 
 DEFINE_STATE (STEP_BEGIN, StepBegin)
 
 DEFINE_STATE (STEP_SIMULATORS, StepSimulators)
 
 DEFINE_STATE (STEP_CONTROLLERS, StepControllers)
 
 DEFINE_STATE (STEP_END, StepEnd)
 
 DEFINE_STATE (PAUSE, Pause)
 
 DEFINE_STATE (RESUME, Resume)
 
 DEFINE_STATE (SUCCESS, Success)
 
 DEFINE_STATE (FAIL, Fail)
 
 DEFINE_STATE (ABORT, Abort)
 
 DEFINE_STATE (STOP, Stop)
 
 DEFINE_STATE (RESET, Reset)
 
 DEFINE_STATE (KEEP_ALIVE, KeepAlive)
 
 DEFINE_STATE (DISCONNECT, Disconnect)
 

Friends

void to_json (cloe::Json &j, const SimulationMachine &m)
 

Detailed Description

The SimulationMachine is statemachine with the given set of states and simulation context.

The state transitions are given by the states themselves and are not stored in the simulation machine itself.

The entry-point for this simulation machine is the run() method.

If you want to modify the simulation flow, you need to do this with the simulation context and by adding a new transition from the desired state. You may need to add a new state, which you can do in this file by defining it and then registering it in the SimulationMachine constructor.

Member Function Documentation

◆ handle_interrupt()

StateId engine::SimulationMachine::handle_interrupt ( StateId  nominal,
StateId  interrupt,
SimulationContext ctx 
)
inlineoverridevirtual

Handle an interrupt.

This method will be called between states, with the nominal state that would have occurred being passed along.

Implements engine::StateMachine< State< SimulationMachine, SimulationContext >, SimulationContext >.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

void engine::SimulationMachine::run ( SimulationContext ctx)
inline

This is the main entry-point of the simulation.

This should be used even if you have a shortened simulation flow, like CONNECT -> PROBING -> DISCONNECT.

Here is the call graph for this function:

◆ run_machine()

void engine::SimulationMachine::run_machine ( StateId  initial,
SimulationContext ctx 
)
inline

Starting with the initial state, keep running states until the sentinel state (nullptr) has been reached.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_state_async()

StateId engine::SimulationMachine::run_state_async ( StateId  id,
SimulationContext ctx 
)
inline

Run state in a separate thread asynchronously and abort if watchdog_timeout is exceeded.

See configuration: stack.hpp See documentation: doc/reference/watchdog.rst

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: