Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef RC_DYNAMICS_API_REMOTEINTERFACE_H
00037 #define RC_DYNAMICS_API_REMOTEINTERFACE_H
00038
00039 #include <string>
00040 #include <list>
00041 #include <memory>
00042 #include <iostream>
00043
00044 #include <netinet/in.h>
00045
00046 #include "roboception/msgs/frame.pb.h"
00047 #include "roboception/msgs/dynamics.pb.h"
00048 #include "roboception/msgs/imu.pb.h"
00049
00050 #include "data_receiver.h"
00051 #include "net_utils.h"
00052
00053 namespace rc
00054 {
00055 namespace dynamics
00056 {
00057
00058
00080 class RemoteInterface : public std::enable_shared_from_this<RemoteInterface>
00081 {
00082 public:
00083
00084 using Ptr = std::shared_ptr<RemoteInterface>;
00085
00086 enum State
00087 {
00088 RUNNING,
00089 STOPPED
00090 };
00091
00092
00099 static Ptr create(const std::string &rcVisardIP,
00100 unsigned int requestsTimeout = 5000);
00101
00102 virtual ~RemoteInterface();
00103
00109 void start(bool flagRestart = false);
00110
00114 void stop();
00115
00121 State getState();
00122
00127 std::list<std::string> getAvailableStreams();
00128
00137 std::string getPbMsgTypeOfStream(const std::string &stream);
00138
00139
00149 std::list<std::string> getDestinationsOfStream(const std::string &stream);
00150
00151
00159 void addDestinationToStream(const std::string &stream,
00160 const std::string &destination);
00161
00169 void deleteDestinationFromStream(const std::string &stream,
00170 const std::string &destination);
00171
00177 void deleteAllDestinationsFromStream(const std::string &stream);
00178
00200 DataReceiver::Ptr
00201 createReceiverForStream(const std::string &stream,
00202 const std::string &destInterface = "",
00203 unsigned int destPort = 0);
00204
00205
00206 protected:
00207
00208 static std::map<std::string, RemoteInterface::Ptr> _remoteInterfaces;
00209
00210 RemoteInterface(const std::string& rcVisardIP,
00211 unsigned int requestsTimeout = 5000);
00212
00213 void cleanUpRequestedStreams();
00214 void checkStreamTypeAvailable(const std::string& stream);
00215
00216 std::string _visardAddrs;
00217 std::map<std::string, std::list<std::string>> _reqStreams;
00218 std::list<std::string> _availStreams;
00219 std::map<std::string, std::string> _protobufMap;
00220 std::string _baseUrl;
00221 int _timeoutCurl;
00222 };
00223
00224 }
00225 }
00226
00227
00228 #endif //RC_DYNAMICS_API_REMOTEINTERFACE_H