Rework machine diag:

- allways check for whole system state (all errors / warnings)
   -> e.g. an error does not hide an other error or warning
 - send machine event only once
 - store sent events in a QSet-container
 - clear this container if no error / warning is detected

Note: there is currently no message for releasing a certain single error
/ warning. So it is no worth in removing a single entry in
QSet-container. This is a task for later program versions.
This commit is contained in:
Siegfried Siegert 2023-07-26 18:11:41 +02:00
parent df3a83521f
commit 0fd20d1dc4
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03
2 changed files with 128 additions and 90 deletions

View File

@ -54,7 +54,7 @@ void DeviceControllerDiag::private_startDiag()
// check for DiagRequestTimeoutTimerTimeout:
if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
this->private_finishedDiag(DeviceController::State::E255);
this->private_sendDiagEvent(DeviceController::State::E255);
return;
}
@ -86,7 +86,7 @@ void DeviceControllerDiag::sys_superviseSystem()
// check for DiagRequestTimeoutTimerTimeout:
if (this->flagInterruptDiag) {
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
this->private_finishedDiag(DeviceController::State::E255);
this->private_sendDiagEvent(DeviceController::State::E255);
return;
}
@ -94,7 +94,7 @@ void DeviceControllerDiag::sys_superviseSystem()
{
// es gibt keinerlei gültige Daten vom DC
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
this->private_finishedDiag(DeviceController::State::E254);
this->private_sendDiagEvent(DeviceController::State::E254);
return;
}
@ -121,29 +121,26 @@ void DeviceControllerDiag::sys_superviseSystem()
if (dynMaCond.lowerDoor || dynMaCond.upperDoor) {
// Service or battery door is open, goto INTRUSION MODE
qCritical() << "DeviceControllerDiag::sys_superviseSystem() Service or battery door is open, goto INTRUSION MODE";
this->private_finishedDiag(DeviceController::State::E253);
this->private_sendDiagEvent(DeviceController::State::E253);
return;
}
if (dynMaCond.middleDoor) {
// vault door is open, goto INTRUSION MODE
qCritical() << "DeviceControllerDiag::sys_superviseSystem() vault door is open, goto INTRUSION MODE";
this->private_finishedDiag(DeviceController::State::E252);
this->private_sendDiagEvent(DeviceController::State::E252);
return;
}
qCritical() << " --> call sub_componentAssessment()";
DeviceController::State proposedError = sub_componentAssessment();
this->private_finishedDiag(proposedError);
sub_componentAssessment();
}
DeviceController::State DeviceControllerDiag::sub_componentAssessment()
void DeviceControllerDiag::sub_componentAssessment()
{
// this function decides if vending mode is possible, independant from door
// return >0 in case of error
bool flag_sendOperate = true;
struct T_moduleCondition modCond;
hw->sys_getDeviceConditions(&modCond);
@ -160,72 +157,90 @@ DeviceController::State DeviceControllerDiag::sub_componentAssessment()
emit newVoltage(voltage);
// check for alarm:
if (dynMaCond.onAlarm>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::A000);
}
// check for invalid states:
if (modCond.rtc>=200)
return DeviceController::State::E002;
if (modCond.printer==200 || modCond.printer==201) // 200: not connected 201: printer-HW-error 202: no paper
return DeviceController::State::E020;
if (modCond.printer==202)
return DeviceController::State::E018;
if (modCond.rtc>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(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);
}
if (modCond.printer==202) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E018);
}
if (modCond.coinBlocker>=200)
return DeviceController::State::E025;
if (modCond.mdbBus>=200)
return DeviceController::State::E034;
if (modCond.intEe>=200)
return DeviceController::State::E011;
if (modCond.coinBlocker>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E025);
}
if (modCond.mdbBus>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E034);
}
if (modCond.intEe>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E011);
}
// 2023-07-26: workaround for 00281/Szeged --------------------------------------------------------------
// because we need certain errors and we do get for 'kindOfCoinChecker' -> 16 !
qCritical() << "-----------diag: kindOfCoinChecker = " << devPara.kindOfCoinChecker;
qCritical() << " modCond.coinSafe = " << modCond.coinSafe;
if (devPara.kindOfCoinChecker > 0) {
if (modCond.coinSafe==201) // full
{
return DeviceController::State::E007;
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe==200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{
return DeviceController::State::E009;
if (modCond.coinSafe==200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
}
if (modCond.coinEscrow>=200)
{
return DeviceController::State::E010;
if (modCond.coinEscrow>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E010);
}
}
// -----------------------------------------------------------------------------------------------
if (devPara.kindOfCoinChecker==1 || devPara.kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW)
{
if (modCond.coinEscrow>=200)
{
return DeviceController::State::E010;
if (modCond.coinEscrow>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E010);
}
if (modCond.coinSafe==201) // full
{
return DeviceController::State::E007;
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe==200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{
return DeviceController::State::E009;
if (modCond.coinSafe==200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
}
} else
if (devPara.kindOfCoinChecker==3)
{
if (modCond.changer>=200)
{
if (modCond.changer>=200) {
// Fehler Münzver.
return DeviceController::State::E026;
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E026);
}
if (modCond.coinSafe==201) // full
{
return DeviceController::State::E007;
if (modCond.coinSafe==201) { // full
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E007);
}
if (modCond.coinSafe == 200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{
return DeviceController::State::E009;
if (modCond.coinSafe == 200) { // 200: kasse fehlt 201: voll 100:fast voll 1:ok
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E009);
}
}
@ -243,44 +258,56 @@ DeviceController::State DeviceControllerDiag::sub_componentAssessment()
}
*/
if (dynMaCond.onAlarm>0)
return DeviceController::State::A000;
if (dynMaCond.modeAbrech>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E011);
}
if (dynMaCond.modeAbrech>0)
return DeviceController::State::E011;
if (dynMaCond.nowCardTest>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E072);
}
if (dynMaCond.nowCardTest>0)
return DeviceController::State::E072;
if (dynMaCond.startupTestIsRunning>0) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E073);
}
if (dynMaCond.startupTestIsRunning>0)
return DeviceController::State::E073;
if (modCond.voltage>=200)
return DeviceController::State::E003;
if (modCond.temper>=200)
return DeviceController::State::E004;
if (modCond.voltage>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E003);
}
if (modCond.temper>=200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E004);
}
// check for warnings
if (modCond.printer>=100 && modCond.printer<200)
return DeviceController::State::W001;
if (modCond.coinSafe>=100 && modCond.coinSafe<200)
return DeviceController::State::W002;
if (modCond.voltage>=100 && modCond.voltage<200)
return DeviceController::State::W003;
if (modCond.temper>=100 && modCond.temper<200)
return DeviceController::State::W004;
if (modCond.printer>=100 && modCond.printer<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W001);
}
if (modCond.coinSafe>=100 && modCond.coinSafe<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W002);
}
if (modCond.voltage>=100 && modCond.voltage<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W003);
}
if (modCond.temper>=100 && modCond.temper<200) {
flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::W004);
}
return DeviceController::State::O000;
if (flag_sendOperate) {
this->private_sendDiagEvent(DeviceController::State::O000);
}
}
DeviceController::State DeviceControllerDiag::sys_getSystemErrors()
{
return this->sub_componentAssessment();
}
/**
* @brief DeviceControllerDiag::private_finishedDiag
* @brief DeviceControllerDiag::private_sendDiagEvent
* @param result - result value from 'sub_componentAssessment()',
* - 0x00 everything is fine
* - 0xFF on timer interrupt
@ -288,13 +315,13 @@ DeviceController::State DeviceControllerDiag::sys_getSystemErrors()
* - 0xFD Service or battery door is open
* - 0xFE vault door is open
*/
void DeviceControllerDiag::private_finishedDiag(DeviceController::State result)
void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
{
this->diagRequestTimeoutTimer->stop();
this->isRequestRunning = false;
this->flagInterruptDiag = false;
qCritical() << "DeviceControllerDiag::private_finishedDiag() result: " << result;
qCritical() << "DeviceControllerDiag::private_sendDiagEvent() result: " << result;
if (this->eventReceiver == nullptr) {
@ -302,6 +329,15 @@ void DeviceControllerDiag::private_finishedDiag(DeviceController::State result)
return;
}
if (machineEventSet.contains(result)) {
// do not send already sent events
qCritical() << " ... is in machineEventList";
return;
}
else {
machineEventSet.insert(result);
}
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
@ -380,14 +416,14 @@ void DeviceControllerDiag::private_finishedDiag(DeviceController::State result)
parameter = "startup-test is running";
break;
case DeviceController::State::E252: // oper door / lower door open
eventClass = EVENT_CLASS::STATE;
parameter = "oper door / lower door open";
break;
case DeviceController::State::E253: // cash box door open
case DeviceController::State::E252: // cash box door open
eventClass = EVENT_CLASS::STATE;
parameter = "cash box door open";
break;
case DeviceController::State::E253: // 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
eventClass = EVENT_CLASS::STATE;
parameter = "no valid data from DeviceController";
@ -399,6 +435,7 @@ void DeviceControllerDiag::private_finishedDiag(DeviceController::State result)
return;
break;
case DeviceController::State::O000: // everything is fine
this->machineEventSet.clear();
eventClass = EVENT_CLASS::OPERATE;
parameter = "";
qCritical() << " ... everything fine";

View File

@ -2,6 +2,7 @@
#define DEVICECONTROLLERDIAG_H
#include <QObject>
#include <QSet>
#include <QTimer>
#include "ATBMachineEvent.h"
@ -78,17 +79,17 @@ private:
QTimer *diagRequestTimeoutTimer;
//uint8_t sub_componentAssessment();
DeviceController::State sub_componentAssessment();
DeviceController::State sys_getSystemErrors();
void sub_componentAssessment(); // diag exit method
int lastVoltage;
QSet<DeviceController::State> machineEventSet;
private slots:
void onDiagRequestTimeoutTimerTimeout();
void private_startDiag(); // diag entry method
void private_finishedDiag(DeviceController::State result); // diag exit method
void private_sendDiagEvent(DeviceController::State result);
void sys_superviseSystem();