1// Copyright (C) 2017 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#ifndef QOPCUAMONITORINGPARAMETERS_H
5#define QOPCUAMONITORINGPARAMETERS_H
6
7#include <QtOpcUa/qopcuacontentfilterelement.h>
8#include <QtOpcUa/qopcuasimpleattributeoperand.h>
9
10#include <QtCore/qshareddata.h>
11
12QT_BEGIN_NAMESPACE
13
14class QOpcUaEventFilterResult;
15
16class QOpcUaMonitoringParametersPrivate;
17
18class Q_OPCUA_EXPORT QOpcUaMonitoringParameters
19{
20 Q_GADGET
21
22public:
23
24 enum class MonitoringMode {
25 Disabled = 0,
26 Sampling = 1,
27 Reporting = 2
28 };
29
30 enum class SubscriptionType {
31 Shared,
32 Exclusive
33 };
34
35 enum class Parameter {
36 PublishingEnabled = (1 << 0),
37 PublishingInterval = (1 << 1),
38 LifetimeCount = (1 << 2),
39 MaxKeepAliveCount = (1 << 3),
40 MaxNotificationsPerPublish = (1 << 4),
41 Priority = (1 << 5),
42 SamplingInterval = (1 << 6),
43 Filter = (1 << 7),
44 QueueSize = (1 << 8),
45 DiscardOldest = (1 << 9),
46 MonitoringMode = (1 << 10)
47 };
48 Q_ENUM(Parameter)
49 Q_DECLARE_FLAGS(Parameters, Parameter)
50
51 // This type and the enums are defined in OPC-UA part 4, 7.12.2
52 class DataChangeFilterData;
53 class Q_OPCUA_EXPORT DataChangeFilter
54 {
55 public:
56 enum class DataChangeTrigger {
57 Status = 0,
58 StatusOrValue = 1,
59 StatusOrValueOrTimestamp = 2
60 };
61
62 enum class DeadbandType {
63 None = 0,
64 Absolute = 1,
65 Percent = 2
66 };
67
68 DataChangeFilter();
69 DataChangeFilter(const DataChangeFilter &);
70 DataChangeFilter(DataChangeTrigger trigger, DeadbandType deadbandType, double deadbandValue);
71 DataChangeFilter &operator=(const DataChangeFilter &);
72 bool operator==(const DataChangeFilter &rhs) const;
73 operator QVariant() const;
74 ~DataChangeFilter();
75
76 DataChangeTrigger trigger() const;
77 void setTrigger(DataChangeTrigger trigger);
78
79 DeadbandType deadbandType() const;
80 void setDeadbandType(DeadbandType deadbandType);
81
82 double deadbandValue() const;
83 void setDeadbandValue(double deadbandValue);
84
85 private:
86 QSharedDataPointer<DataChangeFilterData> data;
87 };
88
89 class EventFilterData;
90 class Q_OPCUA_EXPORT EventFilter
91 {
92 public:
93 EventFilter();
94 EventFilter(const EventFilter &);
95 EventFilter &operator=(const EventFilter &);
96 operator QVariant const();
97 bool operator==(const QOpcUaMonitoringParameters::EventFilter &rhs) const;
98 EventFilter &operator<<(const QOpcUaContentFilterElement &whereClauseElement);
99 EventFilter &operator<<(const QOpcUaSimpleAttributeOperand &selectClauseElement);
100 ~EventFilter();
101
102 QList<QOpcUaSimpleAttributeOperand> selectClauses() const;
103 QList<QOpcUaSimpleAttributeOperand> &selectClausesRef();
104 void setSelectClauses(const QList<QOpcUaSimpleAttributeOperand> &selectClauses);
105
106 QList<QOpcUaContentFilterElement> whereClause() const;
107 QList<QOpcUaContentFilterElement> &whereClauseRef();
108 void setWhereClause(const QList<QOpcUaContentFilterElement> &whereClause);
109
110 private:
111 QSharedDataPointer<QOpcUaMonitoringParameters::EventFilterData> data;
112 };
113
114 QOpcUaMonitoringParameters();
115 ~QOpcUaMonitoringParameters();
116 QOpcUaMonitoringParameters(double publishingInterval, SubscriptionType subscriptionType = SubscriptionType::Shared, quint32 subscriptionId = 0);
117 QOpcUaMonitoringParameters(const QOpcUaMonitoringParameters &other);
118 QOpcUaMonitoringParameters &operator=(const QOpcUaMonitoringParameters &other);
119
120 double samplingInterval() const;
121 void setSamplingInterval(double samplingInterval);
122 QVariant filter() const;
123 void setFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter);
124 void setFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter);
125 void clearFilter();
126 QVariant filterResult() const;
127 void setFilterResult(const QOpcUaEventFilterResult &eventFilterResult);
128 void clearFilterResult();
129 quint32 queueSize() const;
130 void setQueueSize(quint32 queueSize);
131 bool discardOldest() const;
132 void setDiscardOldest(bool discardOldest);
133 QOpcUaMonitoringParameters::MonitoringMode monitoringMode() const;
134 void setMonitoringMode(MonitoringMode monitoringMode);
135 quint32 subscriptionId() const;
136 void setSubscriptionId(quint32 subscriptionId);
137 quint32 monitoredItemId() const;
138 void setMonitoredItemId(quint32 monitoredItemId);
139 double publishingInterval() const;
140 void setPublishingInterval(double publishingInterval);
141 quint32 lifetimeCount() const;
142 void setLifetimeCount(quint32 lifetimeCount);
143 quint32 maxKeepAliveCount() const;
144 void setMaxKeepAliveCount(quint32 maxKeepAliveCount);
145 quint32 maxNotificationsPerPublish() const;
146 void setMaxNotificationsPerPublish(quint32 maxNotificationsPerPublish);
147 quint8 priority() const;
148 void setPriority(quint8 priority);
149 bool isPublishingEnabled() const;
150 void setPublishingEnabled(bool publishingEnabled);
151 QOpcUa::UaStatusCode statusCode() const;
152 void setStatusCode(QOpcUa::UaStatusCode statusCode);
153 QOpcUaMonitoringParameters::SubscriptionType subscriptionType() const;
154 void setSubscriptionType(SubscriptionType subscriptionType);
155 QString indexRange() const;
156 void setIndexRange(const QString &indexRange);
157
158private:
159 QSharedDataPointer<QOpcUaMonitoringParametersPrivate> d_ptr;
160};
161
162Q_DECLARE_TYPEINFO(QOpcUaMonitoringParameters::SubscriptionType, Q_PRIMITIVE_TYPE);
163Q_DECLARE_TYPEINFO(QOpcUaMonitoringParameters::DataChangeFilter::DataChangeTrigger, Q_PRIMITIVE_TYPE);
164Q_DECLARE_TYPEINFO(QOpcUaMonitoringParameters::DataChangeFilter::DeadbandType, Q_PRIMITIVE_TYPE);
165Q_DECLARE_OPERATORS_FOR_FLAGS(QOpcUaMonitoringParameters::Parameters)
166
167QT_END_NAMESPACE
168
169Q_DECLARE_METATYPE(QOpcUaMonitoringParameters)
170Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::SubscriptionType)
171Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::DataChangeFilter)
172Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::DataChangeFilter::DataChangeTrigger)
173Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::DataChangeFilter::DeadbandType)
174Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::Parameter)
175Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::Parameters)
176Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::MonitoringMode)
177Q_DECLARE_METATYPE(QOpcUaMonitoringParameters::EventFilter)
178
179#endif // QOPCUAMONITORINGPARAMETERS_H
180

source code of qtopcua/src/opcua/client/qopcuamonitoringparameters.h