Compare commits

..

No commits in common. "7e708d68971b413799106f964a642adb060cf84a" and "6fbde29cad3222bd6c923884cff7688e847b5a52" have entirely different histories.

6 changed files with 155 additions and 200 deletions

View File

@ -9,7 +9,7 @@ QT += serialport
INCLUDEPATH += $${PWD}/plugins INCLUDEPATH += $${PWD}/plugins
INCLUDEPATH += $${PWD}/include INCLUDEPATH += $${PWD}/include
QMAKE_CXXFLAGS += -Wno-deprecated-copy -O QMAKE_CXXFLAGS += -Wno-deprecated-copy
# default # default
ARCH = PTU5 ARCH = PTU5
@ -49,8 +49,6 @@ INTERFACE_DEFINITION = $${PWD}/src/ATBAPP/DeviceControllerInterface.h
DEFINES += DEVICECONTROLLERPLUGIN_LIBRARY DEFINES += DEVICECONTROLLERPLUGIN_LIBRARY
DEFINES += USE_DC_VMC_UNIFICATION
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings # any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the # depend on your compiler). Please consult the documentation of the
@ -79,7 +77,6 @@ HEADERS += \
src/ATBAPP/ATBMachineEvent.h \ src/ATBAPP/ATBMachineEvent.h \
src/ATBAPP/ATBDeviceControllerPlugin.h \ src/ATBAPP/ATBDeviceControllerPlugin.h \
src/ATBAPP/Utils.h \ src/ATBAPP/Utils.h \
src/ATBAPP/UnifiedDCVMCInterface.h \
src/ATBAPP/support/DBusControllerInterface.h \ src/ATBAPP/support/DBusControllerInterface.h \
src/ATBAPP/support/JSON.h \ src/ATBAPP/support/JSON.h \
src/ATBAPP/support/PTUSystem.h src/ATBAPP/support/PTUSystem.h

View File

