From 8c1aa261451d764d51dc5d7058e03da8fc0b72b4 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 30 Nov 2023 12:04:11 +0100 Subject: [PATCH 01/18] Update DeviceControllerInterface 1.0.2 Send cashInputFinished with coins/notes/change --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 12 ++++++++++++ src/ATBAPP/DeviceControllerInterface.h | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index c81d3a8..c60d725 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -929,6 +929,9 @@ void ATBDeviceControllerPlugin::onCashPayStopByEscrow() emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, amountString, "", + "", + "", + "", ""); } @@ -944,6 +947,9 @@ void ATBDeviceControllerPlugin::onCashPayStopByError() emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, amountString, "", + "", + "", + "", ""); } @@ -959,6 +965,9 @@ void ATBDeviceControllerPlugin::onCashPayStopByTimeout() emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, amountString, "", + "", + "", + "", ""); } @@ -976,6 +985,9 @@ void ATBDeviceControllerPlugin::onCashPayStopedSuccess() emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, amountString, + "", // coins + "", // notes + "", // change "", ""); } diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index 61e1318..edd737e 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -119,7 +119,9 @@ signals: */ void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState, const QString & newCashValue, - /* additional variables? */ + const QString & coinValue, + const QString & noteValue, + const QString & changeValue, const QString & errorCode, const QString & errorDescription); @@ -165,7 +167,7 @@ signals: Q_DECLARE_INTERFACE(DeviceControllerInterface, - "eu.atb.ptu.plugin.DeviceControllerInterface/1.0.1") + "eu.atb.ptu.plugin.DeviceControllerInterface/1.0.2") namespace nsDeviceControllerInterface { From e95de7f9e4d475201470907c0b8028696427892a Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 30 Nov 2023 16:33:47 +0100 Subject: [PATCH 02/18] Print: dates in QLocale::ShortFormat Note: this needs test! Expected behaviour is that date format switches with language switch! This my be no problem in most cases however, e.g. in some cases there would be a different date format on the tickets. --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index c60d725..aef35e9 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -506,6 +506,10 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface:: QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate); QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate); + QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat); + QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat); + + // set dynamic printer data: QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString()); memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8)); @@ -517,11 +521,11 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface:: QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm")); memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); - QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("yy.MM.dd")); + QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString); memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); // ! and yes... 'ParkingEndDate' is 'currentTime' - QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("yy.MM.dd")); + QByteArray ba_currentDate = codec->fromUnicode(currentDateString); memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); // STAN for Szeged Start/Stop: must be 9 digits @@ -673,6 +677,9 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashfromUnicode(parkingEndDateTime.toString("hh:mm")); memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8)); - QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("yy.MM.dd")); + QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateString); memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8)); // ! and yes... 'ParkingEndDate' is 'currentTime' - QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("yy.MM.dd")); + QByteArray ba_currentDate = codec->fromUnicode(currentDateString); memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8)); From 247abb75204d02ee0da7867d19815dac98d3089e Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 30 Nov 2023 18:15:07 +0100 Subject: [PATCH 03/18] Add class CashUtils: utility methods for CashProcessing --- DCPlugin.pro | 2 + src/ATBAPP/ATBDeviceControllerPlugin.cpp | 1 + src/ATBAPP/support/CashUtils.cpp | 74 ++++++++++++++++++++++++ src/ATBAPP/support/CashUtils.h | 23 ++++++++ 4 files changed, 100 insertions(+) create mode 100644 src/ATBAPP/support/CashUtils.cpp create mode 100644 src/ATBAPP/support/CashUtils.h diff --git a/DCPlugin.pro b/DCPlugin.pro index 4379416..412637f 100644 --- a/DCPlugin.pro +++ b/DCPlugin.pro @@ -77,6 +77,7 @@ HEADERS += \ src/ATBAPP/ATBMachineEvent.h \ src/ATBAPP/ATBDeviceControllerPlugin.h \ src/ATBAPP/Utils.h \ + src/ATBAPP/support/CashUtils.h \ src/ATBAPP/support/DBusControllerInterface.h \ src/ATBAPP/support/JSON.h \ src/ATBAPP/support/PTUSystem.h @@ -87,6 +88,7 @@ SOURCES += \ src/ATBAPP/ATBDeviceControllerPlugin.cpp \ src/ATBAPP/DeviceControllerDiag.cpp \ src/ATBAPP/Utils.cpp \ + src/ATBAPP/support/CashUtils.cpp \ src/ATBAPP/support/DBusControllerInterface.cpp \ src/ATBAPP/support/JSON.cpp \ src/ATBAPP/support/PTUSystem.cpp diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index aef35e9..76ecb26 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -5,6 +5,7 @@ #include "src/ATBAPP/support/JSON.h" #include "src/ATBAPP/support/DBusControllerInterface.h" #include "src/ATBAPP/support/PTUSystem.h" +#include "src/ATBAPP/support/CashUtils.h" #include #include diff --git a/src/ATBAPP/support/CashUtils.cpp b/src/ATBAPP/support/CashUtils.cpp new file mode 100644 index 0000000..2785e02 --- /dev/null +++ b/src/ATBAPP/support/CashUtils.cpp @@ -0,0 +1,74 @@ +#include "CashUtils.h" + +CashUtils::CashUtils(QObject *parent) : QObject(parent){} + +#define MAX_COINS 64 +#define MAX_NOTES 16 + +/***************************************************************************** +* Get current inserted coins +* +* getAllInsertedCoins(uint16_t *types, uint16_t *values) +* all inserted coins of this past transaction are stored, max 64 +*/ +uint32_t getAmountOfInsertedCoins(hwinf* hw) +{ + uint32_t result = 0; + + uint16_t types[MAX_COINS]; + uint16_t values[MAX_COINS]; + hw->getAllInsertedCoins(types, values); + + for (int i = 0; i < MAX_COINS; i++) { + result += (types[i] * values[i]); + } + + return result; +} + + +/***************************************************************************** + * Get current inserted notes + * + * virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const =0; + * returns number of collected bank notes since start-command (current transaction) + * latestBill: not used + * currentNotes[0] = last bill value + * currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker) + * currentNotes[2,3] = total sum of collected bills within this transaction + * + */ +uint32_t getAmountOfInsertedNotes(hwinf* hw) +{ + uint32_t result = 0; + + uint16_t currentNotes[MAX_NOTES]; + hw->bna_getCurrentNotes(0, currentNotes); + + result = currentNotes[2] + ( currentNotes[3] >> 16); + + return result; +} + + + +/***************************************************************************** + * Get changer result + * + * virtual uint8_t changer_getChangeResult(uint32_t *returnedAmount) const =0; + * get result of coin dispensing + * receivedData[0]: 0: not yet started + * 1:amount returned + * 2:only partial return + * 3: no return possible + * receivedData[2,3,4,5]: returned amount + * + * Note: to get changed amount this method must be called after changing! + */ + +uint32_t getAmountDueToChange(hwinf* hw) +{ + Q_UNUSED(hw) + + return 0; +} diff --git a/src/ATBAPP/support/CashUtils.h b/src/ATBAPP/support/CashUtils.h new file mode 100644 index 0000000..a856821 --- /dev/null +++ b/src/ATBAPP/support/CashUtils.h @@ -0,0 +1,23 @@ +#ifndef CASHUTILS_H +#define CASHUTILS_H + +#include +#include "interfaces.h" + +class CashUtils : public QObject +{ + Q_OBJECT + +public: + static uint32_t getAmountOfInsertedCoins(hwinf* hw); + static uint32_t getAmountOfInsertedNotes(hwinf* hw); + static uint32_t getAmountDueToChange(hwinf* hw); + +private: + explicit CashUtils(QObject *parent = nullptr); + +signals: + +}; + +#endif // CASHUTILS_H From 96db7be1262784785a651559d30230f30a7d2f86 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 30 Nov 2023 18:16:45 +0100 Subject: [PATCH 04/18] Add object variable cashStartAmountInt Used to track proposed change amount. --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 8 +++++--- src/ATBAPP/ATBDeviceControllerPlugin.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 76ecb26..156a4f3 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -67,6 +67,8 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) this->currentSelectedTicketType = 0; this->currentCashState = CASH_STATE::CACHE_EMPTY; + + this->cashStartAmountInt = 0; } ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {} @@ -201,11 +203,11 @@ void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount) { qCritical() << "Start Cash vending with amount = " << amount; - uint32_t amountInt = static_cast(amount.toUInt()); + this->cashStartAmountInt = static_cast(amount.toUInt()); - if (amountInt == 0) amountInt = UINT_MAX; + if (this->cashStartAmountInt == 0) this->cashStartAmountInt = UINT_MAX; - hw->cash_startPayment(amountInt); + hw->cash_startPayment(this->cashStartAmountInt); } void ATBDeviceControllerPlugin::requestStopCashInput() diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index b07e209..9c1a0cc 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -111,6 +111,8 @@ private: DeviceControllerDiag* diag; + uint32_t cashStartAmountInt; + QTextCodec *codec; From d2a0491bba9fceac3463400157d0d8494c7712a1 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 30 Nov 2023 18:18:43 +0100 Subject: [PATCH 05/18] cashInputFinished: return coins/notes/change --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 156a4f3..dce98a7 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -986,18 +986,32 @@ void ATBDeviceControllerPlugin::onCashPayStopedSuccess() // DEBUG qCritical() << "ATBDeviceControllerPlugin::onCashPayStopedSuccess()"; + // inserted amount uint32_t amountInt = this->hw->getInsertedAmount(); - QString amountString = QString::number(amountInt); + // inserted coins + uint32_t amountCoinsInt = CashUtils::getAmountOfInsertedCoins(this->hw); + QString amountCoinsString = QString::number(amountCoinsInt); + + // inserted notes + uint32_t amountNotesInt = CashUtils::getAmountOfInsertedNotes(this->hw); + QString amountNotesString = QString::number(amountNotesInt); + + // amount due to change + uint32_t amountDueToChangeInt = this->cashStartAmountInt - amountInt; + QString amountDueToChangeString = QString::number(amountDueToChangeInt); + + + // DEBUG qCritical() << " insertedAmount (int) = " << amountInt; qCritical() << " insertedAmount = " << amountString; emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, amountString, - "", // coins - "", // notes - "", // change + amountCoinsString, // coins + amountNotesString, // notes + amountDueToChangeString, // proposed change "", ""); } From 60c4d5896a535e20cd61e591e871f940c8f83da9 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 1 Dec 2023 15:07:29 +0100 Subject: [PATCH 06/18] Set 'printerLocale' from settings --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 11 +++++++---- src/ATBAPP/ATBDeviceControllerPlugin.h | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index dce98a7..4e98404 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -80,6 +80,9 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con // read variables from setting this->serialPortName = settings.value("ATBDeviceControllerPlugin/serialPort", "ttymxc2").toString(); QByteArray printerEncoding = settings.value("ATBDeviceControllerPlugin/printerEncoding", "ISO 8859-2").toString().toLatin1(); + QString printerLocaleString = settings.value("ATBDeviceControllerPlugin/printerLocale", "de_DE").toString().toLatin1(); + this->printerLocale = QLocale(printerLocaleString); + if (this->isMaster) { // open serial port @@ -509,8 +512,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface:: QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate); QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate); - QString parkingEndDateString = QLocale().toString(parkingEndDateTime.date(), QLocale::ShortFormat); - QString currentDateString = QLocale().toString(currentDateTime.date(), QLocale::ShortFormat); + QString parkingEndDateString = this->printerLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat); + QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat); // set dynamic printer data: @@ -680,8 +683,8 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashprinterLocale.toString(parkingEndDateTime.date(), QLocale::ShortFormat); + QString currentDateString = this->printerLocale.toString(currentDateTime.date(), QLocale::ShortFormat); /* ----------------------------------------------------------------------------------------- * note: the following highly depends on printer template files! diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index 9c1a0cc..48709f6 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -2,6 +2,7 @@ #define ATBDEVICECONTROLLERPLUGIN_H #include +#include #include "src/ATBAPP/DeviceControllerInterface.h" #include "src/ATBAPP/ATBAPPplugin.h" @@ -128,6 +129,8 @@ private: // dbus int init_sc_dbus(); + QLocale printerLocale; + private slots: // printer From 7affcb03135a21bdb6bad5f3788eb942d762687c Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 4 Dec 2023 10:31:52 +0100 Subject: [PATCH 07/18] Update DeviceControllerInterface 1.0.3 Signal cashPaymentFinished() --- src/ATBAPP/DeviceControllerInterface.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index edd737e..39645c8 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -125,6 +125,21 @@ signals: const QString & errorCode, const QString & errorDescription); + /** + * emitted if cashPayment has been finished, e.g. in result to task cashCollect(): + * -> ticket should be printed sucessfully + * -> coins in excrow or changer are given back to user + * Provides data for logging, especially changed value + */ + void cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE resultState, + const QString & newCashValue, // total inserted amount amount + const QString & coinValue, // inserted amount, paid with coins + const QString & noteValue, // inserted amount, paid with notes + const QString & changeValue, // amount changed by changer/escrow + const QString & errorCode, + const QString & errorDescription); + + /** * emitted e.g. if service door is opened @@ -167,7 +182,7 @@ signals: Q_DECLARE_INTERFACE(DeviceControllerInterface, - "eu.atb.ptu.plugin.DeviceControllerInterface/1.0.2") + "eu.atb.ptu.plugin.DeviceControllerInterface/1.0.3") namespace nsDeviceControllerInterface { From 05113057b0c78265f79d62eb6be79a29e93b0986 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 8 Dec 2023 12:33:46 +0100 Subject: [PATCH 08/18] CashUtils: is not a class, it is a namespace --- src/ATBAPP/support/CashUtils.cpp | 45 ++++++++------------------------ src/ATBAPP/support/CashUtils.h | 17 +++--------- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/src/ATBAPP/support/CashUtils.cpp b/src/ATBAPP/support/CashUtils.cpp index 2785e02..3943ee6 100644 --- a/src/ATBAPP/support/CashUtils.cpp +++ b/src/ATBAPP/support/CashUtils.cpp @@ -1,6 +1,6 @@ #include "CashUtils.h" -CashUtils::CashUtils(QObject *parent) : QObject(parent){} +#include #define MAX_COINS 64 #define MAX_NOTES 16 @@ -11,7 +11,7 @@ CashUtils::CashUtils(QObject *parent) : QObject(parent){} * getAllInsertedCoins(uint16_t *types, uint16_t *values) * all inserted coins of this past transaction are stored, max 64 */ -uint32_t getAmountOfInsertedCoins(hwinf* hw) +uint32_t CashUtils::getAmountOfInsertedCoins(hwinf* hw) { uint32_t result = 0; @@ -20,7 +20,7 @@ uint32_t getAmountOfInsertedCoins(hwinf* hw) hw->getAllInsertedCoins(types, values); for (int i = 0; i < MAX_COINS; i++) { - result += (types[i] * values[i]); + result += values[i]; } return result; @@ -32,43 +32,20 @@ uint32_t getAmountOfInsertedCoins(hwinf* hw) * * virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const =0; * returns number of collected bank notes since start-command (current transaction) - * latestBill: not used - * currentNotes[0] = last bill value - * currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker) - * currentNotes[2,3] = total sum of collected bills within this transaction + * latestBill: last accepted bank note, value in cent + * currentNotes an array with up to 16 (further) notes collected * */ -uint32_t getAmountOfInsertedNotes(hwinf* hw) +uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw) { uint32_t result = 0; - uint16_t currentNotes[MAX_NOTES]; - hw->bna_getCurrentNotes(0, currentNotes); + uint16_t values[MAX_NOTES]; + hw->bna_getCurrentNotes(0, values); - result = currentNotes[2] + ( currentNotes[3] >> 16); + for (int i = 0; i < MAX_COINS; i++) { + result += values[i]; + } return result; } - - - -/***************************************************************************** - * Get changer result - * - * virtual uint8_t changer_getChangeResult(uint32_t *returnedAmount) const =0; - * get result of coin dispensing - * receivedData[0]: 0: not yet started - * 1:amount returned - * 2:only partial return - * 3: no return possible - * receivedData[2,3,4,5]: returned amount - * - * Note: to get changed amount this method must be called after changing! - */ - -uint32_t getAmountDueToChange(hwinf* hw) -{ - Q_UNUSED(hw) - - return 0; -} diff --git a/src/ATBAPP/support/CashUtils.h b/src/ATBAPP/support/CashUtils.h index a856821..1bfc654 100644 --- a/src/ATBAPP/support/CashUtils.h +++ b/src/ATBAPP/support/CashUtils.h @@ -4,20 +4,11 @@ #include #include "interfaces.h" -class CashUtils : public QObject -{ - Q_OBJECT +namespace CashUtils { -public: - static uint32_t getAmountOfInsertedCoins(hwinf* hw); - static uint32_t getAmountOfInsertedNotes(hwinf* hw); - static uint32_t getAmountDueToChange(hwinf* hw); +uint32_t getAmountOfInsertedCoins(hwinf* hw); +uint32_t getAmountOfInsertedNotes(hwinf* hw); -private: - explicit CashUtils(QObject *parent = nullptr); - -signals: - -}; +} #endif // CASHUTILS_H From 25cb23a5876ab43dd1f35cda7f644d904ffff23e Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 8 Dec 2023 12:41:57 +0100 Subject: [PATCH 09/18] Send cashPaymentFinished() onCashChangerState() ... This is for checking changer result and includes lot of debug code! --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 190 ++++++++++++++++++++++- src/ATBAPP/ATBDeviceControllerPlugin.h | 1 + 2 files changed, 187 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 4e98404..883b9d6 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -224,7 +224,33 @@ void ATBDeviceControllerPlugin::requestStopCashInput() void ATBDeviceControllerPlugin::cashCollect() { hw->vend_success(); - this->currentCashState = CASH_STATE::CACHE_EMPTY; + + // inserted amount + uint32_t amountInt = this->hw->getInsertedAmount(); + QString amountString = QString::number(amountInt); + + // inserted coins + uint32_t amountCoinsInt = CashUtils::getAmountOfInsertedCoins(this->hw); + QString amountCoinsString = QString::number(amountCoinsInt); + + // inserted notes + uint32_t amountNotesInt = CashUtils::getAmountOfInsertedNotes(this->hw); + QString amountNotesString = QString::number(amountNotesInt); + + + if (this->coinProcessor() == nsDeviceControllerInterface::COIN_PROCESSOR::CHANGER) { + QTimer::singleShot(1000, this, &ATBDeviceControllerPlugin::onCashChangerState); + } + else { + emit this->cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, + amountString, + amountCoinsString, // coins + amountNotesString, // notes + 0, // proposed change + "", + ""); + this->currentCashState = CASH_STATE::CACHE_EMPTY; + } } void ATBDeviceControllerPlugin::cashAbort() @@ -1002,13 +1028,34 @@ void ATBDeviceControllerPlugin::onCashPayStopedSuccess() QString amountNotesString = QString::number(amountNotesInt); // amount due to change - uint32_t amountDueToChangeInt = this->cashStartAmountInt - amountInt; + uint32_t amountDueToChangeInt; + if (amountInt > this->cashStartAmountInt) { + amountDueToChangeInt = amountInt - this->cashStartAmountInt; + } + else { + amountDueToChangeInt = 0; + } QString amountDueToChangeString = QString::number(amountDueToChangeInt); // DEBUG - qCritical() << " insertedAmount (int) = " << amountInt; - qCritical() << " insertedAmount = " << amountString; + qCritical() << "---------------------------------------------------------"; + qCritical() << "ATBDeviceControllerPlugin::onCashPayStopedSuccess()"; + qCritical() << ""; + qCritical() << " amountInt: " << amountInt; + qCritical() << " amountString: " << amountString; + qCritical() << ""; + qCritical() << " amountNotesInt: " << amountNotesInt; + qCritical() << " amountNotesString: " << amountNotesString; + qCritical() << ""; + qCritical() << " amountCoinsInt: " << amountCoinsInt; + qCritical() << " amountCoinsString: " << amountCoinsString; + qCritical() << ""; + qCritical() << " this->cashStartAmountInt: " << this->cashStartAmountInt; + qCritical() << " amountDueToChangeInt: " << amountDueToChangeInt; + qCritical() << " amountDueToChangeString: " << amountDueToChangeString; + qCritical() << "---------------------------------------------------------"; + emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, amountString, @@ -1019,6 +1066,141 @@ void ATBDeviceControllerPlugin::onCashPayStopedSuccess() ""); } +void ATBDeviceControllerPlugin::onCashChangerState() +{ + uint32_t amountThatCouldNotBeChangedInt; + + static int changerStateRequestCounter = 0; + static uint8_t lastChangerResult = 0; + + + // inserted amount + uint32_t amountInt = this->hw->getInsertedAmount(); + QString amountString = QString::number(amountInt); + + // inserted coins + uint32_t amountCoinsInt = CashUtils::getAmountOfInsertedCoins(this->hw); + QString amountCoinsString = QString::number(amountCoinsInt); + + // inserted notes + uint32_t amountNotesInt = CashUtils::getAmountOfInsertedNotes(this->hw); + QString amountNotesString = QString::number(amountNotesInt); + + // amount due to change + uint32_t amountCoinsChangedInt; + if (amountInt > this->cashStartAmountInt) { + amountCoinsChangedInt = amountInt - this->cashStartAmountInt; + } + else { + amountCoinsChangedInt = 0; + } + QString amountCoinsChangedString = QString::number(amountCoinsChangedInt); + + + // get changer state ------------------------------------------------ + // Note: 'returnedAmount'-parameter is missleading here! + // 'returnedAmount' is the amount which could not be changed! + + lastChangerResult = hw->changer_getChangeResult(&amountThatCouldNotBeChangedInt); + + // DEBUG + qCritical() << "---------------------------------------------------------"; + qCritical() << "ATBDeviceControllerPlugin::onCashChangerState()"; + qCritical() << " changerStateRequestCounter: " << changerStateRequestCounter; + qCritical() << " lastChangerResult: " << lastChangerResult; + qCritical() << " amountThatCouldNotBeChangedInt: " << amountThatCouldNotBeChangedInt; + qCritical() << ""; + qCritical() << " amountInt: " << amountInt; + qCritical() << " amountString: " << amountString; + qCritical() << ""; + qCritical() << " amountCoinsInt: " << amountCoinsInt; + qCritical() << " amountCoinsString: " << amountCoinsString; + qCritical() << ""; + qCritical() << " amountNotesInt: " << amountNotesInt; + qCritical() << " amountNotesString: " << amountNotesString; + qCritical() << ""; + qCritical() << " this->cashStartAmountInt: " << this->cashStartAmountInt; + qCritical() << " amountCoinsChangedInt: " << amountCoinsChangedInt; + qCritical() << " amountCoinsChangedString: " << amountCoinsChangedString; + qCritical() << "---------------------------------------------------------"; + + if (lastChangerResult == 1) { // change is returned + + + QString amountCoinsChangedString = QString::number(amountCoinsChangedInt); + + emit this->cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS, + amountString, + amountCoinsString, // coins + amountNotesString, // notes + amountCoinsChangedString, // change + "", + ""); + changerStateRequestCounter = 0; + lastChangerResult = 0; + return; + } + else + if (lastChangerResult == 0) { // not yet started + qCritical() << "ATBDeviceControllerPlugin::onCashChangerState(): ERROR: change not yet started: amount due to return: " << amountCoinsChangedString; + } + else + if (lastChangerResult == 2) { // only partial return + qCritical() << "ATBDeviceControllerPlugin::onCashChangerState(): ERROR: only partial return: amount due to return: " << amountCoinsChangedString; + } + else + if (lastChangerResult == 3) { // no return possible + qCritical() << "ATBDeviceControllerPlugin::onCashChangerState(): ERROR: no return possible: amount due to return: " << amountCoinsChangedString; + } + else { + qCritical() << "ATBDeviceControllerPlugin::onCashChangerState(): ERROR: invalid changerState (" << lastChangerResult << ")"; + } + + + // handle timeout ------------------------------------------------ + if (changerStateRequestCounter > 15) { + QString errorCode; + QString errorDescription; + switch (lastChangerResult) { + case 0: // not yet started + errorCode = "DC::CHANGER::START"; + errorDescription = "Changer does not start"; + break; + case 1: // amount returned + // This error should not occur! + errorCode = "DC::CHANGER::INVALID"; + errorDescription = "Changer returned amount"; + break; + case 2: // only partial return + errorCode = "DC::CHANGER::CHANGE"; + errorDescription = "Changer does only partial return"; + break; + case 3: // no return possible + errorCode = "DC::CHANGER::CHANGE_NOT_POSSIBLE"; + errorDescription = "Changing not possible"; + break; + default: + + break; + } + emit this->cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND, + amountString, + amountCoinsString, + amountNotesString, + 0, + errorCode, + errorDescription); + changerStateRequestCounter = 0; + lastChangerResult = 0; + return; + } + + // restart changer check: + changerStateRequestCounter++; + QTimer::singleShot(1000, this, &ATBDeviceControllerPlugin::onCashChangerState); +} + + /** diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.h b/src/ATBAPP/ATBDeviceControllerPlugin.h index 48709f6..e3f39f6 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.h +++ b/src/ATBAPP/ATBDeviceControllerPlugin.h @@ -151,6 +151,7 @@ private slots: void onCashPayStopByEscrow(); void onCashPayStopByError(); void onCashPayStopByTimeout(); + void onCashChangerState(); // doors and hardware contacts void onServiceDoorOpened(); From bee611651c98b1296f71d57dee2153c438db702e Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 8 Dec 2023 12:42:58 +0100 Subject: [PATCH 10/18] Update interfaces.h --- include/interfaces.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/interfaces.h b/include/interfaces.h index 65a0f67..7234315 100755 --- a/include/interfaces.h +++ b/include/interfaces.h @@ -1834,6 +1834,9 @@ public: virtual uint8_t prn_getPrintResult() const { return 0; } + // return: 0: just printing, wait + // 1: OK - last print was succesful + // 2: error - not printed @@ -2273,7 +2276,32 @@ public: signals: + virtual void hwapi_templatePrintFinished_OK(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_payStopByMax(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; + + virtual void hwapi_doorServiceDoorOpened(void) const=0; + virtual void hwapi_doorVaultDoorOpened(void) const=0; + virtual void hwapi_doorCoinBoxRemoved(void) const=0; + virtual void hwapi_doorCoinBoxInserted(void) const=0; + virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0; + virtual void hwapi_doorAllDoorsClosed(void) const=0; + + // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid. + /* GH Version, bringt Fehler void hwapi_templatePrintFinished_OK() const; void hwapi_templatePrintFinished_Err() const; @@ -2296,6 +2324,7 @@ signals: void hwapi_doorCoinBoxInserted() const; void hwapi_doorCBinAndAllDoorsClosed() const; void hwapi_doorAllDoorsClosed() const; + */ }; From b3ad8e1ee9a20742705fab6815516cbc600fe7f3 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 11 Dec 2023 14:08:39 +0100 Subject: [PATCH 11/18] Interrupt DiagRequest on error --- src/ATBAPP/DeviceControllerDiag.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ATBAPP/DeviceControllerDiag.cpp b/src/ATBAPP/DeviceControllerDiag.cpp index e74775d..3d801db 100644 --- a/src/ATBAPP/DeviceControllerDiag.cpp +++ b/src/ATBAPP/DeviceControllerDiag.cpp @@ -57,6 +57,8 @@ void DeviceControllerDiag::private_startDiag() if (this->flagInterruptDiag) { qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!"; this->private_sendDiagEvent(DeviceController::State::E255); + this->isRequestRunning = false; + this->flagInterruptDiag = false; return; } @@ -89,6 +91,8 @@ void DeviceControllerDiag::sys_superviseSystem() if (this->flagInterruptDiag) { qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!"; this->private_sendDiagEvent(DeviceController::State::E255); + this->flagInterruptDiag = false; + this->isRequestRunning = false; return; } @@ -97,6 +101,8 @@ void DeviceControllerDiag::sys_superviseSystem() // es gibt keinerlei gültige Daten vom DC qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!"; this->private_sendDiagEvent(DeviceController::State::E254); + this->diagRequestTimeoutTimer->stop(); + this->isRequestRunning = false; return; } From c603313d73bd289b8abe69061d910d143b1e0e66 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 11 Dec 2023 18:32:37 +0100 Subject: [PATCH 12/18] PrintTicket: skip check of serial port --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 883b9d6..9e1f9eb 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -609,11 +609,13 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface:: } + /* if (!this->hw->dc_isPortOpen()) { qCritical() << " ... serial port is not open!"; this->onPrintFinishedERR(); return; } + */ // TODO: wird hier nur 'licensePlate' gedruckt? if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { @@ -750,12 +752,13 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHashhw->dc_isPortOpen()) { qCritical() << " ... serial port is not open!"; this->onPrintFinishedERR(); return; } - + */ // TODO: wird hier nur 'licensePlate' gedruckt? if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { From 80c7992d5b88e9a57d15a1dccd88580107c9cdd8 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Wed, 13 Dec 2023 09:23:03 +0100 Subject: [PATCH 13/18] Start autoRequest allways ... ... we need this! --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 9e1f9eb..3727576 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -87,9 +87,10 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con if (this->isMaster) { // open serial port hw->dc_openSerial(5, "115200", this->serialPortName, 1); - hw->dc_autoRequest(true); } + hw->dc_autoRequest(true); + hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber()); hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber()); hw->dc_setNewZone(PTUSystem::readZoneNumber()); @@ -176,20 +177,20 @@ void ATBDeviceControllerPlugin::reset() void ATBDeviceControllerPlugin::onChangedProgramModeToSELL() { + hw->dc_autoRequest(true); hw->rtc_setDateTime(); hw->mdb_switchWake(0); // wakeup MDB components } void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE() { - //hw->dc_autoRequest(true); + hw->dc_autoRequest(true); hw->mdb_switchWake(0); // wakeup MDB components } void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE() { - //hw->dc_autoRequest(false); // <-- TODO: ??? - + hw->dc_autoRequest(true); this->diag->diagRequest(); hw->mdb_switchWake(1); From 012f3430c5d277c0831ee951042c5ebca766de3c Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Thu, 14 Dec 2023 15:48:37 +0100 Subject: [PATCH 14/18] Rework for getAmountOfInsertedNotes due to wrong description in interface --- src/ATBAPP/support/CashUtils.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/ATBAPP/support/CashUtils.cpp b/src/ATBAPP/support/CashUtils.cpp index 3943ee6..6e09aae 100644 --- a/src/ATBAPP/support/CashUtils.cpp +++ b/src/ATBAPP/support/CashUtils.cpp @@ -39,13 +39,36 @@ uint32_t CashUtils::getAmountOfInsertedCoins(hwinf* hw) uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw) { uint32_t result = 0; + uint8_t numberOfInsertedNotes; - uint16_t values[MAX_NOTES]; - hw->bna_getCurrentNotes(0, values); + uint16_t beforeArray = 0; + uint16_t currentNotes[4]; + uint16_t afterArray = 0; + numberOfInsertedNotes = hw->bna_getCurrentNotes(0, currentNotes); - for (int i = 0; i < MAX_COINS; i++) { - result += values[i]; + if ( (beforeArray != 0) || (afterArray != 0) ) { + qCritical() << "CashUtils::getAmountOfInsertedNotes() ERROR: Array"; } + if (numberOfInsertedNotes == 99) { + // Error + qCritical() << "CashUtils::getAmountOfInsertedNotes() ERROR: "; + for (int i = 0; i < 4; i++) { + qCritical() << " currentNotes[" << i << "] = " << currentNotes[i]; + } + } + else { + // no error + result = currentNotes[3]; + result = ( result << 16 ) | currentNotes[2]; + } + + // DEBUG + qCritical() << "--------------------------------------------------"; + qCritical() << "CashUtils::getAmountOfInsertedNotes()"; + qCritical() << " numberOfInsertedNotes = " << numberOfInsertedNotes; + qCritical() << " result = " << result; + qCritical() << "--------------------------------------------------"; + return result; } From 81a70bf387ce8ec5d7a04cb523821d2cf0232d0a Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 15 Dec 2023 11:29:08 +0100 Subject: [PATCH 15/18] Upate DeviceControllerInterface to 1.1.0 --- src/ATBAPP/DeviceControllerInterface.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index 39645c8..6de0068 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -146,6 +146,11 @@ signals: */ void requestModeSERVICE(); + /** + * emitted e.g. if vault door is opened + */ + void requestModeACCOUNT(); + /** * emitted e.g. if doors are closed */ @@ -162,7 +167,11 @@ signals: void requestAccountResponse(const QHash & accountData); - + /** + * show text messaged in service mode + */ + void showServiceText(const QString & text); + void showServiceText(quint16 textNumber); /** @@ -182,7 +191,7 @@ signals: Q_DECLARE_INTERFACE(DeviceControllerInterface, - "eu.atb.ptu.plugin.DeviceControllerInterface/1.0.3") + "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.0") namespace nsDeviceControllerInterface { From 07bb1bde508d967a49a725c7e60c49b6d6fcd58c Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 15 Dec 2023 11:54:36 +0100 Subject: [PATCH 16/18] Send interface signal on VaultDoor opened --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 3727576..4819a51 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -439,9 +439,6 @@ void ATBDeviceControllerPlugin::onServiceDoorOpened() void ATBDeviceControllerPlugin::onVaultDoorOpened() { - // TODO: - // - show special screen / message on screen - // - create an HealthEvent (-> ISMAS-Event) qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()"; // ... to detect alarm etc. @@ -452,7 +449,7 @@ void ATBDeviceControllerPlugin::onVaultDoorOpened() // BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS! this->dbus->startBackgroundTask("DOOR_OPEN"); - // do not: emit this->requestModeSERVICE(); + emit this->requestModeACCOUNT(); } void ATBDeviceControllerPlugin::onCoinBoxRemoved() From 246e23bffd78c3c960eb3779838e596a2a65d92a Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Mon, 18 Dec 2023 08:21:08 +0100 Subject: [PATCH 17/18] Fix: typo --- src/ATBAPP/DeviceControllerInterface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index 6de0068..249e1b3 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -168,7 +168,7 @@ signals: /** - * show text messaged in service mode + * show text messages in service mode */ void showServiceText(const QString & text); void showServiceText(quint16 textNumber); From 1c643c6cafca2e05df429510fb540ba72032e811 Mon Sep 17 00:00:00 2001 From: Siegfried Siegert Date: Fri, 22 Dec 2023 09:26:13 +0100 Subject: [PATCH 18/18] Update DeviceControllerInterface to 1.1.1 --- src/ATBAPP/ATBDeviceControllerPlugin.cpp | 11 +++++++++++ src/ATBAPP/DeviceControllerInterface.h | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/ATBAPP/ATBDeviceControllerPlugin.cpp b/src/ATBAPP/ATBDeviceControllerPlugin.cpp index 4819a51..c2f90fb 100644 --- a/src/ATBAPP/ATBDeviceControllerPlugin.cpp +++ b/src/ATBAPP/ATBDeviceControllerPlugin.cpp @@ -450,6 +450,12 @@ void ATBDeviceControllerPlugin::onVaultDoorOpened() this->dbus->startBackgroundTask("DOOR_OPEN"); emit this->requestModeACCOUNT(); + + // send service message, delayed: + QTimer::singleShot(1000, this, [this](){ + emit this->showServiceText(nsDeviceControllerInterface::SERVICE_TEXT::VAULT_DOOR_OPENED, "Please remove coinbox"); + hw->prn_cut(3); + } ); } void ATBDeviceControllerPlugin::onCoinBoxRemoved() @@ -459,12 +465,17 @@ void ATBDeviceControllerPlugin::onCoinBoxRemoved() // BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS! this->dbus->startBackgroundTask("ACCOUNT"); + emit this->showServiceText(nsDeviceControllerInterface::SERVICE_TEXT::COIN_BOX_REMOVED, "Please insert coinbox"); + QTimer::singleShot(4000, this, SLOT(private_startAccount())); } void ATBDeviceControllerPlugin::onCoinBoxInserted() { qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()"; + + emit this->showServiceText(nsDeviceControllerInterface::SERVICE_TEXT::COIN_BOX_INSERTED, "Please close vault door"); + // emit this->showServiceText(0x1234); } /** diff --git a/src/ATBAPP/DeviceControllerInterface.h b/src/ATBAPP/DeviceControllerInterface.h index 249e1b3..4026051 100644 --- a/src/ATBAPP/DeviceControllerInterface.h +++ b/src/ATBAPP/DeviceControllerInterface.h @@ -15,6 +15,9 @@ namespace nsDeviceControllerInterface { enum class TICKET_VARIANT : quint8; enum class COIN_PROCESSOR : quint8; enum class BILL_ACCEPTOR : quint8; + + + enum class SERVICE_TEXT : quint16; } @@ -170,8 +173,7 @@ signals: /** * show text messages in service mode */ - void showServiceText(const QString & text); - void showServiceText(quint16 textNumber); + void showServiceText(nsDeviceControllerInterface::SERVICE_TEXT serviceText, const QString & text); /** @@ -191,7 +193,7 @@ signals: Q_DECLARE_INTERFACE(DeviceControllerInterface, - "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.0") + "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.1") namespace nsDeviceControllerInterface { @@ -235,6 +237,14 @@ namespace nsDeviceControllerInterface { YES, NO }; + + enum class SERVICE_TEXT : quint16 { + SERVICE_DOOR_OPENED, + VAULT_DOOR_OPENED, + COIN_BOX_REMOVED, + COIN_BOX_INSERTED + /* t.b.d. */ + }; } #endif // DEVICECONTROLLERINTERFACE_H