From fa095de6cc8ec5a5b5c14091f2b3179ad7071876 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 16 Mar 2026 16:19:49 +0100 Subject: EV_ events with Q_GADGET status types, mock periodic emission, tabbed demo UI --- src/Xpl2Client.cpp | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'src/Xpl2Client.cpp') diff --git a/src/Xpl2Client.cpp b/src/Xpl2Client.cpp index d6eb28a..ac7079f 100644 --- a/src/Xpl2Client.cpp +++ b/src/Xpl2Client.cpp @@ -132,6 +132,26 @@ Xpl2Client::s_responseTable = { /* 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); } } }, + + /* EV_ events */ + { "EV_PH_CONNECTION_CHANGED", { ResponseShape::PhConnectionChanged, 3, + [](auto *s, const auto &p) { emit s->phConnectionChanged (p[0].toInt (), p[1].toInt (), p[2].toInt () == 1); } } }, + { "EV_JC_ERROR_CODE", { ResponseShape::ErrorCode, 3, + [](auto *s, const auto &p) { + QStringList ep; for (int i = 3; i < p.size (); ++i) ep << p[i].toString (); + emit s->jcErrorCode (p[0].toInt (), p[1].toInt (), ep); } } }, + { "EV_IMG_ERROR_CODE", { ResponseShape::ErrorCode, 3, + [](auto *s, const auto &p) { + QStringList ep; for (int i = 3; i < p.size (); ++i) ep << p[i].toString (); + emit s->imgErrorCode (p[0].toInt (), p[1].toInt (), ep); } } }, + { "EV_STATUS_ERROR_CODE", { ResponseShape::ErrorCode, 3, + [](auto *s, const auto &p) { + QStringList ep; for (int i = 3; i < p.size (); ++i) ep << p[i].toString (); + emit s->statusErrorCode (p[0].toInt (), p[1].toInt (), ep); } } }, + { "EV_PH_ERROR_CODE", { ResponseShape::PhErrorCode, 4, + [](auto *s, const auto &p) { + QStringList ep; for (int i = 4; i < p.size (); ++i) ep << p[i].toString (); + emit s->phErrorCode (p[0].toInt (), p[1].toInt (), p[2].toInt (), ep); } } }, }; // clang-format on @@ -567,6 +587,8 @@ Xpl2Client::dispatchCommandMessage (const Xpl2Protocol::ParsedMessage &msg) { if (msg.command == "KA_PING") handleKaPing (m_commandSocket); + else if (msg.command == "EV_SHUTTING_DOWN") + emit shuttingDown (); else if (msg.command == "GS_JC_VERSION") handleGsJcVersion (msg.params); else if (msg.command == "GS_PH_VERSION") @@ -581,6 +603,8 @@ Xpl2Client::dispatchImagingMessage (const Xpl2Protocol::ParsedMessage &msg) { if (msg.command == "KA_PING") handleKaPing (m_imagingSocket); + else if (msg.command == "EV_SHUTTING_DOWN") + emit shuttingDown (); else qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_imagingSocket)), msg.command.constData ()); @@ -591,6 +615,12 @@ Xpl2Client::dispatchStatusMessage (const Xpl2Protocol::ParsedMessage &msg) { if (msg.command == "KA_PING") handleKaPing (m_statusSocket); + else if (msg.command == "EV_SHUTTING_DOWN") + emit shuttingDown (); + else if (msg.command == "EV_STATUS_MSG_JC") + handleEvStatusMsgJc (msg.params); + else if (msg.command == "EV_STATUS_MSG_PH") + handleEvStatusMsgPh (msg.params); else if (!dispatchResponse (msg.command, msg.params, &m_statusSocket)) qWarning ("%s Unknown command: %s", qPrintable (logTag (&m_statusSocket)), msg.command.constData ()); @@ -778,6 +808,26 @@ Xpl2Client::dispatchResponse (const QByteArray &command, .arg (params[4].toString ()) .arg (params[5].toInt () == 1); break; + case ResponseShape::PhConnectionChanged: + logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 connected=%4") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[2].toInt () == 1); + break; + case ResponseShape::ErrorCode: + logStr = QStringLiteral ("RX %1: controller=%2 error=%3") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()); + break; + case ResponseShape::PhErrorCode: + logStr = QStringLiteral ("RX %1: controller=%2 ph=%3 error=%4") + .arg (cmd) + .arg (cid) + .arg (params[1].toInt ()) + .arg (params[2].toInt ()); + break; } qDebug ("%s %s", qPrintable (logTag (socket)), qPrintable (logStr)); @@ -786,6 +836,35 @@ Xpl2Client::dispatchResponse (const QByteArray &command, return true; } +void +Xpl2Client::handleEvStatusMsgJc (const QVariantList ¶ms) +{ + Xpl2JcStatus status = Xpl2JcStatus::fromParams (params); + qDebug ("%s EV_STATUS_MSG_JC controller=%d level=%d temp=%.1f cpu=%.1f%%", + qPrintable (logTag (&m_statusSocket)), status.controllerId, + status.statusLevel, status.temperature, status.cpuPercentageBusy); + emit statusMessage ( + QStringLiteral ("RX EV_STATUS_MSG_JC: controller=%1 level=%2") + .arg (status.controllerId) + .arg (status.statusLevel)); + emit jcStatusReceived (status); +} + +void +Xpl2Client::handleEvStatusMsgPh (const QVariantList ¶ms) +{ + Xpl2PhStatus status = Xpl2PhStatus::fromParams (params); + qDebug ("%s EV_STATUS_MSG_PH controller=%d level=%d ph=%d temp=%.1f", + qPrintable (logTag (&m_statusSocket)), status.controllerId, + status.statusLevel, status.printheadId, status.temperature); + emit statusMessage ( + QStringLiteral ("RX EV_STATUS_MSG_PH: controller=%1 level=%2 ph=%3") + .arg (status.controllerId) + .arg (status.statusLevel) + .arg (status.printheadId)); + emit phStatusReceived (status); +} + /* ------------------------------------------------------------------ */ /* Internal */ /* ------------------------------------------------------------------ */ -- cgit v1.2.3