@ -1045,12 +1045,12 @@ PLUGIN_STATE ATBDeviceControllerPlugin::getState()
return this->pluginState; return this->pluginState;
} }
QString ATBDeviceControllerPlugin::getLastError() QString & ATBDeviceControllerPlugin::getLastError()
{ {
return this->errorCode; return this->errorCode;
} }
QString ATBDeviceControllerPlugin::getLastErrorDescription() const QString & ATBDeviceControllerPlugin::getLastErrorDescription()
{ {
return this->errorDescription; return this->errorDescription;
} }
@ -1061,7 +1061,7 @@ const QString & ATBDeviceControllerPlugin::getPluginInfo()
} }
QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::RESULT_STATE resultState) const QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::RESULT_STATE resultState)
{ {
QString str; QString str;

View File

@ -58,25 +58,25 @@ public:
void requestAccount(); void requestAccount();
// mandantory ATBAPP plugin methods: ------------------------------------------ // mandantory ATBAPP plugin methods: ------------------------------------------
nsDeviceControllerInterface::PLUGIN_STATE getState() override; nsDeviceControllerInterface::PLUGIN_STATE getState();
QString getLastError() override; QString & getLastError();
QString getLastErrorDescription() override; const QString & getLastErrorDescription();
virtual const QString & getPluginInfo() override; const QString & getPluginInfo();
// helpers e.g. for debug / log // helpers e.g. for debug / log
virtual QString getString(nsDeviceControllerInterface::RESULT_STATE resultState) override; const QString getString(nsDeviceControllerInterface::RESULT_STATE resultState);;
public slots: public slots:
virtual void onChangedProgramModeToSELL() override; void onChangedProgramModeToSELL();
virtual void onChangedProgramModeToSERVICE() override; void onChangedProgramModeToSERVICE();
virtual void onChangedProgramModeToIDLE() override; void onChangedProgramModeToIDLE();
virtual void onChangedProgramModeToOOO() override; void onChangedProgramModeToOOO();
void startPhysicalLayer() override; void startPhysicalLayer();
void stopPhysicalLayer() override; void stopPhysicalLayer();
void reboot() override; void reboot();
void reset() override; void reset();

View File

@ -7,27 +7,22 @@
#include <QString> #include <QString>
#include "ATBAPPplugin.h" #include "ATBAPPplugin.h"
#include "UnifiedDCVMCInterface.h"
namespace nsDeviceControllerInterface { namespace nsDeviceControllerInterface {
using PLUGIN_STATE = UnifiedDCVMCInterface::PLUGIN_STATE; enum class PLUGIN_STATE : quint8;
using RESULT_STATE = UnifiedDCVMCInterface::RESULT_STATE; enum class RESULT_STATE : quint8;
using CASH_STATE = UnifiedDCVMCInterface::CASH_STATE; enum class CASH_STATE : quint8;
using TICKET_VARIANT = UnifiedDCVMCInterface::TICKET_VARIANT; enum class TICKET_VARIANT : quint8;
} }
class DeviceControllerInterface : public UnifiedDCVMCInterface
class DeviceControllerInterface : public QObject
, public ATBAPPplugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(ATBAPPplugin) Q_INTERFACES(ATBAPPplugin)
Q_INTERFACES(UnifiedDCVMCInterface)
public: public:
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QSettings const &settings) override {
return initDCPlugin(eventReceiver, settings);
}
virtual ~DeviceControllerInterface() {} virtual ~DeviceControllerInterface() {}
/** /**
@ -36,7 +31,8 @@ public:
* @param settings * @param settings
* @return * @return
*/ */
virtual PLUGIN_STATE initDCPlugin(QObject *eventReceiver, const QSettings & settings) = 0; virtual nsDeviceControllerInterface::PLUGIN_STATE initDCPlugin(QObject *eventReceiver,
const QSettings & settings) = 0;
// TASKS: Cash handling ------------------------------------------------------- // TASKS: Cash handling -------------------------------------------------------
/** /**
@ -64,12 +60,140 @@ 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(TICKET_VARIANT ticketVariant, 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; virtual void requestPrintReceipt(const QHash<QString, QVariant> & printingData) = 0;
virtual void requestPrintReceipt(const QString & printingString) = 0; virtual void requestPrintReceipt(const QString & printingString) = 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;
public slots:
virtual void onChangedProgramModeToSELL() = 0;
virtual void onChangedProgramModeToSERVICE() = 0;
virtual void onChangedProgramModeToIDLE() = 0;
virtual void onChangedProgramModeToOOO() = 0;
virtual void startPhysicalLayer() = 0;
virtual void stopPhysicalLayer() = 0;
virtual void reboot() = 0;
virtual void reset() = 0;
signals:
void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription);
void printReceiptFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription);
/**
* emitted on e.g. a coin input
*/
void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
nsDeviceControllerInterface::CASH_STATE cashState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
/**
* 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
*/
void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
/**
* emitted e.g. if service door is opened
*/
void requestModeSERVICE();
/**
* emitted e.g. if doors are closed
*/
void requestModeIDLE();
/**
* emitted e.g. on severe errors
*/
void requestModeOOO();
/**
* emitted e.g. if service door is opened
*/
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
/**
* emitted on error
* depending on errorCode:
* -> interrupt selling process
* -> machine can go to state OOO
* -> send error event to ISMAS
* -> ...
*/
void Error(
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
}; };
Q_DECLARE_INTERFACE(DeviceControllerInterface, Q_DECLARE_INTERFACE(DeviceControllerInterface,
"eu.atb.ptu.plugin.DeviceControllerInterface/1.0") "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. */
};
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

View File

