This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serialportsettings.cpp
151 lines (136 loc) · 2.7 KB
/
serialportsettings.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//
// SmartServer
// Copyright (C) 2021 АО "Нефтеавтоматика"
//
// Разработчик
// Ананьев А.А. <Ananev-AA@nefteavtomatika.ru>
//
#include <QDataStream>
#include "serialportsettings.h"
///
/// \brief SerialPortSettings::SerialPortSettings
///
SerialPortSettings::SerialPortSettings(const QString& name)
:_name(name)
,_baudRate(QSerialPort::Baud9600)
,_dataBits(QSerialPort::Data8)
,_parity(QSerialPort::NoParity)
,_stopBits(QSerialPort::OneStop)
{
static const int reg = qRegisterMetaType<SerialPortSettings>();
Q_UNUSED(reg)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
static const int regOps = qRegisterMetaTypeStreamOperators<SerialPortSettings>();
Q_UNUSED(regOps)
#endif
}
///
/// \brief SerialPortSettings::name
/// \return
///
QString SerialPortSettings::name() const
{
return _name;
}
///
/// \brief SerialPortSettings::setName
/// \param name
///
void SerialPortSettings::setName(const QString& name)
{
_name = name;
}
///
/// \brief SerialPortSettings::baudRate
/// \return
///
QSerialPort::BaudRate SerialPortSettings::baudRate() const
{
return _baudRate;
}
///
/// \brief SerialPortSettings::setBaudRate
/// \param value
///
void SerialPortSettings::setBaudRate(QSerialPort::BaudRate value)
{
_baudRate = value;
}
///
/// \brief SerialPortSettings::dataBits
/// \return
///
QSerialPort::DataBits SerialPortSettings::dataBits() const
{
return _dataBits;
}
///
/// \brief SerialPortSettings::setDataBits
/// \param value
///
void SerialPortSettings::setDataBits(QSerialPort::DataBits value)
{
_dataBits = value;
}
///
/// \brief SerialPortSettings::parity
/// \return
///
QSerialPort::Parity SerialPortSettings::parity() const
{
return _parity;
}
///
/// \brief SerialPortSettings::setParity
/// \param value
///
void SerialPortSettings::setParity(QSerialPort::Parity value)
{
_parity = value;
}
///
/// \brief SerialPortSettings::stopBits
/// \return
///
QSerialPort::StopBits SerialPortSettings::stopBits() const
{
return _stopBits;
}
///
/// \brief SerialPortSettings::setStopBits
/// \param value
///
void SerialPortSettings::setStopBits(QSerialPort::StopBits value)
{
_stopBits = value;
}
///
/// \brief operator <<
/// \param out
/// \param s
/// \return
///
QDataStream& operator<<(QDataStream& out, const SerialPortSettings& s)
{
out << s._name;
out << s._baudRate;
out << s._dataBits;
out << s._parity;
out << s._stopBits;
return out;
}
///
/// \brief operator >>
/// \param in
/// \param s
/// \return
///
QDataStream& operator>>(QDataStream& in, SerialPortSettings& s)
{
in >> s._name;
in >> s._baudRate;
in >> s._dataBits;
in >> s._parity;
in >> s._stopBits;
return in;
}