diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 18:20:35 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-03-13 18:20:35 +0100 |
| commit | 87169e10cb7ebe732ef388552bb0c057c09767ef (patch) | |
| tree | fba2c9e2255cb02553c43fb37d653a47574824ba /demo | |
| parent | 02fe86ab2a04a02b114d7ca8ce4374a29a1d5f45 (diff) | |
| download | QtXpl2-87169e10cb7ebe732ef388552bb0c057c09767ef.tar.gz QtXpl2-87169e10cb7ebe732ef388552bb0c057c09767ef.zip | |
Unified socket slots, --wire-debug CLI flag, fix mock TX and disconnect logging
Collapse 12 per-socket slots into 4 sender()-based slots. Replace runtime
wireDebug QML property with static --wire-debug CLI flag on both demo and
mock server. Route MockServer::sendKaPing through sendReply so KA_PING TX
shows wire bytes. Simplify sendReply to deduce command token from wire data.
Fix Xpl2Client disconnect logging (logTag takes pointer, null-sender fallback).
Diffstat (limited to 'demo')
| -rw-r--r-- | demo/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | demo/Main.qml | 23 | ||||
| -rw-r--r-- | demo/main.cpp | 13 |
3 files changed, 16 insertions, 21 deletions
diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index dd46473..bdee67f 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -17,3 +17,4 @@ set_target_properties(QtXpl2Demo PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") target_link_libraries(QtXpl2Demo PRIVATE Qt6::Quick QtXpl2plugin) +target_include_directories(QtXpl2Demo PRIVATE "${PROJECT_SOURCE_DIR}/src") diff --git a/demo/Main.qml b/demo/Main.qml index edf317c..db015e3 100644 --- a/demo/Main.qml +++ b/demo/Main.qml @@ -23,23 +23,10 @@ ApplicationWindow { debugConsole.appendLog("ERROR: " + error); } - function onJcVersionReceived() { - debugConsole.appendLog( - "JC Version: controller=%1 fw=%2 hw=%3 phCount=%4".arg( - Xpl2Client.controllerId).arg( - Xpl2Client.firmwareVersion).arg( - Xpl2Client.hardwareVersion).arg( - Xpl2Client.printheadCount)); - } - function onStatusMessage(message: string) { debugConsole.appendLog(message); } - function onWireDebugMessage(message: string) { - debugConsole.appendLog("WIRE: " + message); - } - target: Xpl2Client } @@ -84,13 +71,6 @@ ApplicationWindow { Xpl2Client.connectToServer(); } } - - CheckBox { - checked: Xpl2Client.wireDebug - text: "Wire debug" - - onToggled: Xpl2Client.wireDebug = checked - } } } @@ -134,7 +114,8 @@ ApplicationWindow { id: debugConsole function appendLog(msg: string): void { - let ts = new Date().toLocaleTimeString(Qt.locale(), "HH:mm:ss"); + let ts = new Date().toLocaleTimeString(Qt.locale(), + "HH:mm:ss.zzz"); debugLog.text += "[" + ts + "] " + msg + "\n"; debugLog.cursorPosition = debugLog.text.length; } diff --git a/demo/main.cpp b/demo/main.cpp index 64c4f22..3100254 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -2,6 +2,9 @@ * @file main.cpp * @brief Entry point for the QtXpl2 demo application. */ +#include "Xpl2Client.h" + +#include <QCommandLineParser> #include <QGuiApplication> #include <QQmlApplicationEngine> @@ -11,8 +14,18 @@ Q_IMPORT_QML_PLUGIN (Xpl2Plugin) int main (int argc, char *argv[]) { + qSetMessagePattern ("Demo [%{time HH:mm:ss.zzz}] %{message}"); + QGuiApplication app (argc, argv); + QCommandLineParser parser; + parser.addOption ({ "wire-debug", "Log raw wire TX/RX to dev log" }); + parser.addHelpOption (); + parser.process (app); + + if (parser.isSet ("wire-debug")) + Xpl2Client::enableWireDebug (); + QQmlApplicationEngine engine; QObject::connect ( &engine, &QQmlApplicationEngine::objectCreationFailed, &app, |
