Compare commits

...

42 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
909d1355a0 Declare pure virtual function setPluginInfo() 2023-11-14 14:55:42 +01:00
35f3c5f0a1 implement setPluginInfo() 2023-11-14 14:54:58 +01:00
1c2ac9f4da add handling for meta-data json file 2023-11-14 14:53:52 +01:00
078dd94e60 add meta-data json file 2023-11-14 14:53:11 +01:00
ed8505c177 add meta-info for this plugin 2023-11-14 14:49:51 +01:00
63b4d7577d Delete needless interfaces.h 2023-11-14 13:45:08 +01:00
fc70115079 Minor: comment out some code. 2023-11-14 13:41:09 +01:00
f96ac85a18 Derive from QObject so we can load the VMCInterface.
Add pure virtual functions initPlugin() and initVMCPlugin().
Minor: comment out some code.
2023-11-14 13:39:06 +01:00
028792143a Mior: comment some parts out. 2023-11-14 13:38:08 +01:00
d15d15b55a Add pure virtual functions initPlugin() and initVMCPlugin(). 2023-11-14 13:37:31 +01:00
5f7fc7f168 Do not derive UnifiedDCVMCInterface from QObject. Otherwise we can not load VMCInterface. 2023-11-14 13:36:04 +01:00
0f6e666124 Added default ctor and virtual default dtor 2023-11-14 13:33:59 +01:00
27bc4afd51 Added ATBAPPplugin 2023-11-14 13:32:51 +01:00
12 changed files with 344 additions and 1835 deletions

View File

