ocra-recipes
Doxygen documentation for the ocra-recipes repository
Classes | Public Member Functions | List of all members
ocra_recipes::ClientCommunications Class Reference

#include <ClientCommunications.h>

Inheritance diagram for ocra_recipes::ClientCommunications:
[legend]
Collaboration diagram for ocra_recipes::ClientCommunications:
[legend]

Classes

class  InputCallback
 

Public Member Functions

 ClientCommunications ()
 
virtual ~ClientCommunications ()
 
bool open (double timeout=20.0, bool connectToTasks=true)
 
bool close ()
 
void close (const std::string &taskName)
 
virtual bool read (yarp::os::ConnectionReader &connection)
 
void parseMessage (yarp::os::Bottle &input)
 
std::vector< std::string > getTaskTypes ()
 
yarp::os::Bottle queryController (yarp::os::Bottle &requestBottle)
 
yarp::os::Bottle queryController (const SERVER_COMMUNICATIONS_MESSAGE request)
 
yarp::os::Bottle queryController (const std::vector< SERVER_COMMUNICATIONS_MESSAGE > requestVector)
 
std::vector< std::string > getTaskPortNames ()
 
std::string getTaskPortName (const std::string &taskName)
 
std::vector< std::string > getTaskNames ()
 
std::shared_ptr< yarp::os::RpcClient > getTaskClient (const std::string &taskName)
 
std::string getClientPortName ()
 
bool parseInput (yarp::os::Bottle &input)
 

Detailed Description

Definition at line 30 of file ClientCommunications.h.

Constructor & Destructor Documentation

ClientCommunications::ClientCommunications ( )

Definition at line 9 of file ClientCommunications.cpp.

ClientCommunications::~ClientCommunications ( )
virtual

Definition at line 23 of file ClientCommunications.cpp.

Member Function Documentation

bool ClientCommunications::close ( )

Closes the RPC and input ports opened by this client.

Returns
True after all ports are closed.

Definition at line 69 of file ClientCommunications.cpp.

void ClientCommunications::close ( const std::string &  taskName)

Closes the task-specific RPC ports and deletes this task from the list of current clients.

Parameters
taskNameName of the task.

Definition at line 82 of file ClientCommunications.cpp.

std::string ocra_recipes::ClientCommunications::getClientPortName ( )
inline

Definition at line 127 of file ClientCommunications.h.

std::shared_ptr< yarp::os::RpcClient > ClientCommunications::getTaskClient ( const std::string &  taskName)

Definition at line 178 of file ClientCommunications.cpp.

std::vector< std::string > ClientCommunications::getTaskNames ( )

Definition at line 165 of file ClientCommunications.cpp.

std::string ClientCommunications::getTaskPortName ( const std::string &  taskName)

Definition at line 151 of file ClientCommunications.cpp.

std::vector< std::string > ClientCommunications::getTaskPortNames ( )

Definition at line 138 of file ClientCommunications.cpp.

std::vector< std::string > ClientCommunications::getTaskTypes ( )

Queries the server for the task types as strings.

Returns
A vector of strings containint the task types sent by the server.

Definition at line 56 of file ClientCommunications.cpp.

bool ClientCommunications::open ( double  timeout = 20.0,
bool  connectToTasks = true 
)

Opens an RPC port for the client with the format /ControllerClient/<client-number>/rpc:o and an input one with the format /ControllerClient/<client-number>/:i

Parameters
[in]connectToTasksTrue to automatically connect to task RPC ports. True by default.
Returns
True when the conection to tasks is successful.

Definition at line 29 of file ClientCommunications.cpp.

bool ClientCommunications::parseInput ( yarp::os::Bottle &  input)

Definition at line 285 of file ClientCommunications.cpp.

void ClientCommunications::parseMessage ( yarp::os::Bottle &  input)

The method that does the real parsing. The expected messages from the server are: REMOVE_TASK_PORT or HELP.

Parameters
inputA bottle containing the message sent by the server.

Definition at line 237 of file ClientCommunications.cpp.

yarp::os::Bottle ClientCommunications::queryController ( yarp::os::Bottle &  requestBottle)

Takes a bottled query from the client and sends it to the server via RPC.

Parameters
requestBottleBottled query to be sent to the server.
Returns
A bottled reply from the server.

Definition at line 189 of file ClientCommunications.cpp.

yarp::os::Bottle ClientCommunications::queryController ( const SERVER_COMMUNICATIONS_MESSAGE  request)

Sends a request to the server among one of the predefined messages in ocra_recipes::SERVER_COMMUNICATIONS_MESSAGE.

Parameters
requestThese could be General indicators, controller requests, controller status indicators or task requests. See ocra_recipes::SERVER_COMMUNICATIONS_MESSAGE for more options.
Returns
The reply of the server.

Definition at line 196 of file ClientCommunications.cpp.

yarp::os::Bottle ClientCommunications::queryController ( const std::vector< SERVER_COMMUNICATIONS_MESSAGE requestVector)

Allows to send a series of messages from ocra_recipes::SERVER_COMMUNICATIONS_MESSAGE.

Parameters
requestVectorVector of communication messages to be sent to the server.
Returns
Bottled server reply.

Definition at line 204 of file ClientCommunications.cpp.

bool ClientCommunications::read ( yarp::os::ConnectionReader &  connection)
virtual

Reads and parses (parseMessage()) a message sent by the server.

Parameters
connectionSource of the message.
Returns
True if the message is parsed succesfully, false otherwise.

Definition at line 91 of file ClientCommunications.cpp.


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