Compare commits

...

7 Commits

Author SHA1 Message Date
e703befb2f Merge branch 'improveTicketPrint' into pu/integration 2025-05-13 13:46:48 +02:00
83bcdcb47e Print: improve printing receipt:
- call prn_cut() 200ms after prn_switchPower(true)
 - make an "emergency cut" on error
 - improve log output on error
2025-05-13 13:44:12 +02:00
70e6ec293d Merge branch 'improveDeviceControllerDiag' into pu/integration 2025-05-08 10:12:54 +02:00
3601f2d868 Merge branch 'improveTICKET_VARIANTS' into pu/integration 2025-05-08 10:12:46 +02:00
0876fa229e Diag: do not send reset errors/warnings ...
... this is a proposal for future.
2025-05-08 10:11:19 +02:00
1c13d92171 New proposal for DeviceControllerDiag:
Manage two sets of errors and compare to previous run.
2025-04-14 08:18:11 +02:00
10b0e494b2 requestPrintTicket: switch to legacy, if no template list is configured 2025-04-08 08:58:29 +02:00
3 changed files with 95 additions and 49 deletions

View File

@@ -733,6 +733,15 @@ void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::
{
QList<quint8> templateList = this->ticketTemplateList[ticketVariant];
if (templateList.isEmpty()) {
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
qCritical() << " TICKET_VARIANT: " << ticketVariant;
qCritical() << " -> templateList is empty!";
qCritical() << " -> switching to legacy interface";
this->requestPrintTicket(printingData);
return;
}
// DEBUG
qCritical() << "------------------------------------------------------------------------";
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
@@ -797,7 +806,7 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri
this->printResultCheckCounter = 0;
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt()));
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingReceipt()));
//QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } );
}
@@ -818,7 +827,7 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt()
"",
"");
hw->prn_switchPower(true);
hw->prn_cut(3);
QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } );
break;
case 2: // printing finished, Error
qCritical() << "DC Error: wait for printing receipt";
@@ -828,15 +837,21 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt()
emit this->printReceiptFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
this->errorCode,
this->errorDescription);
hw->prn_switchPower(true);
QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } );
break;
default:
qCritical() << "DC Error: wait for printing receipt";
qCritical() << "DC Error: wait for printing receipt: printerResult = " << printerResult;
this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API
this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API
this->errorDescription = "Printer error(" + QString(printerResult) + ")";
emit this->printReceiptFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
this->errorCode,
this->errorDescription);
// do an emergency cut
hw->prn_switchPower(true);
QTimer::singleShot(200, this, [this](){ hw->prn_cut(3); } );
break;
}

View File

