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

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