1 | // Copyright (C) 2018 basysKom GmbH, opensource@basyskom.com |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qopcuawriteresult.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | /*! |
9 | \class QOpcUaWriteResult |
10 | \inmodule QtOpcUa |
11 | \brief This class stores the result of a write operation. |
12 | |
13 | A write operation on an OPC UA server returns a status code which describes if the value could |
14 | be written and if not, for what reason the write has failed. |
15 | |
16 | In addition to the status code returned by the server, this class also contains the node id, the attribute and the index |
17 | range from the request to enable a client to match the result with a request. |
18 | |
19 | Objects of this class are returned in the \l QOpcUaClient::writeNodeAttributesFinished() |
20 | signal and contain the result of a write operation that was part of a \l QOpcUaClient::writeNodeAttributes() |
21 | request. |
22 | |
23 | \sa QOpcUaClient::writeNodeAttributes() QOpcUaClient::writeNodeAttributesFinished() QOpcUaWriteItem |
24 | */ |
25 | class QOpcUaWriteResultData : public QSharedData |
26 | { |
27 | public: |
28 | QString nodeId; |
29 | QOpcUa::NodeAttribute attribute {QOpcUa::NodeAttribute::Value}; |
30 | QString indexRange; |
31 | QOpcUa::UaStatusCode statusCode {QOpcUa::UaStatusCode::Good}; |
32 | }; |
33 | |
34 | QOpcUaWriteResult::QOpcUaWriteResult() |
35 | : data(new QOpcUaWriteResultData) |
36 | { |
37 | } |
38 | |
39 | /*! |
40 | Constructs a write result from \a other. |
41 | */ |
42 | QOpcUaWriteResult::QOpcUaWriteResult(const QOpcUaWriteResult &other) |
43 | : data(other.data) |
44 | { |
45 | } |
46 | |
47 | /*! |
48 | Sets the values from \a rhs in this write result. |
49 | */ |
50 | QOpcUaWriteResult &QOpcUaWriteResult::operator=(const QOpcUaWriteResult &rhs) |
51 | { |
52 | if (this != &rhs) |
53 | data.operator=(o: rhs.data); |
54 | return *this; |
55 | } |
56 | |
57 | QOpcUaWriteResult::~QOpcUaWriteResult() |
58 | { |
59 | } |
60 | |
61 | /*! |
62 | Returns the node id of the write result. |
63 | */ |
64 | QString QOpcUaWriteResult::nodeId() const |
65 | { |
66 | return data->nodeId; |
67 | } |
68 | |
69 | /*! |
70 | Sets the node id of the write result to \a nodeId. |
71 | */ |
72 | void QOpcUaWriteResult::setNodeId(const QString &nodeId) |
73 | { |
74 | data->nodeId = nodeId; |
75 | } |
76 | |
77 | /*! |
78 | Returns the attribute of the write result. |
79 | */ |
80 | QOpcUa::NodeAttribute QOpcUaWriteResult::attribute() const |
81 | { |
82 | return data->attribute; |
83 | } |
84 | |
85 | /*! |
86 | Sets the attribute of the write result to \a attribute. |
87 | */ |
88 | void QOpcUaWriteResult::setAttribute(QOpcUa::NodeAttribute attribute) |
89 | { |
90 | data->attribute = attribute; |
91 | } |
92 | |
93 | /*! |
94 | Returns the index range of the write result. |
95 | */ |
96 | QString QOpcUaWriteResult::indexRange() const |
97 | { |
98 | return data->indexRange; |
99 | } |
100 | |
101 | /*! |
102 | Sets the index range of the write result to \a indexRange. |
103 | */ |
104 | void QOpcUaWriteResult::setIndexRange(const QString &indexRange) |
105 | { |
106 | data->indexRange = indexRange; |
107 | } |
108 | |
109 | /*! |
110 | Returns the status code of the write result. |
111 | */ |
112 | QOpcUa::UaStatusCode QOpcUaWriteResult::statusCode() const |
113 | { |
114 | return data->statusCode; |
115 | } |
116 | |
117 | /*! |
118 | Sets the status code of the write result to \a statusCode. |
119 | */ |
120 | void QOpcUaWriteResult::setStatusCode(QOpcUa::UaStatusCode statusCode) |
121 | { |
122 | data->statusCode = statusCode; |
123 | } |
124 | |
125 | QT_END_NAMESPACE |
126 |