@ -1,19 +0,0 @@
#include "DeviceControllerInterface.h"
using UNIFIED_PLUGIN_STATE = UnifiedDCVMCInterface<DeviceControllerInterface>::UNIFIED_PLUGIN_STATE;
template<>
UNIFIED_PLUGIN_STATE UnifiedDCVMCInterface<DeviceControllerInterface>::initPlugin(QObject *eventReceiver, QSettings const &settings) {
switch(static_cast<DeviceControllerInterface*>(this)->initDCPlugin(eventReceiver, settings)) {
case nsDeviceControllerInterface::PLUGIN_STATE::INITIALIZED:
return UNIFIED_PLUGIN_STATE::INITIALIZED;
case nsDeviceControllerInterface::PLUGIN_STATE::NOT_INITIALIZED:
return UNIFIED_PLUGIN_STATE::NOT_INITIALIZED;
}
return UNIFIED_PLUGIN_STATE::NOT_INITIALIZED;
}

View File

@ -1,147 +0,0 @@
#ifndef UNIFIED_DCVMC_INTERFACE_H_INCLUDED
#define UNIFIED_DCVMC_INTERFACE_H_INCLUDED
#include <QObject>
#include <QSettings>
#include <QtPlugin>
#include <QSettings>
#include <QString>
#include "ATBAPPplugin.h"
class UnifiedDCVMCInterface : public QObject, public ATBAPPplugin {
Q_OBJECT
Q_INTERFACES(ATBAPPplugin)
public:
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. */
};
enum class TICKET_VARIANT : quint8 {
PARKING_TICKET,
RECEIPT,
ERROR_RECEIPT,
START_RECEIPT, // e.g. Szeged Start
STOP_RECEIPT, // e.g. Szeged Stop
};
explicit UnifiedDCVMCInterface() = default;
virtual ~UnifiedDCVMCInterface() {}
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QSettings const &settings) = 0;
// mandantory ATBAPP plugin methods:
virtual PLUGIN_STATE getState() = 0;
virtual QString getLastError() = 0;
virtual QString getLastErrorDescription() = 0;
virtual QString getString(RESULT_STATE resultState) = 0;
public slots:
virtual void onChangedProgramModeToSELL() = 0;
virtual void onChangedProgramModeToSERVICE() = 0;
virtual void onChangedProgramModeToIDLE() = 0;
virtual void onChangedProgramModeToOOO() = 0;
virtual void startPhysicalLayer() = 0;
virtual void stopPhysicalLayer() = 0;
virtual void reboot() = 0;
virtual void reset() = 0;
signals:
void printTicketFinished(RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription);
void printReceiptFinished(RESULT_STATE resultState,
const QString & errorCode,
const QString & errorDescription);
/**
* emitted on e.g. a coin input
*/
void cashInputEvent(RESULT_STATE resultState,
CASH_STATE cashState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
/**
* 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
*/
void cashInputFinished(RESULT_STATE resultState,
const QString & newCashValue,
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
/**
* emitted e.g. if service door is opened
*/
void requestModeSERVICE();
/**
* emitted e.g. if doors are closed
*/
void requestModeIDLE();
/**
* emitted e.g. on severe errors
*/
void requestModeOOO();
/**
* emitted e.g. if service door is opened
*/
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
/**
* emitted on error
* depending on errorCode:
* -> interrupt selling process
* -> machine can go to state OOO
* -> send error event to ISMAS
* -> ...
*/
void Error(
/* additional variables? */
const QString & errorCode,
const QString & errorDescription);
};
Q_DECLARE_INTERFACE(UnifiedDCVMCInterface,
"eu.atb.ptu.plugin.UnifiedDCVMCInterface/1.0")
using PLUGIN_STATE = UnifiedDCVMCInterface::PLUGIN_STATE;
using RESULT_STATE = UnifiedDCVMCInterface::RESULT_STATE;
using CASH_STATE = UnifiedDCVMCInterface::CASH_STATE;
using TICKET_VARIANT = UnifiedDCVMCInterface::TICKET_VARIANT;
#endif // UNIFIED_DCVMC_INTERFACE_H_INCLUDED