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 <opcuareaditem_p.h>
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \qmltype ReadItem
10 \inqmlmodule QtOpcUa
11 \brief Specifies an item to be read from the server.
12 \since QtOpcUa 5.13
13
14 This type is used to specify items to be read from the server using the function
15 \l Connection::readNodeAttributes.
16*/
17
18/*!
19 \qmlproperty Constants.NodeAttribute ReadItem::attribute
20
21 Determines the attribute of the node to be read.
22*/
23
24/*!
25 \qmlproperty string ReadItem::indexRange
26
27 Determines the index range of the attribute to be read.
28 If not needed, leave this property empty.
29*/
30
31/*!
32 \qmlproperty string ReadItem::nodeId
33
34 Determines the node id of the node to be read.
35*/
36
37/*!
38 \qmlproperty variant ReadItem::ns
39
40 Determines the namespace of the node to be read.
41 The namespace can be given by name or index.
42 If this property is given, any namespace in the node id will be
43 ignored.
44*/
45
46class OpcUaReadItemData : public QSharedData
47{
48public:
49 QOpcUa::NodeAttribute attribute;
50 QString indexRange;
51 QString nodeId;
52 QVariant namespaceIdentifier;
53};
54
55OpcUaReadItem::OpcUaReadItem()
56 : data(new OpcUaReadItemData)
57{
58 data->attribute = QOpcUa::NodeAttribute::Value;
59}
60
61OpcUaReadItem::OpcUaReadItem(const OpcUaReadItem &other)
62 : data(other.data)
63{
64}
65
66OpcUaReadItem &OpcUaReadItem::operator=(const OpcUaReadItem &rhs)
67{
68 if (this != &rhs)
69 data.operator=(o: rhs.data);
70 return *this;
71}
72
73OpcUaReadItem::~OpcUaReadItem() = default;
74
75const QString &OpcUaReadItem::indexRange() const
76{
77 return data->indexRange;
78}
79
80void OpcUaReadItem::setIndexRange(const QString &indexRange)
81{
82 data->indexRange = indexRange;
83}
84
85const QString &OpcUaReadItem::nodeId() const
86{
87 return data->nodeId;
88}
89
90void OpcUaReadItem::setNodeId(const QString &nodeId)
91{
92 data->nodeId = nodeId;
93}
94
95QOpcUa::NodeAttribute OpcUaReadItem::attribute() const
96{
97 return data->attribute;
98}
99
100void OpcUaReadItem::setAttribute(QOpcUa::NodeAttribute attribute)
101{
102 data->attribute = attribute;
103}
104
105const QVariant &OpcUaReadItem::namespaceIdentifier() const
106{
107 return data->namespaceIdentifier;
108}
109
110void OpcUaReadItem::setNamespaceIdentifier(const QVariant &namespaceIdentifier)
111{
112 data->namespaceIdentifier = namespaceIdentifier;
113}
114
115OpcUaReadItem OpcUaReadItemFactory::create()
116{
117 return OpcUaReadItem();
118}
119
120QT_END_NAMESPACE
121
122

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