Compare commits

...

10 Commits
2.2.2 ... 2.2.7

5 changed files with 83 additions and 16 deletions

View File

@@ -82,6 +82,8 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, con
this->diag = new DeviceControllerDiag(this->persistentData, this); this->diag = new DeviceControllerDiag(this->persistentData, this);
connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage); connect(this->diag, &DeviceControllerDiag::newVoltage, this, &ATBDeviceControllerPlugin::onNewVoltage);
int diagTimeout = settings.value("ATBDeviceControllerPlugin/diagTimeout", "45").toInt();
this->diag->setTimeout(diagTimeout);
// currentSelectedTicketType - number of used "Kombiticket" (deprecated) use TICKET_VARIANT in future // currentSelectedTicketType - number of used "Kombiticket" (deprecated) use TICKET_VARIANT in future
this->currentSelectedTicketType = 0; this->currentSelectedTicketType = 0;
@@ -540,6 +542,8 @@ void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
{ {
qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()"; qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
this->diag->diagReInit();
QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE())); QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE()));
this->dbus->finishedBackgroundTask("DOOR_OPEN"); this->dbus->finishedBackgroundTask("DOOR_OPEN");
@@ -654,6 +658,7 @@ void ATBDeviceControllerPlugin::requestPrintReceipt(const QString & printingStri
hw->prn_switchPower(true); hw->prn_switchPower(true);
hw->prn_setFonts(8,12,0,0); hw->prn_setFonts(8,12,0,0);
hw->prn_sendText(&ba); hw->prn_sendText(&ba);
this->printResultCheckCounter = 0;
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt())); QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingReceipt()));
//QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } ); //QTimer::singleShot(2000, this, [this](){ hw->prn_cut(3); } );
@@ -702,7 +707,8 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingReceipt()
void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant> & printingData) void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant> & printingData)
{ {
struct T_dynDat *dynTicketData = new T_dynDat; struct T_dynDat dynamicTicketData;
struct T_dynDat *dynTicketData = &dynamicTicketData;
memset(dynTicketData, 0, sizeof(*dynTicketData)); memset(dynTicketData, 0, sizeof(*dynTicketData));
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
@@ -843,6 +849,7 @@ void ATBDeviceControllerPlugin::onPrinterDataPrepared()
// note: calling prn_getPrintResult() immediately may result in wrong answer! // note: calling prn_getPrintResult() immediately may result in wrong answer!
// We have to wait "about some seconds" until calling this function! // We have to wait "about some seconds" until calling this function!
this->printResultCheckCounter = 0;
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingTicket())); QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrintingTicket()));
// old: use printer templates: // old: use printer templates:
@@ -866,8 +873,17 @@ void ATBDeviceControllerPlugin::onPrinterWaitForPrintingTicket()
this->onPrintFinishedERR(); this->onPrintFinishedERR();
break; break;
default: default:
qCritical() << "DC Error: wait for printing"; // result value is not defined (-> workaround for DC misbehaviour)
this->onPrintFinishedERR(); if (this->printResultCheckCounter < 10) {
this->printResultCheckCounter++;
qCritical() << "DC print result undefined: " << printerResult;
QTimer::singleShot(1000, this, SLOT(onPrinterWaitForPrintingTicket()));
}
else {
qCritical() << "DC Error: wait for printing";
this->onPrintFinishedERR();
}
break; break;
} }
@@ -895,6 +911,7 @@ void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
if (this->currentTicket->templateList()->isEmpty()) { if (this->currentTicket->templateList()->isEmpty()) {
// all templates are printed // all templates are printed
this->printResultCheckCounter = 0;
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingTicket())); QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrintingTicket()));
} }
else { else {
@@ -946,7 +963,8 @@ void ATBDeviceControllerPlugin::onPrinterPrepareDynTemplateData()
} }
void ATBDeviceControllerPlugin::prepareDynTemplateData() void ATBDeviceControllerPlugin::prepareDynTemplateData()
{ {
struct T_dynDat *dynTicketData = new T_dynDat; struct T_dynDat dynamicTicketData;
struct T_dynDat *dynTicketData = &dynamicTicketData;
memset(dynTicketData, 0, sizeof(*dynTicketData)); memset(dynTicketData, 0, sizeof(*dynTicketData));
// setup dynTicketData dependent on currentTicket // setup dynTicketData dependent on currentTicket
@@ -1504,7 +1522,7 @@ int ATBDeviceControllerPlugin::init_sc_dbus()
void ATBDeviceControllerPlugin::onWokeUp(uchar source) void ATBDeviceControllerPlugin::onWokeUp(uchar source)
{ {
if (source == 0x01) { if (source == 0x01 || source == 0xFE) {
// woke up from device controller // woke up from device controller
this->diag->diagRequest(); this->diag->diagRequest();
} }

View File

@@ -129,6 +129,9 @@ private:
// counts failed hw->log_chkIfVaultRecordAvailable() // counts failed hw->log_chkIfVaultRecordAvailable()
int accountCheckCounter; int accountCheckCounter;
// counts faild hw->prn-getPrintResult()
int printResultCheckCounter;
// dbus // dbus
int init_sc_dbus(); int init_sc_dbus();

View File

@@ -15,7 +15,7 @@ class ATBMachineEvent : public QEvent
public: public:
explicit ATBMachineEvent(const QString & id, explicit ATBMachineEvent(const QString & id,
const QString & deviceName, // PTU/PRINTER/DC/... const QString & deviceName, // PTU/PRINTER/DC/...
EVENT_CLASS eventClass, // reason of event: Error/Warning/Alarm EVENT_CLASS eventClass, // reason of event: Error/Warning/Alarm
const QString & name, // 'Event': "E001", "W003" const QString & name, // 'Event': "E001", "W003"
const int state, const int state,
const QString & parameter, const QString & parameter,

View File

@@ -5,6 +5,9 @@
#include <QUuid> #include <QUuid>
#include <QDebug> #include <QDebug>
#include "support/JSON.h"
DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *parent) DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *parent)
: QObject(parent) : QObject(parent)
, coinProcessorType(nsDeviceControllerInterface::COIN_PROCESSOR::ESCROW) , coinProcessorType(nsDeviceControllerInterface::COIN_PROCESSOR::ESCROW)
@@ -17,7 +20,7 @@ DeviceControllerDiag::DeviceControllerDiag(PersistentData *pData, QObject *paren
, pData(pData) , pData(pData)
{ {
diagRequestTimeoutTimer = new QTimer(this); diagRequestTimeoutTimer = new QTimer(this);
diagRequestTimeoutTimer->setInterval(1000*20); // 20s diagRequestTimeoutTimer->setInterval(1000*45);
diagRequestTimeoutTimer->setSingleShot(true); diagRequestTimeoutTimer->setSingleShot(true);
connect(diagRequestTimeoutTimer, &QTimer::timeout, this, &DeviceControllerDiag::onDiagRequestTimeoutTimerTimeout); connect(diagRequestTimeoutTimer, &QTimer::timeout, this, &DeviceControllerDiag::onDiagRequestTimeoutTimerTimeout);
} }
@@ -33,6 +36,17 @@ void DeviceControllerDiag::init(hwinf *hw, QObject* eventReceiver)
} }
void DeviceControllerDiag::diagReInit()
{
this->machineEventSet.clear();
this->_isErrorState = false;
}
void DeviceControllerDiag::setTimeout(int timeout)
{
this->diagRequestTimeoutTimer->setInterval(1000 * timeout);
}
void DeviceControllerDiag::diagRequest() void DeviceControllerDiag::diagRequest()
{ {
qCritical() << "DeviceControllerDiag::diagRequest()"; qCritical() << "DeviceControllerDiag::diagRequest()";
@@ -90,6 +104,14 @@ void DeviceControllerDiag::private_startDiag()
this->private_sendDiagEvent(DeviceController::State::E255); this->private_sendDiagEvent(DeviceController::State::E255);
this->isRequestRunning = false; this->isRequestRunning = false;
this->flagInterruptDiag = false; this->flagInterruptDiag = false;
// try it again, until success:
QTimer::singleShot(400, this, &DeviceControllerDiag::diagRequest);
/**
* But please note:
* - diag does currently not stop suspend (start a background task)
* - diag is called again in ModeOOO wokeup()
*/
return; return;
} }
@@ -244,7 +266,8 @@ void DeviceControllerDiag::sub_componentAssessment()
} }
if (modCond.coinEscrow>=200) { if (modCond.coinEscrow>=200) {
flag_sendOperate = false; flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E010); // coinEscrow>200 is considered a warning:
this->private_sendDiagEvent(DeviceController::State::W010);
} }
} }
// ----------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------
@@ -266,7 +289,8 @@ void DeviceControllerDiag::sub_componentAssessment()
{ {
if (modCond.coinEscrow>=200) { if (modCond.coinEscrow>=200) {
flag_sendOperate = false; flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E010); // coinEscrow>200 is considered a warning:
this->private_sendDiagEvent(DeviceController::State::W010);
} }
if (modCond.coinSafe==201) { // full if (modCond.coinSafe==201) { // full
flag_sendOperate = false; flag_sendOperate = false;
@@ -338,7 +362,7 @@ void DeviceControllerDiag::sub_componentAssessment()
} }
if (modCond.temper>=200) { if (modCond.temper>=200) {
flag_sendOperate = false; flag_sendOperate = false;
this->private_sendDiagEvent(DeviceController::State::E004); this->private_sendDiagEvent(DeviceController::State::W004);
} }
// check for warnings // check for warnings
@@ -449,6 +473,10 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
parameter = "coin escrow"; parameter = "coin escrow";
this->_isErrorState = true; this->_isErrorState = true;
break; break;
case DeviceController::State::W010: // coin escrow
eventClass = EVENT_CLASS::WARNING;
parameter = "coin escrow";
break;
case DeviceController::State::E011: // mem error int.ee. case DeviceController::State::E011: // mem error int.ee.
eventClass = EVENT_CLASS::ERROR; eventClass = EVENT_CLASS::ERROR;
parameter = "mem error int.ee."; parameter = "mem error int.ee.";
@@ -506,10 +534,8 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
parameter = "no valid data from DeviceController"; parameter = "no valid data from DeviceController";
break; break;
case DeviceController::State::E255: // no valid data from DeviceController case DeviceController::State::E255: // no valid data from DeviceController
eventClass = EVENT_CLASS::STATE; eventClass = EVENT_CLASS::ERROR;
parameter = ""; parameter = "no valid data from DeviceController";
qCritical() << " ... ignore " << QMetaEnum::fromType<DeviceController::State>().valueToKey(result);
return;
break; break;
case DeviceController::State::O000: // everything is fine case DeviceController::State::O000: // everything is fine
this->machineEventSet.clear(); this->machineEventSet.clear();
@@ -545,6 +571,16 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
this->lastState = result; this->lastState = result;
/**
* Variant: send 'parameter' as JSON:
*
JSON::setPrettySerialize(false);
JSON::JsonObject json = JSON::objectBuilder()
->set("description", parameter)
->create();
QString parameterJsonString = JSON::serialize(json);
*/
ATBMachineEvent *machineEvent = new ATBMachineEvent( ATBMachineEvent *machineEvent = new ATBMachineEvent(
eventId, eventId,
"DC", "DC",
@@ -555,8 +591,6 @@ void DeviceControllerDiag::private_sendDiagEvent(DeviceController::State result)
"" // second level info "" // second level info
); );
//emit diagResponse(machineEvent);
QCoreApplication::postEvent(eventReceiver, machineEvent); QCoreApplication::postEvent(eventReceiver, machineEvent);
} }

View File

@@ -29,6 +29,7 @@ namespace DeviceController {
E008, E008,
E009, E009,
E010, E010,
W010, // Coin Escrow
E011, E011,
E018, E018,
@@ -79,9 +80,20 @@ public:
bool isOperatingState(); bool isOperatingState();
QSet<DeviceController::State> getCurrentMachineState(); QSet<DeviceController::State> getCurrentMachineState();
void setTimeout(int timeout);
public slots: public slots:
/**
* start diag request
*/
void diagRequest(); void diagRequest();
/**
* reset / re-init diag request.
* Called e.g. when doors are closed.
*/
void diagReInit();
signals: signals:
void diagResponse(ATBMachineEvent* machineEvent); void diagResponse(ATBMachineEvent* machineEvent);