@@ -104,7 +104,7 @@ void DeviceControllerDiag::private_startDiag()
// check for DiagRequestTimeoutTimerTimeout:
if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
this->private_sendDiagEvent(DeviceController::State::E255);
this->private_setDiagEvent(DeviceController::State::E255);
this->isRequestRunning = false;
this->flagInterruptDiag = false;
if (this->E255counter > 5) {
@@ -153,7 +153,7 @@ void DeviceControllerDiag::sys_superviseSystem()
// check for DiagRequestTimeoutTimerTimeout:
if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
this->private_sendDiagEvent(DeviceController::State::E255);
this->private_setDiagEvent(DeviceController::State::E255);
this->flagInterruptDiag = false;
this->isRequestRunning = false;
if (this->E255counter > 5) { this->restartCArun(); }
@@ -166,7 +166,7 @@ void DeviceControllerDiag::sys_superviseSystem()
// es gibt keinerlei gültige Daten vom DC
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
hw->dc_autoRequest(true);
this->private_sendDiagEvent(DeviceController::State::M0254);
this->private_setDiagEvent(DeviceController::State::M0254);
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
if (this->E255counter > 5) { this->restartCArun(); }
@@ -223,7 +223,7 @@ void DeviceControllerDiag::sub_componentAssessment()
if (dynMaCond.onAlarm>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::A000);
this->private_setDiagEvent(DeviceController::State::A000);
}
// check for open doors
@@ -232,41 +232,41 @@ 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::M0253);
this->private_setDiagEvent(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::M0252);
this->private_setDiagEvent(DeviceController::State::M0252);
}
// check for invalid states:
if (modCond.rtc>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E002);
this->private_setDiagEvent(DeviceController::State::E002);
}
if (modCond.printer==200 || modCond.printer==201) { // 200: not connected 201: printer-HW-error 202: no paper
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E020);
this->private_setDiagEvent(DeviceController::State::E020);
}
if (modCond.printer==202) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E018);
this->private_setDiagEvent(DeviceController::State::E018);
}
if (modCond.coinBlocker>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E025);
this->private_setDiagEvent(DeviceController::State::E025);
}
if (modCond.mdbBus>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E034);
this->private_setDiagEvent(DeviceController::State::E034);
}
if (modCond.intEe>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E011);
this->private_setDiagEvent(DeviceController::State::E011);
}
// 2023-07-26: workaround for 00281/Szeged --------------------------------------------------------------
@@ -276,16 +276,16 @@ void DeviceControllerDiag::sub_componentAssessment()
if (devPara.kindOfCoinChecker > 0) {
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
this->private_setDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe==200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
this->private_setDiagEvent(DeviceController::State::E009);
}
if (modCond.coinEscrow>=200) {
flag_sendOperate = false;
// coinEscrow>200 is considered a warning:
this->private_sendDiagEvent(DeviceController::State::W010);
this->private_setDiagEvent(DeviceController::State::W010);
}
}
// -----------------------------------------------------------------------------------------------
@@ -308,15 +308,15 @@ void DeviceControllerDiag::sub_componentAssessment()
if (modCond.coinEscrow>=200) {
flag_sendOperate = false;
// coinEscrow>200 is considered a warning:
this->private_sendDiagEvent(DeviceController::State::W010);
this->private_setDiagEvent(DeviceController::State::W010);
}
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
this->private_setDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe==200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
this->private_setDiagEvent(DeviceController::State::E009);
}
} else
if (devPara.kindOfCoinChecker==3)
@@ -324,15 +324,15 @@ void DeviceControllerDiag::sub_componentAssessment()
if (modCond.changer>=200) {
// Fehler Münzver.
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E026);
this->private_setDiagEvent(DeviceController::State::E026);
}
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
this->private_setDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe == 200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
this->private_setDiagEvent(DeviceController::State::E009);
}
}
@@ -361,61 +361,86 @@ void DeviceControllerDiag::sub_componentAssessment()
if (dynMaCond.modeAbrech>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E011);
this->private_setDiagEvent(DeviceController::State::E011);
}
if (dynMaCond.nowCardTest>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::M0072);
this->private_setDiagEvent(DeviceController::State::M0072);
}
if (dynMaCond.startupTestIsRunning>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::M0073);
this->private_setDiagEvent(DeviceController::State::M0073);
}
if (modCond.voltage>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E003);
this->private_setDiagEvent(DeviceController::State::E003);
}
if (modCond.temper>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W004);
this->private_setDiagEvent(DeviceController::State::W004);
}
// check for warnings
if (modCond.printer>=100 && modCond.printer<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W001);
this->private_setDiagEvent(DeviceController::State::W001);
}
if (modCond.coinSafe>=100 && modCond.coinSafe<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W002);
this->private_setDiagEvent(DeviceController::State::W002);
}
if (modCond.voltage>=100 && modCond.voltage<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W003);
this->private_setDiagEvent(DeviceController::State::W003);
}
if (modCond.temper>=100 && modCond.temper<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W004);
this->private_setDiagEvent(DeviceController::State::W004);
}
if (flag_sendOperate) {
this->private_sendDiagEvent(DeviceController::State::O000);
this->private_setDiagEvent(DeviceController::State::O000);
}
// compare machineEventSets
// New events: present in current but not previous
QSet<DeviceController::State> newEvents = this->machineEventSet - this->previousMachineEventSet;
// Reset events: present in previous but not current
QSet<DeviceController::State> resetEvents = this->previousMachineEventSet - this->machineEventSet;
// Triggering Actions
// Iterate through the results
for (const DeviceController::State& event : newEvents) {
private_sendDiagEvent(event, DeviceController::Action::SET); // New event detected
}
// Proposal: send reset
/*
for (const DeviceController::State& event : resetEvents) {
private_sendDiagEvent(event, DeviceController::Action::RESET); // Event no longer present
}
*/
// finish diag
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
this->flagInterruptDiag = false;
this->previousMachineEventSet = machineEventSet;
this->machineEventSet.clear();
}
/**
* @brief DeviceControllerDiag::private_sendDiagEvent
* @brief DeviceControllerDiag::private_setDiagEvent
* @param result - result value from 'sub_componentAssessment()',
* - 0x00 everything is fine
* - 0xFF on timer interrupt
@@ -423,25 +448,21 @@ void DeviceControllerDiag::sub_componentAssessment()
* - 0xFD Service or battery door is open
* - 0xFE vault door is open
*/
void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
void DeviceControllerDiag::private_setDiagEvent(DeviceController::State result)
{
qCritical() << "DeviceControllerDiag::private_sendDiagEvent() result: " << result;
qCritical() << "DeviceControllerDiag::private_setDiagEvent() result: " << result;
if (this->eventReceiver == nullptr) {
qCritical() << "DeviceControllerDiag: no eventReceiver";
return;
}
if (machineEventSet.contains(result)) {
// do not send already sent events
qCritical() << " ... is in machineEventList";
return;
}
else {
machineEventSet.insert(result);
}
machineEventSet.insert(result);
}
void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result, DeviceController::Action action)
{
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
QString eventName = QMetaEnum::fromType<DeviceController::State>().valueToKey(result);;
@@ -608,7 +629,7 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
"DC",
eventClass,
eventName,
1, // eventState
action, // eventState
parameter,
"" // second level info
);
@@ -625,6 +646,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
void DeviceControllerDiag::restartCArun()
{
this->E255counter = 0;
this->private_sendDiagEvent(DeviceController::State::W255);
this->private_setDiagEvent(DeviceController::State::W255);
QProcess::startDetached("/bin/systemctl", {"restart", "carun"});
}

View File

@@ -61,6 +61,14 @@ namespace DeviceController {
INITIAL_STATE
};
Q_ENUM_NS(State)
enum Action {
SET = 1,
RESET = 0
};
Q_ENUM_NS(Action)
}
@@ -122,6 +130,7 @@ private:
DeviceController::State lastState;
QSet<DeviceController::State> machineEventSet;
QSet<DeviceController::State> previousMachineEventSet;
bool _isErrorState;
PersistentData* pData;
@@ -132,7 +141,8 @@ private slots:
void onDiagRequestTimeoutTimerTimeout();
void private_startDiag(); // diag entry method
void private_sendDiagEvent(DeviceController::State result);
void private_setDiagEvent(DeviceController::State result);
void private_sendDiagEvent(DeviceController::State result, DeviceController::Action action);
void sys_superviseSystem();