Compare commits

...

11 Commits

4 changed files with 91 additions and 16 deletions

View File

@@ -87,9 +87,10 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
if (this->isMaster) { if (this->isMaster) {
// open serial port // open serial port
hw->dc_openSerial(5, "115200", this->serialPortName, 1); hw->dc_openSerial(5, "115200", this->serialPortName, 1);
hw->dc_autoRequest(true);
} }
hw->dc_autoRequest(true);
hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber()); hw->dc_setNewCustomerNumber(PTUSystem::readCustomerNumber());
hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber()); hw->dc_setNewMachineNumber(PTUSystem::readMachineNumber());
hw->dc_setNewZone(PTUSystem::readZoneNumber()); hw->dc_setNewZone(PTUSystem::readZoneNumber());
@@ -176,20 +177,20 @@ void ATBDeviceControllerPlugin::reset()
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL() void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
{ {
hw->dc_autoRequest(true);
hw->rtc_setDateTime(); hw->rtc_setDateTime();
hw->mdb_switchWake(0); // wakeup MDB components hw->mdb_switchWake(0); // wakeup MDB components
} }
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE() void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
{ {
//hw->dc_autoRequest(true); hw->dc_autoRequest(true);
hw->mdb_switchWake(0); // wakeup MDB components hw->mdb_switchWake(0); // wakeup MDB components
} }
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE() void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
{ {
//hw->dc_autoRequest(false); // <-- TODO: ??? hw->dc_autoRequest(true);
this->diag->diagRequest(); this->diag->diagRequest();
hw->mdb_switchWake(1); hw->mdb_switchWake(1);
@@ -438,9 +439,6 @@ void ATBDeviceControllerPlugin::onServiceDoorOpened()
void ATBDeviceControllerPlugin::onVaultDoorOpened() void ATBDeviceControllerPlugin::onVaultDoorOpened()
{ {
// TODO:
// - show special screen / message on screen
// - create an HealthEvent (-> ISMAS-Event)
qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()"; qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()";
// ... to detect alarm etc. // ... to detect alarm etc.
@@ -451,7 +449,13 @@ void ATBDeviceControllerPlugin::onVaultDoorOpened()
// BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS! // BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS!
this->dbus->startBackgroundTask("DOOR_OPEN"); this->dbus->startBackgroundTask("DOOR_OPEN");
// do not: emit this->requestModeSERVICE(); 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() void ATBDeviceControllerPlugin::onCoinBoxRemoved()
@@ -461,12 +465,17 @@ void ATBDeviceControllerPlugin::onCoinBoxRemoved()
// BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS! // BackgroundTask("ACCOUNT") is finished, if account message is sent to ISMAS!
this->dbus->startBackgroundTask("ACCOUNT"); this->dbus->startBackgroundTask("ACCOUNT");
emit this->showServiceText(nsDeviceControllerInterface::SERVICE_TEXT::COIN_BOX_REMOVED, "Please insert coinbox");
QTimer::singleShot(4000, this, SLOT(private_startAccount())); QTimer::singleShot(4000, this, SLOT(private_startAccount()));
} }
void ATBDeviceControllerPlugin::onCoinBoxInserted() void ATBDeviceControllerPlugin::onCoinBoxInserted()
{ {
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()"; qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
emit this->showServiceText(nsDeviceControllerInterface::SERVICE_TEXT::COIN_BOX_INSERTED, "Please close vault door");
// emit this->showServiceText(0x1234);
} }
/** /**
@@ -609,11 +618,13 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::
} }
/*
if (!this->hw->dc_isPortOpen()) { if (!this->hw->dc_isPortOpen()) {
qCritical() << " ... serial port is not open!"; qCritical() << " ... serial port is not open!";
this->onPrintFinishedERR(); this->onPrintFinishedERR();
return; return;
} }
*/
// TODO: wird hier nur 'licensePlate' gedruckt? // TODO: wird hier nur 'licensePlate' gedruckt?
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
@@ -648,6 +659,7 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri
{ {
QByteArray ba = printingString.toUtf8(); QByteArray ba = printingString.toUtf8();
hw->prn_switchPower(true); hw->prn_switchPower(true);
hw->prn_setFonts(8,12,0,0);
hw->prn_sendText(&ba); hw->prn_sendText(&ba);
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt())); QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt()));
@@ -750,12 +762,13 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
// DEBUG // DEBUG
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()"; qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
/*
if (!this->hw->dc_isPortOpen()) { if (!this->hw->dc_isPortOpen()) {
qCritical() << " ... serial port is not open!"; qCritical() << " ... serial port is not open!";
this->onPrintFinishedERR(); this->onPrintFinishedERR();
return; return;
} }
*/
// TODO: wird hier nur 'licensePlate' gedruckt? // TODO: wird hier nur 'licensePlate' gedruckt?
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) { if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
@@ -1092,10 +1105,24 @@ void ATBDeviceControllerPlugin::onCashChangerState()
amountCoinsChangedInt = amountInt - this->cashStartAmountInt; amountCoinsChangedInt = amountInt - this->cashStartAmountInt;
} }
else { else {
amountCoinsChangedInt = 0; amountCoinsChangedInt = 0;
} }
QString amountCoinsChangedString = QString::number(amountCoinsChangedInt); QString amountCoinsChangedString = QString::number(amountCoinsChangedInt);
// if we do not need to give change:
if (amountCoinsChangedInt == 0) {
emit this->cashPaymentFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
amountString,
amountCoinsString, // coins
amountNotesString, // notes
amountCoinsChangedString, // change
"",
"");
changerStateRequestCounter = 0;
lastChangerResult = 0;
return;
}
// get changer state ------------------------------------------------ // get changer state ------------------------------------------------
// Note: 'returnedAmount'-parameter is missleading here! // Note: 'returnedAmount'-parameter is missleading here!

