Public Member Functions | Private Member Functions | Private Attributes | List of all members
pepperl_fuchs::HttpCommandInterface Class Reference

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. More...
 
const std::string & getHttpHost () const
 Get the HTTP hostname/IP of the scanner. More...
 
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< ProtocolInfogetProtocolInfo ()
 
 HttpCommandInterface (const std::string &http_host, int http_port=80)
 
bool rebootDevice ()
 Reboot laserscanner. More...
 
bool releaseHandle (const std::string &handle)
 Release handle. More...
 
boost::optional< HandleInforequestHandleTCP (int start_angle=-1800000)
 
boost::optional< HandleInforequestHandleUDP (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. More...
 
bool stopScanOutput (const std::string &handle)
 Terminate output of scan data. More...
 

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. More...
 
int http_port_
 Port of HTTP-Interface. More...
 
int http_status_code_
 HTTP-Status code of last request. More...
 
boost::property_tree::ptree pt_
 Returned JSON as property_tree. More...
 

Detailed Description

Allows accessing the HTTP/JSON interface of the Pepperl+Fuchs Laserscanner R2000.

Definition at line 22 of file http_command_interface.h.

Constructor & Destructor Documentation

pepperl_fuchs::HttpCommandInterface::HttpCommandInterface ( const std::string &  http_host,
int  http_port = 80 
)

Setup a new HTTP command interface

Parameters
http_ipIP or DNS name of sensor
http_portHTTP/TCP port of sensor

Definition at line 19 of file http_command_interface.cpp.

Member Function Documentation

bool pepperl_fuchs::HttpCommandInterface::checkErrorCode ( )
private

Check the error code and text of the returned JSON by the last request

Returns
False in case of an error, True otherwise

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

Returns
The local IP as a string, an empty string otherwise

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

Parameters
nameParameter name
Returns
Optional string value with value of given 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

Returns
A vector with the names of all available 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

Parameters
namesParameter names
Returns
vector with string values with the values of the given 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)

Returns
A struct with the requested data

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_

Parameters
requestStrThe last part of an URL with a slash leading
headerThe response header returned as std::string, empty string in case of an error
contentThe response content returned as std::string, empty string in case of an error
Returns
The HTTP status code or 0 in case of an error

Definition at line 27 of file http_command_interface.cpp.

bool pepperl_fuchs::HttpCommandInterface::rebootDevice ( )

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

Parameters
start_angleSet start angle for scans in the range 0,3600000
Returns
A valid HandleInfo on success, an empty boost::optional<HandleInfo> container otherwise

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

Parameters
portSet UDP port where scanner data should be sent to
hostnameOptional: Set hostname/IP where scanner data should be sent to, local IP is determined automatically if not specified
start_angleOptional: Set start angle for scans in the range 0,3600000, defaults to -1800000
Returns
A valid HandleInfo on success, an empty boost::optional<HandleInfo> container otherwise

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

Parameters
namesNames 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

Parameters
cmdcommand name
keys_valuesparameter->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

Parameters
cmdCommand name
paramParameter
valueValue

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

Parameters
nameName
valueValue
Returns
True on success, false otherwise

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.

Member Data Documentation

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.


The documentation for this class was generated from the following files:


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