Add first version which at least complies.
This commit is contained in:
215
plugins/CalculatePrice/CalculatePriceDefault.cpp
Normal file
215
plugins/CalculatePrice/CalculatePriceDefault.cpp
Normal file
@@ -0,0 +1,215 @@
|
||||
#include "CalculatePriceDefault.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
using namespace nsCalculatePriceInterface;
|
||||
|
||||
|
||||
|
||||
const std::string CalculatePriceInterfacePluginInfoString = R"(
|
||||
{
|
||||
"PluginName": "CalculatePriceDummy",
|
||||
"Version": "1.0",
|
||||
"git-describe": "",
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
|
||||
CalculatePriceDefault::CalculatePriceDefault(QObject *parent) :
|
||||
QObject(parent),
|
||||
errorCode(1),
|
||||
errorDescription(""),
|
||||
pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
||||
{
|
||||
this->pluginInfo = QString::fromUtf8(CalculatePriceInterfacePluginInfoString.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
CalculatePriceDefault::~CalculatePriceDefault()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
PLUGIN_STATE CalculatePriceDefault::initCalculatePricePlugin(QObject *healthEventReceiver, const QSettings & settings)
|
||||
{
|
||||
Q_UNUSED(healthEventReceiver)
|
||||
|
||||
qDebug() << "called CalculatePriceDummy::initCalculatePricePlugin()";
|
||||
qDebug() << " pluginName from setting is: " << settings.value("PLUGINS/CalculatePricePlugin", "").toString();
|
||||
|
||||
this->pluginState = PLUGIN_STATE::INITIALIZED;
|
||||
|
||||
return this->pluginState;
|
||||
}
|
||||
|
||||
|
||||
void CalculatePriceDefault::requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType)
|
||||
{
|
||||
Q_UNUSED(PermitType)
|
||||
|
||||
emit this->requestCalculatePriceResult(RESULT_STATE::SUCCESS,
|
||||
AccessInformation,
|
||||
AccessInformationType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"1",
|
||||
"dummyPlugin"
|
||||
);
|
||||
}
|
||||
|
||||
void CalculatePriceDefault::requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
const QString & parktime)
|
||||
{
|
||||
Q_UNUSED(PermitType)
|
||||
Q_UNUSED(parktime)
|
||||
|
||||
emit this->requestCalculatePriceResult(RESULT_STATE::SUCCESS,
|
||||
AccessInformation,
|
||||
AccessInformationType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"1",
|
||||
"dummyPlugin"
|
||||
);
|
||||
}
|
||||
|
||||
void CalculatePriceDefault::requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
nsCalculatePriceInterface::STEP step)
|
||||
{
|
||||
Q_UNUSED(AccessInformation)
|
||||
Q_UNUSED(AccessInformationType)
|
||||
Q_UNUSED(PermitType)
|
||||
Q_UNUSED(step)
|
||||
}
|
||||
|
||||
void CalculatePriceDefault::requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
int coinValue)
|
||||
{
|
||||
Q_UNUSED(AccessInformation)
|
||||
Q_UNUSED(AccessInformationType)
|
||||
Q_UNUSED(PermitType)
|
||||
Q_UNUSED(coinValue)
|
||||
}
|
||||
|
||||
void CalculatePriceDefault::requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
const QString & parktime,
|
||||
const QString & cardInfo,
|
||||
const QString & transactionInfo)
|
||||
{
|
||||
Q_UNUSED(PermitType)
|
||||
Q_UNUSED(parktime)
|
||||
Q_UNUSED(cardInfo)
|
||||
Q_UNUSED(transactionInfo)
|
||||
|
||||
emit this->requestCalculatePriceResult(RESULT_STATE::SUCCESS,
|
||||
AccessInformation,
|
||||
AccessInformationType,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"1",
|
||||
"dummyPlugin"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CalculatePriceDefault::requestProcessTransaction(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString &amount,
|
||||
bool isOffline,
|
||||
const QString & TransactionId,
|
||||
const QString & ReceiptData,
|
||||
const QString & PermitType, const QString &PaymentType)
|
||||
{
|
||||
Q_UNUSED(isOffline)
|
||||
Q_UNUSED(AccessInformation)
|
||||
Q_UNUSED(AccessInformationType)
|
||||
Q_UNUSED(amount)
|
||||
Q_UNUSED(TransactionId)
|
||||
Q_UNUSED(ReceiptData)
|
||||
Q_UNUSED(PermitType)
|
||||
Q_UNUSED(PaymentType)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* Mandatory plugin methods
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
PLUGIN_STATE CalculatePriceDefault::getState()
|
||||
{
|
||||
return this->pluginState;
|
||||
}
|
||||
|
||||
quint32 CalculatePriceDefault::getLastError()
|
||||
{
|
||||
return this->errorCode;
|
||||
}
|
||||
|
||||
const QString & CalculatePriceDefault::getLastErrorDescription()
|
||||
{
|
||||
return this->errorDescription;
|
||||
}
|
||||
|
||||
|
||||
const QString & CalculatePriceDefault::getPluginInfo()
|
||||
{
|
||||
return pluginInfo;
|
||||
}
|
||||
|
||||
|
||||
const QString CalculatePriceDefault::getString(nsCalculatePriceInterface::RESULT_STATE resultState)
|
||||
{
|
||||
QString str;
|
||||
|
||||
switch (resultState) {
|
||||
case nsCalculatePriceInterface::RESULT_STATE::SUCCESS:
|
||||
str = QString("RESULT_STATE::SUCCESS");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::ERROR_BACKEND:
|
||||
str = QString("RESULT_STATE::ERROR_BACKEND");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::ERROR_NETWORK:
|
||||
str = QString("RESULT_STATE::ERROR_NETWORK");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::ERROR_TIMEOUT:
|
||||
str = QString("RESULT_STATE::ERROR_TIMEOUT");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::ERROR_PROCESS:
|
||||
str = QString("RESULT_STATE::ERROR_PROCESS");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::ERROR_RETRY:
|
||||
str = QString("RESULT_STATE::ERROR_RETRY");
|
||||
break;
|
||||
case nsCalculatePriceInterface::RESULT_STATE::INFO:
|
||||
str = QString("RESULT_STATE::INFO");
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
95
plugins/CalculatePrice/CalculatePriceDefault.h
Normal file
95
plugins/CalculatePrice/CalculatePriceDefault.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef CALCULATEPRICEDUMMY_H
|
||||
#define CALCULATEPRICEDUMMY_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include "CalculatePriceInterface.h"
|
||||
using namespace nsCalculatePriceInterface;
|
||||
|
||||
|
||||
class CalculatePriceDefault : public QObject,
|
||||
public CalculatePriceInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(CalculatePriceInterface)
|
||||
|
||||
public:
|
||||
CalculatePriceDefault(QObject *parent = 0);
|
||||
~CalculatePriceDefault();
|
||||
|
||||
// interface:
|
||||
PLUGIN_STATE initCalculatePricePlugin(QObject *healthEventReceiver, const QSettings & settings);
|
||||
void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType);
|
||||
void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
const QString & parktime);
|
||||
void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
nsCalculatePriceInterface::STEP step);
|
||||
void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
int coinValue);
|
||||
void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
const QString & parktime,
|
||||
const QString & cardInfo,
|
||||
const QString & transactionInfo);
|
||||
void requestProcessTransaction(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & amount,
|
||||
bool isOffline,
|
||||
const QString & TransactionId,
|
||||
const QString & ReceiptData,
|
||||
const QString & PermitType,
|
||||
const QString & PaymentType);
|
||||
|
||||
|
||||
PLUGIN_STATE getState();
|
||||
quint32 getLastError();
|
||||
const QString & getLastErrorDescription();
|
||||
|
||||
const QString & getPluginInfo();
|
||||
|
||||
const QString getString(nsCalculatePriceInterface::RESULT_STATE resultState);
|
||||
|
||||
signals:
|
||||
void requestCalculatePriceResult(RESULT_STATE resultState,
|
||||
const QString & accessInformation,
|
||||
const QString & accessInformationType,
|
||||
const QString & amountDuePeriodStart,
|
||||
const QString & amountDuePeriodEnd,
|
||||
const QString & amountDueNet,
|
||||
const QString & amountDueTax,
|
||||
const QString & gracePeriod,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
void requestCalculatePriceResult(RESULT_STATE resultState,
|
||||
const QString & accessInformation,
|
||||
const QString & accessInformationType,
|
||||
const QString & amountDuePeriodStart,
|
||||
const QString & amountDuePeriodEnd,
|
||||
const PriceInfo & priceInfo,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
void requestProcessTransactionResult(RESULT_STATE resultState,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
|
||||
|
||||
private:
|
||||
quint32 errorCode;
|
||||
QString errorCodeString;
|
||||
QString errorDescription;
|
||||
QString pluginInfo;
|
||||
|
||||
PLUGIN_STATE pluginState;
|
||||
|
||||
};
|
||||
|
||||
#endif // CALCULATEPRICEDUMMY_H
|
157
plugins/CalculatePrice/CalculatePriceInterface.h
Normal file
157
plugins/CalculatePrice/CalculatePriceInterface.h
Normal file
@@ -0,0 +1,157 @@
|
||||
#ifndef CALCULATEPRICEINTERFACE_H
|
||||
#define CALCULATEPRICEINTERFACE_H
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
#include "ATBAPPplugin.h"
|
||||
|
||||
namespace nsCalculatePriceInterface {
|
||||
enum class PLUGIN_STATE : quint8;
|
||||
enum class RESULT_STATE : quint8;
|
||||
enum class STEP : quint8;
|
||||
}
|
||||
|
||||
class PriceInfo
|
||||
{
|
||||
public:
|
||||
int priceNet; // price net in cent
|
||||
int priceTax; // price tax in cent
|
||||
int priceGross; // price gross in cent
|
||||
int taxRate; // tax rate per mill
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CalculatePriceInterface : public ATBAPPplugin
|
||||
{
|
||||
Q_INTERFACES(ATBAPPplugin)
|
||||
|
||||
public:
|
||||
virtual ~CalculatePriceInterface() {}
|
||||
|
||||
virtual nsCalculatePriceInterface::PLUGIN_STATE initCalculatePricePlugin(QObject *healthEventReceiver,
|
||||
const QSettings & settings) = 0;
|
||||
|
||||
// for price calculation dependent on ID (AccessInformation)
|
||||
virtual void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType) = 0;
|
||||
|
||||
// for price calculation dependent on value (e.g. parking time)
|
||||
virtual void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
const QString & parktime) = 0;
|
||||
|
||||
// for price/time calculation on next step up/down
|
||||
virtual void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
nsCalculatePriceInterface::STEP step) = 0;
|
||||
|
||||
// for price/time calculation on next coin value
|
||||
virtual void requestCalculatePrice(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & PermitType,
|
||||
int coinValue) = 0;
|
||||
|
||||
// for price calculation dependent on additonal values (e.g. parking time, card info, ...)
|
||||
virtual void requestCalculatePrice(const QString & AccessInformation, // primary key e.g. a license plate, credit card number
|
||||
const QString & AccessInformationType, // type of AccessInformation: LICENSEPLATE, CREDITCARD, PIN, ...
|
||||
const QString & PermitType, // e.g. selected product / vehicle
|
||||
const QString & parktime, // parktime in minutes
|
||||
const QString & cardInfo, // additonal card info (e.g. PAN, Institusnummer, Token, ...)
|
||||
const QString & transactionInfo) = 0; // kind of a transcation id, could be used for identification of transaction
|
||||
|
||||
virtual void requestProcessTransaction(const QString & AccessInformation,
|
||||
const QString & AccessInformationType,
|
||||
const QString & amount,
|
||||
bool isOffline,
|
||||
const QString & TransactionId,
|
||||
const QString & ReceiptData,
|
||||
const QString & PermitType,
|
||||
const QString & PaymentType) = 0;
|
||||
|
||||
|
||||
virtual nsCalculatePriceInterface::PLUGIN_STATE getState() = 0;
|
||||
virtual quint32 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(nsCalculatePriceInterface::RESULT_STATE resultState) = 0;
|
||||
|
||||
signals:
|
||||
virtual void requestCalculatePriceResult(nsCalculatePriceInterface::RESULT_STATE resultState,
|
||||
const QString & accessInformation,
|
||||
const QString & accessInformationType,
|
||||
const QString & amountDuePeriodStart,
|
||||
const QString & amountDuePeriodEnd,
|
||||
const QString & amountDueNet,
|
||||
const QString & amountDueTax,
|
||||
const QString & gracePeriod,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
virtual void requestCalculatePriceResult(nsCalculatePriceInterface::RESULT_STATE resultState,
|
||||
const QString & accessInformation,
|
||||
const QString & accessInformationType,
|
||||
const QString & amountDuePeriodStart,
|
||||
const QString & amountDuePeriodEnd,
|
||||
const PriceInfo & priceInfo,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
virtual void requestProcessTransactionResult(nsCalculatePriceInterface::RESULT_STATE resultState,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
// TODO:
|
||||
/* APPLICATION_PROCESS_TYPE is a global ATB-Type:
|
||||
* - BACKGROUND -> process can work in background without display
|
||||
* - HMI -> display is needed
|
||||
* - t.b.d
|
||||
*
|
||||
* PROCESS_ID is an identifier for e.g. debuging or log which process/module/library/plugin...
|
||||
* caused the prevent
|
||||
*
|
||||
virtual void preventSuspend(APPLICATION_PROCESS_TYPE pt, PROCESS_ID pid) = 0;
|
||||
virtual void allowSuspend(PROCESS_ID pid) = 0;
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
Q_DECLARE_INTERFACE(CalculatePriceInterface,
|
||||
"eu.atb.ptu.plugin.CalculatePriceInterface/4.0")
|
||||
|
||||
|
||||
namespace nsCalculatePriceInterface {
|
||||
|
||||
enum class PLUGIN_STATE : quint8 {
|
||||
NOT_INITIALIZED = 0,
|
||||
INITIALIZED = 1
|
||||
};
|
||||
|
||||
enum class RESULT_STATE : quint8 {
|
||||
SUCCESS = 1, // got price and time from remote
|
||||
ERROR_BACKEND = 2, // error from backand (e.g. backend replies with error)
|
||||
ERROR_NETWORK = 3, // error from network (e.g. host not available)
|
||||
ERROR_TIMEOUT = 4, // the operation timed out
|
||||
ERROR_PROCESS = 5, // internal plugin error (e.g. bug in implementation)
|
||||
ERROR_RETRY = 6, // retry operation
|
||||
INFO = 7
|
||||
};
|
||||
|
||||
enum class STEP : quint8 {
|
||||
UP = 1,
|
||||
DOWN = 2
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // CALCULATEPRICEINTERFACE_H
|
Reference in New Issue
Block a user