From c076090e03f47c56d2a5d9f861962c185cc66277 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 27 Jun 2024 11:46:40 +0200 Subject: [PATCH 1/5] DeviceController Interface 1.1.5 (Ticket Variant FINE_PAYMENT) --- src/ATBAPP/DeviceControllerInterface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index 5589d6a..6f7ee03 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -203,7 +203,7 @@ signals: Q_DECLARE_INTERFACE(DeviceControllerInterface, - "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.4") + "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.5") namespace nsDeviceControllerInterface { @@ -236,6 +236,7 @@ namespace nsDeviceControllerInterface { ERROR_RECEIPT, START_RECEIPT, // e.g. Szeged Start STOP_RECEIPT, // e.g. Szeged Stop + FINE_PAYMENT, // e.g. Klaipeda FOOD_STAMP }; From 32d70abf44e32b4f9a9b7251283850c9a6462c9d Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 27 Jun 2024 11:48:16 +0200 Subject: [PATCH 2/5] Proposal for usage of TICKET_VARIANT::FINE_PAYMENT --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 24 ++++++++++++++++++++++++ src/ATBAPP/ATBDeviceControllerPlugin.h | 1 + src/ATBAPP/support/Ticket.cpp | 6 ++++++ 3 files changed, 31 insertions(+) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index fbc58cb..f0fabb4 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -983,6 +983,9 @@ void ATBDeviceControllerPlugin::prepareDynTemplateData() case nsDeviceControllerInterface::TICKET_VARIANT::STOP_RECEIPT: private_setupDynTemplatData_STOP_RECEIPT(dynTicketData, this->currentTicket); break; + case nsDeviceControllerInterface::TICKET_VARIANT::FINE_PAYMENT: + private_setupDynTemplatData_FINE_PAYMENT(dynTicketData, this->currentTicket); + break; case nsDeviceControllerInterface::TICKET_VARIANT::RECEIPT: break; case nsDeviceControllerInterface::TICKET_VARIANT::ERROR_RECEIPT: @@ -1091,6 +1094,27 @@ void ATBDeviceControllerPlugin::private_setupDynTemplatData_FOOD_STAMP(struct T_ qCritical() << "-------------------------------------------------------"; } +void ATBDeviceControllerPlugin::private_setupDynTemplatData_FINE_PAYMENT(struct T_dynDat *dynTicketData, Ticket *ticket) +{ + QDateTime currentDateTime = QDateTime::fromString(ticket->getPrintingData()["currentDateTime"].toString(), Qt::ISODate); + + QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat); + + + // set dynamic printer data: + QByteArray ba_licenseplate = codec->fromUnicode(ticket->getPrintingData()["licenseplate"].toString()); + memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8)); + + QByteArray ba_amount = codec->fromUnicode(ticket->getPrintingData()["amount"].toString()); + memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8)); // Szeged + memcpy((char*)dynTicketData->dynDat6, ba_amount.data(), std::min(ba_amount.size(),8)); // Schoenau + + QByteArray ba_currentDate = codec->fromUnicode(currentDateString); + memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); + + QByteArray ba_ticketId = codec->fromUnicode(ticket->getPrintingData()["ticketId"].toString()); + memcpy((char*)dynTicketData->dynDat7, ba_amount.data(), std::min(ba_ticketId.size(),8)); +} /************************************************************************************************ diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index 7337fc7..02e317b 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -144,6 +144,7 @@ private: void private_setupDynTemplateData_START_RECEIPT(struct T_dynDat *dynTicketData, Ticket *ticket); void private_setupDynTemplatData_STOP_RECEIPT(struct T_dynDat *dynTicketData, Ticket *ticket); void private_setupDynTemplatData_FOOD_STAMP(struct T_dynDat *dynTicketData, Ticket *ticket); + void private_setupDynTemplatData_FINE_PAYMENT(struct T_dynDat *dynTicketData, Ticket *ticket); // --------------------------------------------------------------------------------------------- private slots: diff --git a/src/ATBAPP/support/Ticket.cpp b/src/ATBAPP/support/Ticket.cpp index fb27476..42978a4 100644 --- a/src/ATBAPP/support/Ticket.cpp +++ b/src/ATBAPP/support/Ticket.cpp @@ -64,6 +64,9 @@ bool Ticket::initNew(TICKET_VARIANT ticketVariant, const QList & templat case TICKET_VARIANT::STOP_RECEIPT: this->_templateList << 24 << 25 << 26; break; + case TICKET_VARIANT::FINE_PAYMENT: + this->_templateList << 24 << 25 << 26; + break; case TICKET_VARIANT::FOOD_STAMP: if (printingData.contains("dyn1_list")) { this->_hasTemplateDynData = true; @@ -160,6 +163,9 @@ QDebug operator<<(QDebug debug, TICKET_VARIANT ticketVariant) case TICKET_VARIANT::STOP_RECEIPT: debug << "TICKET_VARIANT::STOP_RECEIPT"; break; + case TICKET_VARIANT::FINE_PAYMENT: + debug << "TICKET_VARIANT::FINE_PAYMENT"; + break; case TICKET_VARIANT::FOOD_STAMP: debug << "TICKET_VARIANT::FOOD_STAMP"; break; From 72dbc8b858159233d8102d20af61e90950e37e53 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 27 Jun 2024 11:55:35 +0200 Subject: [PATCH 3/5] Print receipt: encode QString --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index f0fabb4..2d6e327 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -654,10 +654,21 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QHashcodec->fromUnicode(printingString); + + //QByteArray ba = printingString.toUtf8(); hw->prn_switchPower(true); hw->prn_setFonts(8,12,0,0); - hw->prn_sendText(&ba); + hw->prn_sendText(&ba_receipt); + + // DEBUG + //qCritical() << "---------------------------------------------------------------"; + //qCritical() << "ATBDeviceControllerPlugin::requestPrintReceipt()"; + //qCritical() << " receipt data:"; + //qCritical() << QString(ba_receipt); + //qCritical() << "---------------------------------------------------------------"; + + this->printResultCheckCounter = 0; QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt())); From 6d7d9ade70f6fd93d44d67471f8c296f54f2c87f Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 15 Jul 2024 09:59:08 +0200 Subject: [PATCH 4/5] Restart carun on consecutive E255 --- src/ATBAPP/DeviceControllerDiag.cpp | 38 +++++++++++++++++++++++------ src/ATBAPP/DeviceControllerDiag.h | 8 +++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/ATBAPP/DeviceControllerDiag.cpp b/src/ATBAPP/DeviceControllerDiag.cpp index fe4fb67..d7193cb 100644 --- a/src/ATBAPP/DeviceControllerDiag.cpp +++ b/src/ATBAPP/DeviceControllerDiag.cpp @@ -5,6 +5,8 @@ #include #include +#include + #include "support/JSON.h" @@ -18,6 +20,7 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren , lastState(DeviceController::State::INITIAL_STATE) , _isErrorState(false) , pData(pData) + , E255counter(0) { diagRequestTimeoutTimer = new QTimer(this); diagRequestTimeoutTimer->setInterval(1000*45); @@ -104,14 +107,20 @@ void DeviceControllerDiag::private_startDiag() this->private_sendDiagEvent(DeviceController::State::E255); this->isRequestRunning = false; this->flagInterruptDiag = false; + if (this->E255counter > 5) { + this->restartCArun(); + } + else { + this->E255counter++; - // try it again, until success: - QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest); - /** - * But please note: - * - diag does currently not stop suspend (start a background task) - * - diag is called again in ModeOOO wokeup() - */ + // try it again, until success: + QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest); + /** + * But please note: + * - diag does currently not stop suspend (start a background task) + * - diag is called again in ModeOOO wokeup() + */ + } return; } @@ -146,6 +155,8 @@ void DeviceControllerDiag::sys_superviseSystem() this->private_sendDiagEvent(DeviceController::State::E255); this->flagInterruptDiag = false; this->isRequestRunning = false; + if (this->E255counter > 5) { this->restartCArun(); } + else { this->E255counter++; } return; } @@ -156,6 +167,8 @@ void DeviceControllerDiag::sys_superviseSystem() this->private_sendDiagEvent(DeviceController::State::E254); this->diagRequestTimeoutTimer->stop(); this->isRequestRunning = false; + if (this->E255counter > 5) { this->restartCArun(); } + else { this->E255counter++; } return; } @@ -168,7 +181,7 @@ void DeviceControllerDiag::sys_superviseSystem() { // noch keine Testergebnisse if (dynMaCond.startupTestIsRunning) { - // TODO? + qCritical() << " startupTestIsRunning --> call again"; } @@ -599,3 +612,12 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result) } + +/** + * reset / restart / reinit deviceController + */ +void DeviceControllerDiag::restartCArun() +{ + this->E255counter = 0; + QProcess::startDetached("/bin/systemctl", {"restart", "carun"}); +} diff --git a/src/ATBAPP/DeviceControllerDiag.h b/src/ATBAPP/DeviceControllerDiag.h index 3555877..e89cc39 100644 --- a/src/ATBAPP/DeviceControllerDiag.h +++ b/src/ATBAPP/DeviceControllerDiag.h @@ -94,6 +94,11 @@ public slots: */ void diagReInit(); + /** + * reset / restart / reinit deviceController + */ + void restartCArun(); + signals: void diagResponse(ATBMachineEvent* machineEvent); @@ -118,6 +123,8 @@ private: PersistentData* pData; + int E255counter; + private slots: void onDiagRequestTimeoutTimerTimeout(); @@ -126,7 +133,6 @@ private slots: void sys_superviseSystem(); - }; #endif // DEVICECONTROLLERDIAG_H From 2d60a7bd5c73b5c84a86c4aa157c212e6809f686 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 15 Jul 2024 10:08:56 +0200 Subject: [PATCH 5/5] Send W255 on restart CArun --- src/ATBAPP/DeviceControllerDiag.cpp | 5 +++++ src/ATBAPP/DeviceControllerDiag.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/ATBAPP/DeviceControllerDiag.cpp b/src/ATBAPP/DeviceControllerDiag.cpp index d7193cb..91124d8 100644 --- a/src/ATBAPP/DeviceControllerDiag.cpp +++ b/src/ATBAPP/DeviceControllerDiag.cpp @@ -583,6 +583,10 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result) eventClass = EVENT_CLASS::WARNING; parameter = "temperatur warning"; break; + case DeviceController::State::W255: // restart carun + eventClass = EVENT_CLASS::WARNING; + parameter = "restart carun"; + break; } this->lastState = result; @@ -619,5 +623,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result) void DeviceControllerDiag::restartCArun() { this->E255counter = 0; + this->private_sendDiagEvent(DeviceController::State::W255); QProcess::startDetached("/bin/systemctl", {"restart", "carun"}); } diff --git a/src/ATBAPP/DeviceControllerDiag.h b/src/ATBAPP/DeviceControllerDiag.h index e89cc39..1d44f24 100644 --- a/src/ATBAPP/DeviceControllerDiag.h +++ b/src/ATBAPP/DeviceControllerDiag.h @@ -55,6 +55,8 @@ namespace DeviceController { W003, W004, + W255, + INITIAL_STATE }; Q_ENUM_NS(State)