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 | /*! |
35 | Default constructs a write result with no parameters set. |
36 | */ |
37 | QOpcUaWriteResult::QOpcUaWriteResult() |
38 | : data(new QOpcUaWriteResultData) |
39 | { |
40 | } |
41 | |
42 | /*! |
43 | Constructs a write result from \a other. |
44 | */ |
45 | QOpcUaWriteResult::QOpcUaWriteResult(const QOpcUaWriteResult &other) |
46 | : data(other.data) |
47 | { |
48 | } |
49 | |
50 | /*! |
51 | Sets the values from \a rhs in this write result. |
52 | */ |
53 | QOpcUaWriteResult &QOpcUaWriteResult::operator=(const QOpcUaWriteResult &rhs) |
54 | { |
55 | if (this != &rhs) |
56 | data.operator=(o: rhs.data); |
57 | return *this; |
58 | } |
59 | |
60 | QOpcUaWriteResult::~QOpcUaWriteResult() |
61 | { |
62 | } |
63 | |
64 | /*! |
65 | Returns the node id of the write result. |
66 | */ |
67 | QString QOpcUaWriteResult::nodeId() const |
68 | { |
69 | return data->nodeId; |
70 | } |
71 | |
72 | /*! |
73 | Sets the node id of the write result to \a nodeId. |
74 | */ |
75 | void QOpcUaWriteResult::setNodeId(const QString &nodeId) |
76 | { |
77 | data->nodeId = nodeId; |
78 | } |
79 | |
80 | /*! |
81 | Returns the attribute of the write result. |
82 | */ |
83 | QOpcUa::NodeAttribute QOpcUaWriteResult::attribute() const |
84 | { |
85 | return data->attribute; |
86 | } |
87 | |
88 | /*! |
89 | Sets the attribute of the write result to \a attribute. |
90 | */ |
91 | void QOpcUaWriteResult::setAttribute(QOpcUa::NodeAttribute attribute) |
92 | { |
93 | data->attribute = attribute; |
94 | } |
95 | |
96 | /*! |
97 | Returns the index range of the write result. |
98 | */ |
99 | QString QOpcUaWriteResult::indexRange() const |
100 | { |
101 | return data->indexRange; |
102 | } |
103 | |
104 | /*! |
105 | Sets the index range of the write result to \a indexRange. |
106 | */ |
107 | void QOpcUaWriteResult::setIndexRange(const QString &indexRange) |
108 | { |
109 | data->indexRange = indexRange; |
110 | } |
111 | |
112 | /*! |
113 | Returns the status code of the write result. |
114 | */ |
115 | QOpcUa::UaStatusCode QOpcUaWriteResult::statusCode() const |
116 | { |
117 | return data->statusCode; |
118 | } |
119 | |
120 | /*! |
121 | Sets the status code of the write result to \a statusCode. |
122 | */ |
123 | void QOpcUaWriteResult::setStatusCode(QOpcUa::UaStatusCode statusCode) |
124 | { |
125 | data->statusCode = statusCode; |
126 | } |
127 | |
128 | QT_END_NAMESPACE |
129 | |