Diag: use enum for dc-state (including warnings)
This commit is contained in:
parent
2a5a318c1a
commit
34ec52250b
@ -1,6 +1,7 @@
|
|||||||
#include "DeviceControllerDiag.h"
|
#include "DeviceControllerDiag.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QMetaEnum>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ void DeviceControllerDiag::private_startDiag()
|
|||||||
// check for DiagRequestTimeoutTimerTimeout:
|
// check for DiagRequestTimeoutTimerTimeout:
|
||||||
if (this->flagInterruptDiag) {
|
if (this->flagInterruptDiag) {
|
||||||
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
|
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
|
||||||
this->private_finishedDiag(0xff);
|
this->private_finishedDiag(DeviceController::State::E255);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ void DeviceControllerDiag::sys_superviseSystem()
|
|||||||
// check for DiagRequestTimeoutTimerTimeout:
|
// check for DiagRequestTimeoutTimerTimeout:
|
||||||
if (this->flagInterruptDiag) {
|
if (this->flagInterruptDiag) {
|
||||||
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
|
||||||
this->private_finishedDiag(0xff);
|
this->private_finishedDiag(DeviceController::State::E255);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ 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_finishedDiag(0xfe);
|
this->private_finishedDiag(DeviceController::State::E254);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,34 +121,26 @@ void DeviceControllerDiag::sys_superviseSystem()
|
|||||||
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(DeviceController::State::E253);
|
||||||
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(0xFC);
|
this->private_finishedDiag(DeviceController::State::E252);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << " --> call sub_componentAssessment()";
|
qCritical() << " --> call sub_componentAssessment()";
|
||||||
|
|
||||||
uint8_t proposedError = sub_componentAssessment();
|
DeviceController::State proposedError = sub_componentAssessment();
|
||||||
if (proposedError) {
|
|
||||||
// All doors are closed but errors found, goto OOO MODE (out-of-order)
|
|
||||||
qCritical() << "DeviceControllerDiag::sys_superviseSystem() All doors are closed but errors found, goto OOO MODE (out-of-order)";
|
|
||||||
this->private_finishedDiag(proposedError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// everything fine
|
this->private_finishedDiag(proposedError);
|
||||||
qCritical() << "DeviceControllerDiag::sys_superviseSystem() everything fine";
|
|
||||||
this->private_finishedDiag(0x00);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t DeviceControllerDiag::sub_componentAssessment()
|
DeviceController::State 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
|
||||||
@ -171,29 +164,29 @@ uint8_t DeviceControllerDiag::sub_componentAssessment()
|
|||||||
// check for invalid states:
|
// check for invalid states:
|
||||||
|
|
||||||
if (modCond.rtc>=200)
|
if (modCond.rtc>=200)
|
||||||
return 1;
|
return DeviceController::State::E001;
|
||||||
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 DeviceController::State::E002;
|
||||||
if (modCond.printer==202)
|
if (modCond.printer==202)
|
||||||
return 3;
|
return DeviceController::State::E003;
|
||||||
|
|
||||||
if (modCond.coinBlocker>=200)
|
if (modCond.coinBlocker>=200)
|
||||||
return 4;
|
return DeviceController::State::E004;
|
||||||
if (modCond.mdbBus>=200)
|
if (modCond.mdbBus>=200)
|
||||||
return 5;
|
return DeviceController::State::E005;
|
||||||
if (modCond.intEe>=200)
|
if (modCond.intEe>=200)
|
||||||
return 6;
|
return DeviceController::State::E006;
|
||||||
|
|
||||||
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 DeviceController::State::E007;
|
||||||
}
|
}
|
||||||
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 DeviceController::State::E008;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
if (devPara.kindOfCoinChecker==3)
|
if (devPara.kindOfCoinChecker==3)
|
||||||
@ -201,42 +194,45 @@ uint8_t DeviceControllerDiag::sub_componentAssessment()
|
|||||||
if (modCond.changer>=200)
|
if (modCond.changer>=200)
|
||||||
{
|
{
|
||||||
// Fehler Münzver.
|
// Fehler Münzver.
|
||||||
return 7;
|
return DeviceController::State::E007;
|
||||||
}
|
}
|
||||||
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 DeviceController::State::E008;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( modCond.billReader>=200 && devPara.BillAcceptor>0)
|
if ( modCond.billReader>=200 && devPara.BillAcceptor>0)
|
||||||
{
|
{
|
||||||
// Fehler BNA
|
// Fehler BNA
|
||||||
return 9;
|
return DeviceController::State::E009;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dynMaCond.onAlarm>0)
|
if (dynMaCond.onAlarm>0)
|
||||||
return 10;
|
return DeviceController::State::E010;
|
||||||
|
|
||||||
if (dynMaCond.modeAbrech>0)
|
if (dynMaCond.modeAbrech>0)
|
||||||
return 11;
|
return DeviceController::State::E011;
|
||||||
|
|
||||||
if (dynMaCond.nowCardTest>0)
|
if (dynMaCond.nowCardTest>0)
|
||||||
return 12;
|
return DeviceController::State::E012;
|
||||||
|
|
||||||
if (dynMaCond.startupTestIsRunning>0)
|
if (dynMaCond.startupTestIsRunning>0)
|
||||||
return 13;
|
return DeviceController::State::E013;
|
||||||
|
|
||||||
if (modCond.voltage>=200)
|
if (modCond.voltage>=200)
|
||||||
return 14;
|
return DeviceController::State::E014;
|
||||||
if (modCond.temper>=200)
|
if (modCond.temper>=200)
|
||||||
return 15;
|
return DeviceController::State::E015;
|
||||||
|
|
||||||
return 0;
|
// check for warnings
|
||||||
|
|
||||||
|
|
||||||
|
return DeviceController::State::O000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t DeviceControllerDiag::sys_getSystemErrors()
|
DeviceController::State DeviceControllerDiag::sys_getSystemErrors()
|
||||||
{
|
{
|
||||||
// 0: everything fine 1..15: errors
|
// 0: everything fine 1..15: errors
|
||||||
/* 1: real time clock error
|
/* 1: real time clock error
|
||||||
@ -267,7 +263,7 @@ uint8_t DeviceControllerDiag::sys_getSystemErrors()
|
|||||||
* - 0xFD Service or battery door is open
|
* - 0xFD Service or battery door is open
|
||||||
* - 0xFE vault door is open
|
* - 0xFE vault door is open
|
||||||
*/
|
*/
|
||||||
void DeviceControllerDiag::private_finishedDiag(uint8_t result)
|
void DeviceControllerDiag::private_finishedDiag(DeviceController::State result)
|
||||||
{
|
{
|
||||||
this->diagRequestTimeoutTimer->stop();
|
this->diagRequestTimeoutTimer->stop();
|
||||||
this->isRequestRunning = false;
|
this->isRequestRunning = false;
|
||||||
@ -281,99 +277,114 @@ void DeviceControllerDiag::private_finishedDiag(uint8_t result)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result > 15 && result != 0xFE) return;
|
|
||||||
|
|
||||||
|
|
||||||
// Errors are in this range 1...15:
|
// Errors are in this range 1...15:
|
||||||
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
|
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
|
||||||
QString eventName;
|
|
||||||
|
QString eventName = QMetaEnum::fromType<DeviceController::State>().valueToKey(result);;
|
||||||
EVENT_CLASS eventClass = EVENT_CLASS::STATE;
|
EVENT_CLASS eventClass = EVENT_CLASS::STATE;
|
||||||
QString parameter;
|
QString parameter;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case 1: // real time clock error
|
case DeviceController::State::E001: // real time clock error
|
||||||
eventName = "E001";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "real time clock error";
|
parameter = "real time clock error";
|
||||||
break;
|
break;
|
||||||
case 2: // printer error
|
case DeviceController::State::E002: // printer error
|
||||||
eventName = "E002";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "printer error";
|
parameter = "printer error";
|
||||||
break;
|
break;
|
||||||
case 3: // no paper
|
case DeviceController::State::E003: // no paper
|
||||||
eventName = "E003";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "no paper";
|
parameter = "no paper";
|
||||||
break;
|
break;
|
||||||
case 4: // coin blocker
|
case DeviceController::State::E004: // coin blocker
|
||||||
eventName = "E004";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "coin blocker";
|
parameter = "coin blocker";
|
||||||
break;
|
break;
|
||||||
case 5: // mdb error
|
case DeviceController::State::E005: // mdb error
|
||||||
eventName = "E005";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "mdb error";
|
parameter = "mdb error";
|
||||||
break;
|
break;
|
||||||
case 6: // mem error int.ee.
|
case DeviceController::State::E006: // mem error int.ee.
|
||||||
eventName = "E006";
|
eventName = "E006";
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "mem error int.ee.";
|
parameter = "mem error int.ee.";
|
||||||
break;
|
break;
|
||||||
case 7: // error coin validator
|
case DeviceController::State::E007: // error coin validator
|
||||||
eventName = "E007";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "error coin validator";
|
parameter = "error coin validator";
|
||||||
break;
|
break;
|
||||||
case 8: // coin safe missed or full
|
case DeviceController::State::E008: // coin safe missed or full
|
||||||
eventName = "E008";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "coin safe missed or full";
|
parameter = "coin safe missed or full";
|
||||||
break;
|
break;
|
||||||
case 9: // bill acceptor error
|
case DeviceController::State::E009: // bill acceptor error
|
||||||
eventName = "E009";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "bill acceptor error";
|
parameter = "bill acceptor error";
|
||||||
break;
|
break;
|
||||||
case 10: // alarm / intrusion
|
case DeviceController::State::E010: // alarm / intrusion
|
||||||
eventName = "E010";
|
eventClass = EVENT_CLASS::ALARM;
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
|
||||||
parameter = "alarm / intrusion";
|
parameter = "alarm / intrusion";
|
||||||
break;
|
break;
|
||||||
case 11: // cash box change is ongoing
|
case DeviceController::State::E011: // cash box change is ongoing
|
||||||
eventName = "E011";
|
|
||||||
eventClass = EVENT_CLASS::STATE;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "cash box change is ongoing";
|
parameter = "cash box change is ongoing";
|
||||||
break;
|
break;
|
||||||
case 12: // card test running
|
case DeviceController::State::E012: // card test running
|
||||||
eventName = "E012";
|
|
||||||
eventClass = EVENT_CLASS::STATE;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "card test running";
|
parameter = "card test running";
|
||||||
break;
|
break;
|
||||||
case 13: // startup-test is running
|
case DeviceController::State::E013: // startup-test is running
|
||||||
eventName = "E013";
|
|
||||||
eventClass = EVENT_CLASS::STATE;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "startup-test is running";
|
parameter = "startup-test is running";
|
||||||
break;
|
break;
|
||||||
case 14: // voltage error
|
case DeviceController::State::E014: // voltage error
|
||||||
eventName = "E014";
|
|
||||||
eventClass = EVENT_CLASS::ERROR;
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
parameter = "voltage error";
|
parameter = "voltage error";
|
||||||
break;
|
break;
|
||||||
case 15: // temperature error
|
case DeviceController::State::E015: // temperature error
|
||||||
eventName = "E015";
|
|
||||||
eventClass = EVENT_CLASS::STATE;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "temperature error";
|
parameter = "temperature error";
|
||||||
break;
|
break;
|
||||||
case 0xFE: // no valid data from DeviceController
|
case DeviceController::State::E252: // oper door / lower door open
|
||||||
eventName = "E254";
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "oper door / lower door open";
|
||||||
|
break;
|
||||||
|
case DeviceController::State::E253: // cash box door open
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "cash box door open";
|
||||||
|
break;
|
||||||
|
case DeviceController::State::E254: // no valid data from DeviceController
|
||||||
eventClass = EVENT_CLASS::STATE;
|
eventClass = EVENT_CLASS::STATE;
|
||||||
parameter = "no valid data from DeviceController";
|
parameter = "no valid data from DeviceController";
|
||||||
break;
|
break;
|
||||||
case 0x00: // everything is fine
|
case DeviceController::State::E255: // no valid data from DeviceController
|
||||||
eventName = "O000";
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "";
|
||||||
|
qCritical() << " ... ignore " << QMetaEnum::fromType<DeviceController::State>().valueToKey(result);
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case DeviceController::State::O000: // everything is fine
|
||||||
eventClass = EVENT_CLASS::OPERATE;
|
eventClass = EVENT_CLASS::OPERATE;
|
||||||
parameter = "";
|
parameter = "";
|
||||||
|
qCritical() << " ... everything fine";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DeviceController::State::W001: // paper low
|
||||||
|
eventClass = EVENT_CLASS::WARNING;
|
||||||
|
parameter = "paper low";
|
||||||
|
break;
|
||||||
|
case DeviceController::State::W002: // cashbox almost full
|
||||||
|
eventClass = EVENT_CLASS::WARNING;
|
||||||
|
parameter = "cashbox almost full";
|
||||||
|
break;
|
||||||
|
case DeviceController::State::W003: // voltage low
|
||||||
|
eventClass = EVENT_CLASS::WARNING;
|
||||||
|
parameter = "voltage low";
|
||||||
|
break;
|
||||||
|
case DeviceController::State::W004: // temperatur warning
|
||||||
|
eventClass = EVENT_CLASS::WARNING;
|
||||||
|
parameter = "temperatur warning";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,3 +404,5 @@ void DeviceControllerDiag::private_finishedDiag(uint8_t result)
|
|||||||
QCoreApplication::postEvent(eventReceiver, machineEvent);
|
QCoreApplication::postEvent(eventReceiver, machineEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,42 @@
|
|||||||
#include "ATBMachineEvent.h"
|
#include "ATBMachineEvent.h"
|
||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
|
|
||||||
|
namespace DeviceController {
|
||||||
|
Q_NAMESPACE
|
||||||
|
|
||||||
|
enum State {
|
||||||
|
O000,
|
||||||
|
|
||||||
|
E001,
|
||||||
|
E002,
|
||||||
|
E003,
|
||||||
|
E004,
|
||||||
|
E005,
|
||||||
|
E006,
|
||||||
|
E007,
|
||||||
|
E008,
|
||||||
|
E009,
|
||||||
|
E010,
|
||||||
|
E011,
|
||||||
|
E012,
|
||||||
|
E013,
|
||||||
|
E014,
|
||||||
|
E015,
|
||||||
|
|
||||||
|
E252,
|
||||||
|
E253,
|
||||||
|
E254,
|
||||||
|
E255,
|
||||||
|
|
||||||
|
W001,
|
||||||
|
W002,
|
||||||
|
W003,
|
||||||
|
W004
|
||||||
|
};
|
||||||
|
Q_ENUM_NS(State)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class DeviceControllerDiag : public QObject
|
class DeviceControllerDiag : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -33,16 +69,17 @@ private:
|
|||||||
|
|
||||||
QTimer *diagRequestTimeoutTimer;
|
QTimer *diagRequestTimeoutTimer;
|
||||||
|
|
||||||
uint8_t sub_componentAssessment();
|
//uint8_t sub_componentAssessment();
|
||||||
uint8_t sys_getSystemErrors();
|
DeviceController::State sub_componentAssessment();
|
||||||
|
DeviceController::State sys_getSystemErrors();
|
||||||
|
|
||||||
int lastVoltage;
|
int lastVoltage;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onDiagRequestTimeoutTimerTimeout();
|
void onDiagRequestTimeoutTimerTimeout();
|
||||||
|
|
||||||
void private_startDiag(); // diag entry method
|
void private_startDiag(); // diag entry method
|
||||||
void private_finishedDiag(uint8_t result); // diag exit method
|
void private_finishedDiag(DeviceController::State result); // diag exit method
|
||||||
|
|
||||||
void sys_superviseSystem();
|
void sys_superviseSystem();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user