summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-02-20 11:08:27 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-02-20 11:08:27 +0100
commit5b93aac1f802d0db838d3d12802f2863eb13e0f8 (patch)
tree773da5df7c45f5b17faec3c2b7a7ff3005e62542
parent0012cb312e92c33f5263478d318eb82da22ee879 (diff)
downloadBobinkQtOpcUa-5b93aac1f802d0db838d3d12802f2863eb13e0f8.tar.gz
BobinkQtOpcUa-5b93aac1f802d0db838d3d12802f2863eb13e0f8.zip
Add nodeId and monitored properties to OpcUaMonitoredNode
-rw-r--r--demo/NodePage.qml19
-rw-r--r--src/OpcUaMonitoredNode.cpp30
-rw-r--r--src/OpcUaMonitoredNode.h16
3 files changed, 61 insertions, 4 deletions
diff --git a/demo/NodePage.qml b/demo/NodePage.qml
index bd57583..e00f468 100644
--- a/demo/NodePage.qml
+++ b/demo/NodePage.qml
@@ -1,4 +1,4 @@
-// NodePage.qml — Placeholder while OpcUaMonitoredNode is implemented.
+// NodePage.qml — Demo page with OpcUaMonitoredNode lifecycle logging.
import QtQuick
import QtQuick.Controls
@@ -12,6 +12,15 @@ Page {
required property int pageNumber
required property var logFunction
+ OpcUaMonitoredNode {
+ id: demoNode
+ nodeId: "ns=2;s=DemoVariable.Page" + nodePage.pageNumber
+ monitored: nodePage.StackView.status === StackView.Active
+ onMonitoredChanged: nodePage.logFunction(
+ "Page " + nodePage.pageNumber + " node [" + nodeId + "] "
+ + (monitored ? "MONITORED" : "UNMONITORED"))
+ }
+
ColumnLayout {
anchors.fill: parent
anchors.margins: 20
@@ -31,9 +40,11 @@ Page {
}
Label {
- text: "Node monitoring not yet available (OpcUaMonitoredNode in progress)"
- font.italic: true
- color: "gray"
+ text: "Node: " + demoNode.nodeId
+ }
+ Label {
+ text: "Monitored: " + demoNode.monitored
+ color: demoNode.monitored ? "green" : "gray"
}
Item { Layout.fillHeight: true }
diff --git a/src/OpcUaMonitoredNode.cpp b/src/OpcUaMonitoredNode.cpp
index da66e89..f7a5c9f 100644
--- a/src/OpcUaMonitoredNode.cpp
+++ b/src/OpcUaMonitoredNode.cpp
@@ -6,6 +6,36 @@
OpcUaMonitoredNode::OpcUaMonitoredNode (QObject *parent) : QObject (parent) {}
+QString
+OpcUaMonitoredNode::nodeId () const
+{
+ return m_nodeId;
+}
+
+void
+OpcUaMonitoredNode::setNodeId (const QString &id)
+{
+ if (m_nodeId == id)
+ return;
+ m_nodeId = id;
+ emit nodeIdChanged ();
+}
+
+bool
+OpcUaMonitoredNode::monitored () const
+{
+ return m_monitored;
+}
+
+void
+OpcUaMonitoredNode::setMonitored (bool monitored)
+{
+ if (m_monitored == monitored)
+ return;
+ m_monitored = monitored;
+ emit monitoredChanged ();
+}
+
void
OpcUaMonitoredNode::classBegin ()
{
diff --git a/src/OpcUaMonitoredNode.h b/src/OpcUaMonitoredNode.h
index ccf3444..9d093b5 100644
--- a/src/OpcUaMonitoredNode.h
+++ b/src/OpcUaMonitoredNode.h
@@ -18,13 +18,29 @@ class OpcUaMonitoredNode : public QObject, public QQmlParserStatus
Q_INTERFACES (QQmlParserStatus)
QML_ELEMENT
+ Q_PROPERTY (QString nodeId READ nodeId WRITE setNodeId NOTIFY nodeIdChanged)
+ Q_PROPERTY (
+ bool monitored READ monitored WRITE setMonitored NOTIFY monitoredChanged)
+
public:
explicit OpcUaMonitoredNode (QObject *parent = nullptr);
+ QString nodeId () const;
+ void setNodeId (const QString &id);
+
+ bool monitored () const;
+ void setMonitored (bool monitored);
+
void classBegin () override;
void componentComplete () override;
+signals:
+ void nodeIdChanged ();
+ void monitoredChanged ();
+
private:
+ QString m_nodeId;
+ bool m_monitored = true;
bool m_componentComplete = false;
};