View File

@@ -57,6 +57,8 @@ void DeviceControllerDiag::private_startDiag()
if (this->flagInterruptDiag) { if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!"; qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
this->private_sendDiagEvent(DeviceController::State::E255); this->private_sendDiagEvent(DeviceController::State::E255);
this->isRequestRunning = false;
this->flagInterruptDiag = false;
return; return;
} }
@@ -89,6 +91,8 @@ void DeviceControllerDiag::sys_superviseSystem()
if (this->flagInterruptDiag) { if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!"; qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
this->private_sendDiagEvent(DeviceController::State::E255); this->private_sendDiagEvent(DeviceController::State::E255);
this->flagInterruptDiag = false;
this->isRequestRunning = false;
return; return;
} }
@@ -97,6 +101,8 @@ 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!";
this->private_sendDiagEvent(DeviceController::State::E254); this->private_sendDiagEvent(DeviceController::State::E254);
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
return; return;
} }

View File

@@ -15,6 +15,9 @@ namespace nsDeviceControllerInterface {
enum class TICKET_VARIANT : quint8; enum class TICKET_VARIANT : quint8;
enum class COIN_PROCESSOR : quint8; enum class COIN_PROCESSOR : quint8;
enum class BILL_ACCEPTOR : quint8; enum class BILL_ACCEPTOR : quint8;
enum class SERVICE_TEXT : quint16;
} }
@@ -146,6 +149,11 @@ signals:
*/ */
void requestModeSERVICE(); void requestModeSERVICE();
/**
* emitted e.g. if vault door is opened
*/
void requestModeACCOUNT();
/** /**
* emitted e.g. if doors are closed * emitted e.g. if doors are closed
*/ */
@@ -162,7 +170,10 @@ signals:
void requestAccountResponse(const QHash<QString, QVariant> & accountData); void requestAccountResponse(const QHash<QString, QVariant> & accountData);
/**
* show text messages in service mode
*/
void showServiceText(nsDeviceControllerInterface::SERVICE_TEXT serviceText, const QString & text);
/** /**
@@ -182,7 +193,7 @@ signals:
Q_DECLARE_INTERFACE(DeviceControllerInterface, Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.0.3") "eu.atb.ptu.plugin.DeviceControllerInterface/1.1.1")
namespace nsDeviceControllerInterface { namespace nsDeviceControllerInterface {
@@ -226,6 +237,14 @@ namespace nsDeviceControllerInterface {
YES, YES,
NO NO
}; };
enum class SERVICE_TEXT : quint16 {
SERVICE_DOOR_OPENED,
VAULT_DOOR_OPENED,
COIN_BOX_REMOVED,
COIN_BOX_INSERTED
/* t.b.d. */
};
} }
#endif // DEVICECONTROLLERINTERFACE_H #endif // DEVICECONTROLLERINTERFACE_H

View File

@@ -39,13 +39,36 @@ uint32_t CashUtils::getAmountOfInsertedCoins(hwinf* hw)
uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw) uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw)
{ {
uint32_t result = 0; uint32_t result = 0;
uint8_t numberOfInsertedNotes;
uint16_t values[MAX_NOTES]; uint16_t beforeArray = 0;
hw->bna_getCurrentNotes(0, values); uint16_t currentNotes[4];
uint16_t afterArray = 0;
numberOfInsertedNotes = hw->bna_getCurrentNotes(0, currentNotes);
for (int i = 0; i < MAX_COINS; i++) { if ( (beforeArray != 0) || (afterArray != 0) ) {
result += values[i]; 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; return result;
} }