DCPlugin/src/ATBAPP/ATBDeviceControllerPlugin.h

194 lines
5.2 KiB
C++

#ifndef ATBDEVICECONTROLLERPLUGIN_H
#define ATBDEVICECONTROLLERPLUGIN_H
#include <QObject>
#include <QLocale>
#include "src/ATBAPP/DeviceControllerInterface.h"
#include "src/ATBAPP/ATBAPPplugin.h"
#include "src/ATBAPP/DeviceControllerDiag.h"
#include "src/ATBAPP/support/Ticket.h"
#include "version.h"
#include "support/PersistentData.h"
#include <DeviceController/interfaces.h>
#include <unistd.h>
class DBusControllerInterface;
class QTextCodec;
using namespace nsDeviceControllerInterface;
class QSettings;
class ATBDeviceControllerPlugin :
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 *eventReceiver, const QSettings & settings);
void sendDeviceParameter(const QJsonObject & jsonObject);
// TASKS: Cash handling -------------------------------------------------------
void requestStartCashInput(const QString & amount);
void requestStopCashInput();
void cashCollect();
void cashAbort();
// read coin/cash processing variants -----------------------------------------
nsDeviceControllerInterface::COIN_PROCESSOR coinProcessor();
nsDeviceControllerInterface::BILL_ACCEPTOR billAcceptor();
// TASKS: printing ------------------------------------------------------------
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);
void requestPrintReceipt(const QString & printingString);
// TASKS: Account -------------------------------------------------------------
void requestAccount();
// 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);;
public slots:
void onChangedProgramModeToSELL();
void onChangedProgramModeToSERVICE();
void onChangedProgramModeToIDLE();
void onChangedProgramModeToOOO();
void startPhysicalLayer();
void stopPhysicalLayer();
void reboot();
void reset();
signals:
// public Signals are defined in interface
private:
QString errorCode;
QString errorDescription;
QString pluginInfo;
QString serialPortName;
bool useDebug;
bool isMaster;
PLUGIN_STATE pluginState;
QObject* eventReceiver;
DBusControllerInterface* dbus;
hwinf* hw;
DeviceControllerDiag* diag;
PersistentData *persistentData;
uint32_t cashStartAmountInt;
QTextCodec *codec;
bool private_loadCashAgentLib(QString pluginName);
quint8 currentSelectedTicketType;
nsDeviceControllerInterface::CASH_STATE currentCashState;
// counts failed hw->log_chkIfVaultRecordAvailable()
int accountCheckCounter;
// counts faild hw->prn-getPrintResult()
int printResultCheckCounter;
// dbus
int init_sc_dbus();
// printer privates ----------------------------------------------------------------------------
Ticket * currentTicket;
QLocale printerLocale;
void prepareDynTemplateData();
void private_setupDynTemplateData_START_RECEIPT(struct T_dynDat *dynTicketData, Ticket *ticket);
void private_setupDynTemplatData_STOP_RECEIPT(struct T_dynDat *dynTicketData, Ticket *ticket);
void private_setupDynTemplatData_FOOD_STAMP(struct T_dynDat *dynTicketData, Ticket *ticket);
void private_setupDynTemplatData_FINE_PAYMENT(struct T_dynDat *dynTicketData, Ticket *ticket);
// ---------------------------------------------------------------------------------------------
private slots:
// printer
void onPrinterDataPrepared();
void onPrinterDataPreparedForTemplates();
void onPrinterPrintNextTemplate();
void onPrinterWaitForPrintingTicket();
void onPrinterWaitForPrintingReceipt();
void onPrinterPrepareDynTemplateData();
void onPrintFinishedOK();
void onPrintFinishedERR();
// cash payment
void onCashGotCoin();
void onCashPayStopedSuccess();
void onCashPayStopByMax();
void onCashPayStopByPushbutton();
void onCashPayStopByEscrow();
void onCashPayStopByError();
void onCashPayStopByTimeout();
void onCashChangerState();
// doors and hardware contacts
void onServiceDoorOpened();
void onVaultDoorOpened();
void onCoinBoxRemoved();
void onCoinBoxInserted();
void onAllDoorsClosed();
void onCBinAndAllDoorsClosed();
// account handling
void private_startAccount();
void private_checkAccountData();
void private_getAccountData();
// measurement values
void onNewVoltage(uint32_t voltage);
void onWokeUp(uchar source);
};
#endif // ATBDEVICECONTROLLERPLUGIN_H