Merge commit '6099d07650acb28df1a5c9659479351daa7c2d27'

This commit is contained in:
2023-05-17 16:08:57 +02:00
22 changed files with 1419 additions and 1713 deletions

View File

@@ -0,0 +1,22 @@
#ifndef ATBAPPPLUGIN_H
#define ATBAPPPLUGIN_H
/***********************************************************
* a simple class with only one method for plugin info
*/
#include <QObject>
#include <QString>
class ATBAPPplugin
{
public:
virtual const QString & getPluginInfo() = 0;
};
Q_DECLARE_INTERFACE(ATBAPPplugin,
"eu.atb.ptu.plugin.ATBAPPplugin/0.9")
#endif // ATBAPPPLUGIN_H

View File

@@ -0,0 +1,293 @@
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
#include "src/ATBAPP/ATBHealthEvent.h"
#include <QTimer>
#include <QTextCodec>
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
pluginState(PLUGIN_STATE::NOT_INITIALIZED)
{
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
this->hw = new hwapi();
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onCashGotCoin()));
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_vendStopByMax()), this, SLOT(onCashVendStopByMax()));
}
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceiver, const QSettings & settings)
{
this->healthEventReceiver = healthEventReceiver;
// read variables from setting
QString serialPort = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
// open serial port
hw->dc_openSerial(5, "115200", serialPort, 1);
// text encoding for printer
this->codec = QTextCodec::codecForName(printerEncoding);
this->pluginState = PLUGIN_STATE::INITIALIZED;
return pluginState;
}
// TASKS: Cash handling -------------------------------------------------------
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
{
qCritical() << "Start Cash vending with amount = " << amount;
uint32_t amountInt = static_cast<uint32_t>(amount.toUInt());
hw->cash_startPayment(amountInt);
}
void ATBDeviceControllerPlugin::requestStopCashInput()
{
hw->cash_stopPayment();
}
void ATBDeviceControllerPlugin::cashCollect()
{
hw->vend_success();
}
void ATBDeviceControllerPlugin::cashAbort()
{
hw->vend_failed();
}
// TASKS: printing ------------------------------------------------------------
void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant> & printingData)
{
struct T_dynDat *dynTicketData = new T_dynDat;
memset(dynTicketData, 0, sizeof(*dynTicketData));
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
<< " licenseplate = " << printingData["licenseplate"] << endl
<< " amount = " << printingData["amount"] << endl
<< " parkingEnd = " << printingData["parkingEnd"] << endl
<< " currentTime = " << printingData["currentTime"] << endl
<< " currentDate = " << printingData["currentDate"] << endl;
// set dynamic printer data:
memcpy((char*)dynTicketData->licensePlate, codec->fromUnicode(printingData["licenseplate"].toString()).data(), 8);
memcpy((char*)dynTicketData->vendingPrice, codec->fromUnicode(printingData["amount"].toString()).data(), 8);
QDateTime parkingEndQDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
QDateTime currentDateTime = QDateTime::fromString(printingData["currentTime"].toString(), Qt::ISODate);
memcpy((char*)dynTicketData->parkingEnd, codec->fromUnicode(parkingEndQDateTime.toString("hh:mm")).data(), 8);
memcpy((char*)dynTicketData->currentTime, codec->fromUnicode(currentDateTime.toString("hh:mm")).data(), 8);
memcpy((char*)dynTicketData->currentDate, codec->fromUnicode(currentDateTime.toString("dd.MM.yy")).data(), 8);
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
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;
this->onPrintFinishedERR();
return;
}
QTimer::singleShot(1000, this, SLOT(onPrinterDataPrepared()));
}
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
{
this->currentTemplate = 1;
this->onPrinterPrintNextTemplate();
}
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
{
qCritical() << " ... print template " << this->currentTemplate;
if (!this->hw->prn_printTemplate(this->currentTemplate)) {
this->errorCode = "hwapi::prn_printTemplate";
this->errorDescription = QString("hwapi method 'hwapi::onPrinterPrintNextTemplate(%1)' result is false").arg(this->currentTemplate);
this->onPrintFinishedERR();
return;
}
if (this->currentTemplate >= 3) {
// all templates are printed
this->currentTemplate = 0;
// FAKE SIGNAL:
QTimer::singleShot(1000, this, SLOT(onPrintFinishedOK()));
}
else {
// print next template
this->currentTemplate++;
QTimer::singleShot(3000, this, SLOT(onPrinterPrintNextTemplate()));
}
}
/************************************************************************************************
* private slots, interface to low level hwapi
*
*/
void ATBDeviceControllerPlugin::onPrintFinishedOK()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedOK()";
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
"",
"");
}
void ATBDeviceControllerPlugin::onPrintFinishedERR()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedERR()";
this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API
this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
this->errorCode,
this->errorDescription);
}
/************************************************************************************************
* cash payment
*/
void ATBDeviceControllerPlugin::onCashGotCoin()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onGotCoin()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputEvent(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
nsDeviceControllerInterface::CASH_STATE::CACHE_INPUT,
amountString,
"",
"");
}
void ATBDeviceControllerPlugin::onCashVendStopByMax()
{
// DEBUG
qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
uint32_t amountInt = this->hw->getInsertedAmount();
QString amountString = QString::number(amountInt);
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
amountString,
"",
"");
}
/************************************************************************************************
* Mandatory plugin methods
*
*/
PLUGIN_STATE ATBDeviceControllerPlugin::getState()
{
return this->pluginState;
}
QString & ATBDeviceControllerPlugin::getLastError()
{
return this->errorCode;
}
const QString & ATBDeviceControllerPlugin::getLastErrorDescription()
{
return this->errorDescription;
}
const QString & ATBDeviceControllerPlugin::getPluginInfo()
{
return this->pluginInfo;
}
const QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::RESULT_STATE resultState)
{
QString str;
switch (resultState) {
case nsDeviceControllerInterface::RESULT_STATE::SUCCESS:
str = QString("RESULT_STATE::SUCCESS");
break;
case nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND:
str = QString("RESULT_STATE::ERROR_BACKEND");
break;
case nsDeviceControllerInterface::RESULT_STATE::ERROR_TIMEOUT:
str = QString("RESULT_STATE::ERROR_TIMEOUT");
break;
case nsDeviceControllerInterface::RESULT_STATE::ERROR_PROCESS:
str = QString("RESULT_STATE::ERROR_PROCESS");
break;
case nsDeviceControllerInterface::RESULT_STATE::ERROR_RETRY:
str = QString("RESULT_STATE::ERROR_RETRY");
break;
case nsDeviceControllerInterface::RESULT_STATE::INFO:
str = QString("RESULT_STATE::INFO");
break;
}
return str;
}
/************************************************************************************************
* ... end
*/
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2( ATBDeviceControllerPlugin, ATBDeviceControllerPlugin )
#endif

