$darkmode
simulation.cpp File Reference
#include "simulation.hpp"
#include <cstdint>
#include <fstream>
#include <future>
#include <sstream>
#include <string>
#include <thread>
#include <boost/filesystem.hpp>
#include <cloe/core/abort.hpp>
#include <cloe/registrar.hpp>
#include <cloe/trigger/example_actions.hpp>
#include <cloe/trigger/set_action.hpp>
#include <cloe/utility/resource_handler.hpp>
#include <fable/utility.hpp>
#include "simulation_context.hpp"
#include "utility/command.hpp"
#include "utility/state_machine.hpp"
#include "utility/time_event.hpp"
Include dependency graph for simulation.cpp:

Classes

class  engine::SimulationMachine
 

Macros

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

Functions

 INCLUDE_RESOURCE (index_html, PROJECT_SOURCE_DIR "/webui/index.html")
 
 INCLUDE_RESOURCE (favicon, PROJECT_SOURCE_DIR "/webui/cloe_16x16.png")
 
 INCLUDE_RESOURCE (cloe_logo, PROJECT_SOURCE_DIR "/webui/cloe.svg")
 
 INCLUDE_RESOURCE (bootstrap_css, PROJECT_SOURCE_DIR "/webui/bootstrap.min.css")
 
 engine::actions::DEFINE_SET_STATE_ACTION (KeepAlive, "keep_alive", "keep simulation alive after termination", SimulationContext, { ptr_->config.engine.keep_alive=true;}) DEFINE_SET_STATE_ACTION(ResetStatistics
 
std::string engine::enumerate_simulator_vehicles (const cloe::Simulator &s)
 
void engine::handle_cloe_error (cloe::Logger logger, const cloe::Error &e)
 

Variables

 engine::actions::reset_statistics
 
reset simulation engine::actions::statistics
 
reset simulation engine::actions::SimulationStatistics
 

Detailed Description

See also
simulation.hpp

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.