Compare commits

...

29 Commits

Author SHA1 Message Date
4b38e2e46e Test CRTP. 2023-11-24 13:45:11 +01:00
9fa37d125d Fix interfaces(). 2023-11-17 13:47:55 +01:00
00dbf4485a Implement interfaces(). 2023-11-17 13:44:45 +01:00
88670c1079 Add CLASSINFO() to enumerate supported interfaces. 2023-11-17 13:44:16 +01:00
2efdbe2d68 Extend getString(). 2023-11-17 11:46:29 +01:00
38994ac192 connect() wakeup line. 2023-11-17 11:45:50 +01:00
f6238e5a36 integrate wakeup line 2023-11-17 11:44:51 +01:00
f0762e272f Initialize m_pluginInfoList in constructor.
Implement initPlugin().
Im[plement getString().
2023-11-16 08:31:50 +01:00
46ab0ec80f Removed signals. 2023-11-16 08:30:41 +01:00
1d8eb2a808 Removed signals. 2023-11-16 08:29:17 +01:00
22fb039172 Moved PLUGIN_STATE, RESULT_STATE, CASH_STATE, TICKET_VARIANT to ATBAPPplugin.h
Removed signals.
2023-11-16 08:26:36 +01:00
cf8dd83a48 Add enums for describing plugin status:
PLUGIN_STATE
RESULT_STATE
CASH_STATE
TICKET_VARIANT
STEP
TERMINAL_STATE.
Add default implementation for getPluginInfo().
2023-11-16 08:23:07 +01:00
1a08f8ee3a Return QStringList from getPluginInfo(). 2023-11-15 11:26:45 +01:00
94b51b5794 emulate functionality of generate-version.sh 2023-11-15 11:02:05 +01:00
f833d9d13d remove unused file 2023-11-15 11:01:16 +01:00
aa4cc78380 removed setPluginInfo() 2023-11-15 11:00:32 +01:00
83e282b7fc removed setPluginInfo() 2023-11-15 11:00:19 +01:00
444b2f09e3 removed setPluginInfo() 2023-11-15 11:00:08 +01:00
ce08b4b334 removed setPluginInfo() 2023-11-15 10:59:59 +01:00
5f73704020 removed setPluginInfo() 2023-11-15 10:59:48 +01:00
df9078de98 remove unused file 2023-11-15 10:56:27 +01:00
a139fdb58f remove version.h 2023-11-14 15:58:50 +01:00
6491646243 remove version.h 2023-11-14 15:58:19 +01:00
af351ee092 remove version.h 2023-11-14 15:57:52 +01:00
8490ba8a3a remove version.h 2023-11-14 15:57:30 +01:00
f9680105ab removed version.h 2023-11-14 15:56:36 +01:00
c8c19e8cfc re-implemented setPluginInfo() 2023-11-14 15:56:03 +01:00
c5654509a3 defines for use in setPluginInfo() 2023-11-14 15:55:27 +01:00
be98f7e178 Add pure virtual setPluginInfo() 2023-11-14 15:05:09 +01:00
12 changed files with 268 additions and 416 deletions

View File

@@ -46,7 +46,7 @@ contains( CONFIG, PTU5_YOCTO ) {
}
TARGET = ATBVMCPlugin
#DESTDIR = ../plugins
VERSION = "0.8.0"
INTERFACE = VMCInterface
INTERFACE_DEFINITION = $${PWD}/src/ATBAPP/VMCInterface.h
@@ -56,22 +56,33 @@ win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
BUILD_DATE=$$system("date +%d%m%y")
BUILD_TIME=$$system("date +%H%M")
}
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
GIT_COMMIT=$$system("git log -n 1 --format=oneline | cut -d' ' -f1")
GIT_BRANCH=$$system("git branch --no-color 2> /dev/null | cut -d' ' -f2")
GIT_DESCRIBE=$$system("git describe --dirty --always | tr '-' '_'")
DEV_SUFFIX=""
count(GIT_BRANCH, 2) {
DEV_SUFFIX="_dev"
}
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
CONFIG += c++17
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=ATB_QT_VERSION=\\\"$${QT_VERSION}\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
DEFINES+=PLUGIN_BUILD_DATE=\\\"$${BUILD_DATE}\\\"
DEFINES+=PLUGIN_BUILD_TIME=\\\"$${BUILD_TIME}\\\"
DEFINES+=PLUGIN_EXTENDED_VERSION=\\\"$${EXTENDED_VERSION}\\\"
DEFINES+=INTERFACE=\\\"VMCInterface\\\"
DEFINES+=INTERFACE_VERSION=\\\"eu.atb.ptu.plugin.VMCInterface/1.0\\\"
DEFINES+=PLUGIN_NAME=\\\"ATBVMCPlugin\\\"
DEFINES+=PLUGIN_VERSION=\\\"$${BUILD_DATE}_$${BUILD_TIME}\\\"
DEFINES+=PLUGIN_GIT_DESCRIBE=\\\"$${GIT_DESCRIBE}_$${GIT_BRANCH}$${DEV_SUFFIX}\\\"
# Default rules for deployment.
#qnx: target.path = /tmp/$${TARGET}/bin
@@ -80,7 +91,6 @@ DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
# ATBAPP interface
HEADERS += \
include/interfaces.h \
src/ATBAPP/VMCInterface.h \
src/ATBAPP/ATBVMCPlugin.h \
src/ATBAPP/ATBAPPplugin.h \
@@ -98,6 +108,3 @@ SOURCES += \
src/ATBAPP/support/VMC/SendBuffer.cpp \
src/ATBAPP/support/VMC/vmc.cpp \
src/ATBAPP/support/VendingData.cpp
OTHER_FILES += \
plugins/metadata.json

