From f2251311a8523b6c24839ccd1e6834ef065c679f Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 16 Mar 2026 16:48:34 +0100 Subject: Imaging (m/n) commands: start/stop, masks, image count, n reply --- src/Xpl2Client.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++- src/Xpl2Client.h | 21 +++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Xpl2Client.cpp b/src/Xpl2Client.cpp index ac7079f..d3a6da2 100644 --- a/src/Xpl2Client.cpp +++ b/src/Xpl2Client.cpp @@ -558,6 +558,52 @@ Xpl2Client::phSaveSettings (int printheadId) sendCommand (m_commandSocket, "CF_PH_SAVE_SETTINGS", { printheadId }); } +/* ------------------------------------------------------------------ */ +/* Imaging (m/n) commands */ +/* ------------------------------------------------------------------ */ + +void +Xpl2Client::imagingStart (double speed) +{ + sendCommand (m_imagingSocket, "m2", { speed }); +} + +void +Xpl2Client::imagingStop () +{ + sendCommand (m_imagingSocket, "m4"); +} + +void +Xpl2Client::imageMaskStart (const QString &mask) +{ + sendCommand (m_imagingSocket, "m0", { mask }); +} + +void +Xpl2Client::imageMaskEnd (const QString &tail) +{ + sendCommand (m_imagingSocket, "m1", { tail }); +} + +void +Xpl2Client::dutyCycleMaskStart (const QString &mask) +{ + sendCommand (m_imagingSocket, "m5", { mask }); +} + +void +Xpl2Client::dutyCycleMaskEnd (const QString &tail) +{ + sendCommand (m_imagingSocket, "m6", { tail }); +} + +void +Xpl2Client::imageCount () +{ + sendCommand (m_imagingSocket, "m3"); +} + /* ------------------------------------------------------------------ */ /* Send / dispatch */ /* ------------------------------------------------------------------ */ @@ -605,7 +651,25 @@ Xpl2Client::dispatchImagingMessage (const Xpl2Protocol::ParsedMessage &msg) handleKaPing (m_imagingSocket); else if (msg.command == "EV_SHUTTING_DOWN") emit shuttingDown (); - else + else if (msg.command == "n") + { + int lines = 0; + if (!msg.params.isEmpty ()) + lines = msg.params[0].toString ().toInt (nullptr, 16); + qDebug ("%s n imageLines=%d", qPrintable (logTag (&m_imagingSocket)), + lines); + emit statusMessage (QStringLiteral ("RX n: imageLines=%1").arg (lines)); + emit imagingReply (lines); + } + else if (msg.command == "m4") + { + bool ok = !msg.params.isEmpty () && msg.params[0].toInt () == 1; + qDebug ("%s m4 success=%d", qPrintable (logTag (&m_imagingSocket)), + ok); + emit statusMessage (QStringLiteral ("RX m4: success=%1").arg (ok)); + emit imagingStopResult (ok); + } + else if (!dispatchResponse (msg.command, msg.params, &m_imagingSocket)) qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_imagingSocket)), msg.command.constData ()); } diff --git a/src/Xpl2Client.h b/src/Xpl2Client.h index 724f926..838c344 100644 --- a/src/Xpl2Client.h +++ b/src/Xpl2Client.h @@ -159,6 +159,23 @@ public: /** Save settings for one printhead. */ Q_INVOKABLE void phSaveSettings (int printheadId); + /* -- Imaging (m/n) commands --------------------------------------- */ + + /** Start imaging at the given speed. */ + Q_INVOKABLE void imagingStart (double speed); + /** Stop imaging. */ + Q_INVOKABLE void imagingStop (); + /** Send image mask start (front of formatted message, 180 chars). */ + Q_INVOKABLE void imageMaskStart (const QString &mask); + /** Send image mask end (triggers transmission to JC). */ + Q_INVOKABLE void imageMaskEnd (const QString &tail); + /** Send duty cycle mask start (hex, 2 chars per PH). */ + Q_INVOKABLE void dutyCycleMaskStart (const QString &mask); + /** Send duty cycle mask end (triggers transmission to JC). */ + Q_INVOKABLE void dutyCycleMaskEnd (const QString &tail); + /** Check remaining image line count. */ + Q_INVOKABLE void imageCount (); + signals: void hostChanged (); void connectedChanged (); @@ -264,6 +281,10 @@ signals: void jcStatusReceived (const Xpl2JcStatus &status); void phStatusReceived (const Xpl2PhStatus &status); + /* Imaging response signals */ + void imagingReply (int imageLines); + void imagingStopResult (bool success); + private slots: void onSocketConnected (); void onSocketDisconnected (); -- cgit v1.2.3