remote_interface.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of the rc_dynamics_api package.
00003  *
00004  * Copyright (c) 2017 Roboception GmbH
00005  * All rights reserved
00006  *
00007  * Author: Christian Emmerich
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright notice,
00013  * this list of conditions and the following disclaimer.
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright notice,
00016  * this list of conditions and the following disclaimer in the documentation
00017  * and/or other materials provided with the distribution.
00018  *
00019  * 3. Neither the name of the copyright holder nor the names of its contributors
00020  * may be used to endorse or promote products derived from this software without
00021  * specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  * POSSIBILITY OF SUCH DAMAGE.
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


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06