From 8bcf948b76c9564cb38d3611228ccaf73890a548 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 23 Mar 2026 16:48:32 +0100 Subject: Rename demo/ → jetting-interface/, mock-server/ → mock-jetting-controller/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Executables: QtXpl2Demo → JettingInterfaceDemo, Xpl2MockServer → MockJettingController. Dev log prefixes: "Demo" → "JI", "MockServer" → "MockJC". Window title → "Jetting Interface". --- jetting-interface/Main.qml | 173 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 jetting-interface/Main.qml (limited to 'jetting-interface/Main.qml') diff --git a/jetting-interface/Main.qml b/jetting-interface/Main.qml new file mode 100644 index 0000000..1c7b553 --- /dev/null +++ b/jetting-interface/Main.qml @@ -0,0 +1,173 @@ +pragma ComponentBehavior: Bound + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Xpl2 + +ApplicationWindow { + id: root + + // Set from C++ via setInitialProperties (--printheads CLI arg, default 10). + required property int demoPhCount + + height: 1200 + title: "Jetting Interface" + visible: true + width: 900 + + Component.onCompleted: { + for (let i = 1; i <= root.demoPhCount; ++i) + phModel.append({ + "phId": i, + "versionInfo": "" + }); + } + + ListModel { + id: phModel + + } + + Connections { + function onConnectedChanged() { + debugConsole.appendLog(Xpl2Client.connected + ? "Controller connected" : + "Controller disconnected"); + } + + function onErrorOccurred(error: string) { + debugConsole.appendLog("ERROR: " + error); + } + + function onJcStatusReceived(status) { + statusPage.lastJcStatus = status; + } + + function onListeningChanged() { + debugConsole.appendLog(Xpl2Client.listening + ? "Listening on ports 9110/9111/9112" : + "Stopped listening"); + } + + function onPhStatusReceived(status) { + statusPage.lastPhStatus = status; + } + + 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 onShuttingDown() { + debugConsole.appendLog("SERVER SHUTTING DOWN"); + } + + function onStatusMessage(message: string) { + debugConsole.appendLog(message); + } + + target: Xpl2Client + } + + ColumnLayout { + anchors.fill: parent + spacing: 0 + + // --- Connection (always visible) --- + GroupBox { + Layout.bottomMargin: 0 + Layout.fillWidth: true + Layout.margins: 16 + title: "Connection" + + RowLayout { + anchors.fill: parent + + Label { + text: Xpl2Client.connected ? "Controller connected" : + "Waiting for controller…" + } + + Item { + Layout.fillWidth: true + } + + Button { + text: Xpl2Client.listening ? "Stop" : "Listen" + + onClicked: { + if (Xpl2Client.listening) + Xpl2Client.stopListening(); + else + Xpl2Client.startListening(); + } + } + } + } + + // --- Tab bar --- + TabBar { + id: tabBar + + Layout.fillWidth: true + Layout.leftMargin: 16 + Layout.rightMargin: 16 + + TabButton { + text: "Commands" + } + + TabButton { + text: "Status" + } + } + + // --- Swipe view --- + SwipeView { + id: swipeView + + Layout.fillHeight: true + Layout.fillWidth: true + Layout.margins: 16 + currentIndex: tabBar.currentIndex + + onCurrentIndexChanged: tabBar.currentIndex = currentIndex + + CommandsPage { + demoPhCount: root.demoPhCount + phModel: phModel + } + + StatusPage { + id: statusPage + + } + } + + // --- Debug Console --- + DebugConsole { + id: debugConsole + + Layout.fillWidth: true + Layout.preferredHeight: 160 + } + } +} -- cgit v1.2.3