Compare commits

..

8 Commits

Author SHA1 Message Date
eb33c4e920 Merge branch 'ImproveE255Handling' into pu/integration 2025-09-29 15:24:22 +02:00
26c2120743 Diag: improve E255 handling:
- allways run through finishDiag() method
 - on finishing diag: only remove elements in previousMachineEventSet if
data is valid
2025-09-24 11:25:54 +02:00
2452499073 Diag: call diagRequest() on wokeup from rtc 2025-09-03 13:42:30 +02:00
420ca94f41 Diag: call diagRequest() on wokeup from rtc 2025-09-03 13:33:56 +02:00
5fef45ba3e Merge branch 'pu/integration' into ImproveE255Handling 2025-07-30 16:55:51 +02:00
5c40e088aa Diag: restart carun is M0255 (was W255) 2025-07-29 15:46:26 +02:00
577411289e Trigger diagRequest() on MODE SERVICE => MODE OOO 2025-07-23 09:29:16 +02:00
cc27b982ff Add/Track: currentProgramMode 2025-07-23 09:28:53 +02:00
5 changed files with 77 additions and 76 deletions

View File

@@ -24,10 +24,10 @@
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
: isMaster(false) : currentProgramMode(PROGRAM_MODE::INIT)
, isMaster(false)
, pluginState(PLUGIN_STATE::NOT_INITIALIZED) , pluginState(PLUGIN_STATE::NOT_INITIALIZED)
, eventReceiver(nullptr) , eventReceiver(nullptr)
, latestAccountNumber(0)
{ {
this->setParent(parent); this->setParent(parent);
@@ -291,12 +291,14 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
hw->rtc_setDateTime(); hw->rtc_setDateTime();
hw->mdb_switchWake(0); // wakeup MDB components hw->mdb_switchWake(0); // wakeup MDB components
this->currentProgramMode = PROGRAM_MODE::SELL;
} }
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
this->currentProgramMode = PROGRAM_MODE::SERVICE;
} }
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE() void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
@@ -304,18 +306,19 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
this->diag->diagRequest(); this->diag->diagRequest();
hw->mdb_switchWake(1); hw->mdb_switchWake(1);
this->currentProgramMode = PROGRAM_MODE::IDLE;
} }
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO() void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
{ {
// trigger diagRequest on SERVICE -> IDLE
} if (this->currentProgramMode == PROGRAM_MODE::SERVICE) {
hw->dc_autoRequest(true);
void ATBDeviceControllerPlugin::requestDiag() this->diag->diagRequest();
{ hw->mdb_switchWake(1);
hw->dc_autoRequest(true); }
this->diag->diagRequest(); this->currentProgramMode = PROGRAM_MODE::OOO;
} }
@@ -484,13 +487,13 @@ void ATBDeviceControllerPlugin::private_startAccount()
qsort( backupedAccNumbers, nrOfVals, sizeof (uint16_t), Utils::compare ); qsort( backupedAccNumbers, nrOfVals, sizeof (uint16_t), Utils::compare );
this->latestAccountNumber = backupedAccNumbers[nrOfVals-1]; uint16_t latestAccountNumber = backupedAccNumbers[nrOfVals-1];
// DEBUG // DEBUG
qCritical() << " latestAccountNumber = " << this->latestAccountNumber; qCritical() << " latestAccountNumber = " << latestAccountNumber;
hw->log_selectVaultRecord(this->latestAccountNumber); hw->log_selectVaultRecord(latestAccountNumber);
this->accountCheckCounter = 0; this->accountCheckCounter = 0;
QTimer::singleShot(500, this, SLOT(private_checkAccountData())); QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
@@ -513,25 +516,11 @@ void ATBDeviceControllerPlugin::private_checkAccountData()
// cannot get accountData within ~10*500ms // cannot get accountData within ~10*500ms
qCritical() << "checkAccountData() failed"; qCritical() << "checkAccountData() failed";
JSON::setPrettySerialize(false); // simulate:
JSON::JsonObject json = JSON::objectBuilder() this->private_getAccountData();
->set("Error", QString("check account data failed"))
->set("AccountNumber", this->latestAccountNumber)
->create();
QString parameterJsonString = JSON::serialize(json);
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8); // TODO: create and send an HealthEvent...
ATBMachineEvent *machineEvent = new ATBMachineEvent(
eventId, // id
"DC", // device name: PTU/PRINTER/DC/...
EVENT_CLASS::STATE, // reason of event: Error/Warning/Alarm
"M01000", // eventName
1, // state
parameterJsonString, // parameter
"ACCOUNT" // second level info
);
QCoreApplication::postEvent(this, machineEvent);
} }
} }
} }
@@ -548,14 +537,6 @@ void ATBDeviceControllerPlugin::private_getAccountData()
QHash<QString, QVariant> accountData; QHash<QString, QVariant> accountData;
if (this->latestAccountNumber != retVR.AccountingNumber) {
// this is the wrong account! -> read again
hw->log_selectVaultRecord(this->latestAccountNumber);
QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
return;
}
accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber)); accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber));
@@ -1928,8 +1909,17 @@ int ATBDeviceControllerPlugin::init_sc_dbus()
void ATBDeviceControllerPlugin::onWokeUp(uchar source) void ATBDeviceControllerPlugin::onWokeUp(uchar source)
{ {
if (source == 0x01 || source == 0xFE) { /* PTU5 wakeup sources:
// woke up from device controller * 0x01 - on wakeup from DeviceController
* 0x02 - on wakeup from WakeupButton
* 0x03 - on wakeup from ResetKey
* 0x04 - on wakeup from rtc
* 0xFE - signal emitted by timer (on mains powered machines)
* 0xFF - unknown wakeup source
*/
if (source == 0x01 || source == 0x03 || source == 0xFE) {
// woke up from device controller, rtc or timer
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
this->diag->diagRequest(); this->diag->diagRequest();
} }

View File

@@ -25,6 +25,16 @@ using namespace nsDeviceControllerInterface;
class QSettings; class QSettings;
enum class PROGRAM_MODE {
INIT,
IDLE,
SELL,
SERVICE,
OOO,
NOT_DEFINED
};
class ATBDeviceControllerPlugin : class ATBDeviceControllerPlugin :
public DeviceControllerInterface public DeviceControllerInterface
@@ -87,7 +97,7 @@ public slots:
void reboot(); void reboot();
void reset(); void reset();
void requestDiag();
signals: signals:
// public Signals are defined in interface // public Signals are defined in interface
@@ -100,6 +110,8 @@ private:
QString serialPortName; QString serialPortName;
PROGRAM_MODE currentProgramMode;
bool useDebug; bool useDebug;
bool isMaster; bool isMaster;
@@ -130,8 +142,6 @@ private:
// counts failed hw->log_chkIfVaultRecordAvailable() // counts failed hw->log_chkIfVaultRecordAvailable()
int accountCheckCounter; int accountCheckCounter;
uint16_t latestAccountNumber;
// counts faild hw->prn-getPrintResult() // counts faild hw->prn-getPrintResult()
int printResultCheckCounter; int printResultCheckCounter;

View File

@@ -113,8 +113,8 @@ void DeviceControllerDiag::private_startDiag()
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!"; qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255); DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
if (!this->previousMachineEventSet.contains(E255Event)) { if (!this->previousMachineEventSet.contains(E255Event)) {
machineEventSet.insert(E255Event); this->private_setDiagEvent(DeviceController::State::E255);
private_sendDiagEvent(E255Event, DeviceController::Action::SET); this->private_sendDiagEvent(E255Event, DeviceController::Action::SET);
} }
if (this->E255counter > 5) { if (this->E255counter > 5) {
this->restartCArun(); this->restartCArun();
@@ -132,9 +132,9 @@ void DeviceControllerDiag::private_startDiag()
* - diag is called again in ModeOOO wokeup() * - diag is called again in ModeOOO wokeup()
*/ */
} }
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false; this->private_finishDiag(false);
this->flagInterruptDiag = false;
return; return;
} }
@@ -144,7 +144,7 @@ void DeviceControllerDiag::private_startDiag()
if (result) { if (result) {
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid"; qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
this->machineEventSet.remove(DCMachineEvent(DeviceController::State::E255)); this->machineEventSet.remove(DCMachineEvent(DeviceController::State::E255));
this->machineEventSet.remove(DCMachineEvent(DeviceController::State::W255)); this->machineEventSet.remove(DCMachineEvent(DeviceController::State::M0255));
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem); QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
} }
else { else {
@@ -178,15 +178,16 @@ void DeviceControllerDiag::sys_superviseSystem()
// send // send
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255); DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::E255);
if (!this->previousMachineEventSet.contains(E255Event)) { if (!this->previousMachineEventSet.contains(E255Event)) {
machineEventSet.insert(E255Event); this->private_setDiagEvent(DeviceController::State::E255);
private_sendDiagEvent(E255Event, DeviceController::Action::SET); this->private_sendDiagEvent(E255Event, DeviceController::Action::SET);
} }
if (this->E255counter > 5) { this->restartCArun(); } if (this->E255counter > 5) { this->restartCArun(); }
else { this->E255counter++; } else { this->E255counter++; }
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest); QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false; this->private_finishDiag(false);
this->flagInterruptDiag = false;
return; return;
} }
@@ -196,16 +197,14 @@ void DeviceControllerDiag::sys_superviseSystem()
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!"; qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
hw->dc_autoRequest(true); hw->dc_autoRequest(true);
DCMachineEvent E255Event = DCMachineEvent(DeviceController::State::M0254); DCMachineEvent M0254Event = DCMachineEvent(DeviceController::State::M0254);
previousMachineEventSet.insert(E255Event); this->private_setDiagEvent(DeviceController::State::M0254);
private_sendDiagEvent(E255Event, DeviceController::Action::SET); this->private_sendDiagEvent(M0254Event, DeviceController::Action::SET);
if (this->E255counter > 5) { this->restartCArun(); } if (this->E255counter > 5) { this->restartCArun(); }
else { this->E255counter++; } else { this->E255counter++; }
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest); QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
this->diagRequestTimeoutTimer->stop(); this->private_finishDiag(false);
this->isRequestRunning = false;
this->flagInterruptDiag = false;
return; return;
} }
@@ -477,7 +476,7 @@ void DeviceControllerDiag::sub_componentAssessment()
// finish diag // finish diag
this->private_finishDiag(); this->private_finishDiag(true);
} }
/** /**
@@ -486,14 +485,20 @@ void DeviceControllerDiag::sub_componentAssessment()
* Single point to finish a diag process: * Single point to finish a diag process:
* - * -
*/ */
void DeviceControllerDiag::private_finishDiag() void DeviceControllerDiag::private_finishDiag(bool dataValid)
{ {
this->diagRequestTimeoutTimer->stop(); this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false; this->isRequestRunning = false;
this->flagInterruptDiag = false; this->flagInterruptDiag = false;
this->previousMachineEventSet.unite(machineEventSet); // add new elements from machineEventSet // add new elements from machineEventSet
this->previousMachineEventSet.intersect(machineEventSet); // remove elements not in machineEventSet this->previousMachineEventSet.unite(machineEventSet);
if (dataValid) {
// remove elements not in machineEventSet
// ... only if data is valid
this->previousMachineEventSet.intersect(machineEventSet);
}
if (this->isDiagBackgroundTask) { if (this->isDiagBackgroundTask) {
this->isDiagBackgroundTask = false; this->isDiagBackgroundTask = false;
@@ -680,8 +685,8 @@ void DeviceControllerDiag::private_sendDiagEvent(DCMachineEvent result, DeviceCo
eventClass = EVENT_CLASS::WARNING; eventClass = EVENT_CLASS::WARNING;
parameter = "temperatur warning"; parameter = "temperatur warning";
break; break;
case DeviceController::State::W255: // restart carun case DeviceController::State::M0255: // restart carun
eventClass = EVENT_CLASS::WARNING; eventClass = EVENT_CLASS::STATE;
parameter = "restart carun"; parameter = "restart carun";
break; break;
} }
@@ -722,10 +727,10 @@ void DeviceControllerDiag::restartCArun()
this->E255counter = 0; this->E255counter = 0;
DCMachineEvent W255Event = DCMachineEvent(DeviceController::State::W255); DCMachineEvent M0255Event = DCMachineEvent(DeviceController::State::M0255);
if (!this->previousMachineEventSet.contains(W255Event)) { if (!this->previousMachineEventSet.contains(M0255Event)) {
machineEventSet.insert(W255Event); machineEventSet.insert(M0255Event);
private_sendDiagEvent(W255Event, DeviceController::Action::SET); private_sendDiagEvent(M0255Event, DeviceController::Action::SET);
} }
QProcess::startDetached("/bin/systemctl", {"restart", "carun"}); QProcess::startDetached("/bin/systemctl", {"restart", "carun"});

View File

@@ -49,6 +49,7 @@ namespace DeviceController {
M0252, // cashbox door open M0252, // cashbox door open
M0253, // service or battery door is open M0253, // service or battery door is open
M0254, // no valid data from DC M0254, // no valid data from DC
M0255, // restart carun
E255, E255,
@@ -57,8 +58,6 @@ namespace DeviceController {
W003, W003,
W004, W004,
W255,
INITIAL_STATE INITIAL_STATE
}; };
Q_ENUM_NS(State) Q_ENUM_NS(State)
@@ -171,7 +170,7 @@ private slots:
void private_setDiagEvent(DeviceController::State result); void private_setDiagEvent(DeviceController::State result);
void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action); void private_sendDiagEvent(DCMachineEvent result, DeviceController::Action action);
void private_finishDiag(); void private_finishDiag(bool dataValid = false);
void sys_superviseSystem(); void sys_superviseSystem();

View File

@@ -104,9 +104,6 @@ public slots:
virtual void reboot() = 0; virtual void reboot() = 0;
virtual void reset() = 0; virtual void reset() = 0;
virtual void requestDiag() = 0;
signals: signals:
void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState, void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
@@ -216,7 +213,7 @@ signals:
Q_DECLARE_INTERFACE(DeviceControllerInterface, Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.2.2") "eu.atb.ptu.plugin.DeviceControllerInterface/1.2.1")
namespace nsDeviceControllerInterface { namespace nsDeviceControllerInterface {