View File

@@ -0,0 +1,125 @@
#ifndef ATBDEVICECONTROLLERPLUGIN_H
#define ATBDEVICECONTROLLERPLUGIN_H
#include <QObject>
#include "src/ATBAPP/DeviceControllerInterface.h"
#include "src/ATBAPP/ATBAPPplugin.h"
#include "version.h"
#include "hwapi.h"
#include <unistd.h>
#include <thread>
#include <memory>
#include <QSharedMemory>
class QTextCodec;
using namespace nsDeviceControllerInterface;
class QSettings;
class ATBDeviceControllerPlugin : public QObject,
public DeviceControllerInterface
{
Q_OBJECT
Q_INTERFACES(ATBAPPplugin)
Q_INTERFACES(DeviceControllerInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA( IID "ATBDeviceControllerPlugin" )
#endif
public:
explicit ATBDeviceControllerPlugin(QObject *parent = nullptr);
~ATBDeviceControllerPlugin();
// ----------------------------------------------------------------------------
// interface:
PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver, const QSettings & settings);
// TASKS: Cash handling -------------------------------------------------------
void requestStartCashInput(const QString & amount);
void requestStopCashInput();
void cashCollect();
void cashAbort();
// TASKS: printing ------------------------------------------------------------
void requestPrintTicket(const QHash<QString, QVariant> & printingData);
// mandantory ATBAPP plugin methods: ------------------------------------------
nsDeviceControllerInterface::PLUGIN_STATE getState();
QString & getLastError();
const QString & getLastErrorDescription();
const QString & getPluginInfo();
// helpers e.g. for debug / log
const QString getString(nsDeviceControllerInterface::RESULT_STATE resultState);
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 requestServiceMode();
void Error(
const QString & errorCode,
const QString & errorDescription);
private:
QString errorCode;
QString errorDescription;
QString pluginInfo;
int currentTemplate;
bool useDebug;
PLUGIN_STATE pluginState;
QObject* healthEventReceiver;
hwinf* hw;
QTextCodec *codec;
private slots:
// printer
void onPrinterDataPrepared();
void onPrinterPrintNextTemplate();
void onPrintFinishedOK();
void onPrintFinishedERR();
// cash payment
void onCashGotCoin();
void onCashVendStopByMax();
};
#endif // ATBDEVICECONTROLLERPLUGIN_H

