summaryrefslogtreecommitdiffstats
path: root/src/opcua/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/opcua/client')
-rw-r--r--src/opcua/client/qopcuamonitoringparameters.cpp73
-rw-r--r--src/opcua/client/qopcuamonitoringparameters.h10
-rw-r--r--src/opcua/client/qopcuamonitoringparameters_p.h1
-rw-r--r--src/opcua/client/qopcuanode_p.h14
-rw-r--r--src/opcua/client/qopcuatype.cpp17
-rw-r--r--src/opcua/client/qopcuatype.h2
6 files changed, 101 insertions, 16 deletions
diff --git a/src/opcua/client/qopcuamonitoringparameters.cpp b/src/opcua/client/qopcuamonitoringparameters.cpp
index e4cb93a..70e056a 100644
--- a/src/opcua/client/qopcuamonitoringparameters.cpp
+++ b/src/opcua/client/qopcuamonitoringparameters.cpp
@@ -451,7 +451,8 @@ void QOpcUaMonitoringParameters::setQueueSize(quint32 queueSize)
}
/*!
- Returns the filter result. Empty for DataChangeFilter.
+ Returns the current filter.
+ \sa setFilter()
*/
QVariant QOpcUaMonitoringParameters::filter() const
{
@@ -459,33 +460,75 @@ QVariant QOpcUaMonitoringParameters::filter() const
}
/*!
- Request \l DataChangeFilter \a filter as filter for the monitored item.
- \sa setFilter() setEventFilter()
+ Sets \l DataChangeFilter \a filter as filter for the monitored item.
+ If another data change filter or an event filter is present, it will be replaced.
+
+ If the server does not accept the filter, this will be indicated by the
+ status code after the \l enableMonitoring() request has finished.
+
+ \sa filter()
*/
-void QOpcUaMonitoringParameters::setDataChangeFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter)
+void QOpcUaMonitoringParameters::setFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter)
{
d_ptr->filter = QVariant::fromValue(filter);
}
/*!
Request \a eventFilter as filter for the monitored item.
- \sa setFilter() setDataChangeFilter()
+ If another event filter or a data change filter is present, it will be replaced.
+ If the server does not accept the filter, this will be indicated by the
+ status code and the event filter result after the \l enableMonitoring()
+ request has finished.
+
+ \sa filter()
*/
-void QOpcUaMonitoringParameters::setEventFilter(const EventFilter &eventFilter)
+void QOpcUaMonitoringParameters::setFilter(const EventFilter &eventFilter)
{
d_ptr->filter = QVariant::fromValue(eventFilter);
}
/*!
- Request \a filter as filter for the monitored item.
+ Removes the current filter from the monitoring parameters.
+
+ \sa filter() setFilter()
+*/
+void QOpcUaMonitoringParameters::clearFilter()
+{
+ d_ptr->filter.clear();
+}
+
+/*!
+ Returns the filter result.
+
+ This value is empty for an attribute monitoring. In case of an event monitoring,
+ the filter result can be empty if the server did not detect any errors in the filter.
+*/
+QVariant QOpcUaMonitoringParameters::filterResult() const
+{
+ return d_ptr->filterResult;
+}
+
+/*!
+ Sets the event filter result to \a eventFilterResult.
- For general use, the type-safe versions that are listed below are preferred.
+ This method must only be used by the backend, setting an event filter result as a user
+ does not have any effect.
- \sa setDataChangeFilter() setEventFilter()
+ \sa filterResult()
*/
-void QOpcUaMonitoringParameters::setFilter(const QVariant &filter)
+void QOpcUaMonitoringParameters::setFilterResult(const QOpcUa::QEventFilterResult &eventFilterResult)
{
- d_ptr->filter = filter;
+ d_ptr->filterResult = QVariant::fromValue(eventFilterResult);
+}
+
+/*!
+ Removes the current filter result from the monitoring parameters.
+
+ \sa filterResult() setFilterResult()
+*/
+void QOpcUaMonitoringParameters::clearFilterResult()
+{
+ d_ptr->filterResult.clear();
}
/*!
@@ -731,6 +774,14 @@ QOpcUaMonitoringParameters::EventFilter &QOpcUaMonitoringParameters::EventFilter
}
/*!
+ Returns \c true if this event filter has the same value as \a rhs.
+*/
+bool QOpcUaMonitoringParameters::EventFilter::operator==(const QOpcUaMonitoringParameters::EventFilter &rhs) const
+{
+ return selectClauses() == rhs.selectClauses() && whereClause() == rhs.whereClause();
+}
+
+/*!
Adds the content filter element \a whereClauseElement to the where clause of this event filter.
*/
QOpcUaMonitoringParameters::EventFilter &QOpcUaMonitoringParameters::EventFilter::operator<<(const QOpcUa::QContentFilterElement &whereClauseElement)
diff --git a/src/opcua/client/qopcuamonitoringparameters.h b/src/opcua/client/qopcuamonitoringparameters.h
index 3ce4729..411e567 100644
--- a/src/opcua/client/qopcuamonitoringparameters.h
+++ b/src/opcua/client/qopcuamonitoringparameters.h
@@ -124,6 +124,7 @@ public:
EventFilter(const EventFilter &);
EventFilter &operator=(const EventFilter &);
operator QVariant const();
+ bool operator==(const QOpcUaMonitoringParameters::EventFilter &rhs) const;
EventFilter &operator<<(const QOpcUa::QContentFilterElement &whereClauseElement);
EventFilter &operator<<(const QOpcUa::QSimpleAttributeOperand &selectClauseElement);
~EventFilter();
@@ -149,9 +150,12 @@ public:
double samplingInterval() const;
void setSamplingInterval(double samplingInterval);
QVariant filter() const;
- void setDataChangeFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter);
- void setEventFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter);
- void setFilter(const QVariant &filter);
+ void setFilter(const QOpcUaMonitoringParameters::DataChangeFilter &filter);
+ void setFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter);
+ void clearFilter();
+ QVariant filterResult() const;
+ void setFilterResult(const QOpcUa::QEventFilterResult &eventFilterResult);
+ void clearFilterResult();
quint32 queueSize() const;
void setQueueSize(quint32 queueSize);
bool discardOldest() const;
diff --git a/src/opcua/client/qopcuamonitoringparameters_p.h b/src/opcua/client/qopcuamonitoringparameters_p.h
index cb05e4e..589dce3 100644
--- a/src/opcua/client/qopcuamonitoringparameters_p.h
+++ b/src/opcua/client/qopcuamonitoringparameters_p.h
@@ -78,6 +78,7 @@ public:
// MonitoredItem
double samplingInterval;
QVariant filter;
+ QVariant filterResult;
quint32 queueSize;
bool discardOldest;
QOpcUaMonitoringParameters::MonitoringMode monitoringMode;
diff --git a/src/opcua/client/qopcuanode_p.h b/src/opcua/client/qopcuanode_p.h
index bd61c09..d78aeb9 100644
--- a/src/opcua/client/qopcuanode_p.h
+++ b/src/opcua/client/qopcuanode_p.h
@@ -149,8 +149,18 @@ public:
it->setPriority(param.priority());
if (items & QOpcUaMonitoringParameters::Parameter::SamplingInterval)
it->setSamplingInterval(param.samplingInterval());
- if (items & QOpcUaMonitoringParameters::Parameter::Filter)
- it->setFilter(param.filter());
+ if (items & QOpcUaMonitoringParameters::Parameter::Filter) {
+ if (param.filter().canConvert<QOpcUaMonitoringParameters::DataChangeFilter>())
+ it->setFilter(param.filter().value<QOpcUaMonitoringParameters::DataChangeFilter>());
+ else if (param.filter().canConvert<QOpcUaMonitoringParameters::EventFilter>())
+ it->setFilter(param.filter().value<QOpcUaMonitoringParameters::EventFilter>());
+ else if (param.filter().isNull())
+ it->clearFilter();
+ if (param.filterResult().canConvert<QOpcUa::QEventFilterResult>())
+ it->setFilterResult(param.filterResult().value<QOpcUa::QEventFilterResult>());
+ else if (param.filterResult().isNull())
+ it->clearFilterResult();
+ }
if (items & QOpcUaMonitoringParameters::Parameter::QueueSize)
it->setQueueSize(param.queueSize());
if (items & QOpcUaMonitoringParameters::Parameter::DiscardOldest)
diff --git a/src/opcua/client/qopcuatype.cpp b/src/opcua/client/qopcuatype.cpp
index 4d97802..1416a26 100644
--- a/src/opcua/client/qopcuatype.cpp
+++ b/src/opcua/client/qopcuatype.cpp
@@ -2208,6 +2208,14 @@ QOpcUa::QContentFilterElement &QOpcUa::QContentFilterElement::operator=(const QO
}
/*!
+ Returns \c true if this content filter element has the same value as \a rhs.
+*/
+bool QOpcUa::QContentFilterElement::operator==(const QOpcUa::QContentFilterElement &rhs) const
+{
+ return filterOperator() == rhs.filterOperator() && filterOperands() == rhs.filterOperands();
+}
+
+/*!
Converts this content filter element to \l QVariant.
*/
QOpcUa::QContentFilterElement::operator QVariant() const
@@ -2576,6 +2584,15 @@ QOpcUa::QSimpleAttributeOperand &QOpcUa::QSimpleAttributeOperand::operator=(cons
}
/*!
+ Returns \c true if this simple attribute operand has the same value as \a rhs.
+*/
+bool QOpcUa::QSimpleAttributeOperand::operator==(const QOpcUa::QSimpleAttributeOperand &rhs) const
+{
+ return attributeId() == rhs.attributeId() && browsePath() == rhs.browsePath() &&
+ indexRange() == rhs.indexRange() && typeId() == rhs.typeId();
+}
+
+/*!
Converts this simple attribute operand to \l QVariant.
*/
QOpcUa::QSimpleAttributeOperand::operator QVariant() const
diff --git a/src/opcua/client/qopcuatype.h b/src/opcua/client/qopcuatype.h
index 1aea724..f64ebe3 100644
--- a/src/opcua/client/qopcuatype.h
+++ b/src/opcua/client/qopcuatype.h
@@ -825,6 +825,7 @@ public:
QSimpleAttributeOperand(QOpcUa::NodeAttribute attributeId,
const QString &typeId = QStringLiteral("ns=0;i=2041")); // BaseEventType
QSimpleAttributeOperand &operator=(const QOpcUa::QSimpleAttributeOperand &);
+ bool operator==(const QSimpleAttributeOperand &rhs) const;
operator QVariant() const;
~QSimpleAttributeOperand();
@@ -883,6 +884,7 @@ public:
QContentFilterElement();
QContentFilterElement(const QContentFilterElement &);
QContentFilterElement &operator=(const QContentFilterElement &);
+ bool operator==(const QContentFilterElement &rhs) const;
operator QVariant() const;
~QContentFilterElement();