Roomba App  1.0
communication.hh
Go to the documentation of this file.
1 
12 #ifndef COMMUNICATION_HH
13 #define COMMUNICATION_HH
14 
15 #include <QLabel>
16 #include <QSerialPort>
17 
18 #include "frameBuffer.hh"
19 
24 {
28  QSerialPort* _device = nullptr;
29 
34 
38  bool _continue = true;
39 
43  std::string _deviceName;
44 
48  bool _opened = false;
49 
50  public:
54  Communication();
55 
60 
65  void setDeviceName(const std::string& name) { _deviceName = name; }
66 
71  void setDevice(QSerialPort* device) { _device = device; }
72 
80  bool openSerialPort(const char* serialPort);
81 
88  bool openSerialPort() { return openSerialPort(_deviceName.c_str()); }
89 
96  bool closeSerialPort();
97 
104  bool isOpen() { return _opened; }
105 
110  void setStatus(QLabel* statusBar);
111 
117 
122  const FrameBuffer& getFrameBuffer() const { return _frame; }
123 
130  bool toContinue() const { return _continue; }
131 
135  void endCommunication() { _continue = false; }
136 
140  void receiveData();
141 };
142 
143 #endif // COMMUNICATION_HH
The Communication class.
const FrameBuffer & getFrameBuffer() const
Get unmodifiable frame buffer.
void receiveData()
Receive line one by one in loop until end of communication.
std::string _deviceName
Serial device name.
FrameBuffer & useFrameBuffer()
Get modifiable frame buffer.
bool closeSerialPort()
Close serial port.
~Communication()
Destruct Communication object.
QSerialPort * _device
Serial device handle.
bool _continue
Identifier whether to continue communicating with the serial.
Communication()
Construct new Communication object.
void setDevice(QSerialPort *device)
Set serial device.
void setDeviceName(const std::string &name)
Set serial device name.
bool openSerialPort()
Wraper function for opening serial port.
void setStatus(QLabel *statusBar)
Set status of port openning on status bar.
void endCommunication()
End communicaiton with serial device.
bool isOpen()
Check wether serial poet is open.
bool toContinue() const
Check wether to continue communication with serial device.
FrameBuffer _frame
Frames buffer.
bool _opened
Identifier whether serial device is open.
The FrameBuffer class.
Definition: frameBuffer.hh:24
Header file for FrameBuffer class.