serialportApi.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <boost/function.hpp>
6 #include <boost/system/error_code.hpp>
7 #include <boost/shared_ptr.hpp>
8 #include <vector>
9 
10 #include "serialportTypes.h"
11 
12 class SerialPortClient;
13 
14 //To avoid redefinition in client and app
15 #ifndef SERIALPORT_TYPES
16 #define SERIALPORT_TYPES
17 
23 namespace dpySerialPort {
24 
30 {
31 
32 public:
37  virtual void updateAvailability(const bool &available) = 0;
38 
43  {
44  }
45 };
46 
54 typedef boost::function<void(boost::system::error_code &ec)> handler_function;
55 
61 typedef boost::function<void(boost::system::error_code, std::map<std::string, dpySerialPort::SerialPortConf> serialPortMap)> serialPort_list_handler;
62 
69 typedef boost::function<void(boost::system::error_code error_code, const std::string &portid, const std::string &data)> serialport_receive_handler_function;
70 
71 } //dpyService
72 
73 #endif
74 
75 //Note that the SerialPortApiCPP group must be defined in the general documentation
82 {
83 
84 private:
85  boost::shared_ptr<SerialPortClient> mClient;
86  std::vector<dpySerialPort::SerialPortAvailabilityObserver*> mAvailObserverList;
87 public:
88 
95  explicit SerialPortManager(std::string ip = "127.0.0.1");
97  bool isAlive();
98 
99  void serialPortEvent_S(dpySerialPort::serialport_receive_handler_function handler);
100  void serialPortEvent_U();
101 
102  /*
103  * @brief Method which requests serial port list
104  * @param handler Handler to be called when a response comes from the service
105  */
106  void GetSerialPortList(dpySerialPort::serialPort_list_handler handler);
107 
108  boost::system::error_code monitorServiceAvailability_S(dpySerialPort::SerialPortAvailabilityObserver *observer);
109  boost::system::error_code monitorServiceAvailability_U(dpySerialPort::SerialPortAvailabilityObserver *observer);
110 
117  void asyncSetSerialPortConfiguration(dpySerialPort::handler_function handler, const std::string &portid, dpySerialPort::SerialPortConf serialPortConfiguration);
118 
125  void syncSend(dpySerialPort::handler_function handler, const std::string &portid, const std::string &data);
126 };
boost::function< void(boost::system::error_code, std::map< std::string, dpySerialPort::SerialPortConf > serialPortMap)> serialPort_list_handler
Prototype of the handler function for getting serial port list.
Definition: serialportApi.h:61
virtual ~SerialPortAvailabilityObserver()
Destructor.
Definition: serialportApi.h:42
Definition: serialportTypes.h:44
Service Availability observer class.
Definition: serialportApi.h:29
boost::function< void(boost::system::error_code error_code, const std::string &portid, const std::string &data)> serialport_receive_handler_function
Prototype of the handler function for receiving serial port message.
Definition: serialportApi.h:69
Allows to interact with a SerialPort service.
Definition: serialportApi.h:81
boost::function< void(boost::system::error_code &ec)> handler_function
Handler for status function callback.
Definition: serialportApi.h:54
virtual void updateAvailability(const bool &available)=0
Method called when service availability changes.
Deepsy SERIAL PORT namespace that includes the different enums, structs or method signatures that sho...
Interacts with SerialPort service.
Definition: serialportClient.h:12