31 int ClientManager::CONTROLLER_CLIENT_MANAGER_COUNT = 0;
36 moduleNumber = ++ClientManager::CONTROLLER_CLIENT_MANAGER_COUNT;
38 client = customClient;
39 expectedClientPeriod = client->getExpectedPeriod();
41 suppressWarnings = suppressPerformanceWarnings;
51 return "ControllerClientManager_"+std::to_string(moduleNumber);
56 return client->configure(rf);
80 if (!suppressWarnings) {
82 printf(
"[PERFORMANCE INFORMATION]:\n");
83 printf(
"Expected period %d ms.\nReal period: %3.1f+/-%3.1f ms.\n", expectedClientPeriod, avgTime, stdDev);
84 printf(
"Real duration of 'run' method: %3.1f+/-%3.1f ms.\n", avgTimeUsed, stdDevUsed);
85 if(avgTime<0.5*(
double)expectedClientPeriod)
86 printf(
"Next time you could set a lower period to improve the controller performance.\n");
87 else if(avgTime>1.3*(
double)expectedClientPeriod)
88 printf(
"The period you set was impossible to attain. Next time you could set a higher period.\n");
95 if (client->hasBeenReleased()) {
99 client->getEstPeriod(avgTime, stdDev);
102 client->getEstUsed(avgTimeUsed, stdDevUsed);
105 if( (avgTime > 1.3*(
double)expectedClientPeriod) && !suppressWarnings)
107 yLog.warning() <<
"CLIENT THREAD LOOP IS TOO SLOW\nReal period: "<< avgTime <<
"+/-"<< stdDev <<
"\nExpected period: " << expectedClientPeriod <<
"\nDuration of 'run' method: "<<avgTimeUsed<<
"+/-"<< stdDevUsed<<
"\n";
115 std::cout <<
"Hey there this is the help for the ClientManager. Here is what the client is saying..." << std::endl;
119 void ClientManager::callbackParser(yarp::os::Bottle& message, yarp::os::Bottle& reply)
121 if (message.size() != 0) {
142 : moduleRef(newModuleRef)
149 yarp::os::Bottle input, reply;
151 if (!input.read(connection)){
155 moduleRef.callbackParser(input, reply);
156 yarp::os::ConnectionWriter* returnToSender = connection.getWriter();
157 if (returnToSender!=NULL) {
158 reply.write(*returnToSender);
virtual std::string getManagerName()
bool configure(yarp::os::ResourceFinder &rf)
Module class for the controller Client.
virtual bool customUpdateModule()
moduleCallback(ClientManager &newModuleRef)
virtual void customCallbackParser(yarp::os::Bottle &message, yarp::os::Bottle &reply)
virtual bool read(yarp::os::ConnectionReader &connection)
ClientManager(std::shared_ptr< ControllerClient > customClient, bool suppressPerformanceWarnings=false)
The controller module which launches the controller thread.