.. index:: pair: class; EngineClient .. _doxid-class_engine_client: template class EngineClient =========================== .. toctree:: :hidden: class_EngineClient_EngineLauncher.rst Overview ~~~~~~~~ Base class for all Engines. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class EngineClient: public :ref:`EngineClientInterface` { public: // typedefs typedef ENGINE :target:`engine_t`; // classes template class :ref:`EngineLauncher`; // construction :ref:`EngineClient`( :ref:`nlohmann::json`& engineConfig, :ref:`ProcessLauncherInterface::unique_ptr`&& launcher ); // methods virtual const std::string :ref:`engineName`() const; virtual :ref:`SimulationTime` :ref:`getEngineTimestep`() const; virtual const :ref:`nlohmann::json`& :ref:`engineConfig`() const; virtual :ref:`nlohmann::json`& :ref:`engineConfig`(); virtual const std::string :ref:`engineSchema`() const; virtual :ref:`SimulationTime` :ref:`getEngineTime`() const; virtual void :ref:`runLoopStepAsync`(:ref:`SimulationTime` timeStep); virtual void :ref:`runLoopStepAsyncGet`(:ref:`SimulationTime` timeOut); }; // direct descendants template class :ref:`EngineGrpcClient`; template class :ref:`EngineJSONNRPClient`; 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`; // methods virtual const std::string :ref:`engineName`() const = 0; virtual const :ref:`nlohmann::json`& :ref:`engineConfig`() const = 0; virtual :ref:`nlohmann::json`& :ref:`engineConfig`() = 0; virtual const std::vector :ref:`engineProcStartParams`() const = 0; virtual pid_t :ref:`launchEngine`(); virtual void :ref:`initialize`() = 0; virtual void :ref:`reset`() = 0; virtual void :ref:`shutdown`() = 0; virtual :ref:`SimulationTime` :ref:`getEngineTimestep`() const = 0; virtual :ref:`SimulationTime` :ref:`getEngineTime`() const = 0; virtual const std::string :ref:`engineSchema`() const = 0; virtual void :ref:`runLoopStepAsync`(:ref:`SimulationTime` timeStep) = 0; virtual void :ref:`runLoopStepAsyncGet`(:ref:`SimulationTime` timeOut) = 0; virtual void :ref:`sendDataPacksToEngine`(const :ref:`datapacks_set_t`& dataPacks) = 0; virtual :ref:`datapacks_vector_t` :ref:`getDataPacksFromEngine`(const :ref:`datapack_identifiers_set_t`& datapackIdentifiers) = 0; .. _details-class_engine_client: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ Base class for all Engines. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - ENGINE - Final derived engine class Construction ------------ .. index:: pair: function; EngineClient .. _doxid-class_engine_client_1a30252c2688ef6eadf51fdf08669a749e: .. ref-code-block:: cpp :class: doxyrest-title-code-block EngineClient( :ref:`nlohmann::json`& engineConfig, :ref:`ProcessLauncherInterface::unique_ptr`&& launcher ) Constructor. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - engineConfig - Engine Configuration * - launcher - Process Forker Methods ------- .. index:: pair: function; engineName .. _doxid-class_engine_client_1a04f80dd3fbb46b0056d825addb2231d7: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual const std::string engineName() const Get Engine Name. .. rubric:: Returns: Returns engine name .. index:: pair: function; getEngineTimestep .. _doxid-class_engine_client_1a1089097a855a6ab0b4b27605529e1231: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`SimulationTime` getEngineTimestep() const Get engine timestep. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - Throws - on error .. index:: pair: function; engineConfig .. _doxid-class_engine_client_1a5495185601ad8529d112df7591e18b69: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual const :ref:`nlohmann::json`& engineConfig() const Get Engine Configuration. .. index:: pair: function; engineConfig .. _doxid-class_engine_client_1a645831aa5aae4233085c3739c0669992: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`nlohmann::json`& engineConfig() Get Engine Configuration. .. index:: pair: function; engineSchema .. _doxid-class_engine_client_1a356309d9f16c2d0c38002f7978400370: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual const std::string engineSchema() const Get json schema for this engine type. .. index:: pair: function; getEngineTime .. _doxid-class_engine_client_1a9b05083f880d664d4a4eaaba5e461584: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual :ref:`SimulationTime` getEngineTime() const Returns current engine (simulation) time. The time is updated by :ref:`EngineClient::runLoopStepAsyncGet() ` method. .. rubric:: Returns: Current engine (simulation) time .. index:: pair: function; runLoopStepAsync .. _doxid-class_engine_client_1a4b95a41aa73bbc8367d7acf0f47c2756: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual void runLoopStepAsync(:ref:`SimulationTime` timeStep) Concrete implementation of :ref:`EngineClientInterface::runLoopStepAsync() ` The function starts :ref:`EngineClient::runLoopStepCallback() ` asynchronously using std::async. The callback function should be provided by concrete engine implementation. The result of the callback is going to be retrieved using an std::future object in :ref:`EngineClient::runLoopStepAsyncGet() `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - timeStep - Requested duration of the simulation loop step. * - :ref:`NRPException ` - If the future object is still valid (:ref:`EngineClient::runLoopStepAsyncGet() ` was not called) .. index:: pair: function; runLoopStepAsyncGet .. _doxid-class_engine_client_1ae94c9afd2b99f20dff28c3138e3eb5b1: .. ref-code-block:: cpp :class: doxyrest-title-code-block virtual void runLoopStepAsyncGet(:ref:`SimulationTime` timeOut) Concrete implementation of :ref:`EngineClientInterface::runLoopStepAsyncGet() ` The function should be called after :ref:`EngineClient::runLoopStepAsync() `. It will wait for the worker thread to finish and retrieve the results from the future object. The value returned by the future should be the simulation (engine) time after running the loop step. It will be saved in the engine object, and can be accessed with :ref:`EngineClient::getEngineTime() `. .. rubric:: Parameters: .. list-table:: :widths: 20 80 * - timeOut - Timeout of the loop step. If it's less or equal to 0, the function will wait indefinitely. * - :ref:`NRPException ` - On timeout