diff options
Diffstat (limited to 'demo')
| -rw-r--r-- | demo/Main.qml | 10 | ||||
| -rw-r--r-- | demo/NodePage.qml | 209 |
2 files changed, 117 insertions, 102 deletions
diff --git a/demo/Main.qml b/demo/Main.qml index 9d3e168..ca0a419 100644 --- a/demo/Main.qml +++ b/demo/Main.qml @@ -82,7 +82,7 @@ ApplicationWindow { Bobink.startDiscovery(); } - BobinkAuth { + OpcUaAuth { id: auth mode: authModeCombo.currentValue username: usernameField.text @@ -267,22 +267,22 @@ ApplicationWindow { model: [ { text: "Anonymous", - mode: BobinkAuth.Anonymous + mode: OpcUaAuth.Anonymous }, { text: "Username / Password", - mode: BobinkAuth.UserPass + mode: OpcUaAuth.UserPass }, { text: "Certificate", - mode: BobinkAuth.Certificate + mode: OpcUaAuth.Certificate } ] } GridLayout { columns: 2 - visible: authModeCombo.currentValue === BobinkAuth.UserPass + visible: authModeCombo.currentValue === OpcUaAuth.UserPass Layout.fillWidth: true Label { diff --git a/demo/NodePage.qml b/demo/NodePage.qml index fd81db5..2de0a15 100644 --- a/demo/NodePage.qml +++ b/demo/NodePage.qml @@ -1,6 +1,4 @@ -// NodePage.qml — Monitors a single OPC UA node. -// Two instances demonstrate visibility lifecycle: switching pages -// stops monitoring on the hidden page automatically. +// NodePage.qml — Demo page displaying a single OPC UA node. import QtQuick import QtQuick.Controls @@ -14,28 +12,18 @@ Page { required property int pageNumber required property var logFunction - property string monitoredNodeId: "" - property string nodeDescription: "" - property bool nodeWritable: true - property bool metadataLoaded: false - - BobinkNode { - id: node - nodeId: nodePage.monitoredNodeId - onAttributeRead: (name, val) => { - if (name === "DisplayName") - nodePage.nodeDescription = val.toString(); - else if (name === "AccessLevel") - nodePage.nodeWritable = (val & 0x02) !== 0; - nodePage.metadataLoaded = true; - } - onWriteError: (message) => nodePage.logFunction("WRITE: " + message) + OpcUaMonitoredNode { + id: demoNode + nodeId: nodePage.pageNumber === 1 ? "ns=1;s=double_rw_scalar" : "ns=1;s=string_rw_scalar" + monitored: nodePage.StackView.status === StackView.Active + onMonitoredChanged: nodePage.logFunction("Page " + nodePage.pageNumber + " node [" + nodeId + "] " + (monitored ? "MONITORED" : "UNMONITORED")) + onValueChanged: nodePage.logFunction("Page " + nodePage.pageNumber + " value = " + value) } ColumnLayout { anchors.fill: parent anchors.margins: 20 - spacing: 12 + spacing: 8 RowLayout { Label { @@ -43,108 +31,135 @@ Page { font.bold: true font.pointSize: 14 } - Item { Layout.fillWidth: true } + Item { + Layout.fillWidth: true + } Button { text: "Disconnect" onClicked: Bobink.disconnectFromServer() } } - RowLayout { - TextField { - id: nodeIdField - Layout.fillWidth: true - placeholderText: "ns=2;s=Temperature" - enabled: !nodePage.monitoredNodeId - } - Button { - text: nodePage.monitoredNodeId ? "Stop" : "Monitor" - onClicked: { - if (nodePage.monitoredNodeId) { - nodePage.monitoredNodeId = ""; - nodePage.nodeDescription = ""; - nodePage.nodeWritable = true; - nodePage.metadataLoaded = false; - } else { - nodePage.monitoredNodeId = nodeIdField.text; - node.readAttribute("DisplayName"); - node.readAttribute("AccessLevel"); - } + // Value (prominent) + Rectangle { + Layout.fillWidth: true + height: 60 + color: "#f0f0f0" + radius: 4 + + ColumnLayout { + anchors.fill: parent + anchors.margins: 8 + spacing: 2 + + Label { + text: "Value" + font.pointSize: 10 + color: "gray" + } + Label { + text: demoNode.value !== undefined ? String(demoNode.value) : "—" + font.pointSize: 16 + font.bold: true + elide: Text.ElideRight + Layout.fillWidth: true } } } - GroupBox { + // Node info + GridLayout { Layout.fillWidth: true - visible: nodePage.monitoredNodeId.length > 0 - title: nodePage.nodeDescription || nodePage.monitoredNodeId + columns: 2 + columnSpacing: 12 + rowSpacing: 4 - GridLayout { - columns: 2 - width: parent.width + Label { + text: "Node ID:" + color: "gray" + } + Label { + text: demoNode.nodeId + Layout.fillWidth: true + } - Label { text: "Value:" } - Label { - text: node.value !== undefined ? node.value.toString() : "—" - font.family: "monospace" - font.bold: true - } + Label { + text: "Display Name:" + color: "gray" + } + Label { + text: demoNode.info.displayName || "—" + Layout.fillWidth: true + } - Label { text: "Status:" } - Label { - text: node.status === BobinkNode.Good ? "Good" - : node.status === BobinkNode.Uncertain ? "Uncertain" - : "Bad" - color: node.status === BobinkNode.Good ? "green" - : node.status === BobinkNode.Uncertain ? "orange" - : "red" - } + Label { + text: "Data Type:" + color: "gray" + } + Label { + text: demoNode.info.dataType || "—" + Layout.fillWidth: true + } - Label { text: "Source TS:" } - Label { - text: node.sourceTimestamp.toLocaleString( - Qt.locale(), "HH:mm:ss.zzz") - font.family: "monospace" - } + Label { + text: "Node Class:" + color: "gray" + } + Label { + text: demoNode.info.nodeClass || "—" + Layout.fillWidth: true + } - Label { text: "Server TS:" } - Label { - text: node.serverTimestamp.toLocaleString( - Qt.locale(), "HH:mm:ss.zzz") - font.family: "monospace" - } + Label { + text: "Access Level:" + color: "gray" + } + Label { + text: demoNode.info.accessLevel + Layout.fillWidth: true } - } - RowLayout { - visible: nodePage.monitoredNodeId.length > 0 + Label { + text: "Status:" + color: "gray" + } + Label { + text: demoNode.info.status || "—" + Layout.fillWidth: true + } - TextField { - id: writeField + Label { + text: "Source Time:" + color: "gray" + } + Label { + text: demoNode.info.sourceTimestamp.toLocaleString() || "—" Layout.fillWidth: true - enabled: nodePage.nodeWritable - placeholderText: nodePage.metadataLoaded && !nodePage.nodeWritable - ? "Read-only node" : "Value to write" } - Button { - text: "Write" - enabled: nodePage.nodeWritable - onClicked: { - node.value = writeField.text; - writeField.clear(); - } + + Label { + text: "Server Time:" + color: "gray" + } + Label { + text: demoNode.info.serverTimestamp.toLocaleString() || "—" + Layout.fillWidth: true } - } - Label { - visible: nodePage.monitoredNodeId.length > 0 - && nodePage.metadataLoaded && !nodePage.nodeWritable - text: "Read-only node" - font.italic: true - color: "gray" + Label { + text: "Monitored:" + color: "gray" + } + Label { + text: demoNode.monitored ? "Yes" : "No" + color: demoNode.monitored ? "green" : "gray" + Layout.fillWidth: true + } } - Item { Layout.fillHeight: true } + Item { + Layout.fillHeight: true + } Button { Layout.fillWidth: true |
