Diag: first working version to detect some system errors

Drawbacks:
 - has to be called extra, no events or signals
 - lot of integer result values (where are they documented? Mapping?)
This commit is contained in:
Siegfried Siegert 2023-06-22 14:52:34 +02:00
parent ba3eabec2c
commit 9cd10bfed8
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -61,25 +61,26 @@ void DeviceControllerDiag::private_startDiag()
result = hw->sys_areDCdataValid(); result = hw->sys_areDCdataValid();
if (result) { if (result) {
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem); QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
} }
else { else {
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is not valid"; qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid";
this->private_finishedDiag(0xfe);
// try it again // try it again
// -> this results in a seg. fault after ~10 loops! QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
//QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
} }
} }
void DeviceControllerDiag::sys_superviseSystem() void DeviceControllerDiag::sys_superviseSystem()
{ // this function proofs if vending is possible depending of doors state { // this function proofs if vending is possible depending of doors state
struct T_dynamicCondition *dynMaCond=0; struct T_dynamicCondition dynMaCond;
struct T_moduleCondition *modCond=0; struct T_moduleCondition modCond;
qCritical() << " sys_superviseSystem()";
// check for DiagRequestTimeoutTimerTimeout: // check for DiagRequestTimeoutTimerTimeout:
if (this->flagInterruptDiag) { if (this->flagInterruptDiag) {
@ -97,34 +98,40 @@ void DeviceControllerDiag::sys_superviseSystem()
} }
// jetzt sind die DC-Daten aktuell, also reinholen: // jetzt sind die DC-Daten aktuell, also reinholen:
hw->sys_getDynMachineConditions(dynMaCond); hw->sys_getDynMachineConditions(&dynMaCond);
hw->sys_getDeviceConditions(modCond); hw->sys_getDeviceConditions(&modCond);
if (!modCond->allModulesChecked) qCritical() << "DeviceControllerDiag::sys_superviseSystem() get condition data";
if (!modCond.allModulesChecked)
{ {
// noch keine Testergebnisse // noch keine Testergebnisse
if (dynMaCond->startupTestIsRunning) { if (dynMaCond.startupTestIsRunning) {
// TODO? // TODO?
} }
qCritical() << " allModulesChecked is false --> call again";
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem); QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
return; return;
} }
// all doors: 99: undefined 0:closed 1:open // all doors: 99: undefined 0:closed 1:open
if (dynMaCond->lowerDoor || dynMaCond->upperDoor) { if (dynMaCond.lowerDoor || dynMaCond.upperDoor) {
// Service or battery door is open, goto INTRUSION MODE // Service or battery door is open, goto INTRUSION MODE
qCritical() << "DeviceControllerDiag::sys_superviseSystem() 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(0xFD); this->private_finishedDiag(0xFD);
return; return;
} }
if (dynMaCond->middleDoor) { if (dynMaCond.middleDoor) {
// vault door is open, goto INTRUSION MODE // vault door is open, goto INTRUSION MODE
qCritical() << "DeviceControllerDiag::sys_superviseSystem() vault door is open, goto INTRUSION MODE"; qCritical() << "DeviceControllerDiag::sys_superviseSystem() vault door is open, goto INTRUSION MODE";
this->private_finishedDiag(0xFE); this->private_finishedDiag(0xFC);
return; return;
} }
qCritical() << " --> call sub_componentAssessment()";
uint8_t proposedError = sub_componentAssessment(); uint8_t proposedError = sub_componentAssessment();
if (proposedError) { if (proposedError) {
// All doors are closed but errors found, goto OOO MODE (out-of-order) // All doors are closed but errors found, goto OOO MODE (out-of-order)
@ -145,73 +152,75 @@ uint8_t DeviceControllerDiag::sub_componentAssessment()
// this function decides if vending mode is possible, independant from door // this function decides if vending mode is possible, independant from door
// return >0 in case of error // return >0 in case of error
struct T_moduleCondition *modCond=0; struct T_moduleCondition modCond;
hw->sys_getDeviceConditions(modCond); hw->sys_getDeviceConditions(&modCond);
struct T_dynamicCondition *dynMaCond=0; struct T_dynamicCondition dynMaCond;
hw->sys_getDynMachineConditions(dynMaCond); hw->sys_getDynMachineConditions(&dynMaCond);
struct T_devices *devPara=0; struct T_devices devPara;
if (modCond->rtc>=200) hw->sys_restoreDeviceParameter(&devPara);
if (modCond.rtc>=200)
return 1; return 1;
if (modCond->printer==200 || modCond->printer==201) // 200: not connected 201: printer-HW-error 202: no paper if (modCond.printer==200 || modCond.printer==201) // 200: not connected 201: printer-HW-error 202: no paper
return 2; return 2;
if (modCond->printer==202) if (modCond.printer==202)
return 3; return 3;
if (modCond->coinBlocker>=200) if (modCond.coinBlocker>=200)
return 4; return 4;
if (modCond->mdbBus>=200) if (modCond.mdbBus>=200)
return 5; return 5;
if (modCond->intEe>=200) if (modCond.intEe>=200)
return 6; return 6;
if (devPara->kindOfCoinChecker==1 || devPara->kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW) if (devPara.kindOfCoinChecker==1 || devPara.kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW)
{ {
if (modCond->coinChecker>=200 || modCond->coinEscrow>=200) if (modCond.coinChecker>=200 || modCond.coinEscrow>=200)
{ {
// Fehler Münzver. // Fehler Münzver.
return 7; return 7;
} }
if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok if (modCond.coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{ {
return 8; return 8;
} }
} else } else
if (devPara->kindOfCoinChecker==3) if (devPara.kindOfCoinChecker==3)
{ {
if (modCond->changer>=200) if (modCond.changer>=200)
{ {
// Fehler Münzver. // Fehler Münzver.
return 7; return 7;
} }
if (modCond->coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok if (modCond.coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
{ {
return 8; return 8;
} }
} }
if ( modCond->billReader>=200 && devPara->BillAcceptor>0) if ( modCond.billReader>=200 && devPara.BillAcceptor>0)
{ {
// Fehler BNA // Fehler BNA
return 9; return 9;
} }
if (dynMaCond->onAlarm>0) if (dynMaCond.onAlarm>0)
return 10; return 10;
if (dynMaCond->modeAbrech>0) if (dynMaCond.modeAbrech>0)
return 11; return 11;
if (dynMaCond->nowCardTest>0) if (dynMaCond.nowCardTest>0)
return 12; return 12;
if (dynMaCond->startupTestIsRunning>0) if (dynMaCond.startupTestIsRunning>0)
return 13; return 13;
if (modCond->voltage>=200) if (modCond.voltage>=200)
return 14; return 14;
if (modCond->temper>=200) if (modCond.temper>=200)
return 15; return 15;
return 0; return 0;