View File

@@ -0,0 +1,25 @@
#include "src/ATBAPP/ATBHealthEvent.h"
ATBHealthEvent::ATBHealthEvent(ATB_HEALTH_MODE mode, const QString & errorNumber, const QString & errorDescription) :
QEvent(ATB_HEALTH_EVENT),
healthMode(mode),
errorNumber(errorNumber),
errorDescription(errorDescription)
{
}
QString ATBHealthEvent::getErrorNumber()
{
return this->errorNumber;
}
QString ATBHealthEvent::getErrorDescription()
{
return this->errorDescription;
}
ATB_HEALTH_MODE ATBHealthEvent::getMode()
{
return this->healthMode;
}

View File

@@ -0,0 +1,44 @@
#ifndef ATBHEALTHEVENT_H
#define ATBHEALTHEVENT_H
#include <QEvent>
#include <QString>
enum class ATB_HEALTH_MODE : quint8;
const QEvent::Type ATB_HEALTH_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
class ATBHealthEvent : public QEvent
{
public:
ATBHealthEvent(ATB_HEALTH_MODE mode, const QString & errorNumber, const QString & errorDescription);
QString getErrorNumber();
QString getErrorDescription();
ATB_HEALTH_MODE getMode();
signals:
public slots:
private:
ATB_HEALTH_MODE healthMode;
QString errorNumber;
QString errorDescription;
};
enum class ATB_HEALTH_MODE : quint8 {
WARNING,
ERROR,
WARNING_CORRECTION,
ERROR_CORRECTION,
DEBUG,
STATE,
UNSPECIFIED
};
#endif // ATBHEALTHEVENT_H

View File

