ocra-recipes
Doxygen documentation for the ocra-recipes repository
ClientManager.h
Go to the documentation of this file.
1 
9 /*
10  * This file is part of ocra-icub.
11  * Copyright (C) 2016 Institut des Systèmes Intelligents et de Robotique (ISIR)
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 */
26 
27 #ifndef CLIENT_MANAGER_H
28 #define CLIENT_MANAGER_H
29 
30 #include <iostream>
31 #include <memory>
32 
33 #include <yarp/os/RFModule.h>
34 #include <yarp/os/RpcServer.h>
35 
37 #include <ocra/util/Macros.h>
38 
39 
40 
41 namespace ocra_recipes
42 {
48 class ClientManager : public yarp::os::RFModule
49 {
51 public:
54  ClientManager(std::shared_ptr<ControllerClient> customClient, bool suppressPerformanceWarnings=false);
55 
59 
65  bool configure(yarp::os::ResourceFinder &rf);
66 
69  int launchClient();
70 
73  bool interruptModule();
74 
77  bool close();
78 
82  bool updateModule();
83 
86  void printHelp();
87 
91  virtual std::string getManagerName();
92 
93 
94 public:
98  class moduleCallback : public yarp::os::PortReader
99  {
100 
101  public:
102 
106  moduleCallback(ClientManager& newModuleRef);
107 
113  virtual bool read(yarp::os::ConnectionReader& connection);
114 
115  private:
116  ClientManager& moduleRef;
117  };
118 
119 
120 private:
121  void callbackParser(yarp::os::Bottle& message, yarp::os::Bottle& reply);
122 
123 protected:
124  virtual void customCallbackParser(yarp::os::Bottle& message, yarp::os::Bottle& reply);
125  virtual bool customUpdateModule();
126 
127 
128 private:
129  std::shared_ptr<ControllerClient> client;
130  std::shared_ptr<moduleCallback> rpcCallback;
131  yarp::os::RpcServer rpcPort;
132  yarp::os::Log yLog;
134  int expectedClientPeriod;
135  double avgTime;
136  double stdDev;
137  double avgTimeUsed;
138  double stdDevUsed;
140  std::string rpcPortName;
142  static int CONTROLLER_CLIENT_MANAGER_COUNT;
143  int moduleNumber;
145  bool suppressWarnings;
146 
147 };
148 
149 } /* ocra_recipes */
150 
151 #endif
virtual std::string getManagerName()
bool configure(yarp::os::ResourceFinder &rf)
#define DEFINE_CLASS_POINTER_TYPEDEFS(Class)
Definition: Macros.h:8
A callback function which binds the rpc server port opened in the contoller server module to the cont...
Definition: ClientManager.h:98
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.
Definition: ClientManager.h:48