2023-04-19 16:26:12 +02:00
|
|
|
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
|
|
|
|
#include "src/ATBAPP/ATBHealthEvent.h"
|
|
|
|
|
2023-05-03 11:56:36 +02:00
|
|
|
#include <QTimer>
|
2023-05-04 13:21:14 +02:00
|
|
|
#include <QTextCodec>
|
2023-06-05 12:49:20 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QPluginLoader>
|
|
|
|
#include <QDateTime>
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
|
|
|
|
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
|
|
|
|
pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
|
|
|
{
|
|
|
|
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
|
|
|
|
|
2023-06-05 12:49:20 +02:00
|
|
|
if (!this->private_loadCashAgentLib("")) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
|
2023-05-23 14:29:24 +02:00
|
|
|
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()));
|
|
|
|
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
|
2023-05-22 11:20:28 +02:00
|
|
|
|
|
|
|
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()));
|
2023-06-09 11:18:39 +02:00
|
|
|
|
|
|
|
this->currentSelectedTicketType = 0;
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
|
|
|
|
|
|
|
|
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceiver, const QSettings & settings)
|
|
|
|
{
|
|
|
|
this->healthEventReceiver = healthEventReceiver;
|
|
|
|
|
2023-05-02 17:39:38 +02:00
|
|
|
// read variables from setting
|
|
|
|
QString serialPort = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
|
2023-05-04 13:21:14 +02:00
|
|
|
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
// open serial port
|
2023-05-02 17:39:38 +02:00
|
|
|
hw->dc_openSerial(5, "115200", serialPort, 1);
|
2023-05-02 17:10:17 +02:00
|
|
|
|
2023-06-12 09:51:34 +02:00
|
|
|
hw->rtc_setDateTime();
|
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
|
|
|
|
// text encoding for printer
|
|
|
|
this->codec = QTextCodec::codecForName(printerEncoding);
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
this->pluginState = PLUGIN_STATE::INITIALIZED;
|
|
|
|
|
|
|
|
return pluginState;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-12 08:31:17 +02:00
|
|
|
// Handle Mode-Changes --------------------------------------------------------
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
|
|
|
|
{
|
|
|
|
hw->dc_autoRequest(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::changedProgramModeToSERVICE()
|
|
|
|
{
|
|
|
|
hw->dc_autoRequest(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::changedProgramModeToIDLE()
|
|
|
|
{
|
|
|
|
hw->dc_autoRequest(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::changedProgramModeToOOO()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
// TASKS: Cash handling -------------------------------------------------------
|
|
|
|
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
|
|
|
|
{
|
2023-05-04 14:28:38 +02:00
|
|
|
qCritical() << "Start Cash vending with amount = " << amount;
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-04 14:28:38 +02:00
|
|
|
uint32_t amountInt = static_cast<uint32_t>(amount.toUInt());
|
2023-05-19 15:33:52 +02:00
|
|
|
|
2023-05-23 10:21:00 +02:00
|
|
|
if (amountInt == 0) amountInt = UINT_MAX;
|
|
|
|
|
2023-05-04 14:28:38 +02:00
|
|
|
hw->cash_startPayment(amountInt);
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::requestStopCashInput()
|
|
|
|
{
|
2023-05-04 14:28:38 +02:00
|
|
|
hw->cash_stopPayment();
|
2023-06-05 18:04:34 +02:00
|
|
|
|
|
|
|
// we need new cash value in application...
|
|
|
|
QTimer::singleShot(500, this, SLOT(onCashPayStoped()));
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::cashCollect()
|
|
|
|
{
|
2023-05-04 14:28:38 +02:00
|
|
|
hw->vend_success();
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ATBDeviceControllerPlugin::cashAbort()
|
|
|
|
{
|
2023-05-04 14:28:38 +02:00
|
|
|
hw->vend_failed();
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
2023-06-01 16:30:50 +02:00
|
|
|
// TASKS: Account -------------------------------------------------------------
|
|
|
|
void ATBDeviceControllerPlugin::requestAccount()
|
|
|
|
{
|
|
|
|
qCritical() << "TODO: implement ATBDeviceControllerPlugin::requestAccount()";
|
|
|
|
}
|
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
|
|
|
|
// TASKS: printing ------------------------------------------------------------
|
|
|
|
void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant> & printingData)
|
|
|
|
{
|
|
|
|
struct T_dynDat *dynTicketData = new T_dynDat;
|
2023-05-04 13:21:14 +02:00
|
|
|
memset(dynTicketData, 0, sizeof(*dynTicketData));
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-18 11:57:54 +02:00
|
|
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
|
|
|
|
<< " licenseplate = " << printingData["licenseplate"] << endl
|
|
|
|
<< " amount = " << printingData["amount"] << endl
|
|
|
|
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
|
|
|
<< " currentDateTime = " << printingData["currentDateTime"] << endl;
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-05-18 11:57:54 +02:00
|
|
|
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
|
|
|
|
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
|
|
|
|
|
|
|
|
/* -----------------------------------------------------------------------------------------
|
|
|
|
* note: the following highly depends on printer template files!
|
|
|
|
* -----------------------------------------------------------------------------------------
|
|
|
|
*/
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
// set dynamic printer data:
|
2023-05-18 11:57:54 +02:00
|
|
|
QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString());
|
|
|
|
memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8));
|
|
|
|
|
|
|
|
QByteArray ba_amount = codec->fromUnicode(printingData["amount"].toString());
|
|
|
|
memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8));
|
|
|
|
|
|
|
|
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
|
2023-06-05 12:51:55 +02:00
|
|
|
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
|
2023-05-18 11:57:54 +02:00
|
|
|
|
|
|
|
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
|
2023-06-05 12:51:55 +02:00
|
|
|
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
|
|
|
|
// ! and yes... 'ParkingEndDate' is 'currentTime'
|
2023-05-04 13:21:14 +02:00
|
|
|
|
2023-05-18 11:57:54 +02:00
|
|
|
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy"));
|
|
|
|
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
2023-05-04 13:21:14 +02:00
|
|
|
|
2023-05-18 11:57:54 +02:00
|
|
|
|
|
|
|
// DEBUG
|
|
|
|
/*
|
|
|
|
uint8_t* buf = dynTicketData->licensePlate;
|
|
|
|
int length = 64;
|
|
|
|
for (int i = 0; i < length; ++i) {
|
|
|
|
fprintf(stderr, "%d %02x %c\n", i, buf[i], buf[i]);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
*/
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
|
2023-05-04 13:21:14 +02:00
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
if (!this->hw->dc_isPortOpen()) {
|
|
|
|
qCritical() << " ... serial port is not open!";
|
2023-05-04 13:21:14 +02:00
|
|
|
this->onPrintFinishedERR();
|
|
|
|
return;
|
2023-05-02 17:10:17 +02:00
|
|
|
}
|
|
|
|
|
2023-05-03 11:56:36 +02:00
|
|
|
|
|
|
|
// TODO: wird hier nur 'licensePlate' gedruckt?
|
|
|
|
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
|
|
|
|
this->errorCode = "hwapi::prn_sendDynamicPrnValues";
|
|
|
|
this->errorDescription = "hwapi method 'hwapi::prn_sendDynamicPrnValues' result is false";
|
2023-05-02 17:10:17 +02:00
|
|
|
|
|
|
|
qCritical() << "ERROR:";
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
|
|
|
|
<< " licenseplate = " << printingData["licenseplate"] << endl
|
|
|
|
<< " amount = " << printingData["amount"] << endl
|
|
|
|
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
|
|
|
<< " currentTime = " << printingData["currentTime"] << endl
|
|
|
|
<< " currentDate = " << printingData["currentDate"] << endl;
|
|
|
|
|
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
this->onPrintFinishedERR();
|
2023-05-03 11:56:36 +02:00
|
|
|
return;
|
2023-05-02 17:10:17 +02:00
|
|
|
}
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-06-09 11:19:39 +02:00
|
|
|
// set ticket type:
|
|
|
|
// 00281 - Szeged:
|
|
|
|
// 1 - Cash / ShortTimeParking
|
|
|
|
// 2 - Card / ShortTimeParking
|
|
|
|
// 3 - Cash / DayTicket
|
|
|
|
// 4 - Card / DayTicket
|
|
|
|
QString paymentType = printingData["paymentType"].toString(); // must be "CASH" | "CARD"
|
|
|
|
QString productName = printingData["product"].toString(); // must be "ShortTimeParking" | "DayTicket"
|
|
|
|
|
|
|
|
if ( (paymentType == "CASH") && (productName == "ShortTimeParking") ) {
|
|
|
|
this->currentSelectedTicketType = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ( (paymentType == "CARD") && (productName == "ShortTimeParking") ) {
|
|
|
|
this->currentSelectedTicketType = 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ( (paymentType == "CASH") && (productName == "DayTicket") ) {
|
|
|
|
this->currentSelectedTicketType = 3;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if ( (paymentType == "CARD") && (productName == "DayTicket") ) {
|
|
|
|
this->currentSelectedTicketType = 4;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
qCritical() << "ERROR: requestPrintTicket(): invalid payment data:";
|
|
|
|
qCritical() << " paymentType = " << paymentType << endl
|
|
|
|
<< " productName = " << productName << endl;
|
|
|
|
this->onPrintFinishedERR();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-05-22 11:23:28 +02:00
|
|
|
QTimer::singleShot(1000, this, SLOT(onPrinterDataPrepared()));
|
2023-04-19 16:26:12 +02:00
|
|
|
}
|
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
|
|
|
|
|
2023-05-03 11:56:36 +02:00
|
|
|
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
|
|
|
|
{
|
2023-06-09 11:18:39 +02:00
|
|
|
this->hw->prn_printKombiticket(this->currentSelectedTicketType);
|
|
|
|
|
|
|
|
// FAKE SIGNAL:
|
|
|
|
QTimer::singleShot(2000, this, SLOT(onPrintFinishedOK()));
|
|
|
|
|
|
|
|
|
|
|
|
// old: use printer templates:
|
|
|
|
// this->currentTemplate = 1;
|
|
|
|
// this->onPrinterPrintNextTemplate();
|
2023-05-04 13:21:14 +02:00
|
|
|
}
|
2023-05-03 11:56:36 +02:00
|
|
|
|
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
|
|
|
|
{
|
|
|
|
qCritical() << " ... print template " << this->currentTemplate;
|
|
|
|
|
|
|
|
if (!this->hw->prn_printTemplate(this->currentTemplate)) {
|
|
|
|
this->errorCode = "hwapi::prn_printTemplate";
|
|
|
|
this->errorDescription = QString("hwapi method 'hwapi::onPrinterPrintNextTemplate(%1)' result is false").arg(this->currentTemplate);
|
|
|
|
this->onPrintFinishedERR();
|
|
|
|
return;
|
2023-05-03 11:56:36 +02:00
|
|
|
}
|
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
if (this->currentTemplate >= 3) {
|
|
|
|
// all templates are printed
|
|
|
|
this->currentTemplate = 0;
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-05-04 13:21:14 +02:00
|
|
|
// FAKE SIGNAL:
|
2023-05-18 14:01:07 +02:00
|
|
|
QTimer::singleShot(500, this, SLOT(onPrintFinishedOK()));
|
2023-05-04 13:21:14 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// print next template
|
|
|
|
this->currentTemplate++;
|
2023-05-22 11:23:28 +02:00
|
|
|
QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate()));
|
2023-05-04 13:21:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2023-05-03 11:56:36 +02:00
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
/************************************************************************************************
|
|
|
|
* private slots, interface to low level hwapi
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ATBDeviceControllerPlugin::onPrintFinishedOK()
|
|
|
|
{
|
2023-05-04 13:21:14 +02:00
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedOK()";
|
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
|
|
|
"",
|
|
|
|
"");
|
|
|
|
}
|
|
|
|
void ATBDeviceControllerPlugin::onPrintFinishedERR()
|
|
|
|
{
|
2023-05-04 13:21:14 +02:00
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedERR()";
|
|
|
|
|
|
|
|
|
2023-05-02 17:10:17 +02:00
|
|
|
this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API
|
|
|
|
this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API
|
|
|
|
|
|
|
|
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
|
|
|
|
this->errorCode,
|
|
|
|
this->errorDescription);
|
|
|
|
}
|
|
|
|
|
2023-05-04 14:28:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************************
|
|
|
|
* cash payment
|
|
|
|
*/
|
|
|
|
void ATBDeviceControllerPlugin::onCashGotCoin()
|
2023-05-02 17:10:17 +02:00
|
|
|
{
|
2023-05-04 14:28:38 +02:00
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::onGotCoin()";
|
|
|
|
|
|
|
|
uint32_t amountInt = this->hw->getInsertedAmount();
|
2023-05-02 17:10:17 +02:00
|
|
|
|
2023-05-04 14:28:38 +02:00
|
|
|
QString amountString = QString::number(amountInt);
|
|
|
|
|
|
|
|
|
|
|
|
emit this->cashInputEvent(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
|
|
|
nsDeviceControllerInterface::CASH_STATE::CACHE_INPUT,
|
|
|
|
amountString,
|
|
|
|
"",
|
|
|
|
"");
|
2023-05-02 17:10:17 +02:00
|
|
|
}
|
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-22 11:20:28 +02:00
|
|
|
void ATBDeviceControllerPlugin::onCashPayStopByMax()
|
2023-05-04 14:28:38 +02:00
|
|
|
{
|
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
|
|
|
|
|
|
|
|
uint32_t amountInt = this->hw->getInsertedAmount();
|
|
|
|
|
|
|
|
QString amountString = QString::number(amountInt);
|
|
|
|
|
|
|
|
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
|
|
|
amountString,
|
|
|
|
"",
|
|
|
|
"");
|
|
|
|
|
|
|
|
}
|
2023-04-19 16:26:12 +02:00
|
|
|
|
2023-05-22 11:20:28 +02:00
|
|
|
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,
|
|
|
|
"",
|
|
|
|
"");
|
|
|
|
}
|
|
|
|
|
2023-06-05 18:04:34 +02:00
|
|
|
void ATBDeviceControllerPlugin::onCashPayStoped()
|
|
|
|
{
|
|
|
|
// DEBUG
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin::onCashPayStoped()";
|
|
|
|
|
|
|
|
uint32_t amountInt = this->hw->getInsertedAmount();
|
|
|
|
|
|
|
|
QString amountString = QString::number(amountInt);
|
|
|
|
|
|
|
|
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
|
|
|
amountString,
|
|
|
|
"",
|
|
|
|
"");
|
|
|
|
}
|
|
|
|
|
2023-05-22 11:20:28 +02:00
|
|
|
|
2023-06-05 18:07:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load CashAgentLib
|
|
|
|
* @brief ATBDeviceControllerPlugin::private_loadCashAgentLib
|
|
|
|
* @param pluginName
|
|
|
|
* @return
|
|
|
|
*/
|
2023-06-05 12:49:20 +02:00
|
|
|
bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
|
|
|
|
{
|
|
|
|
if (pluginName == "") {
|
|
|
|
pluginName = "/usr/lib/libCashAgentLib.so";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!QLibrary::isLibrary(pluginName)) {
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: can not load CashAgentLib: " << pluginName;
|
|
|
|
this->errorCode = 5;
|
|
|
|
this->errorDescription = "ERROR: can not load CashAgentLib: " + pluginName;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPluginLoader* pluginLoader = new QPluginLoader();
|
|
|
|
pluginLoader->setFileName(pluginName);
|
|
|
|
|
|
|
|
QObject* plugin = pluginLoader->instance();
|
|
|
|
if (!pluginLoader->isLoaded()) {
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: can not instantiate CashAgentLib: " << pluginName;
|
|
|
|
this->errorCode = 6;
|
|
|
|
this->errorDescription = "ERROR: can not instantiate CashAgentLib: " + pluginName;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (plugin == nullptr) {
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: plugin is NULL";
|
|
|
|
}
|
|
|
|
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: instantiate CashAgentLib: " << pluginName;
|
|
|
|
|
|
|
|
this->hw = qobject_cast<hwinf*>(plugin);
|
|
|
|
|
|
|
|
if (this->hw == nullptr) {
|
|
|
|
qCritical() << "ATBDeviceControllerPlugin: hw is NULL";
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-22 11:20:28 +02:00
|
|
|
|
2023-04-19 16:26:12 +02:00
|
|
|
/************************************************************************************************
|
|
|
|
* Mandatory plugin methods
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
PLUGIN_STATE ATBDeviceControllerPlugin::getState()
|
|
|
|
{
|
|
|
|
return this->pluginState;
|
|
|
|
}
|
|
|
|
|
2023-05-02 17:07:48 +02:00
|
|
|
QString & ATBDeviceControllerPlugin::getLastError()
|
2023-04-19 16:26:12 +02:00
|
|
|
{
|
|
|
|
return this->errorCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString & ATBDeviceControllerPlugin::getLastErrorDescription()
|
|
|
|
{
|
|
|
|
return this->errorDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString & ATBDeviceControllerPlugin::getPluginInfo()
|
|
|
|
{
|
|
|
|
return this->pluginInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::RESULT_STATE resultState)
|
|
|
|
{
|
|
|
|
QString str;
|
|
|
|
|
|
|
|
switch (resultState) {
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::SUCCESS:
|
|
|
|
str = QString("RESULT_STATE::SUCCESS");
|
|
|
|
break;
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND:
|
|
|
|
str = QString("RESULT_STATE::ERROR_BACKEND");
|
|
|
|
break;
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::ERROR_TIMEOUT:
|
|
|
|
str = QString("RESULT_STATE::ERROR_TIMEOUT");
|
|
|
|
break;
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::ERROR_PROCESS:
|
|
|
|
str = QString("RESULT_STATE::ERROR_PROCESS");
|
|
|
|
break;
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::ERROR_RETRY:
|
|
|
|
str = QString("RESULT_STATE::ERROR_RETRY");
|
|
|
|
break;
|
|
|
|
case nsDeviceControllerInterface::RESULT_STATE::INFO:
|
|
|
|
str = QString("RESULT_STATE::INFO");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************************************
|
|
|
|
* ... end
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if QT_VERSION < 0x050000
|
|
|
|
Q_EXPORT_PLUGIN2( ATBDeviceControllerPlugin, ATBDeviceControllerPlugin )
|
|
|
|
#endif
|