@@ -0,0 +1,142 @@
#ifndef DEVICECONTROLLERINTERFACE_H
#define DEVICECONTROLLERINTERFACE_H
#include <QtPlugin>
#include <QSettings>
#include <QString>
#include "ATBAPPplugin.h"
namespace nsDeviceControllerInterface {
enum class PLUGIN_STATE : quint8;
enum class RESULT_STATE : quint8;
enum class CASH_STATE : quint8;
}
class DeviceControllerInterface : public ATBAPPplugin
{
Q_INTERFACES(ATBAPPplugin)
public:
virtual ~DeviceControllerInterface() {}
virtual nsDeviceControllerInterface::PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver,
const QSettings & settings) = 0;
// TASKS: Cash handling -------------------------------------------------------
/**
* enables coin input
* amount = "0": pay-up
* amount > "0": pay-down
*/
virtual void requestStartCashInput(const QString & amount) = 0;
/**
* called e.g. on Button "NEXT" in pay-up (direct coin input)
*/
virtual void requestStopCashInput() = 0;
/**
* called e.g. on Button "NEXT" in pay-up (direct coin input)
*/
virtual void cashCollect() = 0;
virtual void cashAbort() = 0;
// TASKS: printing ------------------------------------------------------------
virtual void requestPrintTicket(const QHash<QString, QVariant> & printingData) = 0;
// mandantory ATBAPP plugin methods:
virtual nsDeviceControllerInterface::PLUGIN_STATE getState() = 0;
virtual const QString & getLastError() = 0;
virtual const QString & getLastErrorDescription() = 0;
// return a plugin description in JSON or XML
// -> ATBAPPplugin::getPluginInfo()
// helpers e.g. for debug / log
virtual const QString getString(nsDeviceControllerInterface::RESULT_STATE resultState) = 0;
signals:
virtual void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription) = 0;
/**
* emitted on e.g. a coin input
*/
virtual void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
nsDeviceControllerInterface::CASH_STATE cashState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription) = 0;
/**
* emitted if cashInput has been stopped, e.g. in result to task requestStopCashInput():
* -> shutter is blocked
* -> no cash input is possible
* -> coins are in cache
*/
virtual void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription) = 0;
/**
* emitted e.g. if service door is opened
*/
virtual void requestServiceMode() = 0;
/**
* emitted on error
* depending on errorCode:
* -> interrupt selling process
* -> machine can go to state OOO
* -> send error event to ISMAS
* -> ...
*/
virtual void Error(
/* additional variables? */
const QString & errorCode,
const QString & errorDescription) = 0;
};
Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.0")
namespace nsDeviceControllerInterface {
enum class PLUGIN_STATE : quint8 {
NOT_INITIALIZED = 0,
INITIALIZED = 1
};
enum class RESULT_STATE : quint8 {
SUCCESS = 1, // operation was successfull
ERROR_BACKEND, // error from backend (e.g. backend replies with error)
ERROR_TIMEOUT, // the operation timed out
ERROR_PROCESS, // internal plugin error, should not occur (this is a bug in implementation)
ERROR_RETRY, // retry operation
INFO // informational (e.g. display a message, log something etc.)
};
enum class CASH_STATE : quint8 {
CACHE_EMPTY, // Cache still empty, default state
CACHE_INPUT, // Coins are in Cache
OVERPAYED,
/* t.b.d. */
};
}
#endif // DEVICECONTROLLERINTERFACE_H

View File

@@ -17,6 +17,8 @@ static uint16_t datif_OutCmdpara5;
static uint32_t datif_OutCmdpara6;
static uint8_t cycl_running;
//static bool datif_DCdataValid;
T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
{
@@ -46,6 +48,8 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
dif_scanStep=0;
selectedSlaveAddr=FIX_SLAVE_ADDR;
cycl_running=0;
//datif_DCdataValid=0;
gpi_storeDcDataValid(0);
}
void T_datif::resetChain(void)
@@ -1478,6 +1482,10 @@ char T_datif::loadRecDataFromFrame()
*/
if (RdDleng>40)
//datif_DCdataValid=1; // das hier sind die wichtigsten Daten, deshalb hierrein!
gpi_storeDcDataValid(1);
gpi_storeDynMachineConditions(RdDleng, receivedData);
prnResult=receivedData[52];

25
DCPlugin/src/hwChk.cpp Executable file
View File

@@ -0,0 +1,25 @@
#include <stdint.h>
#include "hwChk.h"
hwChk::hwChk(QWidget *parent) : QObject(parent)
{
// myDCIF = new T_prot();
// h: T_prot *myDCIF;
//myDatif = new T_datif();
HWaccess = new hwinf();
struct T_moduleCondition dcModCond;
sys_getDeviceConditions(dcModCond);
}
hwChk::~hwChk()
{
}

View File

