Compare commits
21 Commits
pu/account
...
szeged_rel
Author | SHA1 | Date | |
---|---|---|---|
2cd73aaa86
|
|||
37d45f3c69
|
|||
f76a30cb07
|
|||
2b6eecfed7
|
|||
7be678fbe0
|
|||
6e9b1018e5
|
|||
04e2da390c
|
|||
e367538fc4
|
|||
7d722e2b2c
|
|||
80112f23b4
|
|||
9cd10bfed8
|
|||
ba3eabec2c
|
|||
a4d74ed0f7
|
|||
4a7022fd00
|
|||
31f178b241
|
|||
6a19fd7608
|
|||
8fc88662d3
|
|||
29cee7fd1c
|
|||
b39bbcfad5
|
|||
7c3bc484af
|
|||
2b71705c81
|
@@ -71,14 +71,18 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
include/interfaces.h \
|
include/interfaces.h \
|
||||||
src/ATBAPP/ATBAPPplugin.h \
|
src/ATBAPP/ATBAPPplugin.h \
|
||||||
|
src/ATBAPP/DeviceControllerDiag.h \
|
||||||
src/ATBAPP/DeviceControllerInterface.h \
|
src/ATBAPP/DeviceControllerInterface.h \
|
||||||
src/ATBAPP/ATBHealthEvent.h \
|
src/ATBAPP/ATBHealthEvent.h \
|
||||||
|
src/ATBAPP/ATBMachineEvent.h \
|
||||||
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
||||||
src/ATBAPP/Utils.h
|
src/ATBAPP/Utils.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
src/ATBAPP/ATBHealthEvent.cpp \
|
src/ATBAPP/ATBHealthEvent.cpp \
|
||||||
|
src/ATBAPP/ATBMachineEvent.cpp \
|
||||||
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
||||||
|
src/ATBAPP/DeviceControllerDiag.cpp \
|
||||||
src/ATBAPP/Utils.cpp
|
src/ATBAPP/Utils.cpp
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
|
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
|
||||||
#include "src/ATBAPP/ATBHealthEvent.h"
|
#include "src/ATBAPP/ATBHealthEvent.h"
|
||||||
|
#include "src/ATBAPP/ATBMachineEvent.h"
|
||||||
#include "src/ATBAPP/Utils.h"
|
#include "src/ATBAPP/Utils.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -9,23 +10,25 @@
|
|||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
|
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent)
|
||||||
pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
: pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
||||||
|
, eventReceiver(nullptr)
|
||||||
{
|
{
|
||||||
|
this->setParent(parent);
|
||||||
|
|
||||||
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
|
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
|
||||||
|
|
||||||
if (!this->private_loadCashAgentLib("")) {
|
if (!this->private_loadCashAgentLib("")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()), Qt::QueuedConnection);
|
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()), Qt::QueuedConnection);
|
||||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection);
|
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection);
|
||||||
|
|
||||||
@@ -39,26 +42,29 @@ ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(
|
|||||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorVaultDoorOpened()), this, SLOT(onVaultDoorOpened()), Qt::QueuedConnection); // Screen?? with message
|
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorVaultDoorOpened()), this, SLOT(onVaultDoorOpened()), Qt::QueuedConnection); // Screen?? with message
|
||||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxRemoved()), this, SLOT(onCoinBoxRemoved()), Qt::QueuedConnection); // Create/Send Account
|
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxRemoved()), this, SLOT(onCoinBoxRemoved()), Qt::QueuedConnection); // Create/Send Account
|
||||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxInserted()), this, SLOT(onCoinBoxInserted()), Qt::QueuedConnection);
|
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxInserted()), this, SLOT(onCoinBoxInserted()), Qt::QueuedConnection);
|
||||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCBinAndAllDoorsClosed()), this, SLOT( ??? )), Qt::QueuedConnection);
|
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCBinAndAllDoorsClosed()), this, SLOT(onCBinAndAllDoorsClosed()), Qt::QueuedConnection);
|
||||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorAllDoorsClosed()), this, SLOT(onAllDoorsClosed()), Qt::QueuedConnection); // check for errors, switch to mode IDLE
|
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorAllDoorsClosed()), this, SLOT(onAllDoorsClosed()), Qt::QueuedConnection); // check for errors, switch to mode IDLE
|
||||||
|
|
||||||
|
|
||||||
|
this->diag = new DeviceControllerDiag(this);
|
||||||
|
|
||||||
|
|
||||||
this->currentSelectedTicketType = 0;
|
this->currentSelectedTicketType = 0;
|
||||||
this->currentCashState = CASH_STATE::CACHE_EMPTY;
|
this->currentCashState = CASH_STATE::CACHE_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
|
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
|
||||||
|
|
||||||
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceiver, const QSettings & settings)
|
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *eventReceiver, const QSettings & settings)
|
||||||
{
|
{
|
||||||
this->healthEventReceiver = healthEventReceiver;
|
this->eventReceiver = eventReceiver;
|
||||||
|
|
||||||
// read variables from setting
|
// read variables from setting
|
||||||
QString serialPort = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
|
this->serialPortName = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
|
||||||
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
|
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
|
||||||
|
|
||||||
// open serial port
|
// open serial port
|
||||||
hw->dc_openSerial(5, "115200", serialPort, 1);
|
hw->dc_openSerial(5, "115200", this->serialPortName, 1);
|
||||||
|
|
||||||
hw->dc_autoRequest(true);
|
hw->dc_autoRequest(true);
|
||||||
|
|
||||||
@@ -71,7 +77,7 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive
|
|||||||
// text encoding for printer
|
// text encoding for printer
|
||||||
this->codec = QTextCodec::codecForName(printerEncoding);
|
this->codec = QTextCodec::codecForName(printerEncoding);
|
||||||
|
|
||||||
|
this->diag->init(this->hw, this->eventReceiver);
|
||||||
|
|
||||||
this->pluginState = PLUGIN_STATE::INITIALIZED;
|
this->pluginState = PLUGIN_STATE::INITIALIZED;
|
||||||
|
|
||||||
@@ -79,6 +85,38 @@ PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceive
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::startPhysicalLayer()
|
||||||
|
{
|
||||||
|
if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED)
|
||||||
|
{
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open serial port
|
||||||
|
hw->dc_openSerial(5, "115200", this->serialPortName, 1);
|
||||||
|
|
||||||
|
hw->dc_autoRequest(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::stopPhysicalLayer()
|
||||||
|
{
|
||||||
|
if (this->pluginState == PLUGIN_STATE::NOT_INITIALIZED)
|
||||||
|
{
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::startPhysicalLayer(): plugin is not initialized";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hw->dc_autoRequest(false);
|
||||||
|
|
||||||
|
hw->dc_closeSerial();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle Mode-Changes --------------------------------------------------------
|
// Handle Mode-Changes --------------------------------------------------------
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
|
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
|
||||||
@@ -94,6 +132,9 @@ void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
|
|||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
||||||
{
|
{
|
||||||
//hw->dc_autoRequest(false); // <-- TODO: ???
|
//hw->dc_autoRequest(false); // <-- TODO: ???
|
||||||
|
|
||||||
|
this->diag->diagRequest();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
|
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
|
||||||
@@ -119,7 +160,7 @@ void ATBDeviceControllerPlugin::requestStopCashInput()
|
|||||||
hw->cash_stopPayment();
|
hw->cash_stopPayment();
|
||||||
|
|
||||||
// we need new cash value in application...
|
// we need new cash value in application...
|
||||||
QTimer::singleShot(500, this, SLOT(onCashPayStopedSuccess()));
|
QTimer::singleShot(2500, this, SLOT(onCashPayStopedSuccess()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::cashCollect()
|
void ATBDeviceControllerPlugin::cashCollect()
|
||||||
@@ -190,6 +231,10 @@ void ATBDeviceControllerPlugin::private_checkAccountData()
|
|||||||
// cannot get accountData within ~10*500ms
|
// cannot get accountData within ~10*500ms
|
||||||
qCritical() << "checkAccountData() failed";
|
qCritical() << "checkAccountData() failed";
|
||||||
|
|
||||||
|
// simulate:
|
||||||
|
this->private_getAccountData();
|
||||||
|
|
||||||
|
|
||||||
// TODO: create and send an HealthEvent...
|
// TODO: create and send an HealthEvent...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,7 +254,16 @@ void ATBDeviceControllerPlugin::private_getAccountData()
|
|||||||
|
|
||||||
accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber));
|
accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber));
|
||||||
|
|
||||||
for (uint i = 0; i < sizeof(retVR.coinsInVault); ++i) {
|
int numberOfCoinVariants = sizeof(retVR.coinsInVault);
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
qCritical() << " NumberOfCoinVariants = " << numberOfCoinVariants;
|
||||||
|
|
||||||
|
// limit numberOfCoinVariants:
|
||||||
|
if (numberOfCoinVariants > 16) { numberOfCoinVariants = 16; }
|
||||||
|
|
||||||
|
accountData.insert("NumberOfCoinVariants", numberOfCoinVariants);
|
||||||
|
for (int i = 0; i < numberOfCoinVariants; ++i) {
|
||||||
accountData.insert("COIN_" + QString::number(i) + "_Quantity", retVR.coinsInVault[i]);
|
accountData.insert("COIN_" + QString::number(i) + "_Quantity", retVR.coinsInVault[i]);
|
||||||
accountData.insert("COIN_" + QString::number(i) + "_Value", retVR.coinDenomination[i]);
|
accountData.insert("COIN_" + QString::number(i) + "_Value", retVR.coinDenomination[i]);
|
||||||
|
|
||||||
@@ -240,6 +294,10 @@ void ATBDeviceControllerPlugin::onVaultDoorOpened()
|
|||||||
// - show special screen / message on screen
|
// - show special screen / message on screen
|
||||||
// - create an HealthEvent (-> ISMAS-Event)
|
// - create an HealthEvent (-> ISMAS-Event)
|
||||||
qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()";
|
qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()";
|
||||||
|
|
||||||
|
// TODO: Start background task "ACCOUNT"
|
||||||
|
|
||||||
|
// do not: emit this->requestModeSERVICE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onCoinBoxRemoved()
|
void ATBDeviceControllerPlugin::onCoinBoxRemoved()
|
||||||
@@ -254,11 +312,20 @@ void ATBDeviceControllerPlugin::onCoinBoxInserted()
|
|||||||
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
|
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()
|
||||||
|
{
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::onCBinAndAllDoorsClosed()";
|
||||||
|
|
||||||
|
this->diag->diagRequest();
|
||||||
|
|
||||||
|
// TODO: Stop background task "ACCOUNT"
|
||||||
|
|
||||||
|
QTimer::singleShot(2000, this, SIGNAL(requestModeIDLE()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onAllDoorsClosed()
|
void ATBDeviceControllerPlugin::onAllDoorsClosed()
|
||||||
{
|
{
|
||||||
// TODO:
|
|
||||||
// - check for errors, switch to mode IDLE
|
|
||||||
|
|
||||||
qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()";
|
qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()";
|
||||||
|
|
||||||
emit this->requestModeIDLE();
|
emit this->requestModeIDLE();
|
||||||
@@ -266,6 +333,120 @@ void ATBDeviceControllerPlugin::onAllDoorsClosed()
|
|||||||
|
|
||||||
|
|
||||||
// TASKS: printing ------------------------------------------------------------
|
// TASKS: printing ------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData)
|
||||||
|
{
|
||||||
|
struct T_dynDat *dynTicketData = new T_dynDat;
|
||||||
|
memset(dynTicketData, 0, sizeof(*dynTicketData));
|
||||||
|
|
||||||
|
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
|
||||||
|
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
|
||||||
|
|
||||||
|
// set dynamic printer data:
|
||||||
|
QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString());
|
||||||
|
memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8));
|
||||||
|
|
||||||
|
QByteArray ba_amount = codec->fromUnicode(printingData["amount"].toString());
|
||||||
|
memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8));
|
||||||
|
|
||||||
|
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
|
||||||
|
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
|
||||||
|
|
||||||
|
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
|
||||||
|
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
|
||||||
|
// ! and yes... 'ParkingEndDate' is 'currentTime'
|
||||||
|
|
||||||
|
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy"));
|
||||||
|
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
||||||
|
|
||||||
|
// STAN for Szeged Start/Stop: must be 9 digits
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
QString stan = codec->fromUnicode(printingData["STAN"].toString());
|
||||||
|
qCritical() << " requestPrintTicket() STAN = " << stan;
|
||||||
|
QString stan1;
|
||||||
|
QString stan2;
|
||||||
|
if (stan.length() == 9) {
|
||||||
|
stan1 = " " + stan.mid(0,3);
|
||||||
|
stan2 = stan.mid(3,3) + " " + stan.mid(6,3);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qCritical() << "ASSERT: ATBDeviceControllerPlugin::requestPrintTicket() invalid STAN: " << stan;
|
||||||
|
stan1 = " 000";
|
||||||
|
stan2 = "000 000";
|
||||||
|
}
|
||||||
|
QByteArray ba_stan1 = codec->fromUnicode(stan1);
|
||||||
|
QByteArray ba_stan2 = codec->fromUnicode(stan2);
|
||||||
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
this->templateList.clear();
|
||||||
|
|
||||||
|
switch (ticketVariant) {
|
||||||
|
case nsDeviceControllerInterface::TICKET_VARIANT::START_RECEIPT:
|
||||||
|
qCritical() << " -> TICKET_VARIANT::START_RECEIPT";
|
||||||
|
memcpy((char*)dynTicketData->dynDat6, ba_stan1.data(), std::min(ba_stan1.size(),8));
|
||||||
|
memcpy((char*)dynTicketData->dynDat7, ba_stan2.data(), std::min(ba_stan2.size(),8));
|
||||||
|
this->templateList << 21 << 22 << 23;
|
||||||
|
break;
|
||||||
|
case nsDeviceControllerInterface::TICKET_VARIANT::STOP_RECEIPT:
|
||||||
|
qCritical() << " -> TICKET_VARIANT::STOP_RECEIPT";
|
||||||
|
memcpy((char*)dynTicketData->dynDat6, ba_stan1.data(), std::min(ba_stan1.size(),8));
|
||||||
|
memcpy((char*)dynTicketData->dynDat7, ba_stan2.data(), std::min(ba_stan2.size(),8));
|
||||||
|
this->templateList << 24 << 25 << 26;
|
||||||
|
break;
|
||||||
|
case nsDeviceControllerInterface::TICKET_VARIANT::RECEIPT:
|
||||||
|
break;
|
||||||
|
case nsDeviceControllerInterface::TICKET_VARIANT::ERROR_RECEIPT:
|
||||||
|
break;
|
||||||
|
case nsDeviceControllerInterface::TICKET_VARIANT::PARKING_TICKET:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
|
||||||
|
for (int i =0; i < this->templateList.size(); ++i) {
|
||||||
|
qCritical() << " template: " << this->templateList.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!this->hw->dc_isPortOpen()) {
|
||||||
|
qCritical() << " ... serial port is not open!";
|
||||||
|
this->onPrintFinishedERR();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: wird hier nur 'licensePlate' gedruckt?
|
||||||
|
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
|
||||||
|
this->errorCode = "hwapi::prn_sendDynamicPrnValues";
|
||||||
|
this->errorDescription = "hwapi method 'hwapi::prn_sendDynamicPrnValues' result is false";
|
||||||
|
|
||||||
|
qCritical() << "ERROR:";
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
|
||||||
|
<< " licenseplate = " << printingData["licenseplate"] << endl
|
||||||
|
<< " amount = " << printingData["amount"] << endl
|
||||||
|
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
||||||
|
<< " currentTime = " << printingData["currentTime"] << endl
|
||||||
|
<< " currentDate = " << printingData["currentDate"] << endl
|
||||||
|
<< " stan = " << printingData["STAN"] << endl;
|
||||||
|
|
||||||
|
this->onPrintFinishedERR();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTimer::singleShot(1000, this, SLOT(onPrinterDataPreparedForTemplates()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::requestPrintReceipt(const QHash<QString, QVariant> & printingData)
|
||||||
|
{
|
||||||
|
Q_UNUSED(printingData)
|
||||||
|
|
||||||
|
qCritical() << "ATBDeviceControllerPlugin::requestPrintReceipt() is currently not implemented";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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 *dynTicketData = new T_dynDat;
|
||||||
@@ -373,52 +554,85 @@ void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QTimer::singleShot(1000, this, SLOT(onPrinterDataPrepared()));
|
QTimer::singleShot(3000, this, SLOT(onPrinterDataPrepared()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::onPrinterDataPreparedForTemplates()
|
||||||
|
{
|
||||||
|
if (this->templateList.isEmpty()) return;
|
||||||
|
|
||||||
|
this->onPrinterPrintNextTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
|
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
|
||||||
{
|
{
|
||||||
this->hw->prn_printKombiticket(this->currentSelectedTicketType);
|
this->hw->prn_printKombiticket(this->currentSelectedTicketType);
|
||||||
|
|
||||||
// FAKE SIGNAL:
|
// note: calling prn_getPrintResult() immediately may result in wrong answer!
|
||||||
QTimer::singleShot(4000, this, SLOT(onPrintFinishedOK()));
|
// We have to wait "about some seconds" until calling this function!
|
||||||
|
QTimer::singleShot(4000, this, SLOT(onPrinterWaitForPrinting()));
|
||||||
|
|
||||||
// old: use printer templates:
|
// old: use printer templates:
|
||||||
// this->currentTemplate = 1;
|
// this->currentTemplate = 1;
|
||||||
// this->onPrinterPrintNextTemplate();
|
// this->onPrinterPrintNextTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::onPrinterWaitForPrinting()
|
||||||
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
|
|
||||||
{
|
{
|
||||||
qCritical() << " ... print template " << this->currentTemplate;
|
quint8 printerResult = this->hw->prn_getPrintResult();
|
||||||
|
|
||||||
if (!this->hw->prn_printTemplate(this->currentTemplate)) {
|
switch (printerResult) {
|
||||||
this->errorCode = "hwapi::prn_printTemplate";
|
case 0: // still printing
|
||||||
this->errorDescription = QString("hwapi method 'hwapi::onPrinterPrintNextTemplate(%1)' result is false").arg(this->currentTemplate);
|
qCritical() << "--> printer: WaitForPrinting";
|
||||||
|
QTimer::singleShot(2000, this, SLOT(onPrinterWaitForPrinting()));
|
||||||
|
break;
|
||||||
|
case 1: // printing finished, Ok
|
||||||
|
this->onPrintFinishedOK();
|
||||||
|
break;
|
||||||
|
case 2: // printing finished, Error
|
||||||
this->onPrintFinishedERR();
|
this->onPrintFinishedERR();
|
||||||
return;
|
break;
|
||||||
}
|
default:
|
||||||
|
qCritical() << "DC Error: wait for printing";
|
||||||
if (this->currentTemplate >= 3) {
|
this->onPrintFinishedERR();
|
||||||
// all templates are printed
|
break;
|
||||||
this->currentTemplate = 0;
|
|
||||||
|
|
||||||
// FAKE SIGNAL:
|
|
||||||
QTimer::singleShot(500, this, SLOT(onPrintFinishedOK()));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// print next template
|
|
||||||
this->currentTemplate++;
|
|
||||||
QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
|
||||||
|
{
|
||||||
|
// template list must not be empty
|
||||||
|
if (this->templateList.isEmpty()) {
|
||||||
|
this->onPrintFinishedERR();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " ... print template " << this->templateList.first();
|
||||||
|
|
||||||
|
if (!this->hw->prn_printTemplate(this->templateList.first())) {
|
||||||
|
this->errorCode = "hwapi::prn_printTemplate";
|
||||||
|
this->errorDescription = QString("hwapi method 'hwapi::onPrinterPrintNextTemplate(%1)' result is false").arg(this->templateList.first());
|
||||||
|
this->onPrintFinishedERR();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->templateList.removeFirst();
|
||||||
|
|
||||||
|
if (templateList.isEmpty()) {
|
||||||
|
// all templates are printed
|
||||||
|
|
||||||
|
// FAKE SIGNAL:
|
||||||
|
QTimer::singleShot(2000, this, SLOT(onPrintFinishedOK()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// print next template
|
||||||
|
QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************************************
|
/************************************************************************************************
|
||||||
* private slots, interface to low level hwapi
|
* private slots, interface to low level hwapi
|
||||||
*
|
*
|
||||||
@@ -675,6 +889,8 @@ const QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************************
|
/************************************************************************************************
|
||||||
* ... end
|
* ... end
|
||||||
*/
|
*/
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "src/ATBAPP/DeviceControllerInterface.h"
|
#include "src/ATBAPP/DeviceControllerInterface.h"
|
||||||
#include "src/ATBAPP/ATBAPPplugin.h"
|
#include "src/ATBAPP/ATBAPPplugin.h"
|
||||||
|
#include "src/ATBAPP/DeviceControllerDiag.h"
|
||||||
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -12,9 +14,6 @@
|
|||||||
#include "interfaces.h"
|
#include "interfaces.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <thread>
|
|
||||||
#include <memory>
|
|
||||||
#include <QSharedMemory>
|
|
||||||
|
|
||||||
|
|
||||||
class QTextCodec;
|
class QTextCodec;
|
||||||
@@ -24,7 +23,7 @@ using namespace nsDeviceControllerInterface;
|
|||||||
|
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
|
||||||
class ATBDeviceControllerPlugin : public QObject,
|
class ATBDeviceControllerPlugin :
|
||||||
public DeviceControllerInterface
|
public DeviceControllerInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -40,7 +39,7 @@ public:
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// interface:
|
// interface:
|
||||||
PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver, const QSettings & settings);
|
PLUGIN_STATE initDCPlugin(QObject *eventReceiver, const QSettings & settings);
|
||||||
|
|
||||||
// TASKS: Cash handling -------------------------------------------------------
|
// TASKS: Cash handling -------------------------------------------------------
|
||||||
void requestStartCashInput(const QString & amount);
|
void requestStartCashInput(const QString & amount);
|
||||||
@@ -50,6 +49,8 @@ public:
|
|||||||
|
|
||||||
// TASKS: printing ------------------------------------------------------------
|
// TASKS: printing ------------------------------------------------------------
|
||||||
void requestPrintTicket(const QHash<QString, QVariant> & printingData);
|
void requestPrintTicket(const QHash<QString, QVariant> & printingData);
|
||||||
|
void requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData);
|
||||||
|
void requestPrintReceipt(const QHash<QString, QVariant> & printingData);
|
||||||
|
|
||||||
// TASKS: Account -------------------------------------------------------------
|
// TASKS: Account -------------------------------------------------------------
|
||||||
void requestAccount();
|
void requestAccount();
|
||||||
@@ -70,38 +71,12 @@ public slots:
|
|||||||
void onChangedProgramModeToIDLE();
|
void onChangedProgramModeToIDLE();
|
||||||
void onChangedProgramModeToOOO();
|
void onChangedProgramModeToOOO();
|
||||||
|
|
||||||
|
void startPhysicalLayer();
|
||||||
|
void stopPhysicalLayer();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
|
||||||
const QString & errorCode,
|
|
||||||
const QString & errorDescription);
|
|
||||||
|
|
||||||
void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
|
|
||||||
nsDeviceControllerInterface::CASH_STATE cashState,
|
|
||||||
const QString & newCashValue,
|
|
||||||
const QString & errorCode,
|
|
||||||
const QString & errorDescription);
|
|
||||||
|
|
||||||
void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
|
||||||
const QString & newCashValue,
|
|
||||||
const QString & errorCode,
|
|
||||||
const QString & errorDescription);
|
|
||||||
|
|
||||||
void requestModeSERVICE();
|
|
||||||
void requestModeIDLE();
|
|
||||||
void requestModeOOO();
|
|
||||||
|
|
||||||
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Error(
|
|
||||||
const QString & errorCode,
|
|
||||||
const QString & errorDescription);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -110,17 +85,21 @@ private:
|
|||||||
QString errorDescription;
|
QString errorDescription;
|
||||||
QString pluginInfo;
|
QString pluginInfo;
|
||||||
|
|
||||||
int currentTemplate;
|
QList<int> templateList;
|
||||||
|
|
||||||
|
QString serialPortName;
|
||||||
|
|
||||||
bool useDebug;
|
bool useDebug;
|
||||||
|
|
||||||
PLUGIN_STATE pluginState;
|
PLUGIN_STATE pluginState;
|
||||||
|
|
||||||
QObject* healthEventReceiver;
|
QObject* eventReceiver;
|
||||||
|
|
||||||
hwinf* hw;
|
hwinf* hw;
|
||||||
|
|
||||||
|
DeviceControllerDiag* diag;
|
||||||
|
|
||||||
|
|
||||||
QTextCodec *codec;
|
QTextCodec *codec;
|
||||||
|
|
||||||
bool private_loadCashAgentLib(QString pluginName);
|
bool private_loadCashAgentLib(QString pluginName);
|
||||||
@@ -137,7 +116,9 @@ private slots:
|
|||||||
// printer
|
// printer
|
||||||
|
|
||||||
void onPrinterDataPrepared();
|
void onPrinterDataPrepared();
|
||||||
|
void onPrinterDataPreparedForTemplates();
|
||||||
void onPrinterPrintNextTemplate();
|
void onPrinterPrintNextTemplate();
|
||||||
|
void onPrinterWaitForPrinting();
|
||||||
|
|
||||||
void onPrintFinishedOK();
|
void onPrintFinishedOK();
|
||||||
void onPrintFinishedERR();
|
void onPrintFinishedERR();
|
||||||
@@ -156,6 +137,7 @@ private slots:
|
|||||||
void onCoinBoxRemoved();
|
void onCoinBoxRemoved();
|
||||||
void onCoinBoxInserted();
|
void onCoinBoxInserted();
|
||||||
void onAllDoorsClosed();
|
void onAllDoorsClosed();
|
||||||
|
void onCBinAndAllDoorsClosed();
|
||||||
|
|
||||||
// account handling
|
// account handling
|
||||||
void private_startAccount();
|
void private_startAccount();
|
||||||
|
66
src/ATBAPP/ATBMachineEvent.cpp
Normal file
66
src/ATBAPP/ATBMachineEvent.cpp
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* Machine Event
|
||||||
|
*
|
||||||
|
* Used e.g. to send events to ISMAS
|
||||||
|
*
|
||||||
|
* Note: It's an Event, not a State!
|
||||||
|
* -> An Event may cause a transition to a different state, depending on the current state.
|
||||||
|
* -> Compare to edge/level trigger: Event is an "edge", State is a "level"
|
||||||
|
* => Do not mix both
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#include "ATBMachineEvent.h"
|
||||||
|
|
||||||
|
|
||||||
|
ATBMachineEvent::ATBMachineEvent(
|
||||||
|
const QString & id,
|
||||||
|
const QString & deviceName, // PTU/PRINTER/DC/...
|
||||||
|
EVENT_CLASS eventClass, // reason of event: Error/Warning/Alarm
|
||||||
|
const QString & name, // 'Event': "E001", "W003"
|
||||||
|
const int state,
|
||||||
|
const QString & parameter,
|
||||||
|
const QString & secondLevelInfo)
|
||||||
|
: QEvent(ATB_MACHINE_EVENT)
|
||||||
|
, eventId(id)
|
||||||
|
, deviceName(deviceName)
|
||||||
|
, machineEventClass(eventClass)
|
||||||
|
, eventName(name)
|
||||||
|
, eventState(state)
|
||||||
|
// timestamp including timezone offset
|
||||||
|
, timestampString(QDateTime::currentDateTime().toOffsetFromUtc(
|
||||||
|
QDateTime::currentDateTime().offsetFromUtc()).toString(Qt::ISODate)
|
||||||
|
)
|
||||||
|
, parameterString(parameter)
|
||||||
|
, secondLevelInfoString(secondLevelInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString ATBMachineEvent::getEventClassString(EVENT_CLASS eventClass)
|
||||||
|
{
|
||||||
|
switch (eventClass) {
|
||||||
|
case EVENT_CLASS::WARNING:
|
||||||
|
return "WARNING";
|
||||||
|
break;
|
||||||
|
case EVENT_CLASS::ERROR:
|
||||||
|
return "ERROR";
|
||||||
|
break;
|
||||||
|
case EVENT_CLASS::ALARM:
|
||||||
|
return "ALARM";
|
||||||
|
break;
|
||||||
|
case EVENT_CLASS::DEBUG:
|
||||||
|
return "DEBUG";
|
||||||
|
break;
|
||||||
|
case EVENT_CLASS::STATE:
|
||||||
|
return "STATE";
|
||||||
|
break;
|
||||||
|
case EVENT_CLASS::NOT_DEFINED:
|
||||||
|
return "NOT_DEFINED";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "NOT_DEFINED";
|
||||||
|
}
|
||||||
|
|
47
src/ATBAPP/ATBMachineEvent.h
Normal file
47
src/ATBAPP/ATBMachineEvent.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#ifndef ATBMACHINECONDITIONEVENT_H
|
||||||
|
#define ATBMACHINECONDITIONEVENT_H
|
||||||
|
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
enum class EVENT_CLASS : quint8;
|
||||||
|
|
||||||
|
const QEvent::Type ATB_MACHINE_EVENT = static_cast<QEvent::Type>(QEvent::User + 2);
|
||||||
|
|
||||||
|
|
||||||
|
class ATBMachineEvent : public QEvent
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ATBMachineEvent(const QString & id,
|
||||||
|
const QString & deviceName, // PTU/PRINTER/DC/...
|
||||||
|
EVENT_CLASS eventClass, // reason of event: Error/Warning/Alarm
|
||||||
|
const QString & name, // 'Event': "E001", "W003"
|
||||||
|
const int state,
|
||||||
|
const QString & parameter,
|
||||||
|
const QString & secondLevelInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
QString eventId;
|
||||||
|
QString deviceName;
|
||||||
|
EVENT_CLASS machineEventClass;
|
||||||
|
QString eventName;
|
||||||
|
int eventState;
|
||||||
|
QString timestampString;
|
||||||
|
QString parameterString;
|
||||||
|
QString secondLevelInfoString;
|
||||||
|
|
||||||
|
static QString getEventClassString(EVENT_CLASS eventClass);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class EVENT_CLASS : quint8 {
|
||||||
|
WARNING,
|
||||||
|
ERROR,
|
||||||
|
ALARM,
|
||||||
|
DEBUG,
|
||||||
|
STATE,
|
||||||
|
NOT_DEFINED
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ATBMACHINEEVENT_H
|
382
src/ATBAPP/DeviceControllerDiag.cpp
Normal file
382
src/ATBAPP/DeviceControllerDiag.cpp
Normal file
@@ -0,0 +1,382 @@
|
|||||||
|
#include "DeviceControllerDiag.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
DeviceControllerDiag::DeviceControllerDiag(QObject *parent)
|
||||||
|
: QObject(parent)
|
||||||
|
, eventReceiver(nullptr)
|
||||||
|
, isRequestRunning(false)
|
||||||
|
, flagInterruptDiag(false)
|
||||||
|
{
|
||||||
|
diagRequestTimeoutTimer = new QTimer(this);
|
||||||
|
diagRequestTimeoutTimer->setInterval(1000*20); // 20s
|
||||||
|
diagRequestTimeoutTimer->setSingleShot(true);
|
||||||
|
connect(diagRequestTimeoutTimer, &QTimer::timeout, this, &DeviceControllerDiag::onDiagRequestTimeoutTimerTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceControllerDiag::init(hwinf *hw, QObject* eventReceiver)
|
||||||
|
{
|
||||||
|
this->hw = hw;
|
||||||
|
this->eventReceiver = eventReceiver;
|
||||||
|
|
||||||
|
// make a system check on startup:
|
||||||
|
QTimer::singleShot(2000, this, &DeviceControllerDiag::diagRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceControllerDiag::diagRequest()
|
||||||
|
{
|
||||||
|
qCritical() << "DeviceControllerDiag::diagRequest()";
|
||||||
|
|
||||||
|
if (this->isRequestRunning) {
|
||||||
|
qCritical() << "DeviceControllerDiag::diagRequest() is already running";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this->isRequestRunning = true;
|
||||||
|
this->diagRequestTimeoutTimer->start();
|
||||||
|
|
||||||
|
this->private_startDiag();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DeviceControllerDiag::onDiagRequestTimeoutTimerTimeout()
|
||||||
|
{
|
||||||
|
qCritical() << "DeviceControllerDiag::onDiagRequestTimeoutTimerTimeout()";
|
||||||
|
this->flagInterruptDiag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceControllerDiag::private_startDiag()
|
||||||
|
{
|
||||||
|
// check for DiagRequestTimeoutTimerTimeout:
|
||||||
|
if (this->flagInterruptDiag) {
|
||||||
|
qCritical() << "DeviceControllerDiag::private_startDiag() interrupted!";
|
||||||
|
this->private_finishedDiag(0xff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result;
|
||||||
|
result = hw->sys_areDCdataValid();
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is valid";
|
||||||
|
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qCritical() << "DeviceControllerDiag::private_startDiag() DCdata is +++not+++ valid";
|
||||||
|
|
||||||
|
// try it again
|
||||||
|
QTimer::singleShot(200, this, &DeviceControllerDiag::private_startDiag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceControllerDiag::sys_superviseSystem()
|
||||||
|
{ // this function proofs if vending is possible depending of doors state
|
||||||
|
|
||||||
|
struct T_dynamicCondition dynMaCond;
|
||||||
|
struct T_moduleCondition modCond;
|
||||||
|
|
||||||
|
|
||||||
|
qCritical() << " sys_superviseSystem()";
|
||||||
|
|
||||||
|
|
||||||
|
// check for DiagRequestTimeoutTimerTimeout:
|
||||||
|
if (this->flagInterruptDiag) {
|
||||||
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() interrupted!";
|
||||||
|
this->private_finishedDiag(0xff);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hw->sys_areDCdataValid())
|
||||||
|
{
|
||||||
|
// es gibt keinerlei gültige Daten vom DC
|
||||||
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() no valid data!";
|
||||||
|
this->private_finishedDiag(0xfe);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// jetzt sind die DC-Daten aktuell, also reinholen:
|
||||||
|
hw->sys_getDynMachineConditions(&dynMaCond);
|
||||||
|
hw->sys_getDeviceConditions(&modCond);
|
||||||
|
|
||||||
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() get condition data";
|
||||||
|
if (!modCond.allModulesChecked)
|
||||||
|
{
|
||||||
|
// noch keine Testergebnisse
|
||||||
|
if (dynMaCond.startupTestIsRunning) {
|
||||||
|
// TODO?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
qCritical() << " allModulesChecked is false --> call again";
|
||||||
|
|
||||||
|
QTimer::singleShot(200, this, &DeviceControllerDiag::sys_superviseSystem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// all doors: 99: undefined 0:closed 1:open
|
||||||
|
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(0xFD);
|
||||||
|
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(0xFC);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << " --> call sub_componentAssessment()";
|
||||||
|
|
||||||
|
uint8_t 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
|
||||||
|
qCritical() << "DeviceControllerDiag::sys_superviseSystem() everything fine";
|
||||||
|
this->private_finishedDiag(0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t DeviceControllerDiag::sub_componentAssessment()
|
||||||
|
{
|
||||||
|
// this function decides if vending mode is possible, independant from door
|
||||||
|
// return >0 in case of error
|
||||||
|
|
||||||
|
struct T_moduleCondition modCond;
|
||||||
|
hw->sys_getDeviceConditions(&modCond);
|
||||||
|
|
||||||
|
struct T_dynamicCondition dynMaCond;
|
||||||
|
hw->sys_getDynMachineConditions(&dynMaCond);
|
||||||
|
|
||||||
|
struct T_devices devPara;
|
||||||
|
hw->sys_restoreDeviceParameter(&devPara);
|
||||||
|
|
||||||
|
if (modCond.rtc>=200)
|
||||||
|
return 1;
|
||||||
|
if (modCond.printer==200 || modCond.printer==201) // 200: not connected 201: printer-HW-error 202: no paper
|
||||||
|
return 2;
|
||||||
|
if (modCond.printer==202)
|
||||||
|
return 3;
|
||||||
|
|
||||||
|
if (modCond.coinBlocker>=200)
|
||||||
|
return 4;
|
||||||
|
if (modCond.mdbBus>=200)
|
||||||
|
return 5;
|
||||||
|
if (modCond.intEe>=200)
|
||||||
|
return 6;
|
||||||
|
|
||||||
|
if (devPara.kindOfCoinChecker==1 || devPara.kindOfCoinChecker==2) // 0: without 1=EMP820 2=EMP900 3=currenza c² (MW)
|
||||||
|
{
|
||||||
|
if (modCond.coinChecker>=200 || modCond.coinEscrow>=200)
|
||||||
|
{
|
||||||
|
// Fehler Münzver.
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
if (modCond.coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
if (devPara.kindOfCoinChecker==3)
|
||||||
|
{
|
||||||
|
if (modCond.changer>=200)
|
||||||
|
{
|
||||||
|
// Fehler Münzver.
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
if (modCond.coinSafe>200) // 200: kasse fehlt 201: voll 100:fast voll 1:ok
|
||||||
|
{
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( modCond.billReader>=200 && devPara.BillAcceptor>0)
|
||||||
|
{
|
||||||
|
// Fehler BNA
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dynMaCond.onAlarm>0)
|
||||||
|
return 10;
|
||||||
|
|
||||||
|
if (dynMaCond.modeAbrech>0)
|
||||||
|
return 11;
|
||||||
|
|
||||||
|
if (dynMaCond.nowCardTest>0)
|
||||||
|
return 12;
|
||||||
|
|
||||||
|
if (dynMaCond.startupTestIsRunning>0)
|
||||||
|
return 13;
|
||||||
|
|
||||||
|
if (modCond.voltage>=200)
|
||||||
|
return 14;
|
||||||
|
if (modCond.temper>=200)
|
||||||
|
return 15;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t DeviceControllerDiag::sys_getSystemErrors()
|
||||||
|
{
|
||||||
|
// 0: everything fine 1..15: errors
|
||||||
|
/* 1: real time clock error
|
||||||
|
2: printer error
|
||||||
|
3: no paper
|
||||||
|
4: coin blocker
|
||||||
|
5: mdb error
|
||||||
|
6: mem error int.ee.
|
||||||
|
7: error coin validator
|
||||||
|
8: coin safe missed or full
|
||||||
|
9: bill acceptor error
|
||||||
|
10: alarm / intrusion
|
||||||
|
11: cash box change is ongoing
|
||||||
|
12: card test running
|
||||||
|
13: startup-test is running
|
||||||
|
14: voltage error
|
||||||
|
15: temperature error
|
||||||
|
*/
|
||||||
|
return this->sub_componentAssessment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief DeviceControllerDiag::private_finishedDiag
|
||||||
|
* @param result - result value from 'sub_componentAssessment()',
|
||||||
|
* - 0xFF on timer interrupt
|
||||||
|
* - 0xFE no valid data from DeviceController
|
||||||
|
* - 0xFD Service or battery door is open
|
||||||
|
* - 0xFE vault door is open
|
||||||
|
*/
|
||||||
|
void DeviceControllerDiag::private_finishedDiag(uint8_t result)
|
||||||
|
{
|
||||||
|
this->diagRequestTimeoutTimer->stop();
|
||||||
|
this->isRequestRunning = false;
|
||||||
|
this->flagInterruptDiag = false;
|
||||||
|
|
||||||
|
if (result == 0) return;
|
||||||
|
|
||||||
|
qCritical() << "DeviceControllerDiag::private_finishedDiag() result: " << result;
|
||||||
|
|
||||||
|
|
||||||
|
if (this->eventReceiver == nullptr) {
|
||||||
|
qCritical() << "DeviceControllerDiag: no eventReceiver";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result > 15 && result != 0xFE) return;
|
||||||
|
|
||||||
|
|
||||||
|
// Errors are in this range 1...15:
|
||||||
|
QString eventId = QUuid::createUuid().toString(QUuid::WithoutBraces).mid(0, 8);
|
||||||
|
QString eventName;
|
||||||
|
EVENT_CLASS eventClass = EVENT_CLASS::STATE;
|
||||||
|
QString parameter;
|
||||||
|
switch (result) {
|
||||||
|
case 1: // real time clock error
|
||||||
|
eventName = "E001";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "real time clock error";
|
||||||
|
break;
|
||||||
|
case 2: // printer error
|
||||||
|
eventName = "E002";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "printer error";
|
||||||
|
break;
|
||||||
|
case 3: // no paper
|
||||||
|
eventName = "E003";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "no paper";
|
||||||
|
break;
|
||||||
|
case 4: // coin blocker
|
||||||
|
eventName = "E004";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "coin blocker";
|
||||||
|
break;
|
||||||
|
case 5: // mdb error
|
||||||
|
eventName = "E005";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "mdb error";
|
||||||
|
break;
|
||||||
|
case 6: // mem error int.ee.
|
||||||
|
eventName = "E006";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "mem error int.ee.";
|
||||||
|
break;
|
||||||
|
case 7: // error coin validator
|
||||||
|
eventName = "E007";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "error coin validator";
|
||||||
|
break;
|
||||||
|
case 8: // coin safe missed or full
|
||||||
|
eventName = "E008";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "coin safe missed or full";
|
||||||
|
break;
|
||||||
|
case 9: // bill acceptor error
|
||||||
|
eventName = "E009";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "bill acceptor error";
|
||||||
|
break;
|
||||||
|
case 10: // alarm / intrusion
|
||||||
|
eventName = "E010";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "alarm / intrusion";
|
||||||
|
break;
|
||||||
|
case 11: // cash box change is ongoing
|
||||||
|
eventName = "E011";
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "cash box change is ongoing";
|
||||||
|
break;
|
||||||
|
case 12: // card test running
|
||||||
|
eventName = "E012";
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "card test running";
|
||||||
|
break;
|
||||||
|
case 13: // startup-test is running
|
||||||
|
eventName = "E013";
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "startup-test is running";
|
||||||
|
break;
|
||||||
|
case 14: // voltage error
|
||||||
|
eventName = "E014";
|
||||||
|
eventClass = EVENT_CLASS::ERROR;
|
||||||
|
parameter = "voltage error";
|
||||||
|
break;
|
||||||
|
case 15: // temperature error
|
||||||
|
eventName = "E015";
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "temperature error";
|
||||||
|
break;
|
||||||
|
case 0xFE: // no valid data from DeviceController
|
||||||
|
eventName = "E254";
|
||||||
|
eventClass = EVENT_CLASS::STATE;
|
||||||
|
parameter = "no valid data from DeviceController";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ATBMachineEvent *machineEvent = new ATBMachineEvent(
|
||||||
|
eventId,
|
||||||
|
"DC",
|
||||||
|
eventClass,
|
||||||
|
eventName,
|
||||||
|
1,
|
||||||
|
parameter,
|
||||||
|
"" // second level info
|
||||||
|
);
|
||||||
|
|
||||||
|
//emit diagResponse(machineEvent);
|
||||||
|
|
||||||
|
QCoreApplication::postEvent(eventReceiver, machineEvent);
|
||||||
|
|
||||||
|
}
|
49
src/ATBAPP/DeviceControllerDiag.h
Normal file
49
src/ATBAPP/DeviceControllerDiag.h
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef DEVICECONTROLLERDIAG_H
|
||||||
|
#define DEVICECONTROLLERDIAG_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "ATBMachineEvent.h"
|
||||||
|
#include "interfaces.h"
|
||||||
|
|
||||||
|
class DeviceControllerDiag : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DeviceControllerDiag(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
void init(hwinf* hw, QObject* eventReceiver);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void diagRequest();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void diagResponse(ATBMachineEvent* machineEvent);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
QObject *eventReceiver;
|
||||||
|
hwinf* hw;
|
||||||
|
|
||||||
|
bool isRequestRunning;
|
||||||
|
bool flagInterruptDiag;
|
||||||
|
|
||||||
|
QTimer *diagRequestTimeoutTimer;
|
||||||
|
|
||||||
|
uint8_t sub_componentAssessment();
|
||||||
|
uint8_t sys_getSystemErrors();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onDiagRequestTimeoutTimerTimeout();
|
||||||
|
|
||||||
|
void private_startDiag(); // diag entry method
|
||||||
|
void private_finishedDiag(uint8_t result); // diag exit method
|
||||||
|
|
||||||
|
void sys_superviseSystem();
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICECONTROLLERDIAG_H
|
@@ -12,17 +12,26 @@ namespace nsDeviceControllerInterface {
|
|||||||
enum class PLUGIN_STATE : quint8;
|
enum class PLUGIN_STATE : quint8;
|
||||||
enum class RESULT_STATE : quint8;
|
enum class RESULT_STATE : quint8;
|
||||||
enum class CASH_STATE : quint8;
|
enum class CASH_STATE : quint8;
|
||||||
|
enum class TICKET_VARIANT : quint8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class DeviceControllerInterface : public ATBAPPplugin
|
class DeviceControllerInterface : public QObject
|
||||||
|
, public ATBAPPplugin
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
Q_INTERFACES(ATBAPPplugin)
|
Q_INTERFACES(ATBAPPplugin)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~DeviceControllerInterface() {}
|
virtual ~DeviceControllerInterface() {}
|
||||||
|
|
||||||
virtual nsDeviceControllerInterface::PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver,
|
/**
|
||||||
|
* @brief initDCPlugin
|
||||||
|
* @param eventReceiver - QObject to receive ATBMachineEvents or HealthEvents
|
||||||
|
* @param settings
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual nsDeviceControllerInterface::PLUGIN_STATE initDCPlugin(QObject *eventReceiver,
|
||||||
const QSettings & settings) = 0;
|
const QSettings & settings) = 0;
|
||||||
|
|
||||||
// TASKS: Cash handling -------------------------------------------------------
|
// TASKS: Cash handling -------------------------------------------------------
|
||||||
@@ -51,6 +60,8 @@ public:
|
|||||||
|
|
||||||
// TASKS: printing ------------------------------------------------------------
|
// TASKS: printing ------------------------------------------------------------
|
||||||
virtual void requestPrintTicket(const QHash<QString, QVariant> & printingData) = 0;
|
virtual void requestPrintTicket(const QHash<QString, QVariant> & printingData) = 0;
|
||||||
|
virtual void requestPrintTicket(nsDeviceControllerInterface::TICKET_VARIANT ticketVariant, const QHash<QString, QVariant> & printingData) = 0;
|
||||||
|
virtual void requestPrintReceipt(const QHash<QString, QVariant> & printingData) = 0;
|
||||||
|
|
||||||
|
|
||||||
// mandantory ATBAPP plugin methods:
|
// mandantory ATBAPP plugin methods:
|
||||||
@@ -70,20 +81,24 @@ public slots:
|
|||||||
virtual void onChangedProgramModeToIDLE() = 0;
|
virtual void onChangedProgramModeToIDLE() = 0;
|
||||||
virtual void onChangedProgramModeToOOO() = 0;
|
virtual void onChangedProgramModeToOOO() = 0;
|
||||||
|
|
||||||
|
virtual void startPhysicalLayer() = 0;
|
||||||
|
virtual void stopPhysicalLayer() = 0;
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
virtual void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||||
const QString & errorCode,
|
const QString & errorCode,
|
||||||
const QString & errorDescription) = 0;
|
const QString & errorDescription);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted on e.g. a coin input
|
* emitted on e.g. a coin input
|
||||||
*/
|
*/
|
||||||
virtual void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
|
void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||||
nsDeviceControllerInterface::CASH_STATE cashState,
|
nsDeviceControllerInterface::CASH_STATE cashState,
|
||||||
const QString & newCashValue,
|
const QString & newCashValue,
|
||||||
/* additional variables? */
|
/* additional variables? */
|
||||||
const QString & errorCode,
|
const QString & errorCode,
|
||||||
const QString & errorDescription) = 0;
|
const QString & errorDescription);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted if cashInput has been stopped, e.g. in result to task requestStopCashInput():
|
* emitted if cashInput has been stopped, e.g. in result to task requestStopCashInput():
|
||||||
@@ -91,32 +106,32 @@ signals:
|
|||||||
* -> no cash input is possible
|
* -> no cash input is possible
|
||||||
* -> coins are in cache
|
* -> coins are in cache
|
||||||
*/
|
*/
|
||||||
virtual void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||||
const QString & newCashValue,
|
const QString & newCashValue,
|
||||||
/* additional variables? */
|
/* additional variables? */
|
||||||
const QString & errorCode,
|
const QString & errorCode,
|
||||||
const QString & errorDescription) = 0;
|
const QString & errorDescription);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted e.g. if service door is opened
|
* emitted e.g. if service door is opened
|
||||||
*/
|
*/
|
||||||
virtual void requestModeSERVICE() = 0;
|
void requestModeSERVICE();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted e.g. if doors are closed
|
* emitted e.g. if doors are closed
|
||||||
*/
|
*/
|
||||||
virtual void requestModeIDLE() = 0;
|
void requestModeIDLE();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted e.g. on severe errors
|
* emitted e.g. on severe errors
|
||||||
*/
|
*/
|
||||||
virtual void requestModeOOO() = 0;
|
void requestModeOOO();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted e.g. if service door is opened
|
* emitted e.g. if service door is opened
|
||||||
*/
|
*/
|
||||||
virtual void requestAccountResponse(const QHash<QString, QVariant> & accountData) = 0;
|
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emitted on error
|
* emitted on error
|
||||||
@@ -126,10 +141,10 @@ signals:
|
|||||||
* -> send error event to ISMAS
|
* -> send error event to ISMAS
|
||||||
* -> ...
|
* -> ...
|
||||||
*/
|
*/
|
||||||
virtual void Error(
|
void Error(
|
||||||
/* additional variables? */
|
/* additional variables? */
|
||||||
const QString & errorCode,
|
const QString & errorCode,
|
||||||
const QString & errorDescription) = 0;
|
const QString & errorDescription);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -160,6 +175,16 @@ namespace nsDeviceControllerInterface {
|
|||||||
OVERPAYED,
|
OVERPAYED,
|
||||||
/* t.b.d. */
|
/* t.b.d. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum class TICKET_VARIANT : quint8 {
|
||||||
|
PARKING_TICKET,
|
||||||
|
RECEIPT,
|
||||||
|
ERROR_RECEIPT,
|
||||||
|
START_RECEIPT, // e.g. Szeged Start
|
||||||
|
STOP_RECEIPT, // e.g. Szeged Stop
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DEVICECONTROLLERINTERFACE_H
|
#endif // DEVICECONTROLLERINTERFACE_H
|
||||||
|
Reference in New Issue
Block a user