Merge branch 'pu/coinIntegration_TS18052023' into pu/integration

This commit is contained in:
Siegfried Siegert 2023-05-23 14:36:41 +02:00
commit 88cc71e05f
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
12 changed files with 469 additions and 35 deletions

View File

@ -308,6 +308,8 @@ class T_datif : public QMainWindow
QTimer *datif_trigger; QTimer *datif_trigger;
uint8_t selectedSlaveAddr; uint8_t selectedSlaveAddr;
int datif_noResponseCtr;
private slots: private slots:
char datif_cycleSend(); char datif_cycleSend();
void StoredRecData(); void StoredRecData();

View File

@ -1,8 +1,30 @@
/*
matching interfaces.h:
// History
// 11.10.2021: V1.0 222 functions
// 23.12.2021: V1.1 added block-parameter to function "read mifare data"
// 30.12.2021: V1.2 added function: mif_clearDataBuffer(), mif_isBlockAvailable(uint8_t blkNr) and mif_getAvailableDataBlocks()
// 1.1.2022: V1.3 Mifare extended. ( background: read 16 x 48byte from card to DC, read 12 x 64byte from DC to CA)
// new: read full card with 768bytes from HWapi without block borders
// added: mif_getNrOfAvailableDataBytes mif_getCardData768byteDec(uint8_t *buf, uint16_t bufferSize)
// mif_getCardDataDec(uint16_t fromAddr, uint16_t toAddr, uint8_t *buf, uint16_t bufferSize)
// mif_getCardDataStr(bool useHexFormat, char seperator)
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
// V3.2 Bootloader improvement
// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1"
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
*/
#ifndef hwapi_H #ifndef hwapi_H
#define hwapi_H #define hwapi_H
#include <stdint.h> #include <stdint.h>
#include <QTimer>
#include <QObject> #include <QObject>
#include "interfaces.h" #include "interfaces.h"
#include "datIf.h" #include "datIf.h"
@ -15,6 +37,7 @@ class hwapi : public QObject,
Q_INTERFACES(hwinf) Q_INTERFACES(hwinf)
private: private:
void sub_storeSendingText(QByteArray *buf) const; void sub_storeSendingText(QByteArray *buf) const;
QTimer *hwapi_TimerPayment;
DownloadResult sendNextAddress(int bNum) const; DownloadResult sendNextAddress(int bNum) const;
DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const; DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
@ -161,6 +184,13 @@ public:
uint8_t bl_exitBL(uint8_t *sendData) const override; uint8_t bl_exitBL(uint8_t *sendData) const override;
// minimum size of sendData-buffer: 5byte retval: length // minimum size of sendData-buffer: 5byte retval: length
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Level 2 DC2-onboard devices // Level 2 DC2-onboard devices
// WR: set time // WR: set time
@ -963,6 +993,17 @@ public:
bool cash_startPayment(uint32_t amount) const override; bool cash_startPayment(uint32_t amount) const override;
// 17.4.23TS: extended to 32bit // 17.4.23TS: extended to 32bit
uint8_t cash_paymentProcessing(void) const override;
// run this function periodically while coin payment process to generate necessary signals
// return value:
// 0: stopped 1: starting up 2: coin collection
// 3: finished by User (Push button) 4: finished, Max-Value collected
// 5: finished by escrow
// 10,11: error cannot start
// 12: timeout while payment, coins returned
// 13: stopped by unexpected error
bool cash_cancelPayment(void) const override; bool cash_cancelPayment(void) const override;
// and return coins // and return coins
@ -1032,6 +1073,7 @@ public:
void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override; void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override;
bool sys_areDCdataValid(void) const override;
/* --------------------------------------------------------------------------------------------- /* ---------------------------------------------------------------------------------------------
// ------------ supervise all hardware components // ------------ supervise all hardware components
@ -1076,14 +1118,31 @@ public:
signals: signals:
void hwapi_templatePrintFinished_OK(void) const override; void hwapi_templatePrintFinished_OK(void) const override;
void hwapi_templatePrintFinished_Err(void) const override; void hwapi_templatePrintFinished_Err(void) const override;
void hwapi_coinCollectionJustStarted(void) const override;
void hwapi_coinCollectionAborted(void) const override;
void hwapi_gotNewCoin(void) const override; void hwapi_gotNewCoin(void) const override;
void hwapi_vendStopByMax(void) const override; void hwapi_payStopByMax(void) const override;
void hwapi_vendStopByPushbutton(void) const override; void hwapi_payStopByPushbutton(void) const override;
void hwapi_payStopByEscrow(void) const override;
void hwapi_payStopByError(void) const override;
void hwapi_payStopByTimeout(void) const override;
void hwapi_payCancelled(void) const override;
void hwapi_coinProcessJustStopped(void) const override;
private slots: private slots:
void hwapi_slotPrintFinished_OK(void); void hwapi_slotPrintFinished_OK(void);
void hwapi_slotPrintFinished_Err(void); void hwapi_slotPrintFinished_Err(void);
void hwapi_slotGotCoin(void); void hwapi_slotGotCoin(void);
void hwapi_slotPayProc(void);
}; };

View File

@ -1452,6 +1452,8 @@ public:
virtual bool cash_startPayment(uint32_t amount) const=0; virtual bool cash_startPayment(uint32_t amount) const=0;
// 17.4.23TS: extended to 32bit // 17.4.23TS: extended to 32bit
virtual uint8_t cash_paymentProcessing(void) const=0;
virtual uint32_t getInsertedAmount(void) const=0; virtual uint32_t getInsertedAmount(void) const=0;
virtual uint16_t getLastInsertedCoin(void) const=0; virtual uint16_t getLastInsertedCoin(void) const=0;
@ -1616,6 +1618,8 @@ public:
virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0; virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0;
virtual bool sys_areDCdataValid(void) const=0;
/* --------------------------------------------------------------------------------------------- /* ---------------------------------------------------------------------------------------------
// ------------ supervise all hardware components // ------------ supervise all hardware components
// ------------ assess the machine state // ------------ assess the machine state
@ -1669,9 +1673,20 @@ public:
signals: signals:
virtual void hwapi_templatePrintFinished_OK(void) const=0; virtual void hwapi_templatePrintFinished_OK(void) const=0;
virtual void hwapi_templatePrintFinished_Err(void) const=0; virtual void hwapi_templatePrintFinished_Err(void) const=0;
virtual void hwapi_coinCollectionJustStarted(void) const=0;
virtual void hwapi_coinCollectionAborted(void) const=0;
virtual void hwapi_gotNewCoin(void) const=0; virtual void hwapi_gotNewCoin(void) const=0;
virtual void hwapi_vendStopByMax(void) const=0; virtual void hwapi_payStopByMax(void) const=0;
virtual void hwapi_vendStopByPushbutton(void) const=0; virtual void hwapi_payStopByPushbutton(void) const=0;
virtual void hwapi_payStopByEscrow(void) const=0;
virtual void hwapi_payStopByError(void) const=0;
virtual void hwapi_payStopByTimeout(void) const=0;
virtual void hwapi_payCancelled(void) const=0;
virtual void hwapi_coinProcessJustStopped(void) const=0;
}; };

View File

@ -227,7 +227,7 @@ struct SharedMemBuffer {
uint16_t nrOfCoins; uint16_t nrOfCoins;
bool dcDataValid; bool dcDataValid;
uint8_t wakeReason; uint8_t wakeReason;
char curPayNewCoin;
} store; } store;
struct T_globTime { struct T_globTime {

View File

@ -418,6 +418,7 @@ uint8_t epi_mifGetCardType(uint8_t const *holder);
void gpi_storeDcDataValid(bool isVal); void gpi_storeDcDataValid(bool isVal);
bool gpi_areDcDataValid(); bool gpi_areDcDataValid();
bool epi_areDcDataValid();

View File

@ -12,10 +12,15 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(
this->hw = new hwapi(); this->hw = new hwapi();
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK())); //connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR())); //connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onCashGotCoin()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_vendStopByMax()), this, SLOT(onCashVendStopByMax())); connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onCashGotCoin()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByMax()), this, SLOT(onCashPayStopByMax()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByEscrow()), this, SLOT(onCashPayStopByEscrow()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByError()), this, SLOT(onCashPayStopByError()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByTimeout()), this, SLOT(onCashPayStopByTimeout()));
} }
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {} ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
@ -29,6 +34,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1(); QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
hw->dc_autoRequest(true);
// open serial port // open serial port
hw->dc_openSerial(5, "115200", serialPort, 1); hw->dc_openSerial(5, "115200", serialPort, 1);
@ -51,6 +57,9 @@ void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
qCritical() << "Start Cash vending with amount = " << amount; qCritical() << "Start Cash vending with amount = " << amount;
uint32_t amountInt = static_cast<uint32_t>(amount.toUInt()); uint32_t amountInt = static_cast<uint32_t>(amount.toUInt());
if (amountInt == 0) amountInt = UINT_MAX;
hw->cash_startPayment(amountInt); hw->cash_startPayment(amountInt);
} }
@ -127,6 +136,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
} }
// TODO: wird hier nur 'licensePlate' gedruckt? // TODO: wird hier nur 'licensePlate' gedruckt?
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
this->errorCode = "hwapi::prn_sendDynamicPrnValues"; this->errorCode = "hwapi::prn_sendDynamicPrnValues";
@ -145,7 +156,7 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
return; return;
} }
QTimer::singleShot(500, this, SLOT(onPrinterDataPrepared())); QTimer::singleShot(1000, this, SLOT(onPrinterDataPrepared()));
} }
@ -178,7 +189,7 @@ void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
else { else {
// print next template // print next template
this->currentTemplate++; this->currentTemplate++;
QTimer::singleShot(1000, this, SLOT(onPrinterPrintNextTemplate())); QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate()));
} }
} }
@ -234,7 +245,7 @@ void ATBDeviceControllerPlugin::onCashGotCoin()
} }
void ATBDeviceControllerPlugin::onCashVendStopByMax() void ATBDeviceControllerPlugin::onCashPayStopByMax()
{ {
// DEBUG // DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()"; qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
@ -250,6 +261,55 @@ void ATBDeviceControllerPlugin::onCashVendStopByMax()
} }
void ATBDeviceControllerPlugin::onCashPayStopByEscrow()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByEscrow()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
amountString,
"",
"");
}
void ATBDeviceControllerPlugin::onCashPayStopByError()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByError()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
amountString,
"",
"");
}
void ATBDeviceControllerPlugin::onCashPayStopByTimeout()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByTimeout()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
amountString,
"",
"");
}
/************************************************************************************************ /************************************************************************************************
* Mandatory plugin methods * Mandatory plugin methods
* *

View File

@ -119,7 +119,10 @@ private slots:
// cash payment // cash payment
void onCashGotCoin(); void onCashGotCoin();
void onCashVendStopByMax(); void onCashPayStopByMax();
void onCashPayStopByEscrow();
void onCashPayStopByError();
void onCashPayStopByTimeout();
}; };
#endif // ATBDEVICECONTROLLERPLUGIN_H #endif // ATBDEVICECONTROLLERPLUGIN_H

View File

@ -19,7 +19,7 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
sendLen=sendLength; sendLen=sendLength;
if (CatSerial->isOpen()) if (CatSerial->isOpen())
{ {
//qDebug() << "sending..." << sendBuffer; qCritical() << "sending..." << sendBuffer;
CatSerial->write(sendBuffer); CatSerial->write(sendBuffer);
} else } else
qDebug() << "error sending, port is not open"; qDebug() << "error sending, port is not open";

View File

@ -50,6 +50,7 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
cycl_running=0; cycl_running=0;
//datif_DCdataValid=0; //datif_DCdataValid=0;
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
datif_noResponseCtr=0;
} }
void T_datif::resetChain(void) void T_datif::resetChain(void)
@ -69,6 +70,11 @@ char T_datif::datif_cycleSend()
uint8_t length, data[66]; uint8_t length, data[66];
bool b_ret; bool b_ret;
datif_noResponseCtr++; // inc every 10ms fehlt noch in SysCont
if (datif_noResponseCtr>500) // seit 5s kein Lebenszeichen von DC2
gpi_storeDcDataValid(0); // fehlt in SysCont
if (cycl_running) if (cycl_running)
{ {
// request is still running, wait for response before next sending // request is still running, wait for response before next sending
@ -214,7 +220,10 @@ char T_datif::datif_cycleSend()
sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential
} }
else else
{
dif_scanStep=0; // always start from beginning dif_scanStep=0; // always start from beginning
gpi_storeDcDataValid(0); // fehlt in SysCont
}
} }
#ifdef USEHANDSHAKES #ifdef USEHANDSHAKES
else else
@ -225,6 +234,7 @@ char T_datif::datif_cycleSend()
} else } else
{ {
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben //qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
gpi_storeDcDataValid(0); // fehlt in SysCont
} }
return 0; return 0;
@ -842,6 +852,7 @@ char T_datif::isPortOpen(void)
void T_datif::StoredRecData() void T_datif::StoredRecData()
{ {
datif_noResponseCtr=0;
//qDebug() << "StoreRecData called"; //qDebug() << "StoreRecData called";
// call automatically by T_prot // call automatically by T_prot
//if (myDCIF->ifDataReceived()) //if (myDCIF->ifDataReceived())
@ -876,14 +887,17 @@ char T_datif::loadRecDataFromFrame()
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData); ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
// retval: data valid, only one time true, true if CommandState OK and readState OK // retval: data valid, only one time true, true if CommandState OK and readState OK
gpi_storeResultOfLastRequest(ret); gpi_storeResultOfLastRequest(ret);
if (ret==false) if (ret==false)
{ {
// qDebug() << "datif: rec data not valid"; qCritical() << "datif: rec data not valid";
return 0; return 0;
} }
gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi) gpi_storeRecPayLoad(RdDleng, receivedData); // save for host (user of hwapi)
//qCritical() << "loadRecDataFromFrame() readSource = " << readSource;
//qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress //qDebug() << "\n datif: got valid data, rdsrc:" << readSource << " rdadd:" << readAddress
// << " rdlen:" << RdDleng; // << " rdlen:" << RdDleng;
// qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ", // qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
@ -1201,15 +1215,27 @@ char T_datif::loadRecDataFromFrame()
break; break;
case CMD2DC_EMP_GET_ALL: //23 case CMD2DC_EMP_GET_ALL: //23
//qDebug() << "got emp parameters "<< receivedData[1]; //qCritical() << "got emp parameters "<< receivedData[1];
gpi_storeEmpSettings(64, receivedData); gpi_storeEmpSettings(64, receivedData);
break; break;
case CMD2DC_EMP_GOTCOIN: //108 case CMD2DC_EMP_GOTCOIN: //108
//qCritical() << "loadRecDataFromFrame() readSource = " << readSource;
// DB0: 1=coin 0xFF=error 0=got nothing // DB0: 1=coin 0xFF=error 0=got nothing
// DB1: last coin signal (value / scale) // DB1: last coin signal (value / scale)
// DB2,3: last coin value // DB2,3: last coin value
// DB4: lastError from Emp // DB4: lastError from Emp
// 0: nr of stored coins
// 1: got 2:type 3:err 4=valL 5=valH
// qDebug() << "got emp coin "<< " " << receivedData[0] <<" " << receivedData[1]
// << " " << receivedData[2]<< " " << receivedData[3]
// << " " << receivedData[4]<< " " << receivedData[5]
// << " " << receivedData[6]<< " " << receivedData[7];
gpi_storeEmpCoinSignal(receivedData[0], &receivedData[1]); gpi_storeEmpCoinSignal(receivedData[0], &receivedData[1]);
break; break;
@ -1361,15 +1387,25 @@ char T_datif::loadRecDataFromFrame()
break; break;
case 112: // get inserted amount in cent in sum case 112: // get inserted amount in cent in sum
//qCritical() << "loadRecDataFromFrame() readSource = " << readSource;
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value // byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
newInsertedAmount=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]); uitmp=uchar2uint(receivedData[5],receivedData[4]);
uit2=uchar2uint(receivedData[7],receivedData[6]); uit2=uchar2uint(receivedData[7],receivedData[6]);
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); if (uitmp>0) // nur 1x bei neuer Münze
if (newInsertedAmount != lastInsertedAmount)
{ {
emit datif_gotNewCoin(); gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
lastInsertedAmount=newInsertedAmount; //void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
if (newInsertedAmount != lastInsertedAmount)
{
emit datif_gotNewCoin();
//qDebug()<<"emit new coin";
lastInsertedAmount=newInsertedAmount;
}
qDebug()<<" store new coin"<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
} }
break; break;
@ -1586,6 +1622,7 @@ struct T_vaultRecord
break; break;
} }
readSource=0; // 17.05.2023: to avoid multiple recording
return 0; return 0;
} }

View File

@ -27,6 +27,8 @@
#include "interfaces.h" #include "interfaces.h"
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
static uint8_t hwapi_cash_lastCollectionState;
static uint8_t hwapi_paymentStarted;
static const QMap<QString, int> baudrateMap = { static const QMap<QString, int> baudrateMap = {
{"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3},
@ -51,6 +53,18 @@ hwapi::hwapi(QObject *parent) : QObject(parent) {
connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK())); 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_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err()));
connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin())); connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin()));
hwapi_TimerPayment = new QTimer();
hwapi_TimerPayment->setSingleShot(true);
QTimer *hwapi_callPayProc = new QTimer();
connect(hwapi_callPayProc, SIGNAL(timeout()), this, SLOT(hwapi_slotPayProc()));
hwapi_callPayProc->setSingleShot(false);
hwapi_callPayProc->start(100); // in ms
hwapi_lastStartAmount=0;
hwapi_cash_lastCollectionState=0;
hwapi_paymentStarted=0;
} }
hwapi::~hwapi() { hwapi::~hwapi() {
@ -59,6 +73,12 @@ hwapi::~hwapi() {
} }
} }
void hwapi::hwapi_slotPayProc(void)
{
cash_paymentProcessing();
}
void hwapi::hwapi_slotPrintFinished_OK(void) { void hwapi::hwapi_slotPrintFinished_OK(void) {
emit hwapi_templatePrintFinished_OK(); emit hwapi_templatePrintFinished_OK();
} }
@ -74,7 +94,7 @@ void hwapi::hwapi_slotGotCoin(void) {
uint32_t newSum=epi_CurrentPaymentGetAmount(); uint32_t newSum=epi_CurrentPaymentGetAmount();
if (newSum>=hwapi_lastStartAmount) if (newSum>=hwapi_lastStartAmount)
emit hwapi_vendStopByMax(); emit hwapi_payStopByMax();
} }
@ -1636,6 +1656,20 @@ uint8_t hwapi::coin_escrowFlapOpened(void) const
// ------------------------------------------------------------------------------
// Level4 devices are operated by DC
// processes with more then one devices
// timer controlled or long term processes
// ------------------------------------------------------------------------------
void hwapi::sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker, void hwapi::sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker,
uint8_t kindOfMifareReader, uint8_t suppressSleep, uint8_t kindOfMifareReader, uint8_t suppressSleep,
uint8_t kindOfModem, uint8_t kindOfCredit) const uint8_t kindOfModem, uint8_t kindOfCredit) const
@ -3507,11 +3541,7 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
// nr = 1..32 // nr = 1..32
{ {
// return true if sending, false if cmd-stack is full // return true if sending, false if cmd-stack is full
return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0);
// 3.5.23: die dynVals und alle templates sollen am stück gesendet
uint8_t data[64];
data[0]=nrOftemplate;
return longFDcmd_set(152, 0,0, 1, data);
} }
void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const
@ -3608,11 +3638,192 @@ bool hwapi::cash_startPayment(uint32_t amount) const
dat2=ulong2uchar(amount, 1); dat2=ulong2uchar(amount, 1);
dat3=ulong2uchar(amount, 2); dat3=ulong2uchar(amount, 2);
dat4=ulong2uchar(amount, 3); dat4=ulong2uchar(amount, 3);
hwapi_cash_lastCollectionState=0;
sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4);
return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4); hwapi_paymentStarted=1;
hwapi_TimerPayment->start(5000); // in ms
return true;
} }
uint8_t hwapi::cash_paymentProcessing(void) const
{
// run this function periodically while coin payment process to generate necessary signals:
// virtual void hwapi_coinCollectionJustStarted(void) const=0;
// virtual void hwapi_coinCollectionAborted(void) const=0;
// virtual void hwapi_gotNewCoin(void) const=0; // comes from: hwapi_slotGotCoin()
// virtual void hwapi_payStopByMax(void) const=0; // comes from: hwapi_slotGotCoin()
// virtual void hwapi_payStopByPushbutton(void) const=0; // comes from cash_stopPayment()
// virtual void hwapi_payStopByEscrow(void) const=0;
// virtual void hwapi_payStopByError(void) const=0;
// virtual void hwapi_payStopByTimeout(void) const=0;
// virtual void hwapi_payCancelled(void) const=0;
// virtual void hwapi_coinProcessJustStopped(void) const=0;
// return value:
// 0: stopped 1: starting up 2: coin collection
// 3: finished by User (Push button) 4: finished, Max-Value collected
// 5: finished by escrow
// 6: money encashed
// 7: cancelled
// 10,11: error cannot start
// 12: timeout while payment, coins returned
// 13: stopped by unexpected error
struct T_emp empStat;
struct T_dynamicCondition myDynMachCond;
uint8_t collActiv=0, payInProg, empState;
if (hwapi_paymentStarted<1)
return 0; // off
collActiv=1; // starting up payment
emp_getAllParameters(&empStat);
//collActiv=empStat.paymentRunning;
empState=empStat.state;
// 0=start command
// 1=powered, do emp ini, send reset
// 2=delay
// 3=wait for response, requesting status after response
// 4,5 through, startup
// 6: wait for status
// 7: through, startup
// 8: IDLE state. EMP is up and ready, polling is running
// 9: polling on, payment not yet on
// 10: payment, check coins
// 11: through
// 12: wait 1s for last coin
// 90: stop all, 1s delay
// 99: off, all stopped
//qCritical() << "empState = " << empState;
sys_getDynMachineConditions(&myDynMachCond);
payInProg= myDynMachCond.paymentInProgress;
// 0: stopped by timeout
// 1: running 2: wait4lastCoin
// 3: payment stopped manually, coins in Escrow
// 4: payment stopped autom, amount collected, coins in Escrow
// 5: payment stopped, escrow full, coins in Escrow
// 6: coins encashed 7:coins returned
// 8: CoinChecker or MDB on Error
if (payInProg==8)
{
// coin checker faulty, cannot start
if (hwapi_paymentStarted==1)
{
hwapi_paymentStarted=90; // stop due to error
emit hwapi_coinCollectionAborted();
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
collActiv=10; // error cannot start
}
} else
if (empState>=10 && empState<=12)
{
// coin acceptance is active now:
hwapi_TimerPayment->stop(); // to avoid error signal
if (hwapi_paymentStarted==1) // 1=wait for coin checker being ready
{
hwapi_paymentStarted=2; // coins can be inserted no
emit hwapi_coinCollectionJustStarted();
}
} else
{
// EMP not (yet) ready
if (!hwapi_TimerPayment->isActive())
{
// 5s after start-payment the coin-checker is still not ready
hwapi_TimerPayment->stop();
if (hwapi_paymentStarted==1)
{
hwapi_paymentStarted=90; // stop due to error
emit hwapi_coinCollectionAborted(); // error cannot start
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
collActiv=11; // error cannot start
}
}
}
if (hwapi_paymentStarted==2)
{
collActiv=2; // coin collection active
// coins can be inserted now, wait for end
if (payInProg==0) // timeout
{
hwapi_paymentStarted++;
collActiv=12; // stop by timeout
emit hwapi_payStopByTimeout();
} else
if (payInProg==3) // user pressed "Next/Continue"
{
hwapi_paymentStarted++;
collActiv=3;
emit hwapi_payStopByPushbutton();
} else
if (payInProg==4) // max achieved
{
hwapi_paymentStarted++;
collActiv=4;
emit hwapi_payStopByMax();
} else
if (payInProg==5) // escrow full
{
hwapi_paymentStarted++;
collActiv=5;
emit hwapi_payStopByEscrow();
} else
if (payInProg==6) // encashed
{
hwapi_paymentStarted++;
collActiv=6;
} else
if (payInProg==7) // returned, user pressed Cancel button
{
hwapi_paymentStarted++;
collActiv=7;
emit hwapi_payCancelled();
} else
if (empState<9 || payInProg==8)
{
hwapi_paymentStarted++;
collActiv=13; // stopped by unexpected error
emit hwapi_payStopByError();
}
}
if (empState<8 || empState>12)
epi_clearCurrentPayment(); // to avoid wrong "got-coin" messages
if (hwapi_paymentStarted==90 || hwapi_paymentStarted==3 )
{
// EMP error, wait till process finished
if (empState==99 && (payInProg==0 || payInProg>5) )
{
// everything stopped, no more coins in escrow
hwapi_paymentStarted=0;
emit hwapi_coinProcessJustStopped();
}
}
return collActiv;
}
uint32_t hwapi::getInsertedAmount(void) const uint32_t hwapi::getInsertedAmount(void) const
{ {
return epi_CurrentPaymentGetAmount(); return epi_CurrentPaymentGetAmount();
@ -3643,7 +3854,7 @@ bool hwapi::cash_stopPayment(void) const
{ {
// DB1: 1=encash 2=cancel & return coins // DB1: 1=encash 2=cancel & return coins
// 3=stop and keep coins in escrow // 3=stop and keep coins in escrow
emit hwapi_vendStopByPushbutton(); emit hwapi_payStopByPushbutton();
return sendFDcmd_set(156, 0,0, 3,0,0,0); return sendFDcmd_set(156, 0,0, 3,0,0,0);
} }
@ -3666,6 +3877,11 @@ bool hwapi::vend_failed(void) const
} }
uint8_t hwapi::mif_getCardType(QString *cardholder) const uint8_t hwapi::mif_getCardType(QString *cardholder) const
// return 1,2,3,4 = upper, lower access card, printer test, coin test // return 1,2,3,4 = upper, lower access card, printer test, coin test
// cardholder: 7byte Name-String // cardholder: 7byte Name-String
@ -3886,7 +4102,10 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
} }
bool hwapi::sys_areDCdataValid(void) const
{
return epi_areDcDataValid();
}
/* --------------------------------------------------------------------------------------------- /* ---------------------------------------------------------------------------------------------
// ------------ supervise all hardware components // ------------ supervise all hardware components

View File

@ -433,7 +433,8 @@ uint8_t recBuffer[FRAME_MAXLEN];
// read from "VCP": // read from "VCP":
mySerialPort->readFromSerial(Indata, recLength); mySerialPort->readFromSerial(Indata, recLength);
//qDebug()<<"prot: got data " << recLength; //qCritical()<<"prot: got data " << recLength;
//qCritical()<<" Indata: " << Indata;
if (recLength>FRAME_MAXLEN) if (recLength>FRAME_MAXLEN)
recLength=FRAME_MAXLEN; recLength=FRAME_MAXLEN;
for (int nn=0; nn<recLength; nn++) for (int nn=0; nn<recLength; nn++)
@ -443,6 +444,9 @@ uint8_t recBuffer[FRAME_MAXLEN];
tempStr.clear(); tempStr.clear();
//uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave) //uint8_t result=FramecheckInData(recBuffer, recLength); // check input data (response from slave)
uint8_t result=FastCheckInData(recBuffer, recLength); // check input data (response from slave) uint8_t result=FastCheckInData(recBuffer, recLength); // check input data (response from slave)
//qCritical()<<" FastCheckInData() result = " << result;
if (result>0) if (result>0)
{ {
// dann anzeige // dann anzeige

View File

@ -24,6 +24,7 @@ bool indat_isPrinterOn() {
return indat_savePrnPwr; return indat_savePrnPwr;
} }
static bool indat_saveMifPwr; static bool indat_saveMifPwr;
void indat_storeMifarePower(bool isOn) { void indat_storeMifarePower(bool isOn) {
@ -34,6 +35,7 @@ bool indat_isMifareOn() {
return indat_saveMifPwr; return indat_saveMifPwr;
} }
static bool indat_MdbIsOn; static bool indat_MdbIsOn;
void indat_storeMDBisOn(bool isOn) { void indat_storeMDBisOn(bool isOn) {
@ -44,6 +46,11 @@ bool indat_isMdbOn() {
return indat_MdbIsOn; return indat_MdbIsOn;
} }
// //////////////////////////////////////////////////////////////////////////
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits, void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
uint8_t parity, uint8_t NrStopBits) { uint8_t parity, uint8_t NrStopBits) {
// store numbers // store numbers
@ -95,6 +102,7 @@ void gpi_storeGenerals(uint8_t genNr, QString text) {
text.toStdString().c_str(), text.toStdString().c_str(),
sizeof(SharedMemBuffer::getDataConst()->genStrings[0])); sizeof(SharedMemBuffer::getDataConst()->genStrings[0]));
} }
} }
QString epi_loadGenerals(uint8_t genNr) { QString epi_loadGenerals(uint8_t genNr) {
@ -108,6 +116,9 @@ QString epi_loadGenerals(uint8_t genNr) {
return " "; return " ";
} }
// ------------------------------- // -------------------------------
void gpi_storeUID(uint8_t const *buf8byteUid) { void gpi_storeUID(uint8_t const *buf8byteUid) {
@ -282,6 +293,7 @@ QString epi_getSlaveTimeDateStr() {
} }
// /////////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////////
// analog values // analog values
// /////////////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////////////
@ -310,6 +322,7 @@ uint16_t epi_loadAIs(uint8_t aiNr) {
// ADC0: temp // ADC0: temp
// 1: voltage // 1: voltage
// 2: brightness // 2: brightness
#define MAXNROF_MEASURE 4
uint32_t epi_loadMeasureValue(uint8_t ValueNr) { uint32_t epi_loadMeasureValue(uint8_t ValueNr) {
// ValueNr 0=ADC0, 1=ADC1 aso... // ValueNr 0=ADC0, 1=ADC1 aso...
@ -989,6 +1002,15 @@ void gpi_storePrinterFonts(uint8_t const *buf) {
sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS)); sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS));
} }
/*
qDebug()<<"printer fonts stored " <<Sdata_PRN_FONTS[0]<<" "<<Sdata_PRN_FONTS[1]<<" " \
<<Sdata_PRN_FONTS[2]<<" "<<Sdata_PRN_FONTS[3]<<" " \
<<Sdata_PRN_FONTS[4]<<" "<<Sdata_PRN_FONTS[5]<<" " \
<<Sdata_PRN_FONTS[6]<<" "<<Sdata_PRN_FONTS[7]<<" " \
<<Sdata_PRN_FONTS[8]<<" "<<Sdata_PRN_FONTS[9]<<" " \
<<Sdata_PRN_FONTS[10]<<" "<<Sdata_PRN_FONTS[11];
*/
// DB0: mdb_bus_ready (switched on) // DB0: mdb_bus_ready (switched on)
// DB1: rdBackV12devicePower // DB1: rdBackV12devicePower
// DB2: rdBackV5busPwr // DB2: rdBackV5busPwr
@ -1072,6 +1094,10 @@ void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data) {
{ {
vv=uchar2uint(data[pp+4], data[pp+3]); vv=uchar2uint(data[pp+4], data[pp+3]);
sub_enterData(data[pp], data[pp+1], data[pp+2], vv ); sub_enterData(data[pp], data[pp+1], data[pp+2], vv );
//qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
// << " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
pp+=5; pp+=5;
LL--; LL--;
} }
@ -1133,6 +1159,11 @@ void epi_clearCurrentPayment(void) {
// call at beginning of coin collection // call at beginning of coin collection
SharedMemBuffer::getData()->store.insertedAmount = 0; SharedMemBuffer::getData()->store.insertedAmount = 0;
p_lastCoin = 0; p_lastCoin = 0;
memset((char *)&SharedMemBuffer::getData()->store.lastCoinType[0],
0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinType));
memset((char *)&SharedMemBuffer::getData()->store.lastCoinValue[0],
0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinValue));
SharedMemBuffer::getData()->store.curPayNewCoin = 0;
} }
void gpi_storeCurrentPayment(uint32_t insertedAmount, void gpi_storeCurrentPayment(uint32_t insertedAmount,
@ -1140,7 +1171,9 @@ void gpi_storeCurrentPayment(uint32_t insertedAmount,
SharedMemBuffer::getData()->store.insertedAmount = insertedAmount; SharedMemBuffer::getData()->store.insertedAmount = insertedAmount;
SharedMemBuffer::getData()->store.lastCoinType[p_lastCoin] = lastCoinType; SharedMemBuffer::getData()->store.lastCoinType[p_lastCoin] = lastCoinType;
SharedMemBuffer::getData()->store.lastCoinValue[p_lastCoin] = lastCoinValue; SharedMemBuffer::getData()->store.lastCoinValue[p_lastCoin] = lastCoinValue;
p_lastCoin++; p_lastCoin++;
SharedMemBuffer::getData()->store.curPayNewCoin++;
} }
uint32_t epi_CurrentPaymentGetAmount(void) { uint32_t epi_CurrentPaymentGetAmount(void) {
@ -1225,6 +1258,8 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) {
*leng); *leng);
} }
// store dynamic machine conditions // store dynamic machine conditions
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data) { void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data) {
SharedMemBuffer::getData()->store.machCondLen = leng; SharedMemBuffer::getData()->store.machCondLen = leng;
@ -1329,8 +1364,7 @@ bool gpi_areDcDataValid()
} }
bool epi_areDcDataValid()
{
return SharedMemBuffer::getData()->store.dcDataValid;
}