Allows accessing the HTTP/JSON interface of the Pepperl+Fuchs Laserscanner R2000. More...
#include <http_command_interface.h>
Public Member Functions | |
std::string | discoverLocalIP () |
bool | feedWatchdog (const std::string &handle) |
Feed the watchdog to keep the handle alive. | |
const std::string & | getHttpHost () const |
Get the HTTP hostname/IP of the scanner. | |
boost::optional< std::string > | getParameter (const std::string name) |
std::vector< std::string > | getParameterList () |
std::map< std::string, std::string > | getParameters (const std::vector< std::string > &names) |
boost::optional< ProtocolInfo > | getProtocolInfo () |
HttpCommandInterface (const std::string &http_host, int http_port=80) | |
bool | rebootDevice () |
Reboot laserscanner. | |
bool | releaseHandle (const std::string &handle) |
Release handle. | |
boost::optional< HandleInfo > | requestHandleTCP (int start_angle=-1800000) |
boost::optional< HandleInfo > | requestHandleUDP (int port, std::string hostname=std::string(""), int start_angle=-1800000) |
bool | resetParameters (const std::vector< std::string > &names) |
bool | setParameter (const std::string name, const std::string value) |
bool | startScanOutput (const std::string &handle) |
Initiate output of scan data. | |
bool | stopScanOutput (const std::string &handle) |
Terminate output of scan data. | |
Private Member Functions | |
bool | checkErrorCode () |
int | httpGet (const std::string request_path, std::string &header, std::string &content) |
bool | sendHttpCommand (const std::string cmd, const std::map< std::string, std::string > param_values) |
bool | sendHttpCommand (const std::string cmd, const std::string param="", const std::string value="") |
Private Attributes | |
std::string | http_host_ |
Scanner IP. | |
int | http_port_ |
Port of HTTP-Interface. | |
int | http_status_code_ |
HTTP-Status code of last request. | |
boost::property_tree::ptree | pt_ |
Returned JSON as property_tree. |
Allows accessing the HTTP/JSON interface of the Pepperl+Fuchs Laserscanner R2000.
Definition at line 22 of file http_command_interface.h.
pepperl_fuchs::HttpCommandInterface::HttpCommandInterface | ( | const std::string & | http_host, |
int | http_port = 80 |
||
) |
Setup a new HTTP command interface
http_ip | IP or DNS name of sensor |
http_port | HTTP/TCP port of sensor |
Definition at line 19 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::checkErrorCode | ( | ) | [private] |
Check the error code and text of the returned JSON by the last request
Definition at line 207 of file http_command_interface.cpp.
std::string pepperl_fuchs::HttpCommandInterface::discoverLocalIP | ( | ) |
Discovers the local IP of the NIC which talks to the laser range finder
Definition at line 397 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::feedWatchdog | ( | const std::string & | handle | ) |
Feed the watchdog to keep the handle alive.
Definition at line 366 of file http_command_interface.cpp.
const std::string& pepperl_fuchs::HttpCommandInterface::getHttpHost | ( | ) | const [inline] |
Get the HTTP hostname/IP of the scanner.
Definition at line 31 of file http_command_interface.h.
boost::optional< std::string > pepperl_fuchs::HttpCommandInterface::getParameter | ( | const std::string | name | ) |
Get sensor parameter
name | Parameter name |
Definition at line 172 of file http_command_interface.cpp.
std::vector< std::string > pepperl_fuchs::HttpCommandInterface::getParameterList | ( | ) |
List available ro/rw parameters
Definition at line 253 of file http_command_interface.cpp.
std::map< std::string, std::string > pepperl_fuchs::HttpCommandInterface::getParameters | ( | const std::vector< std::string > & | names | ) |
Get multiple sensor parameters
names | Parameter names |
Definition at line 180 of file http_command_interface.cpp.
boost::optional< ProtocolInfo > pepperl_fuchs::HttpCommandInterface::getProtocolInfo | ( | ) |
Get protocol info (protocol_name, version, commands)
Definition at line 222 of file http_command_interface.cpp.
int pepperl_fuchs::HttpCommandInterface::httpGet | ( | const std::string | request_path, |
std::string & | header, | ||
std::string & | content | ||
) | [private] |
Send a HTTP-GET request to http_ip_ at http_port_
requestStr | The last part of an URL with a slash leading |
header | The response header returned as std::string, empty string in case of an error |
content | The response content returned as std::string, empty string in case of an error |
Definition at line 27 of file http_command_interface.cpp.
Reboot laserscanner.
Definition at line 374 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::releaseHandle | ( | const std::string & | handle | ) |
Release handle.
Definition at line 343 of file http_command_interface.cpp.
boost::optional< HandleInfo > pepperl_fuchs::HttpCommandInterface::requestHandleTCP | ( | int | start_angle = -1800000 | ) |
Request TCP handle
start_angle | Set start angle for scans in the range [0,3600000] (1/10000°) |
Definition at line 278 of file http_command_interface.cpp.
boost::optional< HandleInfo > pepperl_fuchs::HttpCommandInterface::requestHandleUDP | ( | int | port, |
std::string | hostname = std::string("") , |
||
int | start_angle = -1800000 |
||
) |
Request UDP handle
port | Set UDP port where scanner data should be sent to |
hostname | Optional: Set hostname/IP where scanner data should be sent to, local IP is determined automatically if not specified |
start_angle | Optional: Set start angle for scans in the range [0,3600000] (1/10000°), defaults to -1800000 |
Definition at line 309 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::resetParameters | ( | const std::vector< std::string > & | names | ) |
Reset laserscanner parameters to factory default
names | Names of parameters to reset |
Definition at line 382 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::sendHttpCommand | ( | const std::string | cmd, |
const std::map< std::string, std::string > | param_values | ||
) | [private] |
Send a sensor specific HTTP-Command
cmd | command name |
keys_values | parameter->value map, which is encoded in the GET-request: ?p1=v1&p2=v2 |
Definition at line 124 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::sendHttpCommand | ( | const std::string | cmd, |
const std::string | param = "" , |
||
const std::string | value = "" |
||
) | [private] |
Send a sensor specific HTTP-Command with a single parameter
cmd | Command name |
param | Parameter |
value | Value |
Definition at line 157 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::setParameter | ( | const std::string | name, |
const std::string | value | ||
) |
Set sensor parameter
name | Name |
value | Value |
Definition at line 166 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::startScanOutput | ( | const std::string & | handle | ) |
Initiate output of scan data.
Definition at line 351 of file http_command_interface.cpp.
bool pepperl_fuchs::HttpCommandInterface::stopScanOutput | ( | const std::string & | handle | ) |
Terminate output of scan data.
Definition at line 359 of file http_command_interface.cpp.
std::string pepperl_fuchs::HttpCommandInterface::http_host_ [private] |
Scanner IP.
Definition at line 117 of file http_command_interface.h.
int pepperl_fuchs::HttpCommandInterface::http_port_ [private] |
Port of HTTP-Interface.
Definition at line 120 of file http_command_interface.h.
int pepperl_fuchs::HttpCommandInterface::http_status_code_ [private] |
HTTP-Status code of last request.
Definition at line 126 of file http_command_interface.h.
boost::property_tree::ptree pepperl_fuchs::HttpCommandInterface::pt_ [private] |
Returned JSON as property_tree.
Definition at line 123 of file http_command_interface.h.