1 | // Copyright (C) 2017 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QMODBUSREPLY_H |
5 | #define QMODBUSREPLY_H |
6 | |
7 | #include <QtCore/qlist.h> |
8 | #include <QtSerialBus/qmodbusdataunit.h> |
9 | #include <QtSerialBus/qmodbusdevice.h> |
10 | #include <QtSerialBus/qmodbuspdu.h> |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QModbusReplyPrivate; |
15 | |
16 | class Q_SERIALBUS_EXPORT QModbusReply : public QObject |
17 | { |
18 | Q_OBJECT |
19 | Q_DECLARE_PRIVATE(QModbusReply) |
20 | |
21 | public: |
22 | enum ReplyType { |
23 | Raw, |
24 | Common, |
25 | Broadcast |
26 | }; |
27 | Q_ENUM(ReplyType) |
28 | |
29 | QModbusReply(ReplyType type, int serverAddress, QObject *parent = nullptr); |
30 | |
31 | ReplyType type() const; |
32 | int serverAddress() const; |
33 | |
34 | bool isFinished() const; |
35 | |
36 | QModbusDataUnit result() const; |
37 | QModbusResponse rawResult() const; |
38 | |
39 | QString errorString() const; |
40 | QModbusDevice::Error error() const; |
41 | |
42 | void setResult(const QModbusDataUnit &unit); |
43 | void setRawResult(const QModbusResponse &unit); |
44 | |
45 | void setFinished(bool isFinished); |
46 | void setError(QModbusDevice::Error error, const QString &errorText); |
47 | |
48 | QList<QModbusDevice::IntermediateError> intermediateErrors() const; |
49 | void addIntermediateError(QModbusDevice::IntermediateError error); |
50 | |
51 | Q_SIGNALS: |
52 | void finished(); |
53 | void errorOccurred(QModbusDevice::Error error); |
54 | void intermediateErrorOccurred(QModbusDevice::IntermediateError error); |
55 | }; |
56 | Q_DECLARE_TYPEINFO(QModbusReply::ReplyType, Q_PRIMITIVE_TYPE); |
57 | |
58 | QT_END_NAMESPACE |
59 | |
60 | #endif // QMODBUSREPLY_H |
61 |