From 7830f0ae98d742467b948ed93c85e122be38fb83 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 16 Mar 2026 15:40:22 +0100 Subject: CF_ configuration commands with JettingParamsResult and SetterResult enums --- src/Xpl2Client.cpp | 283 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Xpl2Client.h | 114 ++++++++++++++++++++- src/Xpl2Protocol.h | 25 +++++ 3 files changed, 421 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Xpl2Client.cpp b/src/Xpl2Client.cpp index 45963fa..d6eb28a 100644 --- a/src/Xpl2Client.cpp +++ b/src/Xpl2Client.cpp @@ -66,6 +66,72 @@ Xpl2Client::s_responseTable = { [](auto *s, const auto &p) { emit s->jcStatusMessagingStartResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt () == 1); } } }, { "CN_PH_STATUS_MESSAGING_START", { ResponseShape::StatusStart, 4, [](auto *s, const auto &p) { emit s->phStatusMessagingStartResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt () == 1); } } }, + + /* CF_ JC success shape: controllerId, successFlag */ + { "CF_PH_DEASSIGN_ID", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->phDeassignIdResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_SAVE_CALIBRATION", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcSaveCalibrationResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_RESET_CALIBRATION", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcResetCalibrationResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_SWITCH_OFF_PURGE", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcSwitchOffPurgeResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_RESET_SETTINGS_ALL_PRINTHEADS", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcResetSettingsAllPrintheadsResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_REBOOT_ALL_PRINTHEADS", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcRebootAllPrintheadsResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_RESET_CONTROLLER_SOFTWARE", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcResetControllerSoftwareResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_RESTART", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcRestartResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_SHUTDOWN", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcShutdownResult (p[0].toInt (), p[1].toInt () == 1); } } }, + { "CF_JC_SAVE_ALL_PRINTHEAD_SETTINGS", { ResponseShape::JcSuccess, 2, + [](auto *s, const auto &p) { emit s->jcSaveAllPrintheadSettingsResult (p[0].toInt (), p[1].toInt () == 1); } } }, + + /* CF_ PH success shape: controllerId, phId, successFlag */ + { "CF_PH_SET_ID", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phSetIdResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "CF_PH_SAVE_CALIBRATION", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phSaveCalibrationResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "CF_PH_RESET_CALIBRATION", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phResetCalibrationResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "CF_PH_RESET_ALL_SETTINGS", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phResetAllSettingsResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "CF_PH_REBOOT", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phRebootResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "CF_PH_SAVE_SETTINGS", { ResponseShape::PhSuccess, 3, + [](auto *s, const auto &p) { emit s->phSaveSettingsResult (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + + /* CF_ purge settings: controllerId, purgeInterval, purgeTime, successFlag */ + { "CF_JC_SET_PURGE_SETTINGS", { ResponseShape::PurgeSettings, 4, + [](auto *s, const auto &p) { emit s->jcSetPurgeSettingsResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt () == 1); } } }, + + /* CF_ JC jetting params: cid, dutyCycle, pwmFreq, drive, nozzleDriveFreq, nozzleDriveDutyCycle, successFlag */ + { "CF_JC_SET_JETTING_PARAMS", { ResponseShape::JcJettingParams, 7, + [](auto *s, const auto &p) { emit s->jcSetJettingParamsResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt (), p[4].toInt (), p[5].toInt (), static_cast (p[6].toInt ())); } } }, + + /* CF_ PH jetting params: cid, phId, dutyCycle, pwmFreq, drive, nozzleDriveFreq, nozzleDriveDutyCycle, successFlag */ + { "CF_PH_SET_JETTING_PARAMS", { ResponseShape::PhJettingParams, 8, + [](auto *s, const auto &p) { emit s->phSetJettingParamsResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt (), p[4].toInt (), p[5].toInt (), p[6].toInt (), static_cast (p[7].toInt ())); } } }, + { "CF_PH_GET_JETTING_PARAMS", { ResponseShape::PhJettingParams, 8, + [](auto *s, const auto &p) { emit s->phGetJettingParamsResult (p[0].toInt (), p[1].toInt (), p[2].toInt (), p[3].toInt (), p[4].toInt (), p[5].toInt (), p[6].toInt (), static_cast (p[7].toInt ())); } } }, + + /* CF_ JC setter: cid, saveNewValue, setterId, newValue, successFlag */ + { "CF_JC_SETTER", { ResponseShape::JcSetter, 5, + [](auto *s, const auto &p) { emit s->jcSetterResult (p[0].toInt (), p[1].toInt () != 0, p[2].toInt (), p[3].toString (), static_cast (p[4].toInt ())); } } }, + + /* CF_ PH setter: cid, phId, saveNewValue, setterId, newValue, successFlag */ + { "CF_PH_SETTER", { ResponseShape::PhSetter, 6, + [](auto *s, const auto &p) { emit s->phSetterResult (p[0].toInt (), p[1].toInt (), p[2].toInt () != 0, p[3].toInt (), p[4].toString (), static_cast (p[5].toInt ())); } } }, + + /* CF_ JC getter: cid, savedValue, getterId, currentValue, successFlag */ + { "CF_JC_GETTER", { ResponseShape::JcGetter, 5, + [](auto *s, const auto &p) { emit s->jcGetterResult (p[0].toInt (), p[1].toInt () != 0, p[2].toInt (), p[3].toString (), p[4].toInt () == 1); } } }, + + /* CF_ PH getter: cid, phId, savedValue, getterId, currentValue, successFlag */ + { "CF_PH_GETTER", { ResponseShape::PhGetter, 6, + [](auto *s, const auto &p) { emit s->phGetterResult (p[0].toInt (), p[1].toInt (), p[2].toInt () != 0, p[3].toInt (), p[4].toString (), p[5].toInt () == 1); } } }, }; // clang-format on @@ -312,6 +378,166 @@ Xpl2Client::phNozzlesDisabled (int printheadId, const QString &mask) { printheadId, mask }); } +/* ------------------------------------------------------------------ */ +/* CF_ Configuration commands */ +/* ------------------------------------------------------------------ */ + +void +Xpl2Client::phSetId (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_SET_ID", { printheadId }); +} + +void +Xpl2Client::phDeassignId () +{ + sendCommand (m_commandSocket, "CF_PH_DEASSIGN_ID"); +} + +void +Xpl2Client::jcSetJettingParams (int dutyCycle, int pwmFreq, int drive, + int nozzleDriveFreq, int nozzleDriveDutyCycle) +{ + sendCommand ( + m_commandSocket, "CF_JC_SET_JETTING_PARAMS", + { dutyCycle, pwmFreq, drive, nozzleDriveFreq, nozzleDriveDutyCycle }); +} + +void +Xpl2Client::phSetJettingParams (int printheadId, int dutyCycle, int pwmFreq, + int drive, int nozzleDriveFreq, + int nozzleDriveDutyCycle) +{ + sendCommand (m_commandSocket, "CF_PH_SET_JETTING_PARAMS", + { printheadId, dutyCycle, pwmFreq, drive, nozzleDriveFreq, + nozzleDriveDutyCycle }); +} + +void +Xpl2Client::phGetJettingParams (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_GET_JETTING_PARAMS", { printheadId }); +} + +void +Xpl2Client::jcSaveCalibration () +{ + sendCommand (m_commandSocket, "CF_JC_SAVE_CALIBRATION"); +} + +void +Xpl2Client::phSaveCalibration (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_SAVE_CALIBRATION", { printheadId }); +} + +void +Xpl2Client::jcResetCalibration () +{ + sendCommand (m_commandSocket, "CF_JC_RESET_CALIBRATION"); +} + +void +Xpl2Client::phResetCalibration (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_RESET_CALIBRATION", { printheadId }); +} + +void +Xpl2Client::jcSetPurgeSettings (int purgeIntervalMs, int purgeTimeMs) +{ + sendCommand (m_commandSocket, "CF_JC_SET_PURGE_SETTINGS", + { purgeIntervalMs, purgeTimeMs }); +} + +void +Xpl2Client::jcSwitchOffPurge () +{ + sendCommand (m_commandSocket, "CF_JC_SWITCH_OFF_PURGE"); +} + +void +Xpl2Client::jcSetter (bool saveNewValue, int setterId, const QString &newValue) +{ + sendCommand (m_commandSocket, "CF_JC_SETTER", + { saveNewValue, setterId, newValue }); +} + +void +Xpl2Client::phSetter (int printheadId, bool saveNewValue, int setterId, + const QString &newValue) +{ + sendCommand (m_commandSocket, "CF_PH_SETTER", + { printheadId, saveNewValue, setterId, newValue }); +} + +void +Xpl2Client::jcGetter (bool getSavedValue, int getterId) +{ + sendCommand (m_commandSocket, "CF_JC_GETTER", { getSavedValue, getterId }); +} + +void +Xpl2Client::phGetter (int printheadId, bool getSavedValue, int getterId) +{ + sendCommand (m_commandSocket, "CF_PH_GETTER", + { printheadId, getSavedValue, getterId }); +} + +void +Xpl2Client::jcResetSettingsAllPrintheads () +{ + sendCommand (m_commandSocket, "CF_JC_RESET_SETTINGS_ALL_PRINTHEADS"); +} + +void +Xpl2Client::phResetAllSettings (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_RESET_ALL_SETTINGS", { printheadId }); +} + +void +Xpl2Client::jcRebootAllPrintheads () +{ + sendCommand (m_commandSocket, "CF_JC_REBOOT_ALL_PRINTHEADS"); +} + +void +Xpl2Client::phReboot (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_REBOOT", { printheadId }); +} + +void +Xpl2Client::jcResetControllerSoftware () +{ + sendCommand (m_commandSocket, "CF_JC_RESET_CONTROLLER_SOFTWARE"); +} + +void +Xpl2Client::jcRestart () +{ + sendCommand (m_commandSocket, "CF_JC_RESTART"); +} + +void +Xpl2Client::jcShutdown () +{ + sendCommand (m_commandSocket, "CF_JC_SHUTDOWN"); +} + +void +Xpl2Client::jcSaveAllPrintheadSettings () +{ + sendCommand (m_commandSocket, "CF_JC_SAVE_ALL_PRINTHEAD_SETTINGS"); +} + +void +Xpl2Client::phSaveSettings (int printheadId) +{ + sendCommand (m_commandSocket, "CF_PH_SAVE_SETTINGS", { printheadId }); +} + /* ------------------------------------------------------------------ */ /* Send / dispatch */ /* ------------------------------------------------------------------ */ @@ -495,6 +721,63 @@ Xpl2Client::dispatchResponse (const QByteArray &command, .arg (params[2].toInt ()) .arg (params[3].toInt () == 1); break; + case ResponseShape::PurgeSettings: + logStr = QStringLiteral ( + "RX %1: controller=%2 interval=%3 time=%4 success=%5") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[2].toInt ()) + .arg (params[3].toInt () == 1); + break; + case ResponseShape::JcJettingParams: + logStr = QStringLiteral ("RX %1: controller=%2 result=%3") + .arg (cmd) + .arg (cid) + .arg (params[6].toInt ()); + break; + case ResponseShape::PhJettingParams: + logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 result=%4") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[7].toInt ()); + break; + case ResponseShape::JcSetter: + logStr = QStringLiteral ("RX %1: controller=%2 setter=%3 result=%4") + .arg (cmd) + .arg (cid) + .arg (params[2].toInt ()) + .arg (params[4].toInt ()); + break; + case ResponseShape::PhSetter: + logStr + = QStringLiteral ("RX %1: controller=%2 ph=%3 setter=%4 result=%5") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[3].toInt ()) + .arg (params[5].toInt ()); + break; + case ResponseShape::JcGetter: + logStr = QStringLiteral ("RX %1: controller=%2 getter=%3 value=%4 " + "success=%5") + .arg (cmd) + .arg (cid) + .arg (params[2].toInt ()) + .arg (params[3].toString ()) + .arg (params[4].toInt () == 1); + break; + case ResponseShape::PhGetter: + logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 getter=%4 " + "value=%5 success=%6") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[3].toInt ()) + .arg (params[4].toString ()) + .arg (params[5].toInt () == 1); + break; } qDebug ("%s %s", qPrintable (logTag (socket)), qPrintable (logStr)); diff --git a/src/Xpl2Client.h b/src/Xpl2Client.h index c9da25d..78eca0a 100644 --- a/src/Xpl2Client.h +++ b/src/Xpl2Client.h @@ -98,6 +98,65 @@ public: /** Disable nozzles on one printhead using a 12-char mask. */ Q_INVOKABLE void phNozzlesDisabled (int printheadId, const QString &mask); + /* -- CF_ Configuration commands ----------------------------------- */ + + /** Set the printhead ID. */ + Q_INVOKABLE void phSetId (int printheadId); + /** De-assign the printhead ID. */ + Q_INVOKABLE void phDeassignId (); + /** Set jetting parameters for all printheads on the controller. */ + Q_INVOKABLE void jcSetJettingParams (int dutyCycle, int pwmFreq, int drive, + int nozzleDriveFreq, + int nozzleDriveDutyCycle); + /** Set jetting parameters for one printhead. */ + Q_INVOKABLE void phSetJettingParams (int printheadId, int dutyCycle, + int pwmFreq, int drive, + int nozzleDriveFreq, + int nozzleDriveDutyCycle); + /** Get jetting parameters from one printhead. */ + Q_INVOKABLE void phGetJettingParams (int printheadId); + /** Save calibration for all printheads. */ + Q_INVOKABLE void jcSaveCalibration (); + /** Save calibration for one printhead. */ + Q_INVOKABLE void phSaveCalibration (int printheadId); + /** Reset calibration for all printheads. */ + Q_INVOKABLE void jcResetCalibration (); + /** Reset calibration for one printhead. */ + Q_INVOKABLE void phResetCalibration (int printheadId); + /** Set purge settings for all printheads on the controller. */ + Q_INVOKABLE void jcSetPurgeSettings (int purgeIntervalMs, int purgeTimeMs); + /** Switch off purge for all printheads on the controller. */ + Q_INVOKABLE void jcSwitchOffPurge (); + /** Set a JC setting by setter ID. */ + Q_INVOKABLE void jcSetter (bool saveNewValue, int setterId, + const QString &newValue); + /** Set a PH setting by setter ID. */ + Q_INVOKABLE void phSetter (int printheadId, bool saveNewValue, int setterId, + const QString &newValue); + /** Get a JC setting by getter ID. */ + Q_INVOKABLE void jcGetter (bool getSavedValue, int getterId); + /** Get a PH setting by getter ID. */ + Q_INVOKABLE void phGetter (int printheadId, bool getSavedValue, + int getterId); + /** Reset settings for all printheads on the controller. */ + Q_INVOKABLE void jcResetSettingsAllPrintheads (); + /** Reset all settings for one printhead. */ + Q_INVOKABLE void phResetAllSettings (int printheadId); + /** Reboot all printheads on the controller. */ + Q_INVOKABLE void jcRebootAllPrintheads (); + /** Reboot one printhead. */ + Q_INVOKABLE void phReboot (int printheadId); + /** Reset the Jetting Controller software. */ + Q_INVOKABLE void jcResetControllerSoftware (); + /** Restart the Jetting Controller. */ + Q_INVOKABLE void jcRestart (); + /** Shut down the Jetting Controller. */ + Q_INVOKABLE void jcShutdown (); + /** Save settings for all printheads on the controller. */ + Q_INVOKABLE void jcSaveAllPrintheadSettings (); + /** Save settings for one printhead. */ + Q_INVOKABLE void phSaveSettings (int printheadId); + signals: void hostChanged (); void connectedChanged (); @@ -143,6 +202,52 @@ signals: void phNozzlesDisabledResult (int controllerId, int printheadId, bool success); + /* CF_ response signals */ + void phSetIdResult (int controllerId, int printheadId, bool success); + void phDeassignIdResult (int controllerId, bool success); + void jcSetJettingParamsResult (int controllerId, int dutyCycle, int pwmFreq, + int drive, int nozzleDriveFreq, + int nozzleDriveDutyCycle, + Xpl2Protocol::JettingParamsResult result); + void phSetJettingParamsResult (int controllerId, int printheadId, + int dutyCycle, int pwmFreq, int drive, + int nozzleDriveFreq, int nozzleDriveDutyCycle, + Xpl2Protocol::JettingParamsResult result); + void phGetJettingParamsResult (int controllerId, int printheadId, + int dutyCycle, int pwmFreq, int drive, + int nozzleDriveFreq, int nozzleDriveDutyCycle, + Xpl2Protocol::JettingParamsResult result); + void jcSaveCalibrationResult (int controllerId, bool success); + void phSaveCalibrationResult (int controllerId, int printheadId, + bool success); + void jcResetCalibrationResult (int controllerId, bool success); + void phResetCalibrationResult (int controllerId, int printheadId, + bool success); + void jcSetPurgeSettingsResult (int controllerId, int purgeIntervalMs, + int purgeTimeMs, bool success); + void jcSwitchOffPurgeResult (int controllerId, bool success); + void jcSetterResult (int controllerId, bool saveNewValue, int setterId, + const QString &newValue, + Xpl2Protocol::SetterResult result); + void phSetterResult (int controllerId, int printheadId, bool saveNewValue, + int setterId, const QString &newValue, + Xpl2Protocol::SetterResult result); + void jcGetterResult (int controllerId, bool savedValue, int getterId, + const QString ¤tValue, bool success); + void phGetterResult (int controllerId, int printheadId, bool savedValue, + int getterId, const QString ¤tValue, + bool success); + void jcResetSettingsAllPrintheadsResult (int controllerId, bool success); + void phResetAllSettingsResult (int controllerId, int printheadId, + bool success); + void jcRebootAllPrintheadsResult (int controllerId, bool success); + void phRebootResult (int controllerId, int printheadId, bool success); + void jcResetControllerSoftwareResult (int controllerId, bool success); + void jcRestartResult (int controllerId, bool success); + void jcShutdownResult (int controllerId, bool success); + void jcSaveAllPrintheadSettingsResult (int controllerId, bool success); + void phSaveSettingsResult (int controllerId, int printheadId, bool success); + private slots: void onSocketConnected (); void onSocketDisconnected (); @@ -164,7 +269,14 @@ private: PhSuccess, CalData, BaseFreq, - StatusStart + StatusStart, + PurgeSettings, + JcJettingParams, + PhJettingParams, + JcSetter, + PhSetter, + JcGetter, + PhGetter }; struct ResponseEntry diff --git a/src/Xpl2Protocol.h b/src/Xpl2Protocol.h index 6d4a348..85d6895 100644 --- a/src/Xpl2Protocol.h +++ b/src/Xpl2Protocol.h @@ -5,11 +5,36 @@ #pragma once #include +#include #include namespace Xpl2Protocol { +Q_NAMESPACE + +/** Extended success flag for CF_JC/PH_SET_JETTING_PARAMS responses. */ +enum class JettingParamsResult +{ + NozzleDriveDutyCycle = -5, + NozzleDriveFrequency = -4, + Drive = -3, + PwmFrequency = -2, + DutyCycle = -1, + Failed = 0, + Ok = 1 +}; +Q_ENUM_NS (JettingParamsResult) + +/** Extended success flag for CF_JC/PH_SETTER responses. */ +enum class SetterResult +{ + IncorrectNewValue = -1, + Failed = 0, + Ok = 1 +}; +Q_ENUM_NS (SetterResult) + constexpr char Terminator = '\n'; struct ParsedMessage -- cgit v1.2.3