-
Notifications
You must be signed in to change notification settings - Fork 25
/
abstractmodbusdevice.cpp
53 lines (44 loc) · 1.13 KB
/
abstractmodbusdevice.cpp
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
#include "abstractmodbusdevice.h"
#include <QTime>
#include <QThread>
#include <QDebug>
#include <QMutexLocker>
#include "./Global/highprecisiontimer.h"
AbstractModbusDevice::AbstractModbusDevice(QObject *parent)
: QObject(parent)
{
m_isOpened = false;
m_nBaudrate = 115200;
m_nDataBits = DataBits_8;
m_nStopBits = StopBits_1;
m_nParityBits = ParityNone;
}
bool AbstractModbusDevice::setBaudrate(int nBaudrate)
{
m_nBaudrate = nBaudrate;
return true;
}
bool AbstractModbusDevice::setDataBits(ModbusDataBits dataBits)
{
if ((m_nStopBits == StopBits_2 && dataBits == DataBits_5)
|| (m_nStopBits == StopBits_1_5 && dataBits != DataBits_5))
{
return false;
}
m_nDataBits = dataBits;
return true;
}
bool AbstractModbusDevice::setStopBits(ModbusStopBits stopBits)
{
if ((m_nDataBits == DataBits_5 && stopBits == StopBits_2)
|| (stopBits == StopBits_1_5 && m_nDataBits != DataBits_5))
{
return false;
}
return true;
}
bool AbstractModbusDevice::setParityBits(ModbusParityBits parityBits)
{
m_nParityBits = parityBits;
return true;
}