-
Notifications
You must be signed in to change notification settings - Fork 25
/
abstractmodbusdevice.h
60 lines (49 loc) · 1.21 KB
/
abstractmodbusdevice.h
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
52
53
54
55
56
57
58
59
60
#ifndef ABSTRACTMODBUSDEVICE_H
#define ABSTRACTMODBUSDEVICE_H
#include <QObject>
#include <QQueue>
#include <QMutex>
#include "./Global/global.h"
#include "./Global/highprecisiontimer.h"
enum ModbusDataBits
{
DataBits_5 = 0,
DataBits_6,
DataBits_7,
DataBits_8
};
enum ModbusStopBits
{
StopBits_1 = 0,
StopBits_1_5,
StopBits_2
};
enum ModbusParityBits
{
ParityNone = 0,
ParityOdd,
ParityEven
};
class AbstractModbusDevice : public QObject
{
Q_OBJECT
public:
explicit AbstractModbusDevice(QObject *parent = 0);
virtual bool open() = 0;
virtual void close() = 0;
virtual bool isOpen(){return m_isOpened;}
virtual bool setBaudrate(int nBaudrate);
virtual bool setDataBits(ModbusDataBits dataBits);
virtual bool setStopBits(ModbusStopBits stopBits);
virtual bool setParityBits(ModbusParityBits parityBits);
virtual int recvData(char* buf, int maxSize) = 0;
virtual int sendData(const QByteArray &datas) = 0;
protected:
bool m_isOpened;
HighPrecisionTimer m_hpTimer;
int m_nBaudrate;
ModbusDataBits m_nDataBits;
ModbusStopBits m_nStopBits;
ModbusParityBits m_nParityBits;
};
#endif // ABSTRACTMODBUSDEVICE_H