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/opcuaelementoperand_p.h>
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \qmltype ElementOperand
10 \inqmlmodule QtOpcUa
11 \brief The OPC UA ElementOperand type.
12 \since QtOpcUa 5.13
13 \deprecated [6.9]
14
15 The ElementOperand is defined in OPC UA 1.05 part 4, 7.7.4.2.
16 It is used to identify another element in the filter by its index
17 (the first element has the index 0).
18
19 This is required to create complex filters, for example to reference
20 the two operands of the AND operation in ((Severity > 500) AND (Message == "TestString")).
21 The first step is to create content filter elements for the two conditions (Severity > 500)
22 and (Message == "TestString"). A third content filter element is required to create an AND
23 combination of the two conditions. It consists of the AND operator and two element operands
24 with the indices of the two conditions created before:
25
26 \code
27 import QtOpcUa as QtOpcUa
28
29 QtOpcUa.EventFilter {
30 select : [ ... ]
31 where: [
32 QtOpcUa.FilterElement {
33 operator: QtOpcUa.FilterElement.GreaterThan
34 firstOperand: QtOpcUa.SimpleAttributeOperand {
35 browsePath: [
36 QtOpcUa.NodeId {
37 identifier: "Severity"
38 ns: "http://opcfoundation.org/UA/"
39 }
40 ]
41 }
42 secondOperand: QtOpcUa.LiteralOperand {
43 value: 500
44 type: QtOpcUa.Constants.UInt16
45 }
46 }
47 QtOpcUa.FilterElement {
48 operator: QtOpcUa.FilterElement.Equals
49 firstOperand: QtOpcUa.SimpleAttributeOperand {
50 browsePath: [
51 QtOpcUa.NodeId {
52 identifier: "Message"
53 ns: "http://opcfoundation.org/UA/"
54 }
55 ]
56 }
57 secondOperand: QtOpcUa.LiteralOperand {
58 value: "TestString"
59 type: QtOpcUa.Constants.String
60 }
61 }
62 QtOpcUa.FilterElement {
63 operator: QtOpcUa.FilterElement.And
64 firstOperand: QtOpcUa.ElementOperand {
65 index: 0
66 }
67 secondOperand: QtOpcUa.ElementOperand {
68 index: 1
69 }
70 }
71 ]
72 }
73 \endcode
74*/
75
76/*!
77 \qmlproperty int ElementOperand::index
78
79 Index of the filter element that is going to be used as operand.
80*/
81
82OpcUaElementOperand::OpcUaElementOperand(QObject *parent)
83 : OpcUaOperandBase(parent)
84{
85}
86
87OpcUaElementOperand::~OpcUaElementOperand() = default;
88
89QVariant OpcUaElementOperand::toCppVariant(QOpcUaClient* client) const
90{
91 Q_UNUSED(client);
92 QOpcUaElementOperand value(*this);
93 return value;
94}
95
96quint32 OpcUaElementOperand::index() const
97{
98 return QOpcUaElementOperand::index();
99}
100
101void OpcUaElementOperand::setIndex(quint32 index)
102{
103 if (index != QOpcUaElementOperand::index()) {
104 QOpcUaElementOperand::setIndex(index);
105 emit dataChanged();
106 }
107}
108
109QT_END_NAMESPACE
110

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