Compare commits

...

9 Commits
2.4.2 ... 2.6.0

6 changed files with 124 additions and 28 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()
{
hw->vend_failed();
@@ -580,7 +647,7 @@ void ATBDeviceControllerPlugin::onNewVoltage(uint32_t voltage)
json = JSON::objectBuilder()
->set("Name", "batt")
->set("Value", voltageString)
->set("Unit", "V")
->set("Unit", "mV")
->create();
@@ -725,6 +792,7 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
<< " licenseplate = " << printingData["licenseplate"] << endl
<< " productText = " << printingData["productText"] << endl
<< " amount = " << printingData["amount"] << endl
<< " parkingEnd = " << printingData["parkingEnd"] << endl
<< " currentDateTime = " << printingData["currentDateTime"] << endl
@@ -774,11 +842,14 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
QByteArray ba_currentDate = codec->fromUnicode(currentDateString);
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
// Product-Text
QByteArray ba_productText = codec->fromUnicode(printingData["productText"].toString());
memcpy((char*)dynTicketData->dynDat5, ba_productText.data(), std::min(ba_productText.size(),8));
// Ticket-Number
QByteArray ba_ticketNumber = codec->fromUnicode(printingData["ticketNumber"].toString());
memcpy((char*)dynTicketData->dynDat7, ba_ticketNumber.data(), std::min(ba_ticketNumber.size(),8));
// DEBUG
/*
uint8_t* buf = dynTicketData->licensePlate;
@@ -1262,8 +1333,8 @@ void ATBDeviceControllerPlugin::onCashPayStopByEscrow()
"",
"",
"",
"",
"");
"CashPayStopByEscrow",
"CashPayStopByEscrow");
}
void ATBDeviceControllerPlugin::onCashPayStopByError()
@@ -1280,8 +1351,8 @@ void ATBDeviceControllerPlugin::onCashPayStopByError()
"",
"",
"",
"",
"");
"onCashPayStopByError",
"onCashPayStopByError");
}
void ATBDeviceControllerPlugin::onCashPayStopByTimeout()
@@ -1298,8 +1369,8 @@ void ATBDeviceControllerPlugin::onCashPayStopByTimeout()
"",
"",
"",
"",
"");
"CashPayStopByTimeout",
"CashPayStopByTimeout");
}
void ATBDeviceControllerPlugin::onCashPayStopedSuccess()
@@ -1444,6 +1515,10 @@ void ATBDeviceControllerPlugin::onCashChangerState()
"");
changerStateRequestCounter = 0;
lastChangerResult = 0;
// finalize vending:
hw->vend_success();
return;
}
else
@@ -1498,6 +1573,10 @@ void ATBDeviceControllerPlugin::onCashChangerState()
errorDescription);
changerStateRequestCounter = 0;
lastChangerResult = 0;
// finalize vending:
hw->vend_success();
return;
}
@@ -1637,6 +1716,7 @@ void ATBDeviceControllerPlugin::onWokeUp(uchar source)
{
if (source == 0x01 || source == 0xFE) {
// woke up from device controller
hw->dc_autoRequest(true);
this->diag->diagRequest();
}
}

View File

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

View File

@@ -135,6 +135,7 @@ void DeviceControllerDiag::private_startDiag()
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid";
// try it again
hw->dc_autoRequest(true);
QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
}
}
@@ -164,7 +165,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);
hw->dc_autoRequest(true);
this->private_sendDiagEvent(DeviceController::State::M0254);
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
if (this->E255counter > 5) { this->restartCArun(); }
@@ -230,13 +232,13 @@ void DeviceControllerDiag::sub_componentAssessment()
// Service or battery door is open
flag_sendOperate = false;
qCritical() << "DeviceControllerDiag::sys_superviseSystem() Service or battery door is open, goto INTRUSION MODE";
this->private_sendDiagEvent(DeviceController::State::E253);
this->private_sendDiagEvent(DeviceController::State::M0253);
}
if (dynMaCond.middleDoor) {
// vault door is open
flag_sendOperate = false;
qCritical() << "DeviceControllerDiag::sys_superviseSystem() vault door is open, goto INTRUSION MODE";
this->private_sendDiagEvent(DeviceController::State::E252);
this->private_sendDiagEvent(DeviceController::State::M0252);
}
// check for invalid states:
@@ -364,12 +366,12 @@ void DeviceControllerDiag::sub_componentAssessment()
if (dynMaCond.nowCardTest>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E072);
this->private_sendDiagEvent(DeviceController::State::M0072);
}
if (dynMaCond.startupTestIsRunning>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E073);
this->private_sendDiagEvent(DeviceController::State::M0073);
}
if (modCond.voltage>=200) {
@@ -524,28 +526,28 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
this->_isErrorState = true;
break;
case DeviceController::State::E071: // cash box change is ongoing
case DeviceController::State::M0071: // cash box change is ongoing
eventClass = EVENT_CLASS::STATE;
parameter = "cash box change is ongoing";
break;
case DeviceController::State::E072: // card test running
case DeviceController::State::M0072: // card test running
eventClass = EVENT_CLASS::STATE;
parameter = "card test running";
break;
case DeviceController::State::E073: // startup-test is running
case DeviceController::State::M0073: // startup-test is running
eventClass = EVENT_CLASS::STATE;
parameter = "startup-test is running";
break;
case DeviceController::State::E252: // cash box door open
case DeviceController::State::M0252: // cash box door open
eventClass = EVENT_CLASS::STATE;
parameter = "cash box door open";
break;
case DeviceController::State::E253: // service or battery door open
case DeviceController::State::M0253: // service or battery door open
eventClass = EVENT_CLASS::STATE;
parameter = "service or battery door open";
break;
case DeviceController::State::E254: // no valid data from DeviceController
case DeviceController::State::M0254: // no valid data from DeviceController
eventClass = EVENT_CLASS::STATE;
parameter = "no valid data from DeviceController";
break;

View File

@@ -41,13 +41,14 @@ namespace DeviceController {
E034,
E071,
E072,
E073,
M0071, // cashbox change is ongoing
M0072, // cardtest is running
M0073, // startup-test is running
M0252, // cashbox door open
M0253, // service or battery door is open
M0254, // no valid data from DC
E252,
E253,
E254,
E255,
W001,

View File

@@ -60,9 +60,10 @@ public:
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(const QString & amount) = 0;
virtual void cashAbort() = 0;
// TASKS: Account -------------------------------------------------------------
@@ -138,6 +139,14 @@ signals:
const QString & errorCode,
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():
* -> ticket should be printed sucessfully
@@ -145,7 +154,7 @@ signals:
* Provides data for logging, especially changed value
*/
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 & noteValue, // inserted amount, paid with notes
const QString & changeValue, // amount changed by changer/escrow
@@ -203,7 +212,7 @@ signals:
Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.1.6")
"eu.atb.ptu.plugin.DeviceControllerInterface/1.2.0")
namespace nsDeviceControllerInterface {

View File

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