From 50034b142dc851da7118032f7218cb1d25ea98e4 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 16 Mar 2026 15:14:13 +0100 Subject: CN_ control commands: typed API, dispatch, mock responses, demo UI --- demo/Main.qml | 48 ++++++ mock-server/MockServer.cpp | 103 ++++++++++++ mock-server/MockServer.h | 13 ++ src/Xpl2Client.cpp | 406 +++++++++++++++++++++++++++++++++++++++++++++ src/Xpl2Client.h | 91 ++++++++++ 5 files changed, 661 insertions(+) diff --git a/demo/Main.qml b/demo/Main.qml index 07e42b1..52d3097 100644 --- a/demo/Main.qml +++ b/demo/Main.qml @@ -139,6 +139,54 @@ ApplicationWindow { } } + // --- Control --- + GroupBox { + Layout.fillWidth: true + enabled: Xpl2Client.connected + title: "Control" + + GridLayout { + anchors.fill: parent + columns: 4 + + Button { + text: "Jetting All On" + + onClicked: Xpl2Client.jettingAllOn() + } + + Button { + text: "Jetting Off" + + onClicked: Xpl2Client.jettingOff() + } + + Button { + text: "JC LED On" + + onClicked: Xpl2Client.jcIdLedOn() + } + + Button { + text: "JC LED Off" + + onClicked: Xpl2Client.jcIdLedOff() + } + + Button { + text: "JC Calibration" + + onClicked: Xpl2Client.jcCalibration() + } + + Button { + text: "Reset Fault Codes" + + onClicked: Xpl2Client.jcResetFaultCodes() + } + } + } + // --- Printheads --- GroupBox { Layout.fillHeight: true diff --git a/mock-server/MockServer.cpp b/mock-server/MockServer.cpp index 981bd1c..d83ad17 100644 --- a/mock-server/MockServer.cpp +++ b/mock-server/MockServer.cpp @@ -121,6 +121,32 @@ MockServer::handleCommand (QTcpSocket *client, const QByteArray &line) handleGsJcVersion (client); else if (cmd == "GS_PH_VERSION") handleGsPhVersion (client, params); + /* CN_ JC success shape (no params needed) */ + else if (cmd == "CN_JETTING_ALL_ON" || cmd == "CN_JETTING_ON" + || cmd == "CN_JETTING_OFF" || cmd == "CN_JC_ID_LED_ON" + || cmd == "CN_JC_ID_LED_OFF" || cmd == "CN_JC_CALIBRATION" + || cmd == "CN_JC_RESET_FAULT_CODES") + handleCnJcSuccess (client, cmd); + /* CN_ PH success shape (params carry printheadId) */ + else if (cmd == "CN_PH_JETTING_ON" || cmd == "CN_PH_JETTING_OFF" + || cmd == "CN_PH_ID_LED_ON" || cmd == "CN_PH_ID_LED_OFF" + || cmd == "CN_PH_CALIBRATION" || cmd == "CN_PH_RESET_FAULT_CODES" + || cmd == "CN_PH_NOZZLES_DISABLED") + handleCnPhSuccess (client, cmd, params); + /* CN_ custom-shape commands */ + else if (cmd == "CN_PH_CALIBRATION_DATA") + handleCnPhCalibrationData (client, params); + else if (cmd == "CN_PH_CALIBRATION_RAW_DATA") + handleCnPhCalibrationRawData (client, params); + else if (cmd == "CN_PH_CALIBRATED_BASE_FREQUENCY") + handleCnPhCalibratedBaseFrequency (client, params); + /* CN_ status messaging (arrives on status port) */ + else if (cmd == "CN_JC_STATUS_MESSAGING_START" + || cmd == "CN_PH_STATUS_MESSAGING_START") + handleCnStatusMessagingStart (client, cmd, params); + else if (cmd == "CN_JC_STATUS_MESSAGING_STOP" + || cmd == "CN_PH_STATUS_MESSAGING_STOP") + handleCnStatusMessagingStop (client, cmd); else qWarning ("%s Unknown command: %s", qPrintable (logTag (client->localPort ())), cmd.constData ()); @@ -167,3 +193,80 @@ MockServer::handleGsPhVersion (QTcpSocket *client, const QByteArray ¶ms) + ",\"3.10\",\"1.00\",\"Standard\"," "\"2.05\",\"1.02\",\"0.9.1\"\n"); } + +void +MockServer::handleCnJcSuccess (QTcpSocket *client, const QByteArray &cmd) +{ + qDebug ("%s RX %s", qPrintable (logTag (client->localPort ())), + cmd.constData ()); + sendReply (client, cmd + ",1,1\n"); +} + +void +MockServer::handleCnPhSuccess (QTcpSocket *client, const QByteArray &cmd, + const QByteArray ¶ms) +{ + qDebug ("%s RX %s,%s", qPrintable (logTag (client->localPort ())), + cmd.constData (), params.constData ()); + /* Extract printhead ID (first field before any comma). */ + int comma = params.indexOf (','); + QByteArray phId = (comma >= 0) ? params.left (comma) : params; + sendReply (client, cmd + ",1," + phId + ",1\n"); +} + +void +MockServer::handleCnPhCalibrationData (QTcpSocket *client, + const QByteArray ¶ms) +{ + qDebug ("%s RX CN_PH_CALIBRATION_DATA,%s", + qPrintable (logTag (client->localPort ())), params.constData ()); + /* Reply: controllerId, phId, then 48 floats (-1 = uncalibrated). */ + QByteArray reply = "CN_PH_CALIBRATION_DATA,1," + params; + for (int i = 0; i < 48; ++i) + reply += ",-1"; + reply += '\n'; + sendReply (client, reply); +} + +void +MockServer::handleCnPhCalibrationRawData (QTcpSocket *client, + const QByteArray ¶ms) +{ + qDebug ("%s RX CN_PH_CALIBRATION_RAW_DATA,%s", + qPrintable (logTag (client->localPort ())), params.constData ()); + QByteArray reply = "CN_PH_CALIBRATION_RAW_DATA,1," + params; + for (int i = 0; i < 48; ++i) + reply += ",-1"; + reply += '\n'; + sendReply (client, reply); +} + +void +MockServer::handleCnPhCalibratedBaseFrequency (QTcpSocket *client, + const QByteArray ¶ms) +{ + qDebug ("%s RX CN_PH_CALIBRATED_BASE_FREQUENCY,%s", + qPrintable (logTag (client->localPort ())), params.constData ()); + sendReply (client, + "CN_PH_CALIBRATED_BASE_FREQUENCY,1," + params + ",10.0,10.0\n"); +} + +void +MockServer::handleCnStatusMessagingStart (QTcpSocket *client, + const QByteArray &cmd, + const QByteArray ¶ms) +{ + qDebug ("%s RX %s,%s", qPrintable (logTag (client->localPort ())), + cmd.constData (), params.constData ()); + /* Echo back: controllerId, level, interval, success. */ + sendReply (client, cmd + ",1," + params + ",1\n"); +} + +void +MockServer::handleCnStatusMessagingStop (QTcpSocket *client, + const QByteArray &cmd) +{ + qDebug ("%s RX %s", qPrintable (logTag (client->localPort ())), + cmd.constData ()); + sendReply (client, cmd + ",1,1\n"); +} diff --git a/mock-server/MockServer.h b/mock-server/MockServer.h index ce76889..c07cdbe 100644 --- a/mock-server/MockServer.h +++ b/mock-server/MockServer.h @@ -43,6 +43,19 @@ private: void handleKaPing (QTcpSocket *client, const QByteArray ¶ms); void handleGsJcVersion (QTcpSocket *client); void handleGsPhVersion (QTcpSocket *client, const QByteArray ¶ms); + /* CN_ control command handlers */ + void handleCnJcSuccess (QTcpSocket *client, const QByteArray &cmd); + void handleCnPhSuccess (QTcpSocket *client, const QByteArray &cmd, + const QByteArray ¶ms); + void handleCnPhCalibrationData (QTcpSocket *client, + const QByteArray ¶ms); + void handleCnPhCalibrationRawData (QTcpSocket *client, + const QByteArray ¶ms); + void handleCnPhCalibratedBaseFrequency (QTcpSocket *client, + const QByteArray ¶ms); + void handleCnStatusMessagingStart (QTcpSocket *client, const QByteArray &cmd, + const QByteArray ¶ms); + void handleCnStatusMessagingStop (QTcpSocket *client, const QByteArray &cmd); Port m_command; Port m_imaging; diff --git a/src/Xpl2Client.cpp b/src/Xpl2Client.cpp index 54346e0..8276577 100644 --- a/src/Xpl2Client.cpp +++ b/src/Xpl2Client.cpp @@ -116,6 +116,141 @@ Xpl2Client::getPhVersion (int printheadId) sendCommand (m_commandSocket, "GS_PH_VERSION", { printheadId }); } +/* ------------------------------------------------------------------ */ +/* CN_ Control commands */ +/* ------------------------------------------------------------------ */ + +void +Xpl2Client::jettingAllOn () +{ + sendCommand (m_commandSocket, "CN_JETTING_ALL_ON"); +} + +void +Xpl2Client::jettingOn (const QString &jettingMask) +{ + sendCommand (m_commandSocket, "CN_JETTING_ON", { jettingMask }); +} + +void +Xpl2Client::jettingOff () +{ + sendCommand (m_commandSocket, "CN_JETTING_OFF"); +} + +void +Xpl2Client::phJettingOn (int printheadId, const QString &jettingMask) +{ + sendCommand (m_commandSocket, "CN_PH_JETTING_ON", + { printheadId, jettingMask }); +} + +void +Xpl2Client::phJettingOff (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_JETTING_OFF", { printheadId }); +} + +void +Xpl2Client::jcIdLedOn () +{ + sendCommand (m_commandSocket, "CN_JC_ID_LED_ON"); +} + +void +Xpl2Client::jcIdLedOff () +{ + sendCommand (m_commandSocket, "CN_JC_ID_LED_OFF"); +} + +void +Xpl2Client::phIdLedOn (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_ID_LED_ON", { printheadId }); +} + +void +Xpl2Client::phIdLedOff (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_ID_LED_OFF", { printheadId }); +} + +void +Xpl2Client::jcCalibration () +{ + sendCommand (m_commandSocket, "CN_JC_CALIBRATION"); +} + +void +Xpl2Client::phCalibration (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_CALIBRATION", { printheadId }); +} + +void +Xpl2Client::phCalibrationData (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_CALIBRATION_DATA", { printheadId }); +} + +void +Xpl2Client::phCalibrationRawData (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_CALIBRATION_RAW_DATA", { printheadId }); +} + +void +Xpl2Client::phCalibratedBaseFrequency (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_CALIBRATED_BASE_FREQUENCY", + { printheadId }); +} + +void +Xpl2Client::jcStatusMessagingStart (int statusLevel, int sendIntervalMs) +{ + sendCommand (m_statusSocket, "CN_JC_STATUS_MESSAGING_START", + { statusLevel, sendIntervalMs }); +} + +void +Xpl2Client::jcStatusMessagingStop () +{ + sendCommand (m_statusSocket, "CN_JC_STATUS_MESSAGING_STOP"); +} + +void +Xpl2Client::phStatusMessagingStart (int statusLevel, int sendIntervalMs) +{ + sendCommand (m_statusSocket, "CN_PH_STATUS_MESSAGING_START", + { statusLevel, sendIntervalMs }); +} + +void +Xpl2Client::phStatusMessagingStop () +{ + sendCommand (m_statusSocket, "CN_PH_STATUS_MESSAGING_STOP"); +} + +void +Xpl2Client::jcResetFaultCodes () +{ + sendCommand (m_commandSocket, "CN_JC_RESET_FAULT_CODES"); +} + +void +Xpl2Client::phResetFaultCodes (int printheadId) +{ + sendCommand (m_commandSocket, "CN_PH_RESET_FAULT_CODES", { printheadId }); +} + +void +Xpl2Client::phNozzlesDisabled (int printheadId, const QString &mask) +{ + sendCommand (m_commandSocket, "CN_PH_NOZZLES_DISABLED", + { printheadId, mask }); +} + /* ------------------------------------------------------------------ */ /* Send / dispatch */ /* ------------------------------------------------------------------ */ @@ -149,6 +284,30 @@ Xpl2Client::dispatchCommandMessage (const Xpl2Protocol::ParsedMessage &msg) handleGsJcVersion (msg.params); else if (msg.command == "GS_PH_VERSION") handleGsPhVersion (msg.params); + /* CN_ commands — JC success shape (controllerId, success) */ + else if (msg.command == "CN_JETTING_ALL_ON" || msg.command == "CN_JETTING_ON" + || msg.command == "CN_JETTING_OFF" + || msg.command == "CN_JC_ID_LED_ON" + || msg.command == "CN_JC_ID_LED_OFF" + || msg.command == "CN_JC_CALIBRATION" + || msg.command == "CN_JC_RESET_FAULT_CODES") + handleJcSuccessResponse (msg.command, msg.params); + /* CN_ commands — PH success shape (controllerId, phId, success) */ + else if (msg.command == "CN_PH_JETTING_ON" + || msg.command == "CN_PH_JETTING_OFF" + || msg.command == "CN_PH_ID_LED_ON" + || msg.command == "CN_PH_ID_LED_OFF" + || msg.command == "CN_PH_CALIBRATION" + || msg.command == "CN_PH_RESET_FAULT_CODES" + || msg.command == "CN_PH_NOZZLES_DISABLED") + handlePhSuccessResponse (msg.command, msg.params); + /* CN_ commands — custom shapes */ + else if (msg.command == "CN_PH_CALIBRATION_DATA") + handleCnPhCalibrationData (msg.params); + else if (msg.command == "CN_PH_CALIBRATION_RAW_DATA") + handleCnPhCalibrationRawData (msg.params); + else if (msg.command == "CN_PH_CALIBRATED_BASE_FREQUENCY") + handleCnPhCalibratedBaseFrequency (msg.params); else qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_commandSocket)), msg.command.constData ()); @@ -169,6 +328,14 @@ Xpl2Client::dispatchStatusMessage (const Xpl2Protocol::ParsedMessage &msg) { if (msg.command == "KA_PING") handleKaPing (m_statusSocket); + else if (msg.command == "CN_JC_STATUS_MESSAGING_START") + handleCnJcStatusMessagingStart (msg.params); + else if (msg.command == "CN_JC_STATUS_MESSAGING_STOP") + handleCnJcStatusMessagingStop (msg.params); + else if (msg.command == "CN_PH_STATUS_MESSAGING_START") + handleCnPhStatusMessagingStart (msg.params); + else if (msg.command == "CN_PH_STATUS_MESSAGING_STOP") + handleCnPhStatusMessagingStop (msg.params); else qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_statusSocket)), msg.command.constData ()); @@ -239,6 +406,245 @@ Xpl2Client::handleGsPhVersion (const QVariantList ¶ms) bootVer); } +void +Xpl2Client::handleJcSuccessResponse (const QByteArray &command, + const QVariantList ¶ms) +{ + if (params.size () < 2) + { + qWarning () << command << ": expected 2 params, got" << params.size (); + return; + } + int cid = params[0].toInt (); + bool ok = params[1].toInt () == 1; + + qDebug ("%s %s controller=%d success=%d", + qPrintable (logTag (&m_commandSocket)), command.constData (), cid, + ok); + emit statusMessage (QStringLiteral ("RX %1: controller=%2 success=%3") + .arg (QString::fromUtf8 (command)) + .arg (cid) + .arg (ok)); + + if (command == "CN_JETTING_ALL_ON") + emit jettingAllOnResult (cid, ok); + else if (command == "CN_JETTING_ON") + emit jettingOnResult (cid, ok); + else if (command == "CN_JETTING_OFF") + emit jettingOffResult (cid, ok); + else if (command == "CN_JC_ID_LED_ON") + emit jcIdLedOnResult (cid, ok); + else if (command == "CN_JC_ID_LED_OFF") + emit jcIdLedOffResult (cid, ok); + else if (command == "CN_JC_CALIBRATION") + emit jcCalibrationResult (cid, ok); + else if (command == "CN_JC_RESET_FAULT_CODES") + emit jcResetFaultCodesResult (cid, ok); +} + +void +Xpl2Client::handlePhSuccessResponse (const QByteArray &command, + const QVariantList ¶ms) +{ + if (params.size () < 3) + { + qWarning () << command << ": expected 3 params, got" << params.size (); + return; + } + int cid = params[0].toInt (); + int phId = params[1].toInt (); + bool ok = params[2].toInt () == 1; + + qDebug ("%s %s controller=%d ph=%d success=%d", + qPrintable (logTag (&m_commandSocket)), command.constData (), cid, + phId, ok); + emit statusMessage (QStringLiteral ("RX %1: controller=%2 ph=%3 success=%4") + .arg (QString::fromUtf8 (command)) + .arg (cid) + .arg (phId) + .arg (ok)); + + if (command == "CN_PH_JETTING_ON") + emit phJettingOnResult (cid, phId, ok); + else if (command == "CN_PH_JETTING_OFF") + emit phJettingOffResult (cid, phId, ok); + else if (command == "CN_PH_ID_LED_ON") + emit phIdLedOnResult (cid, phId, ok); + else if (command == "CN_PH_ID_LED_OFF") + emit phIdLedOffResult (cid, phId, ok); + else if (command == "CN_PH_CALIBRATION") + emit phCalibrationResult (cid, phId, ok); + else if (command == "CN_PH_RESET_FAULT_CODES") + emit phResetFaultCodesResult (cid, phId, ok); + else if (command == "CN_PH_NOZZLES_DISABLED") + emit phNozzlesDisabledResult (cid, phId, ok); +} + +void +Xpl2Client::handleCnPhCalibrationData (const QVariantList ¶ms) +{ + if (params.size () < 50) + { + qWarning () << "CN_PH_CALIBRATION_DATA: expected 50 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + int phId = params[1].toInt (); + QVariantList frequencies = params.mid (2, 48); + qDebug ("%s CN_PH_CALIBRATION_DATA controller=%d ph=%d (%lld freqs)", + qPrintable (logTag (&m_commandSocket)), cid, phId, + static_cast (frequencies.size ())); + emit statusMessage ( + QStringLiteral ("RX CN_PH_CALIBRATION_DATA: controller=%1 ph=%2") + .arg (cid) + .arg (phId)); + emit phCalibrationDataReceived (cid, phId, frequencies); +} + +void +Xpl2Client::handleCnPhCalibrationRawData (const QVariantList ¶ms) +{ + if (params.size () < 50) + { + qWarning () << "CN_PH_CALIBRATION_RAW_DATA: expected 50 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + int phId = params[1].toInt (); + QVariantList frequencies = params.mid (2, 48); + qDebug ("%s CN_PH_CALIBRATION_RAW_DATA controller=%d ph=%d (%lld freqs)", + qPrintable (logTag (&m_commandSocket)), cid, phId, + static_cast (frequencies.size ())); + emit statusMessage ( + QStringLiteral ("RX CN_PH_CALIBRATION_RAW_DATA: controller=%1 ph=%2") + .arg (cid) + .arg (phId)); + emit phCalibrationRawDataReceived (cid, phId, frequencies); +} + +void +Xpl2Client::handleCnPhCalibratedBaseFrequency (const QVariantList ¶ms) +{ + if (params.size () < 4) + { + qWarning () << "CN_PH_CALIBRATED_BASE_FREQUENCY: expected 4 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + int phId = params[1].toInt (); + double baseFreq = params[2].toDouble (); + double activeBaseFreq = params[3].toDouble (); + qDebug ("%s CN_PH_CALIBRATED_BASE_FREQUENCY controller=%d ph=%d " + "base=%.2f active=%.2f", + qPrintable (logTag (&m_commandSocket)), cid, phId, baseFreq, + activeBaseFreq); + emit statusMessage ( + QStringLiteral ("RX CN_PH_CALIBRATED_BASE_FREQUENCY: controller=%1 " + "ph=%2 base=%3 active=%4") + .arg (cid) + .arg (phId) + .arg (baseFreq) + .arg (activeBaseFreq)); + emit phCalibratedBaseFrequencyReceived (cid, phId, baseFreq, activeBaseFreq); +} + +void +Xpl2Client::handleCnJcStatusMessagingStart (const QVariantList ¶ms) +{ + if (params.size () < 4) + { + qWarning () << "CN_JC_STATUS_MESSAGING_START: expected 4 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + int level = params[1].toInt (); + int interval = params[2].toInt (); + bool ok = params[3].toInt () == 1; + qDebug ("%s CN_JC_STATUS_MESSAGING_START controller=%d level=%d " + "interval=%d success=%d", + qPrintable (logTag (&m_statusSocket)), cid, level, interval, ok); + emit statusMessage ( + QStringLiteral ("RX CN_JC_STATUS_MESSAGING_START: controller=%1 " + "level=%2 interval=%3 success=%4") + .arg (cid) + .arg (level) + .arg (interval) + .arg (ok)); + emit jcStatusMessagingStartResult (cid, level, interval, ok); +} + +void +Xpl2Client::handleCnJcStatusMessagingStop (const QVariantList ¶ms) +{ + if (params.size () < 2) + { + qWarning () << "CN_JC_STATUS_MESSAGING_STOP: expected 2 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + bool ok = params[1].toInt () == 1; + qDebug ("%s CN_JC_STATUS_MESSAGING_STOP controller=%d success=%d", + qPrintable (logTag (&m_statusSocket)), cid, ok); + emit statusMessage ( + QStringLiteral ("RX CN_JC_STATUS_MESSAGING_STOP: controller=%1 " + "success=%2") + .arg (cid) + .arg (ok)); + emit jcStatusMessagingStopResult (cid, ok); +} + +void +Xpl2Client::handleCnPhStatusMessagingStart (const QVariantList ¶ms) +{ + if (params.size () < 4) + { + qWarning () << "CN_PH_STATUS_MESSAGING_START: expected 4 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + int level = params[1].toInt (); + int interval = params[2].toInt (); + bool ok = params[3].toInt () == 1; + qDebug ("%s CN_PH_STATUS_MESSAGING_START controller=%d level=%d " + "interval=%d success=%d", + qPrintable (logTag (&m_statusSocket)), cid, level, interval, ok); + emit statusMessage ( + QStringLiteral ("RX CN_PH_STATUS_MESSAGING_START: controller=%1 " + "level=%2 interval=%3 success=%4") + .arg (cid) + .arg (level) + .arg (interval) + .arg (ok)); + emit phStatusMessagingStartResult (cid, level, interval, ok); +} + +void +Xpl2Client::handleCnPhStatusMessagingStop (const QVariantList ¶ms) +{ + if (params.size () < 2) + { + qWarning () << "CN_PH_STATUS_MESSAGING_STOP: expected 2 params, got" + << params.size (); + return; + } + int cid = params[0].toInt (); + bool ok = params[1].toInt () == 1; + qDebug ("%s CN_PH_STATUS_MESSAGING_STOP controller=%d success=%d", + qPrintable (logTag (&m_statusSocket)), cid, ok); + emit statusMessage ( + QStringLiteral ("RX CN_PH_STATUS_MESSAGING_STOP: controller=%1 " + "success=%2") + .arg (cid) + .arg (ok)); + emit phStatusMessagingStopResult (cid, ok); +} + /* ------------------------------------------------------------------ */ /* Internal */ /* ------------------------------------------------------------------ */ diff --git a/src/Xpl2Client.h b/src/Xpl2Client.h index 95ae03e..c6a7c07 100644 --- a/src/Xpl2Client.h +++ b/src/Xpl2Client.h @@ -42,10 +42,59 @@ public: Q_INVOKABLE void connectToServer (); Q_INVOKABLE void disconnectFromServer (); + /** Get the just connected Jetting Controller ID and Software Version. */ Q_INVOKABLE void getJcVersion (); /** Query the specified printhead's version info. */ Q_INVOKABLE void getPhVersion (int printheadId); + /* -- CN_ Control commands ----------------------------------------- */ + + /** Switch jetting on for all printheads. */ + Q_INVOKABLE void jettingAllOn (); + /** Switch jetting on for all printheads with a per-nozzle mask (180 chars). + */ + Q_INVOKABLE void jettingOn (const QString &jettingMask); + /** Switch jetting off for all printheads. */ + Q_INVOKABLE void jettingOff (); + /** Switch jetting on for one printhead with a per-nozzle mask (12 chars). */ + Q_INVOKABLE void phJettingOn (int printheadId, const QString &jettingMask); + /** Switch jetting off for one printhead. */ + Q_INVOKABLE void phJettingOff (int printheadId); + /** Switch the JC identification LED on. */ + Q_INVOKABLE void jcIdLedOn (); + /** Switch the JC identification LED off. */ + Q_INVOKABLE void jcIdLedOff (); + /** Switch a printhead's identification LED on. */ + Q_INVOKABLE void phIdLedOn (int printheadId); + /** Switch a printhead's identification LED off. */ + Q_INVOKABLE void phIdLedOff (int printheadId); + /** Run calibration on all printheads. */ + Q_INVOKABLE void jcCalibration (); + /** Run calibration on one printhead. */ + Q_INVOKABLE void phCalibration (int printheadId); + /** Get nozzle calibration data for one printhead (48 floats). */ + Q_INVOKABLE void phCalibrationData (int printheadId); + /** Get raw nozzle calibration data for one printhead (48 floats). */ + Q_INVOKABLE void phCalibrationRawData (int printheadId); + /** Get the calibrated base frequency and active base frequency. */ + Q_INVOKABLE void phCalibratedBaseFrequency (int printheadId); + /** Start sending JC status messages at the given level and interval. */ + Q_INVOKABLE void jcStatusMessagingStart (int statusLevel, + int sendIntervalMs); + /** Stop sending JC status messages. */ + Q_INVOKABLE void jcStatusMessagingStop (); + /** Start sending PH status messages at the given level and interval. */ + Q_INVOKABLE void phStatusMessagingStart (int statusLevel, + int sendIntervalMs); + /** Stop sending PH status messages. */ + Q_INVOKABLE void phStatusMessagingStop (); + /** Reset fault codes for all printheads on the controller. */ + Q_INVOKABLE void jcResetFaultCodes (); + /** Reset fault codes for one printhead. */ + Q_INVOKABLE void phResetFaultCodes (int printheadId); + /** Disable nozzles on one printhead using a 12-char mask. */ + Q_INVOKABLE void phNozzlesDisabled (int printheadId, const QString &mask); + signals: void hostChanged (); void connectedChanged (); @@ -60,6 +109,37 @@ signals: const QString &fpgaHardwareVersion, const QString &bootloaderVersion); + /* CN_ response signals */ + void jettingAllOnResult (int controllerId, bool success); + void jettingOnResult (int controllerId, bool success); + void jettingOffResult (int controllerId, bool success); + void phJettingOnResult (int controllerId, int printheadId, bool success); + void phJettingOffResult (int controllerId, int printheadId, bool success); + void jcIdLedOnResult (int controllerId, bool success); + void jcIdLedOffResult (int controllerId, bool success); + void phIdLedOnResult (int controllerId, int printheadId, bool success); + void phIdLedOffResult (int controllerId, int printheadId, bool success); + void jcCalibrationResult (int controllerId, bool success); + void phCalibrationResult (int controllerId, int printheadId, bool success); + void phCalibrationDataReceived (int controllerId, int printheadId, + const QVariantList &frequencies); + void phCalibrationRawDataReceived (int controllerId, int printheadId, + const QVariantList &frequencies); + void phCalibratedBaseFrequencyReceived (int controllerId, int printheadId, + double baseFrequency, + double activeBaseFrequency); + void jcStatusMessagingStartResult (int controllerId, int statusLevel, + int sendIntervalMs, bool success); + void jcStatusMessagingStopResult (int controllerId, bool success); + void phStatusMessagingStartResult (int controllerId, int statusLevel, + int sendIntervalMs, bool success); + void phStatusMessagingStopResult (int controllerId, bool success); + void jcResetFaultCodesResult (int controllerId, bool success); + void phResetFaultCodesResult (int controllerId, int printheadId, + bool success); + void phNozzlesDisabledResult (int controllerId, int printheadId, + bool success); + private slots: void onSocketConnected (); void onSocketDisconnected (); @@ -75,6 +155,17 @@ private: void handleKaPing (QTcpSocket &socket); void handleGsJcVersion (const QVariantList ¶ms); void handleGsPhVersion (const QVariantList ¶ms); + void handleJcSuccessResponse (const QByteArray &command, + const QVariantList ¶ms); + void handlePhSuccessResponse (const QByteArray &command, + const QVariantList ¶ms); + void handleCnPhCalibrationData (const QVariantList ¶ms); + void handleCnPhCalibrationRawData (const QVariantList ¶ms); + void handleCnPhCalibratedBaseFrequency (const QVariantList ¶ms); + void handleCnJcStatusMessagingStart (const QVariantList ¶ms); + void handleCnJcStatusMessagingStop (const QVariantList ¶ms); + void handleCnPhStatusMessagingStart (const QVariantList ¶ms); + void handleCnPhStatusMessagingStop (const QVariantList ¶ms); void updateConnectedState (); QString logTag (const QTcpSocket *socket) const; -- cgit v1.2.3