View File

@@ -1,157 +0,0 @@
#!/bin/bash
VERSION_STRING=""
#GIT='/cygdrive/c/Program Files \(x86\)/Git/bin/git'
GIT=git
parse_git_branch () {
$GIT branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
}
ARCH=$1
TARGET=$2
INTERFACE=$3
INTERFACE_DEFINITION=$4
VERSION_H=$5
SCRIPT=$(readlink -f $0)
SCRIPTPATH=`dirname $SCRIPT`
OUTPUTDIR=$(pwd)
echo " current dir is : " $(pwd)
echo $SCRIPT
echo $SCRIPTPATH
echo "changing dir to script path: " $SCRIPTPATH
cd $SCRIPTPATH
# set version string ##################################################################
if [ -z $VERSION_STRING ] ; then
VERSION_STRING=$(date +%Y%m%d_%H%M)
fi
GIT_DESCRIBE=$($GIT describe --always)
GIT_BRANCH=$(parse_git_branch)
# extract path from branchname:
IFS='_' read -ra TMP_ARRAY <<< "${GIT_BRANCH}"
BRANCH_PATH=${TMP_ARRAY[0]}
# detect if we have a development version:
if [ ${#TMP_ARRAY[1]} -gt 0 ] ; then
DEV_SUFFIX="_dev"
else
DEV_SUFFIX=""
fi
# detect if git status is dirty
GIT_DESCRIBE_DIRTY=$($GIT describe --dirty)
if [ "${GIT_DESCRIBE_DIRTY:(-6)}" == "-dirty" ] ; then
DIRTY_SUFFIX="_dirty"
else
DIRTY_SUFFIX=""
fi
if [ -n "$DIRTY_SUFFIX" ] || [ -n "$DEV_SUFFIX" ] ; then
DEVDIRTY=true
else
DEVDIRTY=false
fi
# extract interface definition
#
#Q_DECLARE_INTERFACE(CCInterface,
# "eu.atb.ptu.plugin.CCInterface/2.9.0")
#Q_DECLARE_INTERFACE(DeviceControllerInterface,
# "eu.atb.ptu.plugin.DeviceControllerInterface/1.0")
# -> extract whole string within quotation marks
INTERFACE_VERSION=$(grep 'eu.atb.ptu.plugin.' ${INTERFACE_DEFINITION})
# get string within quotes:
INTERFACE_VERSION=`echo ${INTERFACE_VERSION} | awk -F \" '{print $2}'`
#
# write version.h
echo " TARGET is: $TARGET"
echo " ARCH is: $ARCH"
echo " "
echo " PluginName: $TARGET"
echo " Interface: $INTERFACE"
echo " InterfaceVersion: $INTERFACE_VERSION"
echo " "
echo " new version is: $VERSION_STRING"
echo " git describe is: $GIT_DESCRIBE"
echo " git branch is: $GIT_BRANCH"
echo " branch-path is: $BRANCH_PATH"
echo " "
echo " dev suffix: $DEV_SUFFIX"
echo " dirty suffix: $DIRTY_SUFFIX"
PLUGIN_VERSION=${VERSION_STRING}
#ATB_QT_GIT_DESCRIBE=${GIT_DESCRIBE}_${GIT_BRANCH}
PLUGIN_GIT_DESCRIBE=${GIT_DESCRIBE}_${BRANCH_PATH}${DEV_SUFFIX}${DIRTY_SUFFIX}
#TARGET=IngenicoZVT_CCPlugin
# build version.h #####################################################################
echo " building new version info (version.h) ..."
echo "#ifndef VERSION_H" > ${VERSION_H}
echo "#define VERSION_H" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "#define INTERFACE_VERSION \"${INTERFACE_VERSION}\"" >> ${VERSION_H}
echo "#define PLUGIN_VERSION \"${PLUGIN_VERSION}\"" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "#define PLUGIN_GIT_DESCRIBE \"${PLUGIN_GIT_DESCRIBE}\"" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "" >> ${VERSION_H}
cat <<EOT >> ${VERSION_H}
const std::string pluginInfoString = R"(
{
"Interface": "${INTERFACE}",
"InterfaceVersion": "${INTERFACE_VERSION}",
"PluginName": "${TARGET}",
"Version": "${PLUGIN_VERSION}",
"git-describe": "${PLUGIN_GIT_DESCRIBE}",
}
)";
EOT
echo "" >> ${VERSION_H}
echo "" >> ${VERSION_H}
if [ ${DEVDIRTY} == "true" ] ; then
echo "#define DEVDIRTY" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "" >> ${VERSION_H}
fi
echo "#define SYSTEM_ARCH \"${ARCH}\"" >> ${VERSION_H}
echo "#define ARCH_${ARCH}" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "" >> ${VERSION_H}
echo "#endif //VERSION_H" >> ${VERSION_H}

View File

@@ -1,7 +0,0 @@
{
"type" : "hardware",
"name" : "ATBVMCPlugin",
"longname" : "VMC hardware control",
"version" : "1.0.0",
"dependencies" : []
}

View File

@@ -5,22 +5,66 @@
* a simple class with only one method for plugin info
*/
#include <QObject>
#include <QString>
#include <QStringList>
class ATBAPPplugin
{
class UnifiedDCVMCInterface;
public:
explicit ATBAPPplugin() = default;
virtual ~ATBAPPplugin() = default;
template <typename T>
struct ATBAPPplugin {
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_NETWORK,
ERROR_TIMEOUT, // the operation timed out
ERROR_PROCESS, // internal plugin error, should not occur (this is a bug in implementation)
ERROR_BUSY,
ERROR_STATE,
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
};
enum class STEP : quint8 {
UP = 1,
DOWN = 2
};
enum class TERMINAL_STATE : quint8 {
NOT_AVAILABLE = 1,
AVAILABLE,
PREPARED_FOR_VENDING,
BUSY,
NEEDS_MAINTENANCE
};
virtual const QString & getPluginInfo() = 0;
virtual void setPluginInfo(QString const &info) = 0;
virtual const QString &getPluginInfo() = 0;
virtual QStringList getPluginInfoList() {
return QStringList(QString());
}
};
Q_DECLARE_INTERFACE(ATBAPPplugin,
"eu.atb.ptu.plugin.ATBAPPplugin/0.9")
using PLUGIN_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::PLUGIN_STATE;
using RESULT_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::RESULT_STATE;
using CASH_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::CASH_STATE;
using TICKET_VARIANT = ATBAPPplugin<UnifiedDCVMCInterface>::TICKET_VARIANT;
using STEP = ATBAPPplugin<UnifiedDCVMCInterface>::STEP;
using TERMINAL_STATE = ATBAPPplugin<UnifiedDCVMCInterface>::TERMINAL_STATE;
//Q_DECLARE_INTERFACE(ATBAPPplugin,
// "eu.atb.ptu.plugin.ATBAPPplugin/0.9")
#endif // ATBAPPPLUGIN_H

View File

@@ -17,11 +17,20 @@ ATBVMCPlugin::ATBVMCPlugin(QObject *parent)
: VMCInterface(parent)
, m_errorCode("")
, m_errorDescription("")
, m_pluginInfo("")
, m_serialPortName("")
, m_useDebug(false)
, m_pluginState(PLUGIN_STATE::NOT_INITIALIZED)
, m_vmc(nullptr) {
m_pluginInfoList.clear();
m_pluginInfoList << QString(" Interface: ") + INTERFACE;
m_pluginInfoList << QString("Interface Version: ") + INTERFACE_VERSION;
m_pluginInfoList << QString(" PluginName: ") + PLUGIN_NAME;
m_pluginInfoList << QString(" Version: ") + PLUGIN_VERSION;
m_pluginInfoList << QString(" git-describe: ") + PLUGIN_GIT_DESCRIBE;
m_pluginInfoList << QString(" Extended version: ") + PLUGIN_EXTENDED_VERSION;
m_pluginInfo = m_pluginInfoList.join('\n');
}
ATBVMCPlugin::~ATBVMCPlugin() {
@@ -31,16 +40,34 @@ ATBVMCPlugin::~ATBVMCPlugin() {
}
}
QStringList ATBVMCPlugin::getPluginInfoList() {
return m_pluginInfoList;
}
QString const &ATBVMCPlugin::getPluginInfo() {
return m_pluginInfo;
}
void ATBVMCPlugin::setPluginInfo(QString const &info) {
m_pluginInfo = info;
}
// ----------------------------------------------------------------------------
// interface:
PLUGIN_STATE ATBVMCPlugin::initDCPlugin(QObject *eventReceiver, const QSettings & settings) {
Q_UNUSED(eventReceiver);
Q_UNUSED(settings);
return PLUGIN_STATE::NOT_INITIALIZED;
}
PLUGIN_STATE ATBVMCPlugin::initPlugin(QObject *eventReceiver, QObject *atbSystem, QObject *hmiConfig, QSettings const &settings) {
return initVMCPlugin(eventReceiver, atbSystem, hmiConfig, settings);
}
PLUGIN_STATE ATBVMCPlugin::initPlugin(QObject *eventReceiver, QSettings const &settings) {
Q_UNUSED(eventReceiver);
Q_UNUSED(settings);
return PLUGIN_STATE::NOT_INITIALIZED;
}
PLUGIN_STATE ATBVMCPlugin::initVMCPlugin(QObject *appControl,
QObject *atbSystem,
QObject *hmiConfig,
@@ -64,6 +91,8 @@ PLUGIN_STATE ATBVMCPlugin::initVMCPlugin(QObject *appControl,
connect(m_vmc, SIGNAL(setMachineNr(QString)), hmiConfig, SLOT(setMachineNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setDefaultLanguage(quint8)), hmiConfig, SLOT(setDefaultLanguage(quint8)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(wakeVMC()), m_vmc, SLOT(onWakeVMC()), Qt::QueuedConnection);
return PLUGIN_STATE::INITIALIZED;
}
@@ -75,22 +104,51 @@ PLUGIN_STATE ATBVMCPlugin::getState() {
return m_pluginState;
}
QString ATBVMCPlugin::getLastError() {
QString const &ATBVMCPlugin::getLastError() {
return m_errorCode;
}
QString ATBVMCPlugin::getLastErrorDescription() {
QString const &ATBVMCPlugin::getLastErrorDescription() {
return m_errorDescription;
}
#if 0
// helpers e.g. for debug / log
QString ATBVMCPlugin::getString(RESULT_STATE /*resultState*/) {
return "";
QString const &ATBVMCPlugin::getString(RESULT_STATE resultState) {
static QString str;
switch (resultState) {
case RESULT_STATE::SUCCESS:
str = QString("RESULT_STATE::SUCCESS");
break;
case RESULT_STATE::ERROR_BACKEND:
str = QString("RESULT_STATE::ERROR_BACKEND");
break;
case RESULT_STATE::ERROR_TIMEOUT:
str = QString("RESULT_STATE::ERROR_TIMEOUT");
break;
case RESULT_STATE::ERROR_PROCESS:
str = QString("RESULT_STATE::ERROR_PROCESS");
break;
case RESULT_STATE::ERROR_RETRY:
str = QString("RESULT_STATE::ERROR_RETRY");
break;
case RESULT_STATE::INFO:
str = QString("RESULT_STATE::INFO");
break;
case RESULT_STATE::ERROR_NETWORK:
str = QString("RESULT_STATE::ERROR_NETWORK");
break;
case RESULT_STATE::ERROR_BUSY:
str = QString("RESULT_STATE::ERROR_BUSY");
break;
case RESULT_STATE::ERROR_STATE:
str = QString("RESULT_STATE::ERROR_STATE");
break;
}
return str;
}
void ATBVMCPlugin::onChangedProgramModeToSELL() {
}
@@ -123,7 +181,18 @@ void ATBVMCPlugin::reset() {
}
#endif
QStringList ATBVMCPlugin::interfaces() const {
QStringList result;
int const count = this->metaObject()->classInfoCount();
for (int i = 0; i < count; ++i) {
QString const name(QString::fromLatin1(this->metaObject()->classInfo(i).name()));
QString const value(QString::fromLatin1(this->metaObject()->classInfo(i).value()));
if (name == "Interface") {
result << value;
}
}
return result;
}
#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(ATBVMCPlugin, ATBVMCPlugin)

View File

@@ -9,41 +9,41 @@
#include "src/ATBAPP/VMCInterface.h"
#include "src/ATBAPP/UnifiedDCVMCInterface.h"
#include "version.h"
#include "vmc.h"
class ATBVMCPlugin : public VMCInterface {
Q_OBJECT
Q_INTERFACES(VMCInterface)
Q_CLASSINFO("Interface", "VMCInterface")
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "eu.atb.ptu.plugin.ATBVMCPlugin" FILE "plugins/metadata.json")
Q_PLUGIN_METADATA(IID "eu.atb.ptu.plugin.ATBVMCPlugin")
#endif
public:
explicit ATBVMCPlugin(QObject *parent = nullptr);
virtual ~ATBVMCPlugin();
virtual const QString & getPluginInfo() override;
virtual void setPluginInfo(QString const &info) override;
virtual QStringList getPluginInfoList() override;
virtual const QString &getPluginInfo() override;
// ----------------------------------------------------------------------------
// interface:
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver,
QObject *atbSystem,
QObject *hmiConfig,
QSettings const &settings) override;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QObject *atbSystem, QObject *hmiConfig, QSettings const &settings) override;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QSettings const &settings) override;
virtual PLUGIN_STATE initDCPlugin(QObject *eventReceiver, const QSettings & settings) override;
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver, QObject *atbSystem, QObject *hmiConfig, QSettings const &settings) override;
// mandantory ATBAPP plugin methods: ------------------------------------------
PLUGIN_STATE getState() override;
QString getLastError() override;
QString getLastErrorDescription() override;
#if 0
QString const &getLastError() override;
QString const &getLastErrorDescription() override;
// helpers e.g. for debug / log
virtual QString getString(RESULT_STATE resultState) override;
virtual QString const &getString(RESULT_STATE resultState) override;
QStringList interfaces() const;
public slots:
virtual void onChangedProgramModeToSELL() override;
@@ -56,11 +56,10 @@ public slots:
virtual void reboot() override;
virtual void reset() override;
#endif
private:
QString m_errorCode;
QString m_errorDescription;
QStringList m_pluginInfoList;
QString m_pluginInfo;
QString m_serialPortName;
bool m_useDebug;

View File

@@ -12,60 +12,40 @@
#include "ATBAPPplugin.h"
class UnifiedDCVMCInterface : public ATBAPPplugin {
Q_INTERFACES(ATBAPPplugin)
class UnifiedDCVMCInterface : public ATBAPPplugin<UnifiedDCVMCInterface> {
//Q_INTERFACES(ATBAPPplugin)
//Q_CLASSINFO("Interface", "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() = default;
virtual const QString & getPluginInfo() = 0;
virtual QStringList getPluginInfoList() = 0;
virtual const QString &getPluginInfo() = 0;
// mandantory ATBAPP plugin methods:
virtual PLUGIN_STATE getState() = 0;
virtual QString getLastError() = 0;
virtual QString getLastErrorDescription() = 0;
virtual QString const &getLastError() = 0;
virtual QString const &getLastErrorDescription() = 0;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver,
QObject *atbSystem,
QObject *hmiConfig,
QSettings const &settings) = 0;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QSettings const &settings) = 0;
virtual PLUGIN_STATE initDCPlugin(QObject *eventReceiver,
const QSettings & settings) = 0;
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver,
QObject *atbSystem, QObject *hmiConfig,
QObject *atbSystem, QObject *hmiConfig,
const QSettings & settings) = 0;
#if 0
virtual QString getString(RESULT_STATE resultState) = 0;
virtual QString const &getString(RESULT_STATE resultState) = 0;
public slots:
//public slots:
virtual void onChangedProgramModeToSELL() = 0;
virtual void onChangedProgramModeToSERVICE() = 0;
virtual void onChangedProgramModeToIDLE() = 0;
@@ -75,79 +55,9 @@ public slots:
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);
#endif
};
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;
//Q_DECLARE_INTERFACE(UnifiedDCVMCInterface,
// "eu.atb.ptu.plugin.UnifiedDCVMCInterface/1.0")
#endif // UNIFIED_DCVMC_INTERFACE_H_INCLUDED

