Print: count undefined print result values and retry

This commit is contained in:
Siegfried Siegert 2024-05-16 15:20:52 +02:00
parent b946dc5a92
commit 560b6d3221
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 17 additions and 2 deletions

View File

@ -654,6 +654,7 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri
hw->prn_switchPower(true);
hw->prn_setFonts(8,12,0,0);
hw->prn_sendText(&ba);
this->printResultCheckCounter = 0;
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt()));
//QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } );
@ -844,6 +845,7 @@ void ATBDeviceControllerPlugin::onPrinterDataPrepared()
// note: calling prn_getPrintResult() immediately may result in wrong answer!
// We have to wait "about some seconds" until calling this function!
this->printResultCheckCounter = 0;
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingTicket()));
// old: use printer templates:
@ -867,8 +869,17 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingTicket()
this->onPrintFinishedERR();
break;
default:
qCritical() << "DC Error: wait for printing";
this->onPrintFinishedERR();
// result value is not defined (-> workaround for DC misbehaviour)
if (this->printResultCheckCounter < 10) {
this->printResultCheckCounter++;
qCritical() << "DC print result undefined: " << printerResult;
QTimer::singleShot(1000, this, SLOT(onPrinterWaitForPrintingTicket()));
}
else {
qCritical() << "DC Error: wait for printing";
this->onPrintFinishedERR();
}
break;
}
@ -896,6 +907,7 @@ void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
if (this->currentTicket->templateList()->isEmpty()) {
// all templates are printed
this->printResultCheckCounter = 0;
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingTicket()));
}
else {

View File

@ -129,6 +129,9 @@ private:
// counts failed hw->log_chkIfVaultRecordAvailable()
int accountCheckCounter;
// counts faild hw->prn-getPrintResult()
int printResultCheckCounter;
// dbus
int init_sc_dbus();