NRP Core  1.4.1
NrpCoreServer Class Reference

NRP Server class, responsible for handling simulation control requests coming from the client application or script. More...

#include <nrp_core_server.h>

Inheritance diagram for NrpCoreServer:

Public Types

enum  RequestType {
  RequestType::None, RequestType::Initialize, RequestType::RunLoop, RequestType::RunUntilTimeout,
  RequestType::StopLoop, RequestType::Reset, RequestType::Shutdown
}
 enum with possible request types to be processed by SimulationManager More...
 

Public Member Functions

 NrpCoreServer (const std::string &address, std::shared_ptr< SimulationManager > &&manager)
 Constructor. Spawns an instance of gRPC server with given address. More...
 
void runServerLoop ()
 Enters server loop in which requests are processed sequentially. More...
 
void stopServerLoop ()
 Stops server loop. More...
 

Detailed Description

NRP Server class, responsible for handling simulation control requests coming from the client application or script.

The class has two roles:

  • receive simulation control requests from the client application
  • relay received requests to the main thread of NRP Core and wait for response

The class is an instance of gRPC Service, which means that it will have a pool of worker threads. Every request coming from the client will be handled by a separate thread from the pool. The natural approach to request handling would be to call proper methods of the SimulationManager directly from the callbacks (for example, SimulationManager::initFTILoop() from NrpCoreServer::init()). This proved to cause problems with certain python libraries, like OpenCV, that may be used in the transceiver functions. The problem seems to arise from the fact, that the python code was executed in a worker thread, and not in the thread that spawned the python interpreter (the main thread of NRP Core). The solution is to create a producer-consumer relation between the NRP Server threads and the main thread. The NRP Server relays (produces) the requests to the main thread, which consumes them and returns a status back to the NRP Server.

Member Enumeration Documentation

◆ RequestType

enum with possible request types to be processed by SimulationManager

Enumerator
None 
Initialize 
RunLoop 
RunUntilTimeout 
StopLoop 
Reset 
Shutdown 

Constructor & Destructor Documentation

◆ NrpCoreServer()

NrpCoreServer::NrpCoreServer ( const std::string &  address,
std::shared_ptr< SimulationManager > &&  manager 
)

Constructor. Spawns an instance of gRPC server with given address.

Parameters
addressAddress of the gRPC server
managerSimulationManager which actually perform actions from requests

Member Function Documentation

◆ runServerLoop()

void NrpCoreServer::runServerLoop ( )

Enters server loop in which requests are processed sequentially.

◆ stopServerLoop()

void NrpCoreServer::stopServerLoop ( )

Stops server loop.


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