summaryrefslogtreecommitdiffstats
path: root/src/BobinkNode.h
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-20 10:41:09 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-20 10:41:09 +0100
commit0012cb312e92c33f5263478d318eb82da22ee879 (patch)
treecaac374dd3716b42d13cb85b85a7f90c7d5aac45 /src/BobinkNode.h
parent11b99fda8727f2225961c0b83ecdb18674a9670a (diff)
downloadBobinkQtOpcUa-0012cb312e92c33f5263478d318eb82da22ee879.tar.gz
BobinkQtOpcUa-0012cb312e92c33f5263478d318eb82da22ee879.zip
Rename classes to OpcUa* prefix, replace BobinkNode with OpcUaMonitoredNode boilerplate
Rename BobinkAuth → OpcUaAuth, BobinkClient → OpcUaClient (C++ class names only; QML module URI and singleton name stay as Bobink). Remove BobinkNode (QQuickItem-based) and add OpcUaMonitoredNode skeleton using QObject + QQmlParserStatus, following Qt convention for non-visual QML types.
Diffstat (limited to 'src/BobinkNode.h')
-rw-r--r--src/BobinkNode.h111
1 files changed, 0 insertions, 111 deletions
diff --git a/src/BobinkNode.h b/src/BobinkNode.h
deleted file mode 100644
index c37a883..0000000
--- a/src/BobinkNode.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * @file BobinkNode.h
- * @brief QML component representing a single OPC UA node.
- *
- * Inherits QQuickItem so that monitoring is automatically tied to
- * visibility: when the item (or any ancestor) becomes invisible
- * (e.g. StackView navigates away, Loader unloads), the monitored
- * item is removed from the subscription. When visible again,
- * monitoring resumes.
- */
-#ifndef BOBINKNODE_H
-#define BOBINKNODE_H
-
-#include <QDateTime>
-#include <QHash>
-#include <QOpcUaNode>
-#include <QQuickItem>
-
-class BobinkNode : public QQuickItem
-{
- Q_OBJECT
- QML_ELEMENT
-
- Q_PROPERTY (QString nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged)
- Q_PROPERTY (QVariant value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY (NodeStatus status READ status NOTIFY statusChanged)
- Q_PROPERTY (QDateTime sourceTimestamp READ sourceTimestamp NOTIFY
- sourceTimestampChanged)
- Q_PROPERTY (QDateTime serverTimestamp READ serverTimestamp NOTIFY
- serverTimestampChanged)
-
-public:
- explicit BobinkNode (QQuickItem *parent = nullptr);
- ~BobinkNode () override;
-
- /// Simplified OPC UA status severity.
- enum NodeStatus
- {
- Good,
- Uncertain,
- Bad
- };
- Q_ENUM (NodeStatus)
-
- QString nodeId () const;
- void setNodeId (const QString &id);
-
- QVariant value () const;
- /** Setting value writes to the server; the property updates when
- * the server confirms via the monitored data change. */
- void setValue (const QVariant &value);
-
- NodeStatus status () const;
- QDateTime sourceTimestamp () const;
- QDateTime serverTimestamp () const;
-
- /** Read an attribute on demand (DisplayName, Description, DataType, …).
- * Result arrives asynchronously via attributeRead(). */
- Q_INVOKABLE void readAttribute (const QString &attributeName);
-
-signals:
- void nodeIdChanged ();
- void valueChanged ();
- void statusChanged ();
- void sourceTimestampChanged ();
- void serverTimestampChanged ();
-
- /** Emitted when a readAttribute() call completes. */
- void attributeRead (const QString &attributeName, const QVariant &value);
-
- /** Emitted when a write to the server fails. */
- void writeError (const QString &message);
-
-protected:
- void componentComplete () override;
- void itemChange (ItemChange change, const ItemChangeData &data) override;
-
-private:
- void startMonitoring ();
- void stopMonitoring ();
-
- void handleDataChange (QOpcUa::NodeAttribute attr, const QVariant &val);
- void handleAttributeUpdated (QOpcUa::NodeAttribute attr,
- const QVariant &val);
- void handleAttributeWritten (QOpcUa::NodeAttribute attr,
- QOpcUa::UaStatusCode statusCode);
- void handleClientConnectedChanged ();
- void handleAttributeReadFinished (QOpcUa::NodeAttributes attrs);
- void handleEnableMonitoringFinished (QOpcUa::NodeAttribute attr,
- QOpcUa::UaStatusCode statusCode);
- void handleDisableMonitoringFinished (QOpcUa::NodeAttribute attr,
- QOpcUa::UaStatusCode statusCode);
-
- static NodeStatus statusFromCode (QOpcUa::UaStatusCode code);
- static QOpcUa::NodeAttribute attributeFromName (const QString &name);
- static QLatin1StringView nameFromAttribute (QOpcUa::NodeAttribute attr);
-
- QString m_nodeId;
- QVariant m_value;
- NodeStatus m_status = Bad;
- QDateTime m_sourceTimestamp;
- QDateTime m_serverTimestamp;
-
- QOpcUaNode *m_opcuaNode = nullptr;
- bool m_componentComplete = false;
-
- /** Tracks in-flight readAttribute() requests (enum → original name). */
- QHash<QOpcUa::NodeAttribute, QString> m_pendingReads;
-};
-
-#endif // BOBINKNODE_H