Merge branch 'PayUpWithChanger' into pu/integration
This commit is contained in:
commit
d720c7190f
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 -----------------------------------------
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user