summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2018-08-13 13:18:06 +0200
committerJannis Völker <jannis.voelker@basyskom.com>2018-08-14 07:36:32 +0000
commite2e69ae1fb41efcdfbfd7fab25649450dab4fced (patch)
tree52d0c1533e96e71342fc9cbc121434aea5f02edc
parent111adffce2c1766fe245e9e4bc69e23050c9b692 (diff)
Emit attributeUpdated whenever the attribute cache is updated
This allows to handle all reads, writes and data changes with just a single slot. The dataChangeOccurred signal is added to QOpcUaNode and is only emitted after a data change notification has been received. This is a change in behavior compared to 5.11 where the attributeUpdated() signal was only emitted after a data change and three signals were required to fully keep track of changes to the attribute cache. Change-Id: I3d7d33b7b0eb48b044d64178d448bedc4f3a756d Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
-rw-r--r--examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp10
-rw-r--r--src/imports/opcua/opcuavaluenode.cpp4
-rw-r--r--src/imports/opcua/opcuavaluenode.h2
-rw-r--r--src/opcua/client/qopcuabackend_p.h2
-rw-r--r--src/opcua/client/qopcuaclientimpl.cpp6
-rw-r--r--src/opcua/client/qopcuaclientimpl_p.h2
-rw-r--r--src/opcua/client/qopcuanode.cpp22
-rw-r--r--src/opcua/client/qopcuanode.h1
-rw-r--r--src/opcua/client/qopcuanode_p.h17
-rw-r--r--src/opcua/client/qopcuanodeimpl_p.h2
-rw-r--r--src/plugins/opcua/open62541/qopen62541subscription.cpp4
-rw-r--r--src/plugins/opcua/uacpp/quacppsubscription.cpp2
-rw-r--r--tests/auto/qopcuaclient/tst_client.cpp44
13 files changed, 83 insertions, 35 deletions
diff --git a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
index ab1da00..8a7451d 100644
--- a/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
+++ b/examples/opcua/waterpump/waterpump-qmlcpp/opcuamachinebackend.cpp
@@ -94,11 +94,11 @@ void OpcUaMachineBackend::clientStateHandler(QOpcUaClient::ClientState state)
m_machineDesignationNode.reset(m_client->node("ns=2;s=Machine.Designation"));
// Connect signal handlers for subscribed values
- QObject::connect(m_machineStateNode.data(), &QOpcUaNode::attributeUpdated, this, &OpcUaMachineBackend::machineStateUpdated);
- QObject::connect(m_percentFilledTank1Node.data(), &QOpcUaNode::attributeUpdated, this, &OpcUaMachineBackend::percentFilledTank1Updated);
- QObject::connect(m_percentFilledTank2Node.data(), &QOpcUaNode::attributeUpdated, this, &OpcUaMachineBackend::percentFilledTank2Updated);
- QObject::connect(m_tank2TargetPercentNode.data(), &QOpcUaNode::attributeUpdated, this, &OpcUaMachineBackend::tank2TargetPercentUpdated);
- QObject::connect(m_tank2ValveStateNode.data(), &QOpcUaNode::attributeUpdated, this, &OpcUaMachineBackend::tank2ValveStateUpdated);
+ QObject::connect(m_machineStateNode.data(), &QOpcUaNode::dataChangeOccurred, this, &OpcUaMachineBackend::machineStateUpdated);
+ QObject::connect(m_percentFilledTank1Node.data(), &QOpcUaNode::dataChangeOccurred, this, &OpcUaMachineBackend::percentFilledTank1Updated);
+ QObject::connect(m_percentFilledTank2Node.data(), &QOpcUaNode::dataChangeOccurred, this, &OpcUaMachineBackend::percentFilledTank2Updated);
+ QObject::connect(m_tank2TargetPercentNode.data(), &QOpcUaNode::dataChangeOccurred, this, &OpcUaMachineBackend::tank2TargetPercentUpdated);
+ QObject::connect(m_tank2ValveStateNode.data(), &QOpcUaNode::dataChangeOccurred, this, &OpcUaMachineBackend::tank2ValveStateUpdated);
// Subscribe to data changes
m_machineStateNode->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(100));
diff --git a/src/imports/opcua/opcuavaluenode.cpp b/src/imports/opcua/opcuavaluenode.cpp
index 7ab8523..83f9c13 100644
--- a/src/imports/opcua/opcuavaluenode.cpp
+++ b/src/imports/opcua/opcuavaluenode.cpp
@@ -96,7 +96,7 @@ void OpcUaValueNode::setupNode(const QString &absolutePath)
return;
connect(m_node, &QOpcUaNode::attributeRead, this, &OpcUaValueNode::handleAttributeUpdate);
- connect(m_node, &QOpcUaNode::attributeUpdated, this, &OpcUaValueNode::handleAttributeUpdated);
+ connect(m_node, &QOpcUaNode::dataChangeOccurred, this, &OpcUaValueNode::handleDataChangeOccurred);
if (!m_node->readAttributes(QOpcUa::NodeAttribute::Value
| QOpcUa::NodeAttribute::NodeClass
@@ -135,7 +135,7 @@ void OpcUaValueNode::handleAttributeUpdate(QOpcUa::NodeAttributes attrs)
setReadyToUse();
}
-void OpcUaValueNode::handleAttributeUpdated(QOpcUa::NodeAttribute attr, QVariant value)
+void OpcUaValueNode::handleDataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value)
{
if (attr == QOpcUa::NodeAttribute::Value) {
if (value != m_cachedValue) {
diff --git a/src/imports/opcua/opcuavaluenode.h b/src/imports/opcua/opcuavaluenode.h
index a04ae8e..1d892a9 100644
--- a/src/imports/opcua/opcuavaluenode.h
+++ b/src/imports/opcua/opcuavaluenode.h
@@ -60,7 +60,7 @@ signals:
private slots:
void setupNode(const QString &absolutePath) override;
void handleAttributeUpdate(QOpcUa::NodeAttributes attrs);
- void handleAttributeUpdated(QOpcUa::NodeAttribute attr, QVariant value);
+ void handleDataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value);
private:
QVariant m_cachedValue;
diff --git a/src/opcua/client/qopcuabackend_p.h b/src/opcua/client/qopcuabackend_p.h
index 5ddd036..5ed80b7 100644
--- a/src/opcua/client/qopcuabackend_p.h
+++ b/src/opcua/client/qopcuabackend_p.h
@@ -83,7 +83,7 @@ Q_SIGNALS:
void attributeWritten(quint64 hande, QOpcUa::NodeAttribute attribute, QVariant value, QOpcUa::UaStatusCode statusCode);
void methodCallFinished(quint64 handle, QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode);
- void attributeUpdated(quint64 handle, QOpcUaReadResult res);
+ void dataChangeOccurred(quint64 handle, QOpcUaReadResult res);
void eventOccurred(quint64 handle, QVariantList fields);
void monitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status);
void monitoringStatusChanged(quint64 handle, QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items,
diff --git a/src/opcua/client/qopcuaclientimpl.cpp b/src/opcua/client/qopcuaclientimpl.cpp
index 2f5771d..df83d40 100644
--- a/src/opcua/client/qopcuaclientimpl.cpp
+++ b/src/opcua/client/qopcuaclientimpl.cpp
@@ -74,7 +74,7 @@ void QOpcUaClientImpl::connectBackendWithClient(QOpcUaBackend *backend)
connect(backend, &QOpcUaBackend::attributesRead, this, &QOpcUaClientImpl::handleAttributesRead);
connect(backend, &QOpcUaBackend::stateAndOrErrorChanged, this, &QOpcUaClientImpl::stateAndOrErrorChanged);
connect(backend, &QOpcUaBackend::attributeWritten, this, &QOpcUaClientImpl::handleAttributeWritten);
- connect(backend, &QOpcUaBackend::attributeUpdated, this, &QOpcUaClientImpl::handleAttributeUpdated);
+ connect(backend, &QOpcUaBackend::dataChangeOccurred, this, &QOpcUaClientImpl::handleDataChangeOccurred);
connect(backend, &QOpcUaBackend::monitoringEnableDisable, this, &QOpcUaClientImpl::handleMonitoringEnableDisable);
connect(backend, &QOpcUaBackend::monitoringStatusChanged, this, &QOpcUaClientImpl::handleMonitoringStatusChanged);
connect(backend, &QOpcUaBackend::methodCallFinished, this, &QOpcUaClientImpl::handleMethodCallFinished);
@@ -101,11 +101,11 @@ void QOpcUaClientImpl::handleAttributeWritten(quint64 handle, QOpcUa::NodeAttrib
emit (*it)->attributeWritten(attr, value, statusCode);
}
-void QOpcUaClientImpl::handleAttributeUpdated(quint64 handle, const QOpcUaReadResult &value)
+void QOpcUaClientImpl::handleDataChangeOccurred(quint64 handle, const QOpcUaReadResult &value)
{
auto it = m_handles.constFind(handle);
if (it != m_handles.constEnd() && !it->isNull())
- emit (*it)->attributeUpdated(value.attribute(), value);
+ emit (*it)->dataChangeOccurred(value.attribute(), value);
}
void QOpcUaClientImpl::handleMonitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status)
diff --git a/src/opcua/client/qopcuaclientimpl_p.h b/src/opcua/client/qopcuaclientimpl_p.h
index 08131f7..0b6b8da 100644
--- a/src/opcua/client/qopcuaclientimpl_p.h
+++ b/src/opcua/client/qopcuaclientimpl_p.h
@@ -90,7 +90,7 @@ public:
private Q_SLOTS:
void handleAttributesRead(quint64 handle, QVector<QOpcUaReadResult> attr, QOpcUa::UaStatusCode serviceResult);
void handleAttributeWritten(quint64 handle, QOpcUa::NodeAttribute attr, const QVariant &value, QOpcUa::UaStatusCode statusCode);
- void handleAttributeUpdated(quint64 handle, const QOpcUaReadResult &value);
+ void handleDataChangeOccurred(quint64 handle, const QOpcUaReadResult &value);
void handleMonitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status);
void handleMonitoringStatusChanged(quint64 handle, QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items,
QOpcUaMonitoringParameters param);
diff --git a/src/opcua/client/qopcuanode.cpp b/src/opcua/client/qopcuanode.cpp
index 0fe14c2..2ed162c 100644
--- a/src/opcua/client/qopcuanode.cpp
+++ b/src/opcua/client/qopcuanode.cpp
@@ -89,7 +89,7 @@ QT_BEGIN_NAMESPACE
\l QOpcUaNode offers an abstraction to interact with subscriptions and monitored items.
\l enableMonitoring() enables data change notifications for one or more attributes.
- The \l attributeUpdated signal contains new values and the local cache is updated.
+ The \l dataChangeOccurred signal contains new values and the local cache is updated.
\l disableMonitoring() disables the data change notifications.
The \l monitoringStatusChanged signal notifies about changes of the monitoring status, e. g. after
manual enable and disable or a status change on the server.
@@ -166,10 +166,22 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QOpcUaNode::attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value)
+ \fn void QOpcUaNode::dataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value)
This signal is emitted after a data change notification has been received. \a value contains the
new value for the node attribute \a attr.
+
+ \sa attribute() serverTimestamp() sourceTimestamp()
+*/
+
+/*!
+ \fn void QOpcUaNode::attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value)
+
+ This signal is emitted after the value in the attribute cache has been updated by a
+ data change notification from the server, a read or a write operation. \a value contains the
+ new value for the node attribute \a attr.
+
+ \sa attribute() attributeError() serverTimestamp() sourceTimestamp()
*/
/*!
@@ -330,7 +342,7 @@ QVariant QOpcUaNode::attribute(QOpcUa::NodeAttribute attribute) const
The returned value is only valid after the Value attribute has been successfully read or written
or after a data change from a monitoring has updated the attribute cache.
This is indicated by a \l attributeRead() or \l attributeWritten() signal with status code
- \l {QOpcUa::UaStatusCode} {Good} or a \l attributeUpdated() signal for the Value attribute.
+ \l {QOpcUa::UaStatusCode} {Good} or a \l dataChangeOccurred() signal for the Value attribute.
If there is no value in the attribute cache, an invalid \l QVariant is returned.
@@ -372,7 +384,7 @@ QOpcUa::UaStatusCode QOpcUaNode::valueAttributeError() const
/*!
Returns the source timestamp from the last read or data change of \a attribute.
- Before at least one \l attributeRead or \l attributeUpdated signal has been emitted,
+ Before at least one \l attributeRead or \l dataChangeOccurred signal has been emitted,
a null datetime is returned.
*/
@@ -388,7 +400,7 @@ QDateTime QOpcUaNode::sourceTimestamp(QOpcUa::NodeAttribute attribute) const
/*!
Returns the server timestamp from the last read or data change of \a attribute.
- Before at least one \l attributeRead or \l attributeUpdated signal has been emitted,
+ Before at least one \l attributeRead or \l dataChangeOccurred signal has been emitted,
a null datetime is returned.
*/
QDateTime QOpcUaNode::serverTimestamp(QOpcUa::NodeAttribute attribute) const
diff --git a/src/opcua/client/qopcuanode.h b/src/opcua/client/qopcuanode.h
index f211af4..9f4fde1 100644
--- a/src/opcua/client/qopcuanode.h
+++ b/src/opcua/client/qopcuanode.h
@@ -105,6 +105,7 @@ public:
Q_SIGNALS:
void attributeRead(QOpcUa::NodeAttributes attributes);
void attributeWritten(QOpcUa::NodeAttribute attribute, QOpcUa::UaStatusCode statusCode);
+ void dataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value);
void attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value);
void eventOccurred(QVariantList eventFields);
diff --git a/src/opcua/client/qopcuanode_p.h b/src/opcua/client/qopcuanode_p.h
index 3d3230d..bd61c09 100644
--- a/src/opcua/client/qopcuanode_p.h
+++ b/src/opcua/client/qopcuanode_p.h
@@ -72,6 +72,7 @@ public:
[this](QVector<QOpcUaReadResult> attr, QOpcUa::UaStatusCode serviceResult)
{
QOpcUa::NodeAttributes updatedAttributes;
+ Q_Q(QOpcUaNode);
for (auto &entry : qAsConst(attr)) {
if (serviceResult == QOpcUa::UaStatusCode::Good)
@@ -84,9 +85,9 @@ public:
}
updatedAttributes |= entry.attribute();
+ emit q->attributeUpdated(entry.attribute(), entry.value());
}
- Q_Q(QOpcUaNode);
emit q->attributeRead(updatedAttributes);
});
@@ -94,18 +95,22 @@ public:
[this](QOpcUa::NodeAttribute attr, QVariant value, QOpcUa::UaStatusCode statusCode)
{
m_nodeAttributes[attr].setStatusCode(statusCode);
- if (statusCode == QOpcUa::UaStatusCode::Good)
+ Q_Q(QOpcUaNode);
+
+ if (statusCode == QOpcUa::UaStatusCode::Good) {
m_nodeAttributes[attr].setValue(value);
+ emit q->attributeUpdated(attr, value);
+ }
- Q_Q(QOpcUaNode);
emit q->attributeWritten(attr, statusCode);
});
- m_attributeUpdatedConnection = QObject::connect(impl, &QOpcUaNodeImpl::attributeUpdated,
+ m_dataChangeOccurredConnection = QObject::connect(impl, &QOpcUaNodeImpl::dataChangeOccurred,
[this](QOpcUa::NodeAttribute attr, QOpcUaReadResult value)
{
this->m_nodeAttributes[attr] = value;
Q_Q(QOpcUaNode);
+ emit q->dataChangeOccurred(attr, value.value());
emit q->attributeUpdated(attr, value.value());
});
@@ -193,7 +198,7 @@ public:
{
QObject::disconnect(m_attributesReadConnection);
QObject::disconnect(m_attributeWrittenConnection);
- QObject::disconnect(m_attributeUpdatedConnection);
+ QObject::disconnect(m_dataChangeOccurredConnection);
QObject::disconnect(m_monitoringEnableDisableConnection);
QObject::disconnect(m_monitoringStatusChangedConnection);
QObject::disconnect(m_methodCallFinishedConnection);
@@ -220,7 +225,7 @@ public:
QMetaObject::Connection m_attributesReadConnection;
QMetaObject::Connection m_attributeWrittenConnection;
- QMetaObject::Connection m_attributeUpdatedConnection;
+ QMetaObject::Connection m_dataChangeOccurredConnection;
QMetaObject::Connection m_monitoringEnableDisableConnection;
QMetaObject::Connection m_monitoringStatusChangedConnection;
QMetaObject::Connection m_methodCallFinishedConnection;
diff --git a/src/opcua/client/qopcuanodeimpl_p.h b/src/opcua/client/qopcuanodeimpl_p.h
index 532c6b6..9a9793e 100644
--- a/src/opcua/client/qopcuanodeimpl_p.h
+++ b/src/opcua/client/qopcuanodeimpl_p.h
@@ -92,7 +92,7 @@ Q_SIGNALS:
void attributeWritten(QOpcUa::NodeAttribute attr, QVariant value, QOpcUa::UaStatusCode statusCode);
void browseFinished(QVector<QOpcUaReferenceDescription> children, QOpcUa::UaStatusCode statusCode);
- void attributeUpdated(QOpcUa::NodeAttribute attr, QOpcUaReadResult value);
+ void dataChangeOccurred(QOpcUa::NodeAttribute attr, QOpcUaReadResult value);
void eventOccurred(QVariantList eventFields);
void monitoringEnableDisable(QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status);
void monitoringStatusChanged(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items,
diff --git a/src/plugins/opcua/open62541/qopen62541subscription.cpp b/src/plugins/opcua/open62541/qopen62541subscription.cpp
index 42b97f8..3f16d20 100644
--- a/src/plugins/opcua/open62541/qopen62541subscription.cpp
+++ b/src/plugins/opcua/open62541/qopen62541subscription.cpp
@@ -353,7 +353,7 @@ void QOpen62541Subscription::monitoredValueUpdated(UA_UInt32 monId, UA_DataValue
if (!value || value == UA_EMPTY_ARRAY_SENTINEL) {
res.setStatusCode(QOpcUa::UaStatusCode::Good);
- emit m_backend->attributeUpdated(item.value()->handle, res);
+ emit m_backend->dataChangeOccurred(item.value()->handle, res);
return;
}
@@ -364,7 +364,7 @@ void QOpen62541Subscription::monitoredValueUpdated(UA_UInt32 monId, UA_DataValue
if (value->hasSourceTimestamp)
res.setSourceTimestamp(QOpen62541ValueConverter::scalarToQt<QDateTime, UA_DateTime>(&value->sourceTimestamp));
res.setStatusCode(QOpcUa::UaStatusCode::Good);
- emit m_backend->attributeUpdated(item.value()->handle, res);
+ emit m_backend->dataChangeOccurred(item.value()->handle, res);
}
void QOpen62541Subscription::sendTimeoutNotification()
diff --git a/src/plugins/opcua/uacpp/quacppsubscription.cpp b/src/plugins/opcua/uacpp/quacppsubscription.cpp
index 9c6230c..f90cbc2 100644
--- a/src/plugins/opcua/uacpp/quacppsubscription.cpp
+++ b/src/plugins/opcua/uacpp/quacppsubscription.cpp
@@ -323,7 +323,7 @@ void QUACppSubscription::dataChange(OpcUa_UInt32 clientSubscriptionHandle, const
temp.setAttribute(m_monitoredIds[monitorId].second);
temp.setStatusCode(QOpcUa::UaStatusCode::Good);
- emit m_backend->attributeUpdated(m_monitoredIds[monitorId].first, temp);
+ emit m_backend->dataChangeOccurred(m_monitoredIds[monitorId].first, temp);
}
}
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index b48eddd..864b06b 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -425,6 +425,8 @@ private slots:
void addDuplicateMonitoredItem();
defineDataMethod(checkMonitoredItemCleanup_data);
void checkMonitoredItemCleanup();
+ defineDataMethod(checkAttributeUpdated_data);
+ void checkAttributeUpdated();
defineDataMethod(stringCharset_data)
void stringCharset();
@@ -1095,7 +1097,7 @@ void Tst_QOpcUaClient::dataChangeSubscription()
WRITE_VALUE_ATTRIBUTE(node, QVariant(double(0)), QOpcUa::Types::Double);
- QSignalSpy dataChangeSpy(node.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(node.data(), &QOpcUaNode::dataChangeOccurred);
QSignalSpy monitoringEnabledSpy(node.data(), &QOpcUaNode::enableMonitoringFinished);
node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(100, QOpcUaMonitoringParameters::SubscriptionType::Exclusive));
@@ -2508,7 +2510,7 @@ void Tst_QOpcUaClient::subscriptionIndexRange()
QSignalSpy monitoringEnabledSpy(integerArrayNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(integerArrayNode.data(), &QOpcUaNode::disableMonitoringFinished);
QSignalSpy writeSpy(integerArrayNode.data(), &QOpcUaNode::attributeWritten);
- QSignalSpy dataChangeSpy(integerArrayNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(integerArrayNode.data(), &QOpcUaNode::dataChangeOccurred);
QVariantList l({0, 1});
WRITE_VALUE_ATTRIBUTE(integerArrayNode, l, QOpcUa::Types::Int32);
@@ -2559,7 +2561,7 @@ void Tst_QOpcUaClient::subscriptionDataChangeFilter()
QSignalSpy monitoringEnabledSpy(doubleNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(doubleNode.data(), &QOpcUaNode::disableMonitoringFinished);
- QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::dataChangeOccurred);
QSignalSpy monitoringModifiedSpy(doubleNode.data(), &QOpcUaNode::monitoringStatusChanged);
WRITE_VALUE_ATTRIBUTE(doubleNode, 1.0, QOpcUa::Types::Double);
@@ -2622,7 +2624,7 @@ void Tst_QOpcUaClient::modifyPublishingMode()
QSignalSpy monitoringEnabledSpy(doubleNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(doubleNode.data(), &QOpcUaNode::disableMonitoringFinished);
- QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::dataChangeOccurred);
QSignalSpy monitoringStatusSpy(doubleNode.data(), &QOpcUaNode::monitoringStatusChanged);
WRITE_VALUE_ATTRIBUTE(doubleNode, 1.0, QOpcUa::Types::Double);
@@ -2672,7 +2674,7 @@ void Tst_QOpcUaClient::modifyMonitoringMode()
QSignalSpy monitoringEnabledSpy(doubleNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(doubleNode.data(), &QOpcUaNode::disableMonitoringFinished);
- QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::dataChangeOccurred);
QSignalSpy monitoringStatusSpy(doubleNode.data(), &QOpcUaNode::monitoringStatusChanged);
WRITE_VALUE_ATTRIBUTE(doubleNode, 1.0, QOpcUa::Types::Double);
@@ -2723,7 +2725,7 @@ void Tst_QOpcUaClient::modifyMonitoredItem()
QSignalSpy monitoringEnabledSpy(doubleNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(doubleNode.data(), &QOpcUaNode::disableMonitoringFinished);
- QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(doubleNode.data(), &QOpcUaNode::dataChangeOccurred);
QSignalSpy monitoringStatusSpy(doubleNode.data(), &QOpcUaNode::monitoringStatusChanged);
WRITE_VALUE_ATTRIBUTE(doubleNode, 1.0, QOpcUa::Types::Double);
@@ -2851,6 +2853,34 @@ void Tst_QOpcUaClient::checkMonitoredItemCleanup()
QCOMPARE(methodSpy.at(0).at(2).value<QOpcUa::UaStatusCode>(), QOpcUa::UaStatusCode::BadNoMatch);
}
+void Tst_QOpcUaClient::checkAttributeUpdated()
+{
+ QFETCH(QOpcUaClient *, opcuaClient);
+ OpcuaConnector connector(opcuaClient, m_endpoint);
+
+ QScopedPointer<QOpcUaNode> node(opcuaClient->node(QStringLiteral("ns=3;s=TestNode.ReadWrite")));
+ QVERIFY(node != nullptr);
+
+ QSignalSpy spy(node.data(), &QOpcUaNode::attributeUpdated);
+
+ node->readAttributes(QOpcUa::NodeAttribute::Value);
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+
+ node->writeValueAttribute(23.0, QOpcUa::Types::Double);
+ spy.wait();
+ QCOMPARE(spy.size(), 2);
+
+ node->enableMonitoring(QOpcUa::NodeAttribute::Value, QOpcUaMonitoringParameters(100));
+ spy.wait();
+ QCOMPARE(spy.size(), 3);
+
+ for (auto it : spy) {
+ QCOMPARE(it.at(0).value<QOpcUa::NodeAttribute>(), QOpcUa::NodeAttribute::Value);
+ QVERIFY(it.at(1).isValid());
+ }
+}
+
void Tst_QOpcUaClient::stringCharset()
{
QFETCH(QOpcUaClient *, opcuaClient);
@@ -3012,7 +3042,7 @@ void Tst_QOpcUaClient::timeStamps()
QOpcUaMonitoringParameters p(100);
QSignalSpy monitoringEnabledSpy(stringScalarNode.data(), &QOpcUaNode::enableMonitoringFinished);
QSignalSpy monitoringDisabledSpy(stringScalarNode.data(), &QOpcUaNode::disableMonitoringFinished);
- QSignalSpy dataChangeSpy(stringScalarNode.data(), &QOpcUaNode::attributeUpdated);
+ QSignalSpy dataChangeSpy(stringScalarNode.data(), &QOpcUaNode::dataChangeOccurred);
QTest::qWait(10); // Make sure the timestamp has a chance to change