http_command_interface.h
Go to the documentation of this file.
1 // Copyright (c) 2014, Pepperl+Fuchs GmbH, Mannheim
2 // Copyright (c) 2014, Denis Dillenberger
3 // All rights reserved.
4 //
5 // Use, modification, and distribution is subject to the
6 // 3-clause BSD license ("Revised BSD License",
7 // "New BSD License", or "Modified BSD License")
8 // You should have received a copy of this license
9 // in a file named COPYING or LICENSE.
10 
11 #ifndef HTTP_COMMAND_INTERFACE_H
12 #define HTTP_COMMAND_INTERFACE_H
13 #include <string>
14 #include <map>
15 #include <boost/property_tree/ptree.hpp>
17 
18 namespace pepperl_fuchs {
19 
23 {
24 public:
28  HttpCommandInterface(const std::string& http_host, int http_port=80);
29 
31  const std::string& getHttpHost() const { return http_host_; }
32 
37  bool setParameter(const std::string name, const std::string value);
38 
42  boost::optional<std::string> getParameter(const std::string name);
43 
47  std::map< std::string, std::string > getParameters( const std::vector< std::string >& names );
48 
51  std::vector< std::string > getParameterList();
52 
55  boost::optional<ProtocolInfo> getProtocolInfo();
56 
60  boost::optional<HandleInfo> requestHandleTCP(int start_angle=-1800000);
61 
67  boost::optional<HandleInfo> requestHandleUDP(int port, std::string hostname = std::string(""), int start_angle=-1800000);
68 
70  bool releaseHandle( const std::string& handle );
71 
73  bool startScanOutput( const std::string& handle );
74 
76  bool stopScanOutput( const std::string& handle );
77 
79  bool feedWatchdog( const std::string& handle );
80 
82  bool rebootDevice();
83 
86  bool resetParameters(const std::vector< std::string >& names);
87 
90  std::string discoverLocalIP();
91 
92 private:
93 
99  int httpGet(const std::string request_path, std::string& header, std::string& content);
100 
104  bool sendHttpCommand(const std::string cmd, const std::map< std::string, std::string > param_values );
105 
110  bool sendHttpCommand(const std::string cmd, const std::string param = "", const std::string value = "" );
111 
114  bool checkErrorCode();
115 
117  std::string http_host_;
118 
121 
123  boost::property_tree::ptree pt_;
124 
127 
128 };
129 }
130 
131 #endif // HTTP_COMMAND_INTERFACE_H
bool param(const std::string &param_name, T &param_val, const T &default_val)
bool setParameter(const std::string name, const std::string value)
int httpGet(const std::string request_path, std::string &header, std::string &content)
bool startScanOutput(const std::string &handle)
Initiate output of scan data.
bool sendHttpCommand(const std::string cmd, const std::map< std::string, std::string > param_values)
bool resetParameters(const std::vector< std::string > &names)
boost::optional< HandleInfo > requestHandleTCP(int start_angle=-1800000)
HttpCommandInterface(const std::string &http_host, int http_port=80)
const std::string & getHttpHost() const
Get the HTTP hostname/IP of the scanner.
boost::optional< std::string > getParameter(const std::string name)
std_msgs::Header * header(M &m)
bool releaseHandle(const std::string &handle)
Release handle.
int http_status_code_
HTTP-Status code of last request.
std::map< std::string, std::string > getParameters(const std::vector< std::string > &names)
boost::optional< HandleInfo > requestHandleUDP(int port, std::string hostname=std::string(""), int start_angle=-1800000)
Allows accessing the HTTP/JSON interface of the Pepperl+Fuchs Laserscanner R2000. ...
boost::optional< ProtocolInfo > getProtocolInfo()
int http_port_
Port of HTTP-Interface.
bool stopScanOutput(const std::string &handle)
Terminate output of scan data.
boost::property_tree::ptree pt_
Returned JSON as property_tree.
std::vector< std::string > getParameterList()
bool feedWatchdog(const std::string &handle)
Feed the watchdog to keep the handle alive.


pepperl_fuchs_r2000
Author(s): Denis Dillenberger
autogenerated on Mon Jun 10 2019 14:12:48