View File

@@ -20,13 +20,19 @@ namespace nsVMCInterface {
class VMCInterface : public QObject, public UnifiedDCVMCInterface {
Q_OBJECT
Q_INTERFACES(ATBAPPplugin UnifiedDCVMCInterface)
//Q_INTERFACES(ATBAPPplugin UnifiedDCVMCInterface)
//Q_INTERFACES(UnifiedDCVMCInterface)
//Q_CLASSINFO("Interface", "ATBAPPplugin")
//Q_CLASSINFO("Interface", "UnifiedDCVMCInterface")
public:
explicit VMCInterface(QObject *parent = nullptr) : QObject(parent) {}
virtual ~VMCInterface() = default;
virtual QStringList getPluginInfoList() = 0;
virtual const QString &getPluginInfo() = 0;
virtual QString const &getString(RESULT_STATE resultState) = 0;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QObject *atbSystem,
QObject *hmiConfig, QSettings const &settings) override {
return initVMCPlugin(eventReceiver, atbSystem, hmiConfig, settings);
@@ -41,86 +47,6 @@ public:
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver,
QObject *atbSystem, QObject *hmiConfig,
const QSettings & settings) = 0;
#if 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);
#endif
};
Q_DECLARE_INTERFACE(VMCInterface,

View File

@@ -2,7 +2,6 @@
#include "SendBuffer.h"
#include "vmc.h"
#include <QDebug>
#include "version.h"
SendBuffer::SendBuffer(COM_interface *cinterface, QObject *parent) :
QObject(parent)

View File

@@ -1,5 +1,4 @@
#include "vmc.h"
#include "version.h"
#include "ATBAPP.h"
#include <QObject>
@@ -14,6 +13,13 @@
VMC::VMC(QObject *appControl, QSettings const *settings,
QObject *parent)
: QObject(parent) {
this->REMOTE_OUT_gpio_outstream = nullptr;
this->REMOTE_OUT_gpio = nullptr;
this->sendBuffer = nullptr;
this->receiveBuffer = nullptr;
this->com_interface = nullptr;
this->flag_blockVMCScreen = 0;
this->currentCachedScreen = VMC_CMD_SCREEN_START;
@@ -24,6 +30,8 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
this->receiveBuffer = new ReceiveBuffer(com_interface, this);
this->sendBuffer = new SendBuffer(com_interface, this);
this->privateInit_REMOTE_OUT();
connect(receiveBuffer, SIGNAL(ReceiveResponse(quint8)), sendBuffer, SLOT(onReceiveResponse(quint8)));
com_interface->open(settings->value("VMC/serialPort", "ttymxc2").toString(),
@@ -42,11 +50,59 @@ VMC::VMC(QObject *appControl, QSettings const *settings,
VMC::~VMC() {
delete(this->sendBuffer);
delete(this->receiveBuffer);
delete(this->com_interface);
if (this->REMOTE_OUT_gpio_outstream) {
delete(this->REMOTE_OUT_gpio_outstream);
}
if (this->REMOTE_OUT_gpio) {
delete(this->REMOTE_OUT_gpio);
}
if (this->sendBuffer) {
delete(this->sendBuffer);
}
if (this->receiveBuffer) {
delete(this->receiveBuffer);
}
if (this->com_interface) {
delete(this->com_interface);
}
}
/*****************************************************************************
* functions for wake vmc
*/
void VMC::onWakeVMC() {
this->privateWakeVMC();
}
void VMC::privateWakeVMC() {
QTimer::singleShot (100, this, SLOT(privateSuspendVMC()));
this->privateSet_REMOTE_OUT(true);
}
void VMC::privateSuspendVMC() {
this->privateSet_REMOTE_OUT(false);
}
void VMC::privateSet_REMOTE_OUT(bool state) {
if (state) { *(this->REMOTE_OUT_gpio_outstream) << "1"; }
else { *(this->REMOTE_OUT_gpio_outstream) << "0"; }
this->REMOTE_OUT_gpio_outstream->flush();
}
void VMC::privateInit_REMOTE_OUT() {
QString sysfs_remout_out("/sys/class/leds/REMOTE_OUT/brightness");
this->REMOTE_OUT_gpio = new QFile(sysfs_remout_out);
if (!REMOTE_OUT_gpio->open(QIODevice::WriteOnly | QIODevice::Text)) {
qDebug() << "ATB_system::privateInit_REMOTE_OUT() cannot open file: " << sysfs_remout_out;
qDebug() << " file.errorString() = " << REMOTE_OUT_gpio->errorString();
return;
}
this->REMOTE_OUT_gpio_outstream = new QTextStream(this->REMOTE_OUT_gpio);
}
/********************************************************************************
* S E N D M E S S A G E S t o V M C

View File

@@ -11,7 +11,8 @@
#include <QTimer>
#include <QList>
#include <QSettings>
#include "version.h"
#include <QFile>
#include <QTextStream>
#define VMC_RECEIVE_TIMEOUT 1000
@@ -148,11 +149,8 @@ class SendBuffer;
using FormatedStringList = QList<QByteArray>;
class VMC : public QObject
{
class VMC : public QObject {
Q_OBJECT
private:
QObject *m_appControl;
COM_interface *com_interface;
@@ -160,6 +158,9 @@ private:
SendBuffer *sendBuffer;
QSettings const *m_settings;
QFile *REMOTE_OUT_gpio;
QTextStream *REMOTE_OUT_gpio_outstream;
// internal: write a ByteArray to com-port:
int SendMessage(QByteArray ba, bool enqueue = false);
@@ -186,10 +187,14 @@ private:
quint8 flag_blockVMCScreen;
quint16 currentCachedScreen;
void privateInit_REMOTE_OUT();
private slots:
void onDelayedMessageTimerTimeout();
void skipDiscount();
void privateSet_REMOTE_OUT(bool state);
void privateWakeVMC();
void privateSuspendVMC();
public:
explicit VMC(QObject *eventReceiver, QSettings const *settings,
@@ -388,6 +393,8 @@ public slots:
void ccStartTransactionRequest(); // called to start/restart a CC transaction
void ccStartConfirmTransaction(); // called to start confirmation
void ccPrintReceipt(QString receipt); // called to send receipt to vmc
void onWakeVMC();
};
#endif // VMC_H

View File

@@ -1,7 +1,6 @@
#include "VendingData.h"
#include <QDebug>
#include "ATBAPP.h"
#include "version.h"
VendingData::VendingData(QObject *parent) : QObject(parent)
{