Compare commits

..

5 Commits
2.4.2 ... 2.5.1

5 changed files with 94 additions and 3 deletions

View File

@@ -311,6 +311,73 @@ void ATBDeviceControllerPlugin::cashCollect()
} }
} }
void ATBDeviceControllerPlugin::cashCollect(const QString & amount)
{
if (this->coinProcessor() != nsDeviceControllerInterface::COIN_PROCESSOR::CHANGER) {
this->cashCollect();
return;
}
// check if we must change coins:
// inserted amount
uint32_t amountInsertedInt = this->hw->getInsertedAmount();
bool ok;
uint32_t amountToPayInt = amount.toInt(&ok);
// check if we must change coins:
if (amountInsertedInt > amountToPayInt) {
uint32_t amountToChangeInt = amountInsertedInt - amountToPayInt;
qCritical() << "cashCollect(" << amount << ")";
qCritical() << " amount to change: " << QString::number(amountToChangeInt);
// trigger changer:
emit this->cashPaymentChanging(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
QString::number(amountToChangeInt),
"", // ErrorCode
""); // ErrorDescription
// change
hw->changer_returnCoins(amountToChangeInt);
QTimer::singleShot(1000, this, &ATBDeviceControllerPlugin::onCashChangerState);
}
else {
// nothing to change:
qCritical() << "cashCollect(" << amount << ")";
qCritical() << " nothing to change. ";
hw->vend_success();
QString amountString = QString::number(amountInsertedInt);
// 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);
emit this->cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
amountString,
amountCoinsString, // coins
amountNotesString, // notes
0, // proposed change
"",
"");
this->currentCashState = CASH_STATE::CACHE_EMPTY;
}
}
void ATBDeviceControllerPlugin::cashAbort() void ATBDeviceControllerPlugin::cashAbort()
{ {
hw->vend_failed(); hw->vend_failed();
@@ -1444,6 +1511,10 @@ void ATBDeviceControllerPlugin::onCashChangerState()
""); "");
changerStateRequestCounter = 0; changerStateRequestCounter = 0;
lastChangerResult = 0; lastChangerResult = 0;
// finalize vending:
hw->vend_success();
return; return;
} }
else else
@@ -1498,6 +1569,10 @@ void ATBDeviceControllerPlugin::onCashChangerState()
errorDescription); errorDescription);
changerStateRequestCounter = 0; changerStateRequestCounter = 0;
lastChangerResult = 0; lastChangerResult = 0;
// finalize vending:
hw->vend_success();
return; return;
} }
@@ -1637,6 +1712,7 @@ void ATBDeviceControllerPlugin::onWokeUp(uchar source)
{ {
if (source == 0x01 || source == 0xFE) { if (source == 0x01 || source == 0xFE) {
// woke up from device controller // woke up from device controller
hw->dc_autoRequest(true);
this->diag->diagRequest(); this->diag->diagRequest();
} }
} }

View File

@@ -50,6 +50,7 @@ public:
void requestStartCashInput(const QString & amount); void requestStartCashInput(const QString & amount);
void requestStopCashInput(); void requestStopCashInput();
void cashCollect(); void cashCollect();
void cashCollect(const QString & amount);
void cashAbort(); void cashAbort();
// read coin/cash processing variants ----------------------------------------- // read coin/cash processing variants -----------------------------------------

View File

@@ -135,6 +135,7 @@ void DeviceControllerDiag::private_startDiag()
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid"; qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid";
// try it again // try it again
hw->dc_autoRequest(true);
QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag); QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
} }
} }
@@ -164,6 +165,7 @@ void DeviceControllerDiag::sys_superviseSystem()
{ {
// es gibt keinerlei gültige Daten vom DC // es gibt keinerlei gültige Daten vom DC
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!"; qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
hw->dc_autoRequest(true);
this->private_sendDiagEvent(DeviceController::State::E254); this->private_sendDiagEvent(DeviceController::State::E254);
this->diagRequestTimeoutTimer->stop(); this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false; this->isRequestRunning = false;

View File

@@ -60,9 +60,10 @@ public:
virtual void requestStopCashInput() = 0; virtual void requestStopCashInput() = 0;
/** /**
* called e.g. on Button "NEXT" in pay-up (direct coin input) * called e.g. after printing
*/ */
virtual void cashCollect() = 0; virtual void cashCollect() = 0;
virtual void cashCollect(const QString & amount) = 0;
virtual void cashAbort() = 0; virtual void cashAbort() = 0;
// TASKS: Account ------------------------------------------------------------- // TASKS: Account -------------------------------------------------------------
@@ -138,6 +139,14 @@ signals:
const QString & errorCode, const QString & errorCode,
const QString & errorDescription); const QString & errorDescription);
/**
* emitted if cashPayment has been finished, e.g. in result to task cashCollect():
* if coins in changer must be given back to user.
*/
void cashPaymentChanging(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & changeValue, // amount changed by changer/escrow
const QString & errorCode,
const QString & errorDescription);
/** /**
* emitted if cashPayment has been finished, e.g. in result to task cashCollect(): * emitted if cashPayment has been finished, e.g. in result to task cashCollect():
* -> ticket should be printed sucessfully * -> ticket should be printed sucessfully
@@ -145,7 +154,7 @@ signals:
* Provides data for logging, especially changed value * Provides data for logging, especially changed value
*/ */
void cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE resultState, void cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & newCashValue, // total inserted amount amount const QString & newCashValue, // total inserted amount
const QString & coinValue, // inserted amount, paid with coins const QString & coinValue, // inserted amount, paid with coins
const QString & noteValue, // inserted amount, paid with notes const QString & noteValue, // inserted amount, paid with notes
const QString & changeValue, // amount changed by changer/escrow const QString & changeValue, // amount changed by changer/escrow
@@ -203,7 +212,7 @@ signals:
Q_DECLARE_INTERFACE(DeviceControllerInterface, Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.1.6") "eu.atb.ptu.plugin.DeviceControllerInterface/1.2.0")
namespace nsDeviceControllerInterface { namespace nsDeviceControllerInterface {

View File

@@ -172,6 +172,9 @@ QDebug operator<<(QDebug debug, TICKET_VARIANT ticketVariant)
case TICKET_VARIANT::FOOD_STAMP: case TICKET_VARIANT::FOOD_STAMP:
debug << "TICKET_VARIANT::FOOD_STAMP"; debug << "TICKET_VARIANT::FOOD_STAMP";
break; break;
case TICKET_VARIANT::FREE_TICKET:
debug << "TICKET_VARIANT::FREE_TICKET";
break;
} }
return debug; return debug;