-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeater.hpp
51 lines (35 loc) · 1.06 KB
/
Heater.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef HEATER_HPP
#define HEATER_HPP
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QList>
#include <QDebug>
#include "HeaterCommand.hpp"
#include "HeaterResponse.hpp"
Q_DECLARE_METATYPE(QSerialPortInfo)
class Heater : public QObject
{
Q_OBJECT
public:
Heater(QObject* parent = NULL);
~Heater();
bool serialConnect(const QSerialPortInfo& port, bool emit_errors = true);
bool serialAutoconnect();
void serialDisconnect();
inline bool isConnected() const { return this->is_connected; }
const HeaterResponse sendCommand(const HeaterCommand& cmd);
signals:
void heater_connected(const QSerialPort& port);
void heater_disconnected();
void serial_error(const QString& category, const QString& message);
void heater_got_value(const HeaterResponse& value);
private slots:
void readData();
void handleError(QSerialPort::SerialPortError error);
private:
QSerialPort serial;
bool is_connected;
QByteArray received_data;
bool setSerialSettings();
};
#endif // HEATER_HPP