1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
// NodePage.qml — Displays 10 OPC UA nodes per page with tooltips.
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Bobink
Page {
id: nodePage
required property StackView stackRef
required property int pageNumber
required property var logFunction
readonly property var pages: [
{
title: "Read-Write Scalars",
nodes: [
"ns=1;s=bool_rw_scalar",
"ns=1;s=int16_rw_scalar",
"ns=1;s=uint16_rw_scalar",
"ns=1;s=int32_rw_scalar",
"ns=1;s=uint32_rw_scalar",
"ns=1;s=int64_rw_scalar",
"ns=1;s=uint64_rw_scalar",
"ns=1;s=float_rw_scalar",
"ns=1;s=double_rw_scalar",
"ns=1;s=string_rw_scalar"
]
},
{
title: "Read-Only Scalars",
nodes: [
"ns=1;s=bool_ro_scalar",
"ns=1;s=int16_ro_scalar",
"ns=1;s=uint16_ro_scalar",
"ns=1;s=int32_ro_scalar",
"ns=1;s=uint32_ro_scalar",
"ns=1;s=int64_ro_scalar",
"ns=1;s=uint64_ro_scalar",
"ns=1;s=float_ro_scalar",
"ns=1;s=double_ro_scalar",
"ns=1;s=string_ro_scalar"
]
},
{
title: "Read-Write Arrays",
nodes: [
"ns=1;s=bool_rw_array",
"ns=1;s=int16_rw_array",
"ns=1;s=uint16_rw_array",
"ns=1;s=int32_rw_array",
"ns=1;s=uint32_rw_array",
"ns=1;s=int64_rw_array",
"ns=1;s=uint64_rw_array",
"ns=1;s=float_rw_array",
"ns=1;s=double_rw_array",
"ns=1;s=string_rw_array"
]
}
]
readonly property var currentPage: pages[pageNumber - 1]
Component.onCompleted: nodePage.logFunction(
currentPage.title + " page loaded (" + currentPage.nodes.length + " nodes)")
ColumnLayout {
anchors.fill: parent
anchors.margins: 20
spacing: 4
// Header
RowLayout {
Label {
text: currentPage.title
font.bold: true
font.pointSize: 14
}
Label {
text: "(" + nodePage.pageNumber + "/3)"
color: "gray"
}
Item { Layout.fillWidth: true }
Button {
text: "Disconnect"
onClicked: Bobink.disconnectFromServer()
}
}
// Column headers
RowLayout {
Layout.fillWidth: true
spacing: 0
Label {
text: "Identifier"
font.bold: true
Layout.preferredWidth: 200
leftPadding: 12
}
Label {
text: "Value"
font.bold: true
Layout.fillWidth: true
}
}
Rectangle {
Layout.fillWidth: true
height: 1
color: "#ccc"
}
// Nodes
Repeater {
model: currentPage.nodes
ItemDelegate {
id: delegate
required property string modelData
required property int index
Layout.fillWidth: true
padding: 4
leftPadding: 12
rightPadding: 12
OpcUaMonitoredNode {
id: node
nodeId: delegate.modelData
monitored: nodePage.StackView.status === StackView.Active
}
background: Rectangle {
color: delegate.index % 2 === 0 ? "#f8f8f8" : "transparent"
radius: 2
}
contentItem: RowLayout {
spacing: 12
Label {
text: {
var idx = node.nodeId.indexOf(";s=");
return idx >= 0 ? node.nodeId.substring(idx + 3) : node.nodeId;
}
Layout.preferredWidth: 188
elide: Text.ElideRight
}
Label {
text: node.value !== undefined && String(node.value) !== "" ? String(node.value) : "—"
Layout.fillWidth: true
elide: Text.ElideRight
}
}
ToolTip.visible: hovered
ToolTip.delay: 400
ToolTip.text:
"Display Name: " + (node.info.displayName || "—")
+ "\nDescription: " + (node.info.description || "—")
+ "\nNode Class: " + (node.info.nodeClass || "—")
+ "\nData Type: " + (node.info.dataType || "—")
+ "\nAccess Level: " + node.info.accessLevel
+ "\nStatus: " + (node.info.status || "—")
+ "\nSource Time: " + (node.info.sourceTimestamp.toLocaleString() || "—")
+ "\nServer Time: " + (node.info.serverTimestamp.toLocaleString() || "—")
}
}
Item { Layout.fillHeight: true }
// Navigation
RowLayout {
Layout.fillWidth: true
Button {
text: "← Previous"
visible: nodePage.pageNumber > 1
onClicked: nodePage.stackRef.pop()
}
Item { Layout.fillWidth: true }
Button {
text: "Next →"
visible: nodePage.pageNumber < 3
onClicked: nodePage.stackRef.push("NodePage.qml", {
stackRef: nodePage.stackRef,
pageNumber: nodePage.pageNumber + 1,
logFunction: nodePage.logFunction
})
}
}
}
}
|