http_command_interface.h
Go to the documentation of this file.
00001 // Copyright (c) 2014, Pepperl+Fuchs GmbH, Mannheim
00002 // Copyright (c) 2014, Denis Dillenberger
00003 // All rights reserved.
00004 //
00005 // Use, modification, and distribution is subject to the
00006 // 3-clause BSD license ("Revised BSD License",
00007 // "New BSD License", or "Modified BSD License")
00008 // You should have received a copy of this license
00009 // in a file named COPYING or LICENSE.
00010 
00011 #ifndef HTTP_COMMAND_INTERFACE_H
00012 #define HTTP_COMMAND_INTERFACE_H
00013 #include <string>
00014 #include <map>
00015 #include <boost/property_tree/ptree.hpp>
00016 #include <pepperl_fuchs_r2000/protocol_info.h>
00017 
00018 namespace pepperl_fuchs {
00019 
00022 class HttpCommandInterface
00023 {
00024 public:
00028     HttpCommandInterface(const std::string& http_host, int http_port=80);
00029 
00031     const std::string& getHttpHost() const { return http_host_; }
00032 
00037     bool setParameter(const std::string name, const std::string value);
00038 
00042     boost::optional<std::string> getParameter(const std::string name);
00043 
00047     std::map< std::string, std::string > getParameters( const std::vector< std::string >& names );
00048 
00051     std::vector< std::string > getParameterList();
00052 
00055     boost::optional<ProtocolInfo> getProtocolInfo();
00056 
00060     boost::optional<HandleInfo> requestHandleTCP(int start_angle=-1800000);
00061 
00067     boost::optional<HandleInfo> requestHandleUDP(int port, std::string hostname = std::string(""), int start_angle=-1800000);
00068 
00070     bool releaseHandle( const std::string& handle );
00071 
00073     bool startScanOutput( const std::string& handle );
00074 
00076     bool stopScanOutput( const std::string& handle );
00077 
00079     bool feedWatchdog( const std::string& handle );
00080 
00082     bool rebootDevice();
00083 
00086     bool resetParameters(const std::vector< std::string >& names);
00087 
00090     std::string discoverLocalIP();
00091 
00092 private:
00093 
00099     int httpGet(const std::string request_path, std::string& header, std::string& content);
00100 
00104     bool sendHttpCommand(const std::string cmd, const std::map< std::string, std::string > param_values );
00105 
00110     bool sendHttpCommand(const std::string cmd, const std::string param = "", const std::string value = "" );
00111 
00114     bool checkErrorCode();
00115 
00117     std::string http_host_;
00118 
00120     int http_port_;
00121 
00123     boost::property_tree::ptree pt_;
00124 
00126     int http_status_code_;
00127 
00128 };
00129 }
00130 
00131 #endif // HTTP_COMMAND_INTERFACE_H


pepperl_fuchs_r2000
Author(s): Denis Dillenberger
autogenerated on Wed Aug 26 2015 15:22:22