aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-16 16:48:34 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-16 16:48:34 +0100
commitf2251311a8523b6c24839ccd1e6834ef065c679f (patch)
tree56d89508f564281c6a8ae09f3e7c05d214c87170
parentfa095de6cc8ec5a5b5c14091f2b3179ad7071876 (diff)
downloadQtXpl2-f2251311a8523b6c24839ccd1e6834ef065c679f.tar.gz
QtXpl2-f2251311a8523b6c24839ccd1e6834ef065c679f.zip
Imaging (m/n) commands: start/stop, masks, image count, n reply
-rw-r--r--demo/CommandsPage.qml30
-rw-r--r--mock-server/MockServer.cpp50
-rw-r--r--mock-server/MockServer.h8
-rw-r--r--src/Xpl2Client.cpp66
-rw-r--r--src/Xpl2Client.h21
5 files changed, 174 insertions, 1 deletions
diff --git a/demo/CommandsPage.qml b/demo/CommandsPage.qml
index 2e4437b..5a084e6 100644
--- a/demo/CommandsPage.qml
+++ b/demo/CommandsPage.qml
@@ -123,6 +123,36 @@ ColumnLayout {
}
}
+ // --- Imaging ---
+ GroupBox {
+ Layout.fillWidth: true
+ enabled: Xpl2Client.connected
+ title: "Imaging"
+
+ GridLayout {
+ anchors.fill: parent
+ columns: 4
+
+ Button {
+ text: "Start Imaging"
+
+ onClicked: Xpl2Client.imagingStart(1.0)
+ }
+
+ Button {
+ text: "Stop Imaging"
+
+ onClicked: Xpl2Client.imagingStop()
+ }
+
+ Button {
+ text: "Image Count"
+
+ onClicked: Xpl2Client.imageCount()
+ }
+ }
+ }
+
// --- Printheads ---
GroupBox {
Layout.fillHeight: true
diff --git a/mock-server/MockServer.cpp b/mock-server/MockServer.cpp
index f8831da..87279b4 100644
--- a/mock-server/MockServer.cpp
+++ b/mock-server/MockServer.cpp
@@ -185,6 +185,17 @@ MockServer::handleCommand (QTcpSocket *client, const QByteArray &line)
handleCfJcGetter (client, params);
else if (cmd == "CF_PH_GETTER")
handleCfPhGetter (client, params);
+ /* Imaging commands (port 2) */
+ else if (cmd == "m2")
+ handleImagingStart (client, params);
+ else if (cmd == "m4")
+ handleImagingStop (client);
+ else if (cmd == "m0" || cmd == "m5")
+ handleImagingMaskStart (client, cmd, params);
+ else if (cmd == "m1" || cmd == "m6")
+ handleImagingMaskEnd (client, cmd, params);
+ else if (cmd == "m3")
+ handleImageCount (client);
else
qWarning ("%s Unknown command: %s",
qPrintable (logTag (client->localPort ())), cmd.constData ());
@@ -469,3 +480,42 @@ MockServer::sendPhStatusMsg ()
&& client->localPort () == m_status.number)
sendReply (client, base);
}
+
+void
+MockServer::handleImagingStart (QTcpSocket *client, const QByteArray &params)
+{
+ qDebug ("%s RX m2,%s", qPrintable (logTag (client->localPort ())),
+ params.constData ());
+ sendReply (client, "n,\"A\"\n");
+}
+
+void
+MockServer::handleImagingStop (QTcpSocket *client)
+{
+ qDebug ("%s RX m4", qPrintable (logTag (client->localPort ())));
+ sendReply (client, "m4,1\n");
+}
+
+void
+MockServer::handleImagingMaskStart (QTcpSocket *client, const QByteArray &cmd,
+ const QByteArray &params)
+{
+ qDebug ("%s RX %s,%s", qPrintable (logTag (client->localPort ())),
+ cmd.constData (), params.constData ());
+}
+
+void
+MockServer::handleImagingMaskEnd (QTcpSocket *client, const QByteArray &cmd,
+ const QByteArray &params)
+{
+ qDebug ("%s RX %s,%s", qPrintable (logTag (client->localPort ())),
+ cmd.constData (), params.constData ());
+ sendReply (client, "n,\"A\"\n");
+}
+
+void
+MockServer::handleImageCount (QTcpSocket *client)
+{
+ qDebug ("%s RX m3", qPrintable (logTag (client->localPort ())));
+ sendReply (client, "n,\"0\"\n");
+}
diff --git a/mock-server/MockServer.h b/mock-server/MockServer.h
index 3086057..74b2731 100644
--- a/mock-server/MockServer.h
+++ b/mock-server/MockServer.h
@@ -69,6 +69,14 @@ private:
void handleCfPhSetter (QTcpSocket *client, const QByteArray &params);
void handleCfJcGetter (QTcpSocket *client, const QByteArray &params);
void handleCfPhGetter (QTcpSocket *client, const QByteArray &params);
+ /* Imaging command handlers */
+ void handleImagingStart (QTcpSocket *client, const QByteArray &params);
+ void handleImagingStop (QTcpSocket *client);
+ void handleImagingMaskStart (QTcpSocket *client, const QByteArray &cmd,
+ const QByteArray &params);
+ void handleImagingMaskEnd (QTcpSocket *client, const QByteArray &cmd,
+ const QByteArray &params);
+ void handleImageCount (QTcpSocket *client);
Port m_command;
Port m_imaging;
diff --git a/src/Xpl2Client.cpp b/src/Xpl2Client.cpp
index ac7079f..d3a6da2 100644
--- a/src/Xpl2Client.cpp
+++ b/src/Xpl2Client.cpp
@@ -559,6 +559,52 @@ Xpl2Client::phSaveSettings (int 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 ();