@@ -5,12 +5,8 @@ QT += serialport
INCLUDEPATH+=$$_PRO_FILE_PWD_
INCLUDEPATH+=$$_PRO_FILE_PWD_/support
INCLUDEPATH+=$$_PRO_FILE_PWD_/plugins
INCLUDEPATH+=$$_PRO_FILE_PWD_/include
INCLUDEPATH+=$$_PRO_FILE_PWD_/HMI
INCLUDEPATH+=$$_PRO_FILE_PWD_/HMI/screens
INCLUDEPATH+=$$_PRO_FILE_PWD_/HMI/support
INCLUDEPATH+=$$_PRO_FILE_PWD_/src
INCLUDEPATH+=$$_PRO_FILE_PWD_/src/ATBAPP
INCLUDEPATH+=$$_PRO_FILE_PWD_/src/ATBAPP/support
@@ -21,12 +17,11 @@ QMAKE_CXXFLAGS += -Wno-deprecated-copy -O
# default
ARCH = PTU5
DEFINES+=ATB_QT_VERSION=\\\"5.11\\\"
contains( CONFIG, DesktopLinux ) {
QMAKE_CC = ccache $$QMAKE_CC
QMAKE_CXX = ccache $$QMAKE_CXX
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -std=c++17
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
ARCH = DesktopLinux
@@ -35,7 +30,7 @@ contains( CONFIG, DesktopLinux ) {
contains( CONFIG, PTU5 ) {
# QMAKE_CC = ccache $$QMAKE_CC
# QMAKE_CXX = ccache $$QMAKE_CXX
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -std=c++17
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
CONFIG += link_pkgconfig
ARCH = PTU5
@@ -51,12 +46,44 @@ contains( CONFIG, PTU5_YOCTO ) {
}
TARGET = ATBVMCPlugin
#DESTDIR = ../plugins
VERSION = "0.8.0"
INTERFACE = VMCInterface
INTERFACE_DEFINITION = $${PWD}/src/ATBAPP/VMCInterface.h
DEFINES += VMCPLUGIN_LIBRARY
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")
}
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+=ATB_QT_VERSION=\\\"$${QT_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
#else: unix:!android: target.path = /opt/$${TARGET}/bin
@@ -64,9 +91,9 @@ DEFINES += VMCPLUGIN_LIBRARY
# ATBAPP interface
HEADERS += \
include/interfaces.h \
src/ATBAPP/VMCInterface.h \
src/ATBAPP/ATBVMCPlugin.h \
src/ATBAPP/ATBAPPplugin.h \
src/ATBAPP/UnifiedDCVMCInterface.h \
src/ATBAPP/support/VMC/com_interface.h \
src/ATBAPP/support/VMC/ReceiveBuffer.h \
@@ -81,17 +108,3 @@ SOURCES += \
src/ATBAPP/support/VMC/SendBuffer.cpp \
src/ATBAPP/support/VMC/vmc.cpp \
src/ATBAPP/support/VendingData.cpp
DISTFILES += \
generate-version.sh
# Define how to create version.h
VERSION_H = $$PWD/include/version.h
version.output = $$PWD/include/version.h
version.commands = $$PWD/generate-version.sh $${ARCH} $${TARGET} $${INTERFACE} $${INTERFACE_DEFINITION} $${VERSION_H}
version.depends = FORCE
version.input = VERSION_H
version.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += version
QMAKE_CLEAN += $${PWD}/include/version.h

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}

File diff suppressed because it is too large Load Diff

View File

@@ -5,13 +5,66 @@
* a simple class with only one method for plugin info
*/
#include <QObject>
#include <QString>
#include <QStringList>
class ATBAPPplugin {
public:
virtual const QString & getPluginInfo() = 0;
class UnifiedDCVMCInterface;
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 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,58 +40,115 @@ ATBVMCPlugin::~ATBVMCPlugin() {
}
}
QStringList ATBVMCPlugin::getPluginInfoList() {
return m_pluginInfoList;
}
QString const &ATBVMCPlugin::getPluginInfo() {
return m_pluginInfo;
}
// ----------------------------------------------------------------------------
// 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,
QSettings const &settings) {
if (appControl && atbSystem && hmiConfig) {
m_vmc = new VMC(appControl, &settings);
m_vmc = new VMC(appControl, &settings);
// -------------------- connect vmc --------------------------------------------
connect(m_vmc, SIGNAL(VMCFormatedString(FormatedStringList)), appControl, SLOT(onVMCFormatedString(FormatedStringList)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(displayData(quint8,QString)), appControl, SLOT(onVMCSellData(quint8,QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(retriggerModeSell()), appControl, SLOT(restartSellModeTimeoutTimer()), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setVendingData(QString,QByteArray)), appControl, SLOT(onSetVendingData(QString,QByteArray)), Qt::QueuedConnection);
// -------------------- connect vmc --------------------------------------------
connect(m_vmc, SIGNAL(VMCFormatedString(FormatedStringList)), appControl, SLOT(onVMCFormatedString(FormatedStringList)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(displayData(quint8,QString)), appControl, SLOT(onVMCSellData(quint8,QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(retriggerModeSell()), appControl, SLOT(restartSellModeTimeoutTimer()), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setVendingData(QString,QByteArray)), appControl, SLOT(onSetVendingData(QString,QByteArray)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(sysCommand(quint16, QByteArray)), atbSystem, SLOT(executeSystemCommand(quint16, QByteArray)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(newDateTime(QString)), atbSystem, SLOT(setDateTime(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(wakeVMC()), atbSystem, SLOT(onWakeVMC()));
connect(m_vmc, SIGNAL(sysCommand(quint16, QByteArray)), atbSystem, SLOT(executeSystemCommand(quint16, QByteArray)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(newDateTime(QString)), atbSystem, SLOT(setDateTime(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(wakeVMC()), atbSystem, SLOT(onWakeVMC()));
connect(m_vmc, SIGNAL(setCustNr(QString)), hmiConfig, SLOT(setCustNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setGroupNr(QString)), hmiConfig, SLOT(setGroupNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setZoneNr(QString)), hmiConfig, SLOT(setZoneNr(QString)), Qt::QueuedConnection);
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(setCustNr(QString)), hmiConfig, SLOT(setCustNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setGroupNr(QString)), hmiConfig, SLOT(setGroupNr(QString)), Qt::QueuedConnection);
connect(m_vmc, SIGNAL(setZoneNr(QString)), hmiConfig, SLOT(setZoneNr(QString)), Qt::QueuedConnection);
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;
return PLUGIN_STATE::INITIALIZED;
}
return PLUGIN_STATE::NOT_INITIALIZED;
}
// mandantory ATBAPP plugin methods: ------------------------------------------
PLUGIN_STATE ATBVMCPlugin::getState() {
return PLUGIN_STATE::NOT_INITIALIZED;
return m_pluginState;
}
QString ATBVMCPlugin::getLastError() {
return "";
QString const &ATBVMCPlugin::getLastError() {
return m_errorCode;
}
QString ATBVMCPlugin::getLastErrorDescription() {
return "";
}
QString const &ATBVMCPlugin::getPluginInfo() {
static QString info;
return info;
QString const &ATBVMCPlugin::getLastErrorDescription() {
return m_errorDescription;
}
// 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() {
}
@@ -114,3 +180,20 @@ void ATBVMCPlugin::reboot() {
void ATBVMCPlugin::reset() {
}
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)
#endif

View File

@@ -3,43 +3,47 @@
#include <QObject>
#include <QSettings>
#include <QtPlugin>
#include "src/ATBAPP/VMCInterface.h"
#include "src/ATBAPP/ATBAPPplugin.h"
#include "src/ATBAPP/VMCInterface.h"
#include "src/ATBAPP/UnifiedDCVMCInterface.h"
#include "version.h"
#include "include/interfaces.h"
#include "vmc.h"
class ATBVMCPlugin : public VMCInterface {
Q_OBJECT
Q_INTERFACES(ATBAPPplugin)
Q_INTERFACES(UnifiedDCVMCInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA( IID "ATBVMCPlugin" )
#endif
Q_INTERFACES(VMCInterface)
Q_CLASSINFO("Interface", "VMCInterface")
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "eu.atb.ptu.plugin.ATBVMCPlugin")
#endif
public:
explicit ATBVMCPlugin(QObject *parent = nullptr);
~ATBVMCPlugin();
virtual ~ATBVMCPlugin();
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;
virtual const QString & getPluginInfo() override;
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;
@@ -55,6 +59,7 @@ public slots:
private:
QString m_errorCode;
QString m_errorDescription;
QStringList m_pluginInfoList;
QString m_pluginInfo;
QString m_serialPortName;
bool m_useDebug;

View File

@@ -11,58 +11,41 @@
#include "ATBAPPplugin.h"
class ATBHMIconfig;
class AppControl;
class ATBSystem;
class UnifiedDCVMCInterface : public QObject, public ATBAPPplugin {
Q_OBJECT
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;
explicit UnifiedDCVMCInterface(QObject *parent = nullptr) : QObject(parent) {}
virtual ~UnifiedDCVMCInterface() {}
virtual QStringList getPluginInfoList() = 0;
virtual const QString &getPluginInfo() = 0;
// mandantory ATBAPP plugin methods:
virtual PLUGIN_STATE getState() = 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;
// mandantory ATBAPP plugin methods:
virtual PLUGIN_STATE getState() = 0;
virtual QString getLastError() = 0;
virtual QString getLastErrorDescription() = 0;
virtual PLUGIN_STATE initPlugin(QObject *eventReceiver, QSettings const &settings) = 0;
virtual QString getString(RESULT_STATE resultState) = 0;
virtual PLUGIN_STATE initDCPlugin(QObject *eventReceiver,
const QSettings & settings) = 0;
public slots:
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver,
QObject *atbSystem, QObject *hmiConfig,
const QSettings & settings) = 0;
virtual QString const &getString(RESULT_STATE resultState) = 0;
//public slots:
virtual void onChangedProgramModeToSELL() = 0;
virtual void onChangedProgramModeToSERVICE() = 0;
virtual void onChangedProgramModeToIDLE() = 0;
@@ -72,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);
};
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

@@ -17,33 +17,39 @@ namespace nsVMCInterface {
}
class VMCInterface : public UnifiedDCVMCInterface {
class VMCInterface : public QObject, public UnifiedDCVMCInterface {
Q_OBJECT
Q_INTERFACES(ATBAPPplugin)
Q_INTERFACES(UnifiedDCVMCInterface)
//Q_INTERFACES(ATBAPPplugin UnifiedDCVMCInterface)
//Q_INTERFACES(UnifiedDCVMCInterface)
//Q_CLASSINFO("Interface", "ATBAPPplugin")
//Q_CLASSINFO("Interface", "UnifiedDCVMCInterface")
public:
explicit VMCInterface(QObject *parent = nullptr)
: UnifiedDCVMCInterface(parent) {}
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);
}
virtual ~VMCInterface() {}
/**
* @brief initDCPlugin
* @brief initVMCPlugin
* @param eventReceiver - QObject to receive ATBMachineEvents or HealthEvents
* @param settings
* @return
*/
virtual PLUGIN_STATE initVMCPlugin(QObject *eventReceiver,
QObject *atbSystem, QObject *hmiConfig,
const QSettings & settings) = 0;
QObject *atbSystem, QObject *hmiConfig,
const QSettings & settings) = 0;
};
Q_DECLARE_INTERFACE(VMCInterface,
"eu.atb.ptu.plugin.VMCInterface/1.0")
#endif // VMCINTERFACE_H

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)
{