@@ -24,7 +24,6 @@
#include "shared_mem_buffer.h"
#include <QDebug>
#include <QSharedMemory>
#include "interfaces.h"
static uint32_t hwapi_lastStartAmount;
@@ -34,7 +33,7 @@ static const QMap<QString, int> baudrateMap = {
{"57600" , 4}, {"115200" , 5}
};
hwapi::hwapi(QWidget *parent) : QObject(parent) {
hwapi::hwapi(QObject *parent) : QObject(parent) {
// create or attach shared memory segment
// !!! The compoment creating the shared memory MUST be ATBQT !!!
m_sharedMem = SharedMemBuffer::getShm(sizeof(SharedMemBuffer));
@@ -1652,20 +1651,6 @@ uint8_t hwapi::coin_escrowFlapOpened(void) const
// ------------------------------------------------------------------------------
// Level4 devices are operated by DC
// processes with more then one devices
// timer controlled or long term processes
// ------------------------------------------------------------------------------
void hwapi::sendDeviceSettings(uint8_t kindOfPrinter, uint8_t kindOfCoinChecker,
uint8_t kindOfMifareReader, uint8_t suppressSleep,
uint8_t kindOfModem, uint8_t kindOfCredit) const
@@ -3531,12 +3516,17 @@ bool hwapi::prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const
}
bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
// print one of the templates loaded by Json prior
// nr = 1..32
{
// return true if sending, false if cmd-stack is full
return sendFDcmd_set(152, 0,0, nrOftemplate,0,0,0);
// 3.5.23: die dynVals und alle templates sollen am stück gesendet
uint8_t data[64];
data[0]=nrOftemplate;
return longFDcmd_set(152, 0,0, 1, data);
}
void hwapi::log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const
@@ -3717,6 +3707,20 @@ uint64_t hwapi::sys_getWakeSource(void) const
return epi_getWakeSources();
}
uint8_t hwapi::sys_getWakeReason(void) const
{
// Master was woken by following reason:
// 1: MDB Event
// 2: Coin Event
// ( 3: Master Event) - will not set the wake line
// ( 4: 32s pulse) - will not set the wake line
// 5: Door Event
// ( 6: Diag Event) - will not set the wake line
// 7: 30min-Pulse for HB
return epi_getWakeReason();
}
void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const
{
@@ -3852,3 +3856,209 @@ uint8_t hwapi::prn_getCurrentPrinterState() const
}
// 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices"
void hwapi::sys_sendDeviceParameter(struct T_devices *deviceSettings) const
{
// same as "sendDeviceSettings()" but with much more data
uint8_t buf[64];
uint16_t LL, nn;
tslib_strclr(buf,0,64);
uint8_t *start;
// den gesamten struct in einen Puffer kopieren
LL=sizeof(struct T_devices);
start = &deviceSettings->kindOfPrinter;
nn=0;
do
{
buf[nn] = *start;
start++;
} while(++nn<LL);
epi_store64BdevParameter(LL,buf); // this buffer holds the device settings to be used here in hwapi
epi_store64ByteSendData(LL, buf); // this buffer holds sending data temporarely
sendWRcmd_setSendCommand0(SENDDIRCMD_DEVICE_PARA);
}
void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
{
uint8_t buf[64];
uint8_t LL, nn;
tslib_strclr(buf,0,64);
uint8_t *start;
epi_restore64BdevParameter(&LL, buf);
// Puffer in struct eintragen:
start = &deviceSettings->kindOfPrinter;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
}
/* ---------------------------------------------------------------------------------------------
// ------------ supervise all hardware components
// ------------ assess the machine state
1. check if DC startup test is through, retrigger if not
2. get results and find errors
3. in case of error check if component is used (e.g. billreader is seldom used)
4: check doors
5. return value: 0: no response from DC
1: no Test results and Test not running. need retrigger!
2: state not clear by now, test ongoing, wait
3: Service or battery door is open, goto INTRUSION MODE
from here: after valid ID-card goto SERVICE MODE
4: vault door is open, goto INTRUSION MODE
from here: after valid ID-card and vault door closed goto TEST MODE
in TEST MODE: complete system check decides if vending mode allowed
5: All doors are closed but errors found,
goto OOO MODE (out-of-order)
from here: run system test until problem is fixed
6: All doors are closed, no error, maybe warnings,
goto VENDING MODE (normal operation)
(priority sinks from 0 to 6)
--------------------------------------------------------------------------------------------- */
uint8_t hwapi::sys_componentAssessment(void) const
{
// this function decides if vending mode is possible, independant from door
// return >0 in case of error
// is inncluded in sys_superviseSystem
struct T_moduleCondition *modCond=0;
sys_getDeviceConditions(modCond);
struct T_dynamicCondition *dynMaCond=0;
sys_getDynMachineConditions(dynMaCond);
struct T_devices *devPara=0;
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;
}
// retrigger System-Check with:
// bool hwapi::sys_runCompleteTest(void) const
uint8_t hwapi::sys_superviseSystem(void) const
{
// this function proofs if vending is possible depending of doors state
struct T_dynamicCondition *dynMaCond=0;
struct T_moduleCondition *modCond=0;
if (!gpi_areDcDataValid())
{
// es gibt keinerlei gültige Daten vom DC
return 0;
}
// jetzt sind die DC-Daten aktuell, also reinholen:
sys_getDynMachineConditions(dynMaCond);
sys_getDeviceConditions(modCond);
if (!modCond->allModulesChecked)
{
// noch keine Testergebnisse
if (dynMaCond->startupTestIsRunning)
return 2; // Starttest läuft gerade
else
return 1; // Starttest ist noch nicht gelaufen
}
// all doors: 99: undefined 0:closed 1:open
if (dynMaCond->lowerDoor || dynMaCond->upperDoor)
return 3;
if (dynMaCond->middleDoor)
return 4;
if (sys_componentAssessment() >0)
return 5; // errors found
return 6; // everything fine
}
uint8_t hwapi::sys_getSystemErrors(void) const
{
return sys_componentAssessment();
}

