1// Copyright (C) 2019 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#include <private/opcuawriteresult_p.h>
5#include <private/universalnode_p.h>
6
7#include <QOpcUaWriteResult>
8#include <QOpcUaClient>
9#include <qopcuatype.h>
10
11QT_BEGIN_NAMESPACE
12
13/*!
14 \qmltype WriteResult
15 \inqmlmodule QtOpcUa
16 \brief Contains result data after writing to the server.
17 \since QtOpcUa 5.13
18
19 This type is used to pass the results after writing to the server using the function
20 \l Connection::writeNodeAttributes.
21
22 \sa WriteItem
23*/
24
25/*!
26 \qmlproperty Constants.NodeAttribute WriteResult::attribute
27 \readonly
28
29 The node attribute of data that was written.
30*/
31
32/*!
33 \qmlproperty string WriteResult::indexRange
34 \readonly
35
36 The index range of the data that was written.
37*/
38
39/*!
40 \qmlproperty string WriteResult::nodeId
41 \readonly
42
43 The node id of the node that was written.
44*/
45
46/*!
47 \qmlproperty string WriteResult::namespaceName
48 \readonly
49
50 The namespace name of the node that was written.
51*/
52
53/*!
54 \qmlproperty Status WriteResult::status
55 \readonly
56
57 Result status of this WriteResult.
58 If the write request was successful the status is \l {Status::Status}
59 {Status.Good}.
60*/
61
62class OpcUaWriteResultData : public QSharedData
63{
64public:
65 OpcUaStatus status;
66 QOpcUa::NodeAttribute attribute;
67 QString indexRange;
68 QString nodeId;
69 QString namespaceName;
70};
71
72OpcUaWriteResult::OpcUaWriteResult()
73 : data(new OpcUaWriteResultData)
74{
75 data->attribute = QOpcUa::NodeAttribute::None;
76}
77
78OpcUaWriteResult::OpcUaWriteResult(const OpcUaWriteResult &other)
79 : data(other.data)
80{
81}
82
83OpcUaWriteResult::OpcUaWriteResult(const QOpcUaWriteResult &other, const QOpcUaClient *client)
84 : data(new OpcUaWriteResultData)
85{
86 data->status = OpcUaStatus(other.statusCode());
87 data->attribute = other.attribute();
88 data->indexRange = other.indexRange();
89
90 int namespaceIndex = -1;
91 UniversalNode::splitNodeIdAndNamespace(nodeIdentifier: other.nodeId(), namespaceIndex: &namespaceIndex, identifier: &data->nodeId);
92 data->namespaceName = client->namespaceArray().at(i: namespaceIndex);
93}
94
95OpcUaWriteResult &OpcUaWriteResult::operator=(const OpcUaWriteResult &rhs)
96{
97 if (this != &rhs)
98 data.operator=(o: rhs.data);
99 return *this;
100}
101
102OpcUaWriteResult::~OpcUaWriteResult() = default;
103
104const QString &OpcUaWriteResult::indexRange() const
105{
106 return data->indexRange;
107}
108
109const QString &OpcUaWriteResult::nodeId() const
110{
111 return data->nodeId;
112}
113
114QOpcUa::NodeAttribute OpcUaWriteResult::attribute() const
115{
116 return data->attribute;
117}
118
119const QString &OpcUaWriteResult::namespaceName() const
120{
121 return data->namespaceName;
122}
123
124OpcUaStatus OpcUaWriteResult::status() const
125{
126 return data->status;
127}
128
129QT_END_NAMESPACE
130
131

source code of qtopcua/src/declarative_opcua/opcuawriteresult.cpp