aboutsummaryrefslogtreecommitdiffstats
path: root/demo/Main.qml
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-16 11:04:21 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-16 11:04:21 +0100
commit9ac64169720fb2b9852589b74f7300bcfebcaf62 (patch)
tree693e6582542c0c420cf521f42084d35c72ceff8f /demo/Main.qml
parent87169e10cb7ebe732ef388552bb0c057c09767ef (diff)
downloadQtXpl2-9ac64169720fb2b9852589b74f7300bcfebcaf62.tar.gz
QtXpl2-9ac64169720fb2b9852589b74f7300bcfebcaf62.zip
GS_PH_VERSION command, per-printhead demo UI with --printheads CLI arg
Add getPhVersion(printheadId) to Xpl2Client with phVersionReceived signal carrying all 8 response fields. Mock server echoes canned version data for any requested printhead ID. Demo app accepts --printheads N (default 10) to simulate N printheads. The UI shows a scrollable per-PH list with individual and bulk version query buttons, updating each row's version info on response.
Diffstat (limited to 'demo/Main.qml')
-rw-r--r--demo/Main.qml132
1 files changed, 111 insertions, 21 deletions
diff --git a/demo/Main.qml b/demo/Main.qml
index db015e3..07e42b1 100644
--- a/demo/Main.qml
+++ b/demo/Main.qml
@@ -8,10 +8,26 @@ import Xpl2
ApplicationWindow {
id: root
- height: 600
+ // Set from C++ via setInitialProperties (--printheads CLI arg, default 10).
+ required property int demoPhCount
+
+ height: 700
title: "XPL2 Demo"
visible: true
- width: 800
+ width: 900
+
+ Component.onCompleted: {
+ for (let i = 1; i <= root.demoPhCount; ++i)
+ phModel.append({
+ "phId": i,
+ "versionInfo": ""
+ });
+ }
+
+ ListModel {
+ id: phModel
+
+ }
Connections {
function onConnectedChanged() {
@@ -23,6 +39,28 @@ ApplicationWindow {
debugConsole.appendLog("ERROR: " + error);
}
+ function onPhVersionReceived(controllerId: int, printheadId: int,
+ mcuFirmwareVersion: string,
+ mcuHardwareVersion: string,
+ mcuFirmwareVariant: string,
+ fpgaFirmwareVersion: string,
+ fpgaHardwareVersion: string,
+ bootloaderVersion: string) {
+ for (let i = 0; i < phModel.count; ++i) {
+ if (phModel.get(i).phId === printheadId) {
+ phModel.setProperty(i, "versionInfo",
+ "MCU %1/%2 (%3) | FPGA %4/%5 | Boot %6".arg(
+ mcuFirmwareVersion).arg(
+ mcuHardwareVersion).arg(
+ mcuFirmwareVariant).arg(
+ fpgaFirmwareVersion).arg(
+ fpgaHardwareVersion).arg(
+ bootloaderVersion));
+ break;
+ }
+ }
+ }
+
function onStatusMessage(message: string) {
debugConsole.appendLog(message);
}
@@ -74,38 +112,90 @@ ApplicationWindow {
}
}
- // --- Protocol Commands ---
+ // --- JC Version ---
GroupBox {
Layout.fillWidth: true
enabled: Xpl2Client.connected
- title: "Protocol Commands"
+ title: "Jetting Controller"
- ColumnLayout {
+ RowLayout {
anchors.fill: parent
- RowLayout {
- Button {
- text: "Get JC Version"
+ Button {
+ text: "Get JC Version"
- onClicked: Xpl2Client.getJcVersion()
- }
+ onClicked: Xpl2Client.getJcVersion()
+ }
- Label {
- text: Xpl2Client.controllerId > 0
- ? "Controller: %1 | FW: %2 | HW: %3 | PHs: %4".arg(
- Xpl2Client.controllerId).arg(
- Xpl2Client.firmwareVersion).arg(
- Xpl2Client.hardwareVersion).arg(
- Xpl2Client.printheadCount) :
- "No version data"
- }
+ Label {
+ text: Xpl2Client.controllerId > 0
+ ? "Controller: %1 | FW: %2 | HW: %3 | PHs: %4".arg(
+ Xpl2Client.controllerId).arg(
+ Xpl2Client.firmwareVersion).arg(
+ Xpl2Client.hardwareVersion).arg(
+ Xpl2Client.printheadCount) :
+ "No version data"
}
}
}
- // --- Spacer ---
- Item {
+ // --- Printheads ---
+ GroupBox {
Layout.fillHeight: true
+ Layout.fillWidth: true
+ enabled: Xpl2Client.connected
+ title: "Printheads (%1)".arg(root.demoPhCount)
+
+ ColumnLayout {
+ anchors.fill: parent
+
+ Button {
+ text: "Get All PH Versions"
+
+ onClicked: {
+ for (let i = 0; i < phModel.count; ++i)
+ Xpl2Client.getPhVersion(phModel.get(i).phId);
+ }
+ }
+
+ ScrollView {
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+
+ ListView {
+ model: phModel
+ spacing: 4
+
+ delegate: RowLayout {
+ id: phDelegate
+
+ required property int phId
+ required property string versionInfo
+
+ width: ListView.view.width
+
+ Label {
+ Layout.preferredWidth: 50
+ font.bold: true
+ text: "PH %1".arg(phDelegate.phId)
+ }
+
+ Button {
+ text: "Version"
+
+ onClicked: Xpl2Client.getPhVersion(
+ phDelegate.phId)
+ }
+
+ Label {
+ Layout.fillWidth: true
+ elide: Text.ElideRight
+ text: phDelegate.versionInfo || "—"
+ }
+ }
+ }
+ }
+ }
}
}