Update printing ticket (version 2.1)

Use hwapi::prn_getPrintResult() to detect print result.
This commit is contained in:
Siegfried Siegert 2023-06-22 12:14:55 +02:00
parent 4a7022fd00
commit a4d74ed0f7
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 27 additions and 3 deletions

View File

@ -407,15 +407,38 @@ void ATBDeviceControllerPlugin::onPrinterDataPrepared()
{
this->hw->prn_printKombiticket(this->currentSelectedTicketType);
// FAKE SIGNAL:
QTimer::singleShot(4000, this, SLOT(onPrintFinishedOK()));
// note: calling prn_getPrintResult() immediately may result in wrong answer!
// We have to wait "about some seconds" until calling this function!
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrinting()));
// old: use printer templates:
// this->currentTemplate = 1;
// this->onPrinterPrintNextTemplate();
}
void ATBDeviceControllerPlugin::onPrinterWaitForPrinting()
{
quint8 printerResult = this->hw->prn_getPrintResult();
switch (printerResult) {
case 0: // still printing
qCritical() << "--> printer: WaitForPrinting";
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrinting()));
break;
case 1: // printing finished, Ok
this->onPrintFinishedOK();
break;
case 2: // printing finished, Error
this->onPrintFinishedERR();
break;
default:
qCritical() << "DC Error: wait for printing";
this->onPrintFinishedERR();
break;
}
}
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
{

View File

@ -113,6 +113,7 @@ private slots:
void onPrinterDataPrepared();
void onPrinterPrintNextTemplate();
void onPrinterWaitForPrinting();
void onPrintFinishedOK();
void onPrintFinishedERR();