From 652ad9b43d24bddbc3c2636c4ff4b5d74e081e46 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 18 Apr 2023 13:41:04 +0200 Subject: [PATCH] Included changes of TS for version 3.5. --- src/datIf.cpp | 31 +++++++++++++- src/hwapi.cpp | 115 ++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 136 insertions(+), 10 deletions(-) diff --git a/src/datIf.cpp b/src/datIf.cpp index 4df170a..60e76d3 100644 --- a/src/datIf.cpp +++ b/src/datIf.cpp @@ -864,6 +864,10 @@ char T_datif::loadRecDataFromFrame() bool ret; uint8_t uctmp; // maxai char ctmp; + static uint8_t lastResult; + uint8_t prnResult; + static uint32_t lastInsertedAmount; + uint32_t newInsertedAmount; ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData); // retval: data valid, only one time true, true if CommandState OK and readState OK @@ -1354,10 +1358,16 @@ char T_datif::loadRecDataFromFrame() case 112: // get inserted amount in cent in sum // byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value - ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]); + newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]); uitmp=uchar2uint(receivedData[5],receivedData[4]); uit2=uchar2uint(receivedData[7],receivedData[6]); - gpi_storeCurrentPayment(ultmp, uitmp, uit2); + gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); + if (newInsertedAmount != lastInsertedAmount) + { + emit datif_gotNewCoin(); + lastInsertedAmount=newInsertedAmount; + } + break; case 113: // get wake source, 8byte @@ -1469,6 +1479,23 @@ char T_datif::loadRecDataFromFrame() */ gpi_storeDynMachineConditions(RdDleng, receivedData); + + prnResult=receivedData[52]; + if (prnResult != lastResult) + { + // new result + if (prnResult==1) + { + emit datif_templatePrintFinished_OK(); + } else + if (prnResult==2) + { + emit datif_templatePrintFinished_Err(); + } + + lastResult=prnResult; + } + break; case 32: // Get current cash level (in vault) diff --git a/src/hwapi.cpp b/src/hwapi.cpp index 169c4e7..325b0c7 100644 --- a/src/hwapi.cpp +++ b/src/hwapi.cpp @@ -27,6 +27,7 @@ #include "interfaces.h" +static uint32_t hwapi_lastStartAmount; static const QMap baudrateMap = { {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, @@ -47,6 +48,10 @@ hwapi::hwapi(QWidget *parent) : QObject(parent) { } sendWRcmd_INI(); myDatif = new T_datif(); + + connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK())); + connect(myDatif, SIGNAL(datif_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err())); + connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin())); } hwapi::~hwapi() { @@ -55,6 +60,25 @@ hwapi::~hwapi() { } } +void hwapi::hwapi_slotPrintFinished_OK(void) { + emit hwapi_templatePrintFinished_OK(); +} + +void hwapi::hwapi_slotPrintFinished_Err(void) { + emit hwapi_templatePrintFinished_Err(); +} + +void hwapi::hwapi_slotGotCoin(void) { + // new coin was inserted while transaction and new amount reported: + emit hwapi_gotNewCoin(); + + uint32_t newSum=epi_CurrentPaymentGetAmount(); + + if (newSum>=hwapi_lastStartAmount) + emit hwapi_vendStopByMax(); + +} + void hwapi::sub_storeSendingText(QByteArray *buf) const { char local[70], copie[1350]; // 64byte more then max buffer size! @@ -3567,14 +3591,19 @@ bool hwapi::prn_printTestTicket(void) const } -bool hwapi::cash_startPayment(uint16_t amount) const +bool hwapi::cash_startPayment(uint32_t amount) const { - uint8_t dat1, dat2; + // 17.4.23TS: extended to 32bit + uint8_t dat1, dat2, dat3, dat4; + hwapi_lastStartAmount=amount; epi_clearCurrentPayment(); - dat1=uint2uchar(amount, LOWBYTE); - dat2=uint2uchar(amount, HIGHBYTE); - return sendFDcmd_set(155, 0,0, dat1,dat2,0,0); + dat1=ulong2uchar(amount, 0); + dat2=ulong2uchar(amount, 1); + dat3=ulong2uchar(amount, 2); + dat4=ulong2uchar(amount, 3); + + return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4); } @@ -3608,6 +3637,7 @@ bool hwapi::cash_stopPayment(void) const { // DB1: 1=encash 2=cancel & return coins // 3=stop and keep coins in escrow + emit hwapi_vendStopByPushbutton(); return sendFDcmd_set(156, 0,0, 3,0,0,0); } @@ -3650,18 +3680,21 @@ uint8_t hwapi::mif_getCardType(QString *cardholder) const return type; } -uint64_t hwapi::sys_getWakeSource(void) const { +uint64_t hwapi::sys_getWakeSource(void) const +{ // retval: 6 bytes, bit coded, 1=event keeps DC awake return epi_getWakeSources(); } -void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const { +void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const +{ //uint8_t leng, data[66]; epi_restoreDeviceConditions(leng, data); } -void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const { +void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const +{ uint16_t LL, nn; uint8_t *start; uint8_t buf[70], leng; @@ -3721,4 +3754,70 @@ uint16_t hwapi::cash_getNrCoinsInVault(void) const +uint8_t hwapi::prn_getPrintResult() const +{ + // return: 0: unknown + // 1: OK - last template was printed succesful + // 2: error - last template was not printed + + struct T_dynamicCondition dynMachCon; + //uint8_t buf[70], leng, + uint8_t res; + static uint8_t lastState; + //uint32_t aa; + + // aa=&dynMachCon; + sys_getDynMachineConditions(&dynMachCon); + res= dynMachCon.resultOfLastTemplPrint; + // 0: unknown or printing in progress + // 1: OK, doc was printed 2: error, doc was not printed + + if (res==0) + { + if (lastState>0) + { + // print was started + lastState=res; + } + } else + { + if (lastState==0) + { + // result hat sich auf 1 oder 2 geƤndert, d.h. Druck ist fertig + if (res==1) + { + + //emit hwapi_templatePrintFinished_OK(); + } else + if (res==2) + { + + //emit hwapi_templatePrintFinished_Err(); + } + lastState=res; + } + } + return res; +} + +uint8_t hwapi::prn_getCurrentPrinterState() const +{ + // 0: printer OK + // bit0: near paper end bit1: no paper + // bit2: temperature error bit3: error head open + // bit4: paper jam in cutter + // bit6: no response bit7: serial rec. error + // bit5: printer not ready + + + uint8_t lastPrinterStatus; + uint8_t buf[70], leng; + + // 2nd way to get dyn.conditions: + epi_restoreDynMachineConditions(&leng, buf); + lastPrinterStatus=buf[53]; + + return lastPrinterStatus; +} +