$darkmode
simulation_machine.hpp File Reference
#include <future>
#include <cloe/core/abort.hpp>
#include "simulation_context.hpp"
#include "utility/state_machine.hpp"
Include dependency graph for simulation_machine.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  engine::SimulationMachine
 

Macros

#define DEFINE_STATE(Id, S)   DEFINE_STATE_STRUCT(SimulationMachine, SimulationContext, Id, S)
 

Detailed Description

This file provides the simulation state machine.

The following flow diagram shows how the states of a simulation are traversed in a typical simulation. The nominal flow is rendered in solid lines, while irregular situations are rendered in dashed lines.

                    ┌──────────────────────┐
      +------------ │       Connect        │
      |             └──────────────────────┘
      |                        │
      |                        ▼
      |             ┌──────────────────────┐
      +---...       │        Start         │ <-------------------------+
      |             └──────────────────────┘                           |
      |                        │                                       |
      |                        ▼                                       |
      |             ┌──────────────────────┐          +-----------+    |
      +---...       │      StepBegin       │ ◀──┐<--- |   Resume  |    |
      |             └──────────────────────┘    │     +-----------+    |
      |                        │                │           ^          |
      |                        ▼                │           |          |
      |             ┌──────────────────────┐    │           |          |
      +---...       │    StepSimulators    │    │           |          |
      |             └──────────────────────┘    │           |          |
      |                        │                │           |          |
      |                        ▼                │           |          |
      |             ┌──────────────────────┐    │           |          |
      +---...       │    StepControllers   │    │           |          |
      |             └──────────────────────┘    │           |          |
      |                        │                │           |          |
      v                        ▼                │           |          |
+-----------+       ┌──────────────────────┐    │     +-----------+    |
|   Abort   |       │       StepEnd        │ ───┘---> |   Pause   |    |
+-----------+       └──────────────────────┘          +-----------+    |
    |    |                     │                         |     ^       |
    |    |             failure │ success                 |     |       |
    |    |                     ▼                         +-----+       |
    |    |          ┌──────────────────────┐          +-----------+    |
    |    +--------> │        Stop          │ -------> |   Reset   | ---+
    |               └──────────────────────┘          +-----------+
    |                          │
    |                          ▼
    |               ┌──────────────────────┐
    +-------------> │      Disconnect      │
                    └──────────────────────┘

Note that not all possible transitions or states are presented in the above diagram; for example, it is possible to go into the Abort state from almost any other state. Neither can one see the constraints that apply to the above transitions; for example, after Abort, the state machine may go into the Stop state, but then will in every case go into the Disconnect state and never into the Reset state.