|
Simo 0.0.1
|
#include <Context.h>
Public Types | |
| enum struct | State : uint8_t { INITIALIZATION , PORT_CONNECTION , RUNNING , STOPPED , ERROR } |
| enum struct | RunStatus : uint8_t { EVENTS_IN_QUEUE , STOPPED } |
Public Member Functions | |
| InitializationStatus | initialize () |
| std::expected< RunStatus, InitializationStatus > | run (const Time &time_delta) |
| std::expected< RunStatus, InitializationStatus > | run_at (const Time &final_time) |
| void | schedule_at (const Time &time_target, const SimulationCallable &callable) |
| Schedule event at time_target time. | |
| void | schedule_at (const Time &time_target, const std::function< void()> &callable) |
| Schedule event at time_target time. | |
| void | schedule_in (const Time &time_delta, const SimulationCallable &callable) |
| Schedule an event for time current_time + time_delta. | |
| void | schedule_in (const Time &time_delta, const std::function< void()> &callable) |
| Schedule an event for time current_time + time_delta. | |
| template<typename T> | |
| Parameter::ParameterTyped< T > & | add_parameter (const std::string &name, const T &value) |
| Add parameter of specific type. Return reference to parameter. | |
| void | add (Module &module, Parameters &) |
| void | remove (const Module &module) |
| Remove a modules from the context before initialization occurs. | |
| template<typename Function> | |
| void | foreach_module (Function f) const |
| State | get_state () const |
| Time | current_time () const |
Manage Module initialization and schedule simulation events
The initial state of the simulation is INITIALIZATION. In this phase:
| void Simo::Context::add | ( | Module & | module, |
| Parameters & | p ) |
Add module with a set of parameters to the context.
Modules are going to be initialized during initialization
|
nodiscard |
Initialize the context and the registered modules
This can be done before the first call to run method
| std::expected< Context::RunStatus, InitializationStatus > Simo::Context::run | ( | const Time & | time_delta | ) |
Run for the time expressed in time_delta
If the simulation current_time is t and this function is called, current_time will be t + time_delta at the end of the function If the context is not initialized, the initialize method is going to be called before the execution
| std::expected< Context::RunStatus, InitializationStatus > Simo::Context::run_at | ( | const Time & | final_time | ) |
Run at the time expressed in time_target
Run the simulation untile time_target is reached.