summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2018-02-09 11:10:00 +0100
committerFrank Meerkoetter <frank.meerkoetter@basyskom.com>2018-03-14 20:34:22 +0000
commitc62c6d518d14a0bc4d0ff1964253d7d7af9715e9 (patch)
treee122a5d25ae408254a768dd80e4d92ff0970e222 /tests
parent868a04b17c7d14e9339102b69128db4798d30898 (diff)
Add DataChangeFilter support to the open62541 backend
This patch enables the usage of deadband filters for data changes with the open62541 backend. The open62541 test server does not support data change filters, the test case is skipped. This patch has been tested using the Prosys simulation server. There is currently no filter support in freeopcua. Change-Id: I4f47780901fd75c97a858999fcc05b89e5cfda45 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qopcuaclient/tst_client.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index ae736e8..3026f28 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -229,6 +229,8 @@ private slots:
void invalidIndexRange();
defineDataMethod(subscriptionIndexRange_data)
void subscriptionIndexRange();
+ defineDataMethod(subscriptionDataChangeFilter_data)
+ void subscriptionDataChangeFilter();
defineDataMethod(stringCharset_data)
void stringCharset();
@@ -1848,6 +1850,65 @@ void Tst_QOpcUaClient::subscriptionIndexRange()
QCOMPARE(monitoringDisabledSpy.at(0).at(1).value<QOpcUa::UaStatusCode>(), QOpcUa::UaStatusCode::Good);
}
+void Tst_QOpcUaClient::subscriptionDataChangeFilter()
+{
+ QFETCH(QOpcUaClient *, opcuaClient);
+ OpcuaConnector connector(opcuaClient, m_endpoint);
+
+ QSKIP("DataChangeFilter is not supported by the open62541 test server");
+ // To run this test case, change the url for connector to the URL of a Prosys simulation server
+ // and use ns=3;s=Double as node id for doubleNode.
+
+ if (opcuaClient->backend() == QLatin1String("freeopcua"))
+ QSKIP("DataChangeFilter support is not implemented in the freeopcua plugin");
+ if (opcuaClient->backend() == QLatin1String("uacpp"))
+ QSKIP("DataChangeFilter support is not implemented in the unified automation plugin");
+
+
+ QScopedPointer<QOpcUaNode> doubleNode(opcuaClient->node("ns=2;s=Demo.Static.Scalar.Double"));
+ QVERIFY(doubleNode != 0);
+
+ QOpcUaMonitoringParameters p(100);
+ QOpcUaMonitoringParameters::DataChangeFilter filter;
+ filter.deadbandType = QOpcUaMonitoringParameters::DataChangeFilter::DeadbandType::Absolute;
+ filter.trigger = QOpcUaMonitoringParameters::DataChangeFilter::DataChangeTrigger::StatusValue;
+ filter.deadbandValue = 1.0;
+ p.setDataChangeFilter(filter);
+
+ QSignalSpy monitoringEnabledSpy(doubleNode.data(), &QOpcUaNode::enableMonitoringFinished);
+ QSignalSpy monitoringDisabledSpy(doubleNode.data(), &QOpcUaNode::disableMonitoringFinished);
+ QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::attributeUpdated);
+
+ WRITE_VALUE_ATTRIBUTE(doubleNode, 1.0, QOpcUa::Types::Double);
+
+ doubleNode->enableMonitoring(QOpcUa::NodeAttribute::Value, p);
+ monitoringEnabledSpy.wait();
+ QCOMPARE(monitoringEnabledSpy.size(), 1);
+ QCOMPARE(monitoringEnabledSpy.at(0).at(0).value<QOpcUa::NodeAttribute>(), QOpcUa::NodeAttribute::Value);
+ QCOMPARE(monitoringEnabledSpy.at(0).at(1).value<QOpcUa::UaStatusCode>(), QOpcUa::UaStatusCode::Good);
+
+ dataChangeSpy.wait(); // Wait for the initial data change
+ QCOMPARE(dataChangeSpy.size(), 1);
+ dataChangeSpy.clear();
+
+ WRITE_VALUE_ATTRIBUTE(doubleNode, 1.5, QOpcUa::Types::Double);
+
+ dataChangeSpy.wait();
+ QCOMPARE(dataChangeSpy.size(), 0);
+
+ WRITE_VALUE_ATTRIBUTE(doubleNode, 3.0, QOpcUa::Types::Double);
+
+ dataChangeSpy.wait();
+ QCOMPARE(dataChangeSpy.size(), 1);
+ QCOMPARE(doubleNode->attribute(QOpcUa::NodeAttribute::Value), 3.0);
+
+ doubleNode->disableMonitoring(QOpcUa::NodeAttribute::Value);
+ monitoringDisabledSpy.wait();
+ QCOMPARE(monitoringDisabledSpy.size(), 1);
+ QCOMPARE(monitoringDisabledSpy.at(0).at(0).value<QOpcUa::NodeAttribute>(), QOpcUa::NodeAttribute::Value);
+ QCOMPARE(monitoringDisabledSpy.at(0).at(1).value<QOpcUa::UaStatusCode>(), QOpcUa::UaStatusCode::Good);
+}
+
void Tst_QOpcUaClient::stringCharset()
{
QFETCH(QOpcUaClient *, opcuaClient);