NRP Core  1.4.1
EngineGrpcClient< ENGINE, SCHEMA > Class Template Reference

#include <engine_grpc_client.h>

Inheritance diagram for EngineGrpcClient< ENGINE, SCHEMA >:
EngineClient< ENGINE, SCHEMA > EngineClientInterface PtrTemplates< EngineClientInterface >

Public Member Functions

 EngineGrpcClient (nlohmann::json &config, ProcessLauncherInterface::unique_ptr &&launcher)
 
virtual pid_t launchEngine () override
 Launch the engine. More...
 
void connectToServer ()
 
void sendInitializeCommand (const nlohmann::json &data)
 
void sendResetCommand ()
 
void sendShutdownCommand (const nlohmann::json &data)
 
SimulationTime runLoopStepCallback (const SimulationTime timeStep) override
 Executes a single loop step. More...
 
virtual datapacks_vector_t getDataPacksFromEngine (const datapack_identifiers_set_t &requestedDataPackIds) override
 Gets requested datapacks from engine. More...
 
virtual void sendDataPacksToEngine (const datapacks_set_t &dataPacks) override
 Sends datapacks to engine. More...
 
virtual const std::vector< std::string > engineProcStartParams () const override
 Get all Engine Process Startup parameters. More...
 
std::string tryBind (const std::string &address)
 
void validateServerAddress ()
 Validates if server address is already in use. More...
 
const std::string serverAddress () const
 Returns the address used by the gRPC server. More...
 
- Public Member Functions inherited from EngineClient< ENGINE, SCHEMA >
 EngineClient (nlohmann::json &engineConfig, ProcessLauncherInterface::unique_ptr &&launcher)
 Constructor. More...
 
 ~EngineClient () override=default
 
const std::string engineName () const override final
 Get Engine Name. More...
 
SimulationTime getEngineTimestep () const override final
 Get engine timestep. More...
 
const nlohmann::jsonengineConfig () const override final
 Get Engine Configuration. More...
 
nlohmann::jsonengineConfig () override final
 Get Engine Configuration. More...
 
const std::string engineSchema () const override final
 Get json schema for this engine type. More...
 
SimulationTime getEngineTime () const override
 Returns current engine (simulation) time. More...
 
void runLoopStepAsync (SimulationTime timeStep) override
 Concrete implementation of EngineClientInterface::runLoopStepAsync() More...
 
void runLoopStepAsyncGet (SimulationTime timeOut) override
 Concrete implementation of EngineClientInterface::runLoopStepAsyncGet() More...
 
- Public Member Functions inherited from EngineClientInterface
 EngineClientInterface (ProcessLauncherInterface::unique_ptr &&launcher)
 
virtual ~EngineClientInterface ()
 
virtual void initialize ()=0
 Initialize engine. More...
 
virtual void reset ()=0
 Reset engine. More...
 
virtual void shutdown ()=0
 Shutdown engine. More...
 

Protected Member Functions

void resetEngineTime () override
 
- Protected Member Functions inherited from EngineClient< ENGINE, SCHEMA >
template<class T >
void setDefaultProperty (std::string key, T value)
 Attempts to set a default value for a property in the engine configuration. If the property has been already set either in the engine configuration file or from the engine schema, its value is not overwritten. More...
 

Additional Inherited Members

- Public Types inherited from EngineClient< ENGINE, SCHEMA >
using engine_t = ENGINE
 
- Public Types inherited from PtrTemplates< EngineClientInterface >
using shared_ptr = std::shared_ptr< EngineClientInterface >
 
using const_shared_ptr = std::shared_ptr< const EngineClientInterface >
 
using unique_ptr = std::unique_ptr< EngineClientInterface >
 
using const_unique_ptr = std::unique_ptr< const EngineClientInterface >
 
- Protected Attributes inherited from EngineClientInterface
ProcessLauncherInterface::unique_ptr _process
 Process Launcher. Will be used to stop process at end. More...
 

Constructor & Destructor Documentation

◆ EngineGrpcClient()

template<class ENGINE , const char * SCHEMA>
EngineGrpcClient< ENGINE, SCHEMA >::EngineGrpcClient ( nlohmann::json config,
ProcessLauncherInterface::unique_ptr &&  launcher 
)
inline

Member Function Documentation

◆ connectToServer()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::connectToServer ( )
inline

◆ engineProcStartParams()

template<class ENGINE , const char * SCHEMA>
virtual const std::vector<std::string> EngineGrpcClient< ENGINE, SCHEMA >::engineProcStartParams ( ) const
inlineoverridevirtual

Get all Engine Process Startup parameters.

Implements EngineClientInterface.

◆ getDataPacksFromEngine()

template<class ENGINE , const char * SCHEMA>
virtual datapacks_vector_t EngineGrpcClient< ENGINE, SCHEMA >::getDataPacksFromEngine ( const datapack_identifiers_set_t datapackIdentifiers)
inlineoverridevirtual

Gets requested datapacks from engine.

Parameters
datapackNamesAll requested datapack ids
Returns
Returns all requested datapacks
Exceptions
Throwson error

Implements EngineClientInterface.

◆ launchEngine()

template<class ENGINE , const char * SCHEMA>
virtual pid_t EngineGrpcClient< ENGINE, SCHEMA >::launchEngine ( )
inlineoverridevirtual

Launch the engine.

Returns
Returns engine process ID on success, throws on failure

Reimplemented from EngineClientInterface.

◆ resetEngineTime()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::resetEngineTime ( )
inlineoverrideprotectedvirtual

Reimplemented from EngineClient< ENGINE, SCHEMA >.

◆ runLoopStepCallback()

template<class ENGINE , const char * SCHEMA>
SimulationTime EngineGrpcClient< ENGINE, SCHEMA >::runLoopStepCallback ( const SimulationTime  timeStep)
inlineoverridevirtual

Executes a single loop step.

This function is going to be called by runLoopStep using std::async. It will be executed by a worker thread, which allows for runLoopStepFunction from multiple engines to run simultaneously.

Parameters
[in]timeStepA time step by which the simulation should be advanced
Returns
Engine time after loop step execution

Implements EngineClient< ENGINE, SCHEMA >.

◆ sendDataPacksToEngine()

template<class ENGINE , const char * SCHEMA>
virtual void EngineGrpcClient< ENGINE, SCHEMA >::sendDataPacksToEngine ( const datapacks_set_t dataPacks)
inlineoverridevirtual

Sends datapacks to engine.

Parameters
datapacksArrayArray of datapacks that will be send to the engine
Returns
Returns SUCCESS if all datapacks could be handles, ERROR otherwise
Exceptions
Throwson error

Implements EngineClientInterface.

◆ sendInitializeCommand()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::sendInitializeCommand ( const nlohmann::json data)
inline

◆ sendResetCommand()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::sendResetCommand ( )
inline

◆ sendShutdownCommand()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::sendShutdownCommand ( const nlohmann::json data)
inline

◆ serverAddress()

template<class ENGINE , const char * SCHEMA>
const std::string EngineGrpcClient< ENGINE, SCHEMA >::serverAddress ( ) const
inline

Returns the address used by the gRPC server.

◆ tryBind()

template<class ENGINE , const char * SCHEMA>
std::string EngineGrpcClient< ENGINE, SCHEMA >::tryBind ( const std::string &  address)
inline

◆ validateServerAddress()

template<class ENGINE , const char * SCHEMA>
void EngineGrpcClient< ENGINE, SCHEMA >::validateServerAddress ( )
inline

Validates if server address is already in use.


The documentation for this class was generated from the following file: