diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2017-11-13 14:34:17 +0100 |
---|---|---|
committer | Frank Meerkoetter <frank.meerkoetter@basyskom.com> | 2017-12-14 10:52:33 +0000 |
commit | 28f2c5d6bc152948a3ce7f22e55db9afcaba1d3c (patch) | |
tree | 5d7138b25642bfc8f98e1f0432e44cbbad6731c0 /src/plugins/opcua/freeopcua/qfreeopcuaworker.h | |
parent | 0e71f5b4a9b6073f527236f5e6ac9d423ebe315b (diff) |
Add async API for data change subscriptions
Subscriptions and monitored items are now handled entirely in the backend,
no objects are passed to the user.
Monitoring of attributes is activated using enableMonitoring() on the node.
Different attributes of the node can be monitored with different intervals.
Subscriptions are shared by default. Parameters allow requesting the creation
of an exclusive subscription or to assign monitored items for attributes to
an existing subscription. disableMonitoring() removes a monitored item.
The enableMonitoringFinished and disableMonitoringFinished signals inform
the user about the success of adding and removing monitored items.
Data changes are reported by the attributeUpdated signal, this also updates
the attribute cache.
Monitoring parameters can be modified using modifyMonitoring(). Changed
settings are reported by the monitoringStatusChanged signal, the value can be
checked by calling monitoringStatus() for an attribute.
Modifying monitoring parameters is currently not supported in freeopcua.
Open62541 allows modifying subscription settings, monitored items can't be
modified.
Change-Id: I3ba5b3f03bd9f0413c98feefa9ad9571f82e8f0d
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'src/plugins/opcua/freeopcua/qfreeopcuaworker.h')
-rw-r--r-- | src/plugins/opcua/freeopcua/qfreeopcuaworker.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/plugins/opcua/freeopcua/qfreeopcuaworker.h b/src/plugins/opcua/freeopcua/qfreeopcuaworker.h index d4ede6b..65d2c23 100644 --- a/src/plugins/opcua/freeopcua/qfreeopcuaworker.h +++ b/src/plugins/opcua/freeopcua/qfreeopcuaworker.h @@ -37,8 +37,8 @@ #ifndef QFREEOPCUAWORKER_H #define QFREEOPCUAWORKER_H +#include "qfreeopcuasubscription.h" #include <QtOpcUa/qopcuanode.h> -#include <QtOpcUa/qopcuasubscription.h> #include <private/qopcuabackend_p.h> #include <QtCore/qobject.h> @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE class QFreeOpcUaNode; -class QOpcUaSubscription; class QOpcUaNode; class QFreeOpcUaClientImpl; @@ -58,8 +57,7 @@ class QFreeOpcUaWorker : public QOpcUaBackend, public OpcUa::UaClient Q_OBJECT public: QFreeOpcUaWorker(QFreeOpcUaClientImpl *client); - - Q_INVOKABLE QOpcUaSubscription *createSubscription(quint32 interval); + ~QFreeOpcUaWorker(); public slots: void asyncConnectToEndpoint(const QUrl &url); @@ -69,8 +67,20 @@ public slots: void writeAttribute(uintptr_t handle, OpcUa::Node node, QOpcUaNode::NodeAttribute attr, QVariant value, QOpcUa::Types type); void writeAttributes(uintptr_t handle, OpcUa::Node node, QOpcUaNode::AttributeMap toWrite, QOpcUa::Types valueAttributeType); + QFreeOpcUaSubscription *getSubscription(const QOpcUaMonitoringParameters &settings); + bool removeSubscription(quint32 subscriptionId); + + void enableMonitoring(uintptr_t handle, OpcUa::Node node, QOpcUaNode::NodeAttributes attr, const QOpcUaMonitoringParameters &settings); + void disableMonitoring(uintptr_t handle, QOpcUaNode::NodeAttributes attr); + void modifyMonitoring(uintptr_t handle, QOpcUaNode::NodeAttribute attr, QOpcUaMonitoringParameters::Parameter item, QVariant value); + private: + QFreeOpcUaSubscription *getSubscriptionForItem(uintptr_t handle, QOpcUaNode::NodeAttribute attr); + QFreeOpcUaClientImpl *m_client; + + QHash<quint32, QFreeOpcUaSubscription *> m_subscriptions; + QHash<uintptr_t, QHash<QOpcUaNode::NodeAttribute, QFreeOpcUaSubscription *>> m_attributeMapping; // Handle -> Attribute -> Subscription }; QT_END_NAMESPACE |