do some experiments

This commit is contained in:
Gerhard Hoffmann 2023-11-10 13:23:05 +01:00
parent 603e6a20b6
commit 7e708d6897
2 changed files with 166 additions and 0 deletions

View File

@ -0,0 +1,19 @@
#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

@ -0,0 +1,147 @@
#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