View File

@@ -671,3 +671,34 @@ uint8_t check4freeFDlongCmd(void)
}
static uint8_t Sdata_DeviceParameter[64];
static uint8_t Sdata_DevParaLen;
uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf)
{
// HWapi writes data to be stored
uint8_t nn;
for (nn=0; nn<length; nn++)
Sdata_DeviceParameter[nn]=buf[nn];
for (nn=length; nn<64; nn++)
Sdata_DeviceParameter[nn]=0;
Sdata_DevParaLen=length;
return 0;
}
uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf)
{
for (uint8_t nn=0; nn<Sdata_DevParaLen; nn++)
buf[nn]=Sdata_DeviceParameter[nn];
*length=Sdata_DevParaLen;
return 0;
}

View File

@@ -1172,17 +1172,26 @@ bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values) {
void gpi_storeWakeSources(uint8_t const *receivedData) {
SharedMemBuffer::getData()->store.wakeSrc = 0;
for (int nn=7; nn>=0; nn--) {
for (int nn=5; nn>=0; nn--) {
uint8_t const uctmp = receivedData[nn];
SharedMemBuffer::getData()->store.wakeSrc |= uctmp;
SharedMemBuffer::getData()->store.wakeSrc <<= 8;
}
SharedMemBuffer::getData()->store.wakeReason = receivedData[6];
}
uint64_t epi_getWakeSources(void) {
return SharedMemBuffer::getDataConst()->store.wakeSrc;
}
uint8_t epi_getWakeReason(void)
{
return SharedMemBuffer::getDataConst()->store.wakeReason;
}
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data) {
leng = std::min(leng, (uint8_t)(64));
SharedMemBuffer::getData()->store.rbDevParamLen = leng;
@@ -1303,3 +1312,25 @@ uint32_t epi_getCashBoxContent(void) {
uint16_t epi_getNrOfCoinsInCashBox(void) {
return SharedMemBuffer::getDataConst()->store.nrOfCoins;
}
void gpi_storeDcDataValid(bool isVal)
{
SharedMemBuffer::getData()->store.dcDataValid = isVal;
}
bool gpi_areDcDataValid()
{
return SharedMemBuffer::getDataConst()->store.dcDataValid;
}