.. index:: pair: class; SimulationManager .. _doxid-class_simulation_manager: class SimulationManager ======================= .. toctree:: :hidden: enum_SimulationManager_SimState.rst struct_SimulationManager_RequestResult.rst Overview ~~~~~~~~ Manages simulation execution. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include class SimulationManager: public :ref:`PtrTemplates` { public: // enums enum :ref:`SimState`; // structs struct :ref:`RequestResult`; // construction :ref:`SimulationManager`(const :ref:`jsonSharedPtr`& simulationConfig); :target:`SimulationManager`(); // methods static void :ref:`validateConfig`(:ref:`jsonSharedPtr`& config); :ref:`RequestResult` :ref:`initializeSimulation`(); :ref:`RequestResult` :ref:`resetSimulation`(); :ref:`RequestResult` :ref:`stopSimulation`(); :ref:`RequestResult` :ref:`runSimulationUntilDoneOrTimeout`(); virtual bool :target:`hasSimulationTimedOut`() const = 0; :ref:`RequestResult` :ref:`runSimulation`(unsigned numIterations); :ref:`RequestResult` :ref:`shutdownSimulation`(); :ref:`SimState` :ref:`currentState`(); std::string :ref:`printSimState`(const :ref:`SimState`& simState); :ref:`SimulationDataManager`& :target:`getSimulationDataManager`(); }; // direct descendants class :ref:`EventLoopSimManager`; class :ref:`FTILoopSimManager`; Inherited Members ----------------- .. ref-code-block:: cpp :class: doxyrest-overview-inherited-code-block public: // typedefs typedef std::shared_ptr :ref:`shared_ptr`; typedef std::shared_ptr :ref:`const_shared_ptr`; typedef std::unique_ptr :ref:`unique_ptr`; typedef std::unique_ptr :ref:`const_unique_ptr`; .. _details-class_simulation_manager: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Manages simulation execution. Maintain the current state of the simulation and process control requests according to this state. Control request methods are processed sequentially guarded by a lock, with the exception of "stopSimulation", which can be processed in parallel. Control requests are forwarded to Implementations of this interface via a set of callbacks. Exceptions occurring in these callbacks are handled by :ref:`SimulationManager ` by transitioning the simulation to state "Failed", from which the only possible action is to shutdown the simulation. Calling a control request from the wrong state triggers an exception Construction ------------ .. index:: pair: function; SimulationManager .. _doxid-class_simulation_manager_1af976d90860cfe9be1ebcc3a9423b3ddd: .. ref-code-block:: cpp :class: doxyrest-title-code-block SimulationManager(const :ref:`jsonSharedPtr`& simulationConfig) Constructor. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - simulationConfig - Simulation configuration Methods ------- .. index:: pair: function; validateConfig .. _doxid-class_simulation_manager_1a72682b7fff56a816b33a61331428af37: .. ref-code-block:: cpp :class: doxyrest-title-code-block static void validateConfig(:ref:`jsonSharedPtr`& config) Validates config against Simulation schema. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - config - Pointer to a config .. index:: pair: function; initializeSimulation .. _doxid-class_simulation_manager_1a00bfc0314728a354260d2e199f1b140d: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` initializeSimulation() Initialize the simulation. .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; resetSimulation .. _doxid-class_simulation_manager_1a1b2b12f20b3e39a4b353766c618937e5: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` resetSimulation() Reset the currently running simulation. .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; stopSimulation .. _doxid-class_simulation_manager_1aeac325c71030527f32af9ade03b4697f: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` stopSimulation() Request to stop the simulation if it was running, if it wasn't the call has no effect. It is not blocking, i.e. it is not guaranteed that the simulation is in state "Stopped" after the call returns. The simulation will stop after the the "runSimulation" request that started it returns. .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; runSimulationUntilDoneOrTimeout .. _doxid-class_simulation_manager_1a5ed7bff8c1621af257f5570f162848ab: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` runSimulationUntilDoneOrTimeout() Runs the simulation until a separate thread stops it or simTimeout (defined in SimulationConfig) is reached. If simTimeout is zero or negative, ignore it. .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; runSimulation .. _doxid-class_simulation_manager_1a2671f82d0edf322ba5d1afc5aaa16cc8: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` runSimulation(unsigned numIterations) Run the Simulation for specified amount of timesteps. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - numIterations - Number of iterations (i.e timesteps) to run simulation .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; shutdownSimulation .. _doxid-class_simulation_manager_1ad564a7a9be8b21c75805045c704d3ff2: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`RequestResult` shutdownSimulation() Shuts down the simulation. .. rubric:: Returns: Simulation state after processing the request .. index:: pair: function; currentState .. _doxid-class_simulation_manager_1ab073abd3774190585610e2d4913ee109: .. ref-code-block:: cpp :class: doxyrest-title-code-block :ref:`SimState` currentState() returns the current state of the simulation .. index:: pair: function; printSimState .. _doxid-class_simulation_manager_1a58dc227aa53374bb998df2c5d08776ba: .. ref-code-block:: cpp :class: doxyrest-title-code-block std::string printSimState(const :ref:`SimState`& simState) returns a simulation state as a string