Implement cash input interface

This commit is contained in:
Siegfried Siegert 2023-05-04 14:28:38 +02:00
parent f611e07dcf
commit e32142cd62
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 44 additions and 8 deletions

View File

@ -14,7 +14,8 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(
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(onGotCoin())); connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onCashGotCoin()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_vendStopByMax()), this, SLOT(onCashVendStopByMax()));
} }
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {} ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
@ -47,22 +48,25 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive
// TASKS: Cash handling ------------------------------------------------------- // TASKS: Cash handling -------------------------------------------------------
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount) void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
{ {
qCritical() << "Start Cash vending with amount = " << amount;
uint32_t amountInt = static_cast<uint32_t>(amount.toUInt());
hw->cash_startPayment(amountInt);
} }
void ATBDeviceControllerPlugin::requestStopCashInput() void ATBDeviceControllerPlugin::requestStopCashInput()
{ {
hw->cash_stopPayment();
} }
void ATBDeviceControllerPlugin::cashCollect() void ATBDeviceControllerPlugin::cashCollect()
{ {
hw->vend_success();
} }
void ATBDeviceControllerPlugin::cashAbort() void ATBDeviceControllerPlugin::cashAbort()
{ {
hw->vend_failed();
} }
@ -185,12 +189,44 @@ void ATBDeviceControllerPlugin::onPrintFinishedERR()
this->errorDescription); this->errorDescription);
} }
void ATBDeviceControllerPlugin::onGotCoin()
{
/************************************************************************************************
* cash payment
*/
void ATBDeviceControllerPlugin::onCashGotCoin()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onGotCoin()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputEvent(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
nsDeviceControllerInterface::CASH_STATE::CACHE_INPUT,
amountString,
"",
"");
} }
void ATBDeviceControllerPlugin::onCashVendStopByMax()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
amountString,
"",
"");
}
/************************************************************************************************ /************************************************************************************************
* Mandatory plugin methods * Mandatory plugin methods

View File

@ -118,8 +118,8 @@ private slots:
void onPrintFinishedERR(); void onPrintFinishedERR();
// cash payment // cash payment
void onGotCoin(); void onCashGotCoin();
void onCashVendStopByMax();
}; };
#endif // ATBDEVICECONTROLLERPLUGIN_H #endif // ATBDEVICECONTROLLERPLUGIN_H