Compare commits
132 Commits
f64b3f716d
...
pu/account
Author | SHA1 | Date | |
---|---|---|---|
18ff5d42a7
|
|||
ac9486879e
|
|||
1467530e3c
|
|||
414dda009e
|
|||
74753ce644
|
|||
c4cbf89182
|
|||
0baad4689a
|
|||
a4a746658c
|
|||
7e65c4feda
|
|||
e236fc8bce
|
|||
76e67dbbaa
|
|||
b52de16dbc
|
|||
cade03b400
|
|||
7a9f837b88
|
|||
b10e597e59
|
|||
4cc4247744
|
|||
59432735d0
|
|||
1f0720e52b
|
|||
5f3e0babb1
|
|||
f2637e3af8
|
|||
ac6331e5a7
|
|||
7ccbc8bb23
|
|||
017543dd5b
|
|||
d5d2b8917a
|
|||
9d686ae48d
|
|||
a037626d6d
|
|||
a3f32b576e
|
|||
668b10e55d
|
|||
596cf3ed25
|
|||
c330be4f30
|
|||
3722dd4d28
|
|||
f5568f6f81
|
|||
98ef7b7b26
|
|||
2717c614e3
|
|||
de1dc88e51
|
|||
50bf7e8b52
|
|||
d8d315cd49
|
|||
84859064a3
|
|||
ff4c52ddc9
|
|||
f4be010e1a
|
|||
75b597586f
|
|||
88cc71e05f
|
|||
6f00d5b356
|
|||
1f9cc3b8c0
|
|||
584e3af035
|
|||
2ac0f5b275
|
|||
a97ef4ea04
|
|||
30d790b84f
|
|||
ca5e43e0d7
|
|||
3ac91305d4
|
|||
d0445949d2
|
|||
91d9280a4a
|
|||
48d6a34b16
|
|||
e32142cd62
|
|||
f611e07dcf
|
|||
6478eda581
|
|||
1663d09d3a
|
|||
080c00eda1
|
|||
bbce2b02e3
|
|||
8ff17a2e00
|
|||
c6574280ac
|
|||
f0f0493d19
|
|||
9bf99c5515
|
|||
8ff8faf007
|
|||
09a80498e4
|
|||
21fb07b81c
|
|||
01f8c1e49c
|
|||
3029b8da04
|
|||
2143801900
|
|||
6f6d3b7491
|
|||
4cfb8f1804
|
|||
d992ee3fad | |||
b7d8fabfd0 | |||
7129805f4e | |||
01140c523b | |||
c99d0730ce | |||
81c610c48b | |||
6ae7c06d42 | |||
1eb2ac3a1d | |||
f3adba2f0f | |||
652ad9b43d | |||
c85b090306 | |||
87a6ed0795 | |||
99c88c7825 | |||
712ea0fc6e | |||
86311de486 | |||
cb4412779f | |||
a95e174356 | |||
c724b5b9fb | |||
ef7932102f | |||
a7aa75ae5f | |||
dc00c69b82 | |||
eeb35190e1 | |||
30338e24cc | |||
58fdea45f0 | |||
df760f1a52 | |||
3e3e1efe7d | |||
e5a8cfd1cd | |||
5e6e6017b3 | |||
f3d9c690b7 | |||
3f10469b8f | |||
d92bdbfb3e | |||
60c48588b0 | |||
ef48301dad | |||
5f7d34ef12 | |||
863e4b23a9 | |||
37f0012ce9 | |||
82accc4b1a | |||
c1b945225b | |||
debade9942 | |||
ffbe0dfc2e | |||
8f7d4a203d | |||
defe492ec6 | |||
002d58ba7b | |||
76f54cdc0c | |||
591fd89cb5 | |||
e7723f669f | |||
d0e1be11b6 | |||
f63798727f | |||
898f0a4af8 | |||
ed037b99c9 | |||
e4a2f8fce3 | |||
19befc2c58 | |||
7f23e3ea46 | |||
49396c22ee | |||
0b87f44e64 | |||
66b22a4233 | |||
ba5d23d8be | |||
75acd1e3ec | |||
48a0068ebd | |||
f51062010e | |||
a9a5210029 |
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# C++ objects and libs
|
||||
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
moc_*.cpp
|
||||
qrc_*.cpp
|
||||
Makefile
|
||||
Makefile.*
|
||||
*-build-*
|
||||
|
||||
#
|
||||
*.autosave
|
||||
ui_*.h
|
||||
version.h
|
||||
version.txt
|
||||
|
||||
packages/*
|
||||
*.pro.orig
|
||||
Output/setup.exe
|
||||
.directory
|
||||
|
||||
*~
|
||||
resources/icons/*.png
|
||||
resources/icons/*.jpg
|
||||
resources/icons/*.gif
|
||||
resources/style/*.qss
|
||||
text/*.html
|
||||
!text/*_template.html
|
||||
text/*.xml
|
96
DCPlugin.pro
Normal file
96
DCPlugin.pro
Normal file
@@ -0,0 +1,96 @@
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin
|
||||
#CONFIG += c++11 console
|
||||
#CONFIG -= app_bundle
|
||||
#QT += widgets
|
||||
QT -= gui
|
||||
QT += serialport
|
||||
|
||||
INCLUDEPATH += $${PWD}/plugins
|
||||
INCLUDEPATH += $${PWD}/include
|
||||
|
||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||
|
||||
# default
|
||||
ARCH = PTU5
|
||||
|
||||
|
||||
contains( CONFIG, DesktopLinux ) {
|
||||
QMAKE_CC = ccache $$QMAKE_CC
|
||||
QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
ARCH = DesktopLinux
|
||||
}
|
||||
|
||||
contains( CONFIG, PTU5 ) {
|
||||
# QMAKE_CC = ccache $$QMAKE_CC
|
||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||
CONFIG += link_pkgconfig
|
||||
ARCH = PTU5
|
||||
}
|
||||
|
||||
contains( CONFIG, PTU5_YOCTO ) {
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||
PTU5BASEPATH = /opt/devel/ptu5
|
||||
ARCH = PTU5
|
||||
|
||||
# add qmqtt lib
|
||||
#LIBS += -lQt5Qmqtt
|
||||
}
|
||||
|
||||
TARGET = ATBDeviceControllerPlugin
|
||||
#DESTDIR = ../plugins
|
||||
INTERFACE = DeviceController
|
||||
INTERFACE_DEFINITION = $${PWD}/include/ATBAPP/DeviceControllerInterface.h
|
||||
|
||||
DEFINES += DEVICECONTROLLERPLUGIN_LIBRARY
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any Qt feature that has been marked deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
|
||||
# Default rules for deployment.
|
||||
#qnx: target.path = /tmp/$${TARGET}/bin
|
||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
#!isEmpty(target.path): INSTALLS += target
|
||||
|
||||
# ATBAPP interface
|
||||
HEADERS += \
|
||||
include/interfaces.h \
|
||||
src/ATBAPP/ATBAPPplugin.h \
|
||||
src/ATBAPP/DeviceControllerInterface.h \
|
||||
src/ATBAPP/ATBHealthEvent.h \
|
||||
src/ATBAPP/ATBDeviceControllerPlugin.h \
|
||||
src/ATBAPP/Utils.h
|
||||
|
||||
SOURCES += \
|
||||
src/ATBAPP/ATBHealthEvent.cpp \
|
||||
src/ATBAPP/ATBDeviceControllerPlugin.cpp \
|
||||
src/ATBAPP/Utils.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
|
155
generate-version.sh
Executable file
155
generate-version.sh
Executable file
@@ -0,0 +1,155 @@
|
||||
#!/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)
|
||||
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")
|
||||
# -> 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}
|
||||
|
||||
|
||||
|
||||
|
||||
|
1350
include/interfaces.h
Executable file
1350
include/interfaces.h
Executable file
File diff suppressed because it is too large
Load Diff
22
src/ATBAPP/ATBAPPplugin.h
Normal file
22
src/ATBAPP/ATBAPPplugin.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef ATBAPPPLUGIN_H
|
||||
#define ATBAPPPLUGIN_H
|
||||
|
||||
/***********************************************************
|
||||
* a simple class with only one method for plugin info
|
||||
*/
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class ATBAPPplugin
|
||||
{
|
||||
|
||||
public:
|
||||
virtual const QString & getPluginInfo() = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(ATBAPPplugin,
|
||||
"eu.atb.ptu.plugin.ATBAPPplugin/0.9")
|
||||
|
||||
|
||||
|
||||
#endif // ATBAPPPLUGIN_H
|
684
src/ATBAPP/ATBDeviceControllerPlugin.cpp
Normal file
684
src/ATBAPP/ATBDeviceControllerPlugin.cpp
Normal file
@@ -0,0 +1,684 @@
|
||||
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
|
||||
#include "src/ATBAPP/ATBHealthEvent.h"
|
||||
#include "src/ATBAPP/Utils.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QTextCodec>
|
||||
#include <QDebug>
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QDateTime>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
|
||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
|
||||
pluginState(PLUGIN_STATE::NOT_INITIALIZED)
|
||||
{
|
||||
this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
|
||||
|
||||
if (!this->private_loadCashAgentLib("")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()), this, SLOT(onPrintFinishedOK()), Qt::QueuedConnection);
|
||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()), Qt::QueuedConnection);
|
||||
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()), this, SLOT(onCashGotCoin()), Qt::QueuedConnection);
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByMax()), this, SLOT(onCashPayStopByMax()), Qt::QueuedConnection);
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByEscrow()), this, SLOT(onCashPayStopByEscrow()), Qt::QueuedConnection);
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByError()), this, SLOT(onCashPayStopByError()), Qt::QueuedConnection);
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_payStopByTimeout()), this, SLOT(onCashPayStopByTimeout()), Qt::QueuedConnection);
|
||||
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorServiceDoorOpened()), this, SLOT(onServiceDoorOpened()), Qt::QueuedConnection); // switch to ModeSERVICE
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorVaultDoorOpened()), this, SLOT(onVaultDoorOpened()), Qt::QueuedConnection); // Screen?? with message
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxRemoved()), this, SLOT(onCoinBoxRemoved()), Qt::QueuedConnection); // Create/Send Account
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCoinBoxInserted()), this, SLOT(onCoinBoxInserted()), Qt::QueuedConnection);
|
||||
//connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorCBinAndAllDoorsClosed()), this, SLOT( ??? )), Qt::QueuedConnection);
|
||||
connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_doorAllDoorsClosed()), this, SLOT(onAllDoorsClosed()), Qt::QueuedConnection); // check for errors, switch to mode IDLE
|
||||
|
||||
|
||||
this->currentSelectedTicketType = 0;
|
||||
this->currentCashState = CASH_STATE::CACHE_EMPTY;
|
||||
}
|
||||
|
||||
ATBDeviceControllerPlugin::~ATBDeviceControllerPlugin() {}
|
||||
|
||||
PLUGIN_STATE ATBDeviceControllerPlugin::initDCPlugin(QObject *healthEventReceiver, const QSettings & settings)
|
||||
{
|
||||
this->healthEventReceiver = healthEventReceiver;
|
||||
|
||||
// read variables from setting
|
||||
QString serialPort = settings.value("DEVICE_CONTROLLER/serialPort", "ttymxc2").toString();
|
||||
QByteArray printerEncoding = settings.value("DEVICE_CONTROLLER/printerEnconding", "ISO 8859-2").toString().toLatin1();
|
||||
|
||||
// open serial port
|
||||
hw->dc_openSerial(5, "115200", serialPort, 1);
|
||||
|
||||
hw->dc_autoRequest(true);
|
||||
|
||||
hw->rtc_setDateTime();
|
||||
|
||||
// this is necessary to init the CashAgentLib (!)
|
||||
hw->vend_failed();
|
||||
|
||||
|
||||
// text encoding for printer
|
||||
this->codec = QTextCodec::codecForName(printerEncoding);
|
||||
|
||||
|
||||
|
||||
this->pluginState = PLUGIN_STATE::INITIALIZED;
|
||||
|
||||
return pluginState;
|
||||
}
|
||||
|
||||
|
||||
// Handle Mode-Changes --------------------------------------------------------
|
||||
|
||||
void ATBDeviceControllerPlugin::onChangedProgramModeToSELL()
|
||||
{
|
||||
//hw->dc_autoRequest(true);
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onChangedProgramModeToSERVICE()
|
||||
{
|
||||
//hw->dc_autoRequest(true);
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onChangedProgramModeToIDLE()
|
||||
{
|
||||
//hw->dc_autoRequest(false); // <-- TODO: ???
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onChangedProgramModeToOOO()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TASKS: Cash handling -------------------------------------------------------
|
||||
void ATBDeviceControllerPlugin::requestStartCashInput(const QString & amount)
|
||||
{
|
||||
qCritical() << "Start Cash vending with amount = " << amount;
|
||||
|
||||
uint32_t amountInt = static_cast<uint32_t>(amount.toUInt());
|
||||
|
||||
if (amountInt == 0) amountInt = UINT_MAX;
|
||||
|
||||
hw->cash_startPayment(amountInt);
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::requestStopCashInput()
|
||||
{
|
||||
hw->cash_stopPayment();
|
||||
|
||||
// we need new cash value in application...
|
||||
QTimer::singleShot(500, this, SLOT(onCashPayStopedSuccess()));
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::cashCollect()
|
||||
{
|
||||
hw->vend_success();
|
||||
this->currentCashState = CASH_STATE::CACHE_EMPTY;
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::cashAbort()
|
||||
{
|
||||
hw->vend_failed();
|
||||
this->currentCashState = CASH_STATE::CACHE_EMPTY;
|
||||
}
|
||||
|
||||
// TASKS: Account -------------------------------------------------------------
|
||||
|
||||
// for an external account request, e.g. by an ui-button:
|
||||
void ATBDeviceControllerPlugin::requestAccount()
|
||||
{
|
||||
qCritical() << "ATBDeviceControllerPlugin::requestAccount()";
|
||||
|
||||
this->private_startAccount();
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::private_startAccount()
|
||||
{
|
||||
uint16_t backupedAccNumbers[8]; // array of account numbers
|
||||
uint8_t nrOfVals; // number of saved accounts
|
||||
|
||||
// it is not defined which one is the latest account
|
||||
hw->log_getHoldAccountNumbers(&nrOfVals, backupedAccNumbers);
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "Start account: ";
|
||||
qCritical() << " nrOfVals = " << nrOfVals;
|
||||
for (int i=0; i<nrOfVals; ++i) {
|
||||
qCritical() << " backupedAccNumbers[" << i << "] = " << backupedAccNumbers[0];
|
||||
}
|
||||
|
||||
qsort( backupedAccNumbers, nrOfVals, sizeof (uint16_t), Utils::compare );
|
||||
|
||||
uint16_t latestAccountNumber = backupedAccNumbers[nrOfVals-1];
|
||||
|
||||
|
||||
// DEBUG
|
||||
qCritical() << " latestAccountNumber = " << latestAccountNumber;
|
||||
|
||||
hw->log_selectVaultRecord(latestAccountNumber);
|
||||
|
||||
this->accountCheckCounter = 0;
|
||||
QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::private_checkAccountData()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << " --> private_checkAccountData()";
|
||||
|
||||
if (hw->log_chkIfVaultRecordAvailable()) {
|
||||
this->private_getAccountData();
|
||||
}
|
||||
else {
|
||||
if (this->accountCheckCounter < 10) {
|
||||
this->accountCheckCounter++;
|
||||
QTimer::singleShot(500, this, SLOT(private_checkAccountData()));
|
||||
}
|
||||
else {
|
||||
// cannot get accountData within ~10*500ms
|
||||
qCritical() << "checkAccountData() failed";
|
||||
|
||||
// TODO: create and send an HealthEvent...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ATBDeviceControllerPlugin::private_getAccountData()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << " --> private_getAccountData()";
|
||||
|
||||
struct T_vaultRecord retVR;
|
||||
|
||||
hw->log_getVaultRecord(&retVR);
|
||||
|
||||
QHash<QString, QVariant> accountData;
|
||||
|
||||
accountData.insert("AccountingNumber", QString::number(retVR.AccountingNumber));
|
||||
|
||||
for (uint i = 0; i < sizeof(retVR.coinsInVault); ++i) {
|
||||
accountData.insert("COIN_" + QString::number(i) + "_Quantity", retVR.coinsInVault[i]);
|
||||
accountData.insert("COIN_" + QString::number(i) + "_Value", retVR.coinDenomination[i]);
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "COIN_" + QString::number(i) + "_Quantity = " << accountData["COIN_" + QString::number(i) + "_Quantity"];
|
||||
qCritical() << "COIN_" + QString::number(i) + "_Value = " << accountData["COIN_" + QString::number(i) + "_Value"];
|
||||
}
|
||||
|
||||
emit requestAccountResponse(accountData);
|
||||
}
|
||||
|
||||
|
||||
// Door Events / Hardware contacts --------------------------------------------
|
||||
void ATBDeviceControllerPlugin::onServiceDoorOpened()
|
||||
{
|
||||
qCritical() << "ATBDeviceControllerPlugin::onServiceDoorOpened()";
|
||||
|
||||
// switch to mode service
|
||||
emit this->requestModeSERVICE();
|
||||
|
||||
// TODO:
|
||||
// - create an HealthEvent (-> ISMAS-Event)
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onVaultDoorOpened()
|
||||
{
|
||||
// TODO:
|
||||
// - show special screen / message on screen
|
||||
// - create an HealthEvent (-> ISMAS-Event)
|
||||
qCritical() << "ATBDeviceControllerPlugin::onVaultDoorOpened()";
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCoinBoxRemoved()
|
||||
{
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxRemoved()";
|
||||
|
||||
this->private_startAccount();
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCoinBoxInserted()
|
||||
{
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCoinBoxInserted()";
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onAllDoorsClosed()
|
||||
{
|
||||
// TODO:
|
||||
// - check for errors, switch to mode IDLE
|
||||
|
||||
qCritical() << "ATBDeviceControllerPlugin::onAllDoorsClosed()";
|
||||
|
||||
emit this->requestModeIDLE();
|
||||
}
|
||||
|
||||
|
||||
// TASKS: printing ------------------------------------------------------------
|
||||
void ATBDeviceControllerPlugin::requestPrintTicket(const QHash<QString, QVariant> & printingData)
|
||||
{
|
||||
struct T_dynDat *dynTicketData = new T_dynDat;
|
||||
memset(dynTicketData, 0, sizeof(*dynTicketData));
|
||||
|
||||
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
|
||||
<< " licenseplate = " << printingData["licenseplate"] << endl
|
||||
<< " amount = " << printingData["amount"] << endl
|
||||
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
||||
<< " currentDateTime = " << printingData["currentDateTime"] << endl;
|
||||
|
||||
QDateTime parkingEndDateTime = QDateTime::fromString(printingData["parkingEnd"].toString(), Qt::ISODate);
|
||||
QDateTime currentDateTime = QDateTime::fromString(printingData["currentDateTime"].toString(), Qt::ISODate);
|
||||
|
||||
/* -----------------------------------------------------------------------------------------
|
||||
* note: the following highly depends on printer template files!
|
||||
* -----------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// set dynamic printer data:
|
||||
QByteArray ba_licenseplate = codec->fromUnicode(printingData["licenseplate"].toString());
|
||||
memcpy((char*)dynTicketData->licensePlate, ba_licenseplate.data(), std::min(ba_licenseplate.size(),8));
|
||||
|
||||
QByteArray ba_amount = codec->fromUnicode(printingData["amount"].toString());
|
||||
memcpy((char*)dynTicketData->vendingPrice, ba_amount.data(), std::min(ba_amount.size(),8));
|
||||
|
||||
QByteArray ba_parkingEndTime = codec->fromUnicode(parkingEndDateTime.toString("hh:mm"));
|
||||
memcpy((char*)dynTicketData->parkingEnd, ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
|
||||
|
||||
QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
|
||||
memcpy((char*)dynTicketData->currentTime, ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
|
||||
// ! and yes... 'ParkingEndDate' is 'currentTime'
|
||||
|
||||
QByteArray ba_currentDate = codec->fromUnicode(currentDateTime.toString("dd.MM.yy"));
|
||||
memcpy((char*)dynTicketData->currentDate, ba_currentDate.data(), std::min(ba_currentDate.size(),8));
|
||||
|
||||
|
||||
// DEBUG
|
||||
/*
|
||||
uint8_t* buf = dynTicketData->licensePlate;
|
||||
int length = 64;
|
||||
for (int i = 0; i < length; ++i) {
|
||||
fprintf(stderr, "%d %02x %c\n", i, buf[i], buf[i]);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
*/
|
||||
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket()";
|
||||
|
||||
if (!this->hw->dc_isPortOpen()) {
|
||||
qCritical() << " ... serial port is not open!";
|
||||
this->onPrintFinishedERR();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// TODO: wird hier nur 'licensePlate' gedruckt?
|
||||
if (!this->hw->prn_sendDynamicPrnValues(dynTicketData->licensePlate)) {
|
||||
this->errorCode = "hwapi::prn_sendDynamicPrnValues";
|
||||
this->errorDescription = "hwapi method 'hwapi::prn_sendDynamicPrnValues' result is false";
|
||||
|
||||
qCritical() << "ERROR:";
|
||||
qCritical() << "ATBDeviceControllerPlugin::requestPrintTicket( " << endl
|
||||
<< " licenseplate = " << printingData["licenseplate"] << endl
|
||||
<< " amount = " << printingData["amount"] << endl
|
||||
<< " parkingEnd = " << printingData["parkingEnd"] << endl
|
||||
<< " currentTime = " << printingData["currentTime"] << endl
|
||||
<< " currentDate = " << printingData["currentDate"] << endl;
|
||||
|
||||
|
||||
this->onPrintFinishedERR();
|
||||
return;
|
||||
}
|
||||
|
||||
// set ticket type:
|
||||
// 00281 - Szeged:
|
||||
// 1 - Cash / ShortTimeParking
|
||||
// 2 - Card / ShortTimeParking
|
||||
// 3 - Cash / DayTicket
|
||||
// 4 - Card / DayTicket
|
||||
QString paymentType = printingData["paymentType"].toString(); // must be "CASH" | "CARD"
|
||||
QString productName = printingData["product"].toString(); // must be "ShortTimeParking" | "DayTicket"
|
||||
|
||||
if ( (paymentType == "CASH") && (productName == "ShortTimeParking") ) {
|
||||
this->currentSelectedTicketType = 1;
|
||||
}
|
||||
else
|
||||
if ( (paymentType == "CARD") && (productName == "ShortTimeParking") ) {
|
||||
this->currentSelectedTicketType = 2;
|
||||
}
|
||||
else
|
||||
if ( (paymentType == "CASH") && (productName == "DayTicket") ) {
|
||||
this->currentSelectedTicketType = 3;
|
||||
}
|
||||
else
|
||||
if ( (paymentType == "CARD") && (productName == "DayTicket") ) {
|
||||
this->currentSelectedTicketType = 4;
|
||||
}
|
||||
else {
|
||||
qCritical() << "ERROR: requestPrintTicket(): invalid payment data:";
|
||||
qCritical() << " paymentType = " << paymentType << endl
|
||||
<< " productName = " << productName << endl;
|
||||
this->onPrintFinishedERR();
|
||||
return;
|
||||
}
|
||||
|
||||
QTimer::singleShot(1000, this, SLOT(onPrinterDataPrepared()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
|
||||
{
|
||||
this->hw->prn_printKombiticket(this->currentSelectedTicketType);
|
||||
|
||||
// FAKE SIGNAL:
|
||||
QTimer::singleShot(4000, this, SLOT(onPrintFinishedOK()));
|
||||
|
||||
|
||||
// old: use printer templates:
|
||||
// this->currentTemplate = 1;
|
||||
// this->onPrinterPrintNextTemplate();
|
||||
}
|
||||
|
||||
|
||||
void ATBDeviceControllerPlugin::onPrinterPrintNextTemplate()
|
||||
{
|
||||
qCritical() << " ... print template " << this->currentTemplate;
|
||||
|
||||
if (!this->hw->prn_printTemplate(this->currentTemplate)) {
|
||||
this->errorCode = "hwapi::prn_printTemplate";
|
||||
this->errorDescription = QString("hwapi method 'hwapi::onPrinterPrintNextTemplate(%1)' result is false").arg(this->currentTemplate);
|
||||
this->onPrintFinishedERR();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->currentTemplate >= 3) {
|
||||
// all templates are printed
|
||||
this->currentTemplate = 0;
|
||||
|
||||
// FAKE SIGNAL:
|
||||
QTimer::singleShot(500, this, SLOT(onPrintFinishedOK()));
|
||||
}
|
||||
else {
|
||||
// print next template
|
||||
this->currentTemplate++;
|
||||
QTimer::singleShot(2000, this, SLOT(onPrinterPrintNextTemplate()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* private slots, interface to low level hwapi
|
||||
*
|
||||
*/
|
||||
void ATBDeviceControllerPlugin::onPrintFinishedOK()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedOK()";
|
||||
|
||||
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
||||
// TODO: TicketNumber
|
||||
"",
|
||||
"");
|
||||
}
|
||||
void ATBDeviceControllerPlugin::onPrintFinishedERR()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedERR()";
|
||||
|
||||
|
||||
this->errorCode = "PRINTER"; // TODO: get more detailed error code from low level API
|
||||
this->errorDescription = "Printer error"; // TODO: get more detailed error description from low level API
|
||||
|
||||
emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
|
||||
this->errorCode,
|
||||
this->errorDescription);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* cash payment
|
||||
*/
|
||||
void ATBDeviceControllerPlugin::onCashGotCoin()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onGotCoin()";
|
||||
|
||||
this->currentCashState = CASH_STATE::CACHE_INPUT;
|
||||
|
||||
uint32_t amountInt = this->hw->getInsertedAmount();
|
||||
|
||||
QString amountString = QString::number(amountInt);
|
||||
|
||||
|
||||
emit this->cashInputEvent(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
||||
nsDeviceControllerInterface::CASH_STATE::CACHE_INPUT,
|
||||
amountString,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
|
||||
void ATBDeviceControllerPlugin::onCashPayStopByMax()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
|
||||
|
||||
// we need new cash value in application...
|
||||
QTimer::singleShot(500, this, SLOT(onCashPayStopedSuccess()));
|
||||
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCashPayStopByEscrow()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByEscrow()";
|
||||
|
||||
uint32_t amountInt = this->hw->getInsertedAmount();
|
||||
|
||||
QString amountString = QString::number(amountInt);
|
||||
|
||||
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
|
||||
amountString,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCashPayStopByError()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByError()";
|
||||
|
||||
uint32_t amountInt = this->hw->getInsertedAmount();
|
||||
|
||||
QString amountString = QString::number(amountInt);
|
||||
|
||||
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
|
||||
amountString,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCashPayStopByTimeout()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCashPayStopByTimeout()";
|
||||
|
||||
uint32_t amountInt = this->hw->getInsertedAmount();
|
||||
|
||||
QString amountString = QString::number(amountInt);
|
||||
|
||||
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND,
|
||||
amountString,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
void ATBDeviceControllerPlugin::onCashPayStopedSuccess()
|
||||
{
|
||||
// DEBUG
|
||||
qCritical() << "ATBDeviceControllerPlugin::onCashPayStoped()";
|
||||
|
||||
uint32_t amountInt = this->hw->getInsertedAmount();
|
||||
|
||||
QString amountString = QString::number(amountInt);
|
||||
|
||||
qCritical() << " insertedAmount (int) = " << amountInt;
|
||||
qCritical() << " insertedAmount = " << amountString;
|
||||
|
||||
emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
|
||||
amountString,
|
||||
"",
|
||||
"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load CashAgentLib
|
||||
* @brief ATBDeviceControllerPlugin::private_loadCashAgentLib
|
||||
* @param pluginName
|
||||
* @return
|
||||
*/
|
||||
bool ATBDeviceControllerPlugin::private_loadCashAgentLib(QString pluginName)
|
||||
{
|
||||
if (pluginName == "") {
|
||||
|
||||
// search list for plugin (.so) file:
|
||||
QStringList pluginNameList;
|
||||
pluginNameList << "/usr/lib/libCAmaster.so"
|
||||
<< "/usr/lib/libCashAgentLib.so";
|
||||
// using C++11 range based loop:
|
||||
for (const auto& filename : pluginNameList) {
|
||||
if (QFileInfo(filename).isReadable()) {
|
||||
pluginName = filename;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pluginName == "") {
|
||||
qCritical() << "ATBDeviceControllerPlugin: CashAgentLib not installed!";
|
||||
this->errorCode = "CashAgentLib::NOT_FOUND";
|
||||
this->errorDescription = "ERROR: no CashAgentLib: ";
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!QLibrary::isLibrary(pluginName)) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: can not load CashAgentLib: " << pluginName;
|
||||
this->errorCode = "CashAgentLib::NO_LIBRARY";
|
||||
this->errorDescription = "ERROR: can not load CashAgentLib: " + pluginName;
|
||||
return false;
|
||||
}
|
||||
|
||||
QPluginLoader* pluginLoader = new QPluginLoader();
|
||||
pluginLoader->setFileName(pluginName);
|
||||
|
||||
QObject* plugin = pluginLoader->instance();
|
||||
if (!pluginLoader->isLoaded()) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: can not instantiate CashAgentLib: " << pluginName;
|
||||
qCritical() << " error: " << pluginLoader->errorString();
|
||||
this->errorCode = "CashAgentLib::NO_INSTANCE";
|
||||
this->errorDescription = "ERROR: can not instantiate CashAgentLib: " + pluginName;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin == nullptr) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: plugin is NULL";
|
||||
this->errorCode = "CashAgentLib::INSTANCE_IS_NULL";
|
||||
this->errorDescription = "ERROR: CashAgentLib instance is NULL: " + pluginName;
|
||||
}
|
||||
|
||||
qCritical() << "ATBDeviceControllerPlugin: instantiate CashAgentLib: " << pluginName;
|
||||
|
||||
this->hw = qobject_cast<hwinf*>(plugin);
|
||||
|
||||
if (this->hw == nullptr) {
|
||||
qCritical() << "ATBDeviceControllerPlugin: hw is NULL";
|
||||
this->errorCode = "CashAgentLib::HW_IS_NULL";
|
||||
this->errorDescription = "ERROR: CashAgentLib object_cast is NULL: " + pluginName;
|
||||
return false;
|
||||
}
|
||||
|
||||
qCritical() << "ATBDeviceControllerPlugin: loaded CashAgentLib";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************************************************
|
||||
* Mandatory plugin methods
|
||||
*
|
||||
*/
|
||||
|
||||
PLUGIN_STATE ATBDeviceControllerPlugin::getState()
|
||||
{
|
||||
return this->pluginState;
|
||||
}
|
||||
|
||||
QString & ATBDeviceControllerPlugin::getLastError()
|
||||
{
|
||||
return this->errorCode;
|
||||
}
|
||||
|
||||
const QString & ATBDeviceControllerPlugin::getLastErrorDescription()
|
||||
{
|
||||
return this->errorDescription;
|
||||
}
|
||||
|
||||
const QString & ATBDeviceControllerPlugin::getPluginInfo()
|
||||
{
|
||||
return this->pluginInfo;
|
||||
}
|
||||
|
||||
|
||||
const QString ATBDeviceControllerPlugin::getString(nsDeviceControllerInterface::RESULT_STATE resultState)
|
||||
{
|
||||
QString str;
|
||||
|
||||
switch (resultState) {
|
||||
case nsDeviceControllerInterface::RESULT_STATE::SUCCESS:
|
||||
str = QString("RESULT_STATE::SUCCESS");
|
||||
break;
|
||||
case nsDeviceControllerInterface::RESULT_STATE::ERROR_BACKEND:
|
||||
str = QString("RESULT_STATE::ERROR_BACKEND");
|
||||
break;
|
||||
case nsDeviceControllerInterface::RESULT_STATE::ERROR_TIMEOUT:
|
||||
str = QString("RESULT_STATE::ERROR_TIMEOUT");
|
||||
break;
|
||||
case nsDeviceControllerInterface::RESULT_STATE::ERROR_PROCESS:
|
||||
str = QString("RESULT_STATE::ERROR_PROCESS");
|
||||
break;
|
||||
case nsDeviceControllerInterface::RESULT_STATE::ERROR_RETRY:
|
||||
str = QString("RESULT_STATE::ERROR_RETRY");
|
||||
break;
|
||||
case nsDeviceControllerInterface::RESULT_STATE::INFO:
|
||||
str = QString("RESULT_STATE::INFO");
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* ... end
|
||||
*/
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
Q_EXPORT_PLUGIN2( ATBDeviceControllerPlugin, ATBDeviceControllerPlugin )
|
||||
#endif
|
166
src/ATBAPP/ATBDeviceControllerPlugin.h
Normal file
166
src/ATBAPP/ATBDeviceControllerPlugin.h
Normal file
@@ -0,0 +1,166 @@
|
||||
#ifndef ATBDEVICECONTROLLERPLUGIN_H
|
||||
#define ATBDEVICECONTROLLERPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "src/ATBAPP/DeviceControllerInterface.h"
|
||||
#include "src/ATBAPP/ATBAPPplugin.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
||||
#include "interfaces.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
#include <QSharedMemory>
|
||||
|
||||
|
||||
class QTextCodec;
|
||||
|
||||
|
||||
using namespace nsDeviceControllerInterface;
|
||||
|
||||
class QSettings;
|
||||
|
||||
class ATBDeviceControllerPlugin : public QObject,
|
||||
public DeviceControllerInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(ATBAPPplugin)
|
||||
Q_INTERFACES(DeviceControllerInterface)
|
||||
#if QT_VERSION >= 0x050000
|
||||
Q_PLUGIN_METADATA( IID "ATBDeviceControllerPlugin" )
|
||||
#endif
|
||||
|
||||
public:
|
||||
explicit ATBDeviceControllerPlugin(QObject *parent = nullptr);
|
||||
~ATBDeviceControllerPlugin();
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// interface:
|
||||
PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver, const QSettings & settings);
|
||||
|
||||
// TASKS: Cash handling -------------------------------------------------------
|
||||
void requestStartCashInput(const QString & amount);
|
||||
void requestStopCashInput();
|
||||
void cashCollect();
|
||||
void cashAbort();
|
||||
|
||||
// TASKS: printing ------------------------------------------------------------
|
||||
void requestPrintTicket(const QHash<QString, QVariant> & printingData);
|
||||
|
||||
// TASKS: Account -------------------------------------------------------------
|
||||
void requestAccount();
|
||||
|
||||
// mandantory ATBAPP plugin methods: ------------------------------------------
|
||||
nsDeviceControllerInterface::PLUGIN_STATE getState();
|
||||
QString & getLastError();
|
||||
const QString & getLastErrorDescription();
|
||||
|
||||
const QString & getPluginInfo();
|
||||
|
||||
// helpers e.g. for debug / log
|
||||
const QString getString(nsDeviceControllerInterface::RESULT_STATE resultState);;
|
||||
|
||||
public slots:
|
||||
void onChangedProgramModeToSELL();
|
||||
void onChangedProgramModeToSERVICE();
|
||||
void onChangedProgramModeToIDLE();
|
||||
void onChangedProgramModeToOOO();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
|
||||
void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
nsDeviceControllerInterface::CASH_STATE cashState,
|
||||
const QString & newCashValue,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
|
||||
void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
const QString & newCashValue,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
|
||||
void requestModeSERVICE();
|
||||
void requestModeIDLE();
|
||||
void requestModeOOO();
|
||||
|
||||
void requestAccountResponse(const QHash<QString, QVariant> & accountData);
|
||||
|
||||
|
||||
|
||||
void Error(
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription);
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QString errorCode;
|
||||
QString errorDescription;
|
||||
QString pluginInfo;
|
||||
|
||||
int currentTemplate;
|
||||
|
||||
|
||||
bool useDebug;
|
||||
|
||||
PLUGIN_STATE pluginState;
|
||||
|
||||
QObject* healthEventReceiver;
|
||||
|
||||
hwinf* hw;
|
||||
|
||||
QTextCodec *codec;
|
||||
|
||||
bool private_loadCashAgentLib(QString pluginName);
|
||||
|
||||
quint8 currentSelectedTicketType;
|
||||
|
||||
nsDeviceControllerInterface::CASH_STATE currentCashState;
|
||||
|
||||
// counts failed hw->log_chkIfVaultRecordAvailable()
|
||||
int accountCheckCounter;
|
||||
|
||||
|
||||
private slots:
|
||||
// printer
|
||||
|
||||
void onPrinterDataPrepared();
|
||||
void onPrinterPrintNextTemplate();
|
||||
|
||||
void onPrintFinishedOK();
|
||||
void onPrintFinishedERR();
|
||||
|
||||
// cash payment
|
||||
void onCashGotCoin();
|
||||
void onCashPayStopedSuccess();
|
||||
void onCashPayStopByMax();
|
||||
void onCashPayStopByEscrow();
|
||||
void onCashPayStopByError();
|
||||
void onCashPayStopByTimeout();
|
||||
|
||||
// doors and hardware contacts
|
||||
void onServiceDoorOpened();
|
||||
void onVaultDoorOpened();
|
||||
void onCoinBoxRemoved();
|
||||
void onCoinBoxInserted();
|
||||
void onAllDoorsClosed();
|
||||
|
||||
// account handling
|
||||
void private_startAccount();
|
||||
void private_checkAccountData();
|
||||
void private_getAccountData();
|
||||
};
|
||||
|
||||
#endif // ATBDEVICECONTROLLERPLUGIN_H
|
25
src/ATBAPP/ATBHealthEvent.cpp
Normal file
25
src/ATBAPP/ATBHealthEvent.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "src/ATBAPP/ATBHealthEvent.h"
|
||||
|
||||
ATBHealthEvent::ATBHealthEvent(ATB_HEALTH_MODE mode, const QString & errorNumber, const QString & errorDescription) :
|
||||
QEvent(ATB_HEALTH_EVENT),
|
||||
healthMode(mode),
|
||||
errorNumber(errorNumber),
|
||||
errorDescription(errorDescription)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString ATBHealthEvent::getErrorNumber()
|
||||
{
|
||||
return this->errorNumber;
|
||||
}
|
||||
|
||||
QString ATBHealthEvent::getErrorDescription()
|
||||
{
|
||||
return this->errorDescription;
|
||||
}
|
||||
|
||||
ATB_HEALTH_MODE ATBHealthEvent::getMode()
|
||||
{
|
||||
return this->healthMode;
|
||||
}
|
44
src/ATBAPP/ATBHealthEvent.h
Normal file
44
src/ATBAPP/ATBHealthEvent.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef ATBHEALTHEVENT_H
|
||||
#define ATBHEALTHEVENT_H
|
||||
|
||||
#include <QEvent>
|
||||
#include <QString>
|
||||
|
||||
enum class ATB_HEALTH_MODE : quint8;
|
||||
|
||||
const QEvent::Type ATB_HEALTH_EVENT = static_cast<QEvent::Type>(QEvent::User + 1);
|
||||
|
||||
|
||||
class ATBHealthEvent : public QEvent
|
||||
{
|
||||
|
||||
public:
|
||||
ATBHealthEvent(ATB_HEALTH_MODE mode, const QString & errorNumber, const QString & errorDescription);
|
||||
|
||||
QString getErrorNumber();
|
||||
QString getErrorDescription();
|
||||
ATB_HEALTH_MODE getMode();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
|
||||
private:
|
||||
ATB_HEALTH_MODE healthMode;
|
||||
QString errorNumber;
|
||||
QString errorDescription;
|
||||
};
|
||||
|
||||
|
||||
enum class ATB_HEALTH_MODE : quint8 {
|
||||
WARNING,
|
||||
ERROR,
|
||||
WARNING_CORRECTION,
|
||||
ERROR_CORRECTION,
|
||||
DEBUG,
|
||||
STATE,
|
||||
UNSPECIFIED
|
||||
};
|
||||
|
||||
#endif // ATBHEALTHEVENT_H
|
165
src/ATBAPP/DeviceControllerInterface.h
Normal file
165
src/ATBAPP/DeviceControllerInterface.h
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef DEVICECONTROLLERINTERFACE_H
|
||||
#define DEVICECONTROLLERINTERFACE_H
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
#include "ATBAPPplugin.h"
|
||||
|
||||
namespace nsDeviceControllerInterface {
|
||||
enum class PLUGIN_STATE : quint8;
|
||||
enum class RESULT_STATE : quint8;
|
||||
enum class CASH_STATE : quint8;
|
||||
}
|
||||
|
||||
|
||||
class DeviceControllerInterface : public ATBAPPplugin
|
||||
{
|
||||
Q_INTERFACES(ATBAPPplugin)
|
||||
|
||||
public:
|
||||
virtual ~DeviceControllerInterface() {}
|
||||
|
||||
virtual nsDeviceControllerInterface::PLUGIN_STATE initDCPlugin(QObject *healthEventReceiver,
|
||||
const QSettings & settings) = 0;
|
||||
|
||||
// TASKS: Cash handling -------------------------------------------------------
|
||||
/**
|
||||
* enables coin input
|
||||
* amount = "0": pay-up
|
||||
* amount > "0": pay-down
|
||||
*/
|
||||
virtual void requestStartCashInput(const QString & amount) = 0;
|
||||
|
||||
/**
|
||||
* called e.g. on Button "NEXT" in pay-up (direct coin input)
|
||||
*/
|
||||
virtual void requestStopCashInput() = 0;
|
||||
|
||||
/**
|
||||
* called e.g. on Button "NEXT" in pay-up (direct coin input)
|
||||
*/
|
||||
virtual void cashCollect() = 0;
|
||||
virtual void cashAbort() = 0;
|
||||
|
||||
// TASKS: Account -------------------------------------------------------------
|
||||
|
||||
virtual void requestAccount() = 0;
|
||||
|
||||
|
||||
// TASKS: printing ------------------------------------------------------------
|
||||
virtual void requestPrintTicket(const QHash<QString, QVariant> & printingData) = 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;
|
||||
|
||||
signals:
|
||||
virtual void printTicketFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
/**
|
||||
* emitted on e.g. a coin input
|
||||
*/
|
||||
virtual void cashInputEvent(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
nsDeviceControllerInterface::CASH_STATE cashState,
|
||||
const QString & newCashValue,
|
||||
/* additional variables? */
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
virtual void cashInputFinished(nsDeviceControllerInterface::RESULT_STATE resultState,
|
||||
const QString & newCashValue,
|
||||
/* additional variables? */
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
|
||||
/**
|
||||
* emitted e.g. if service door is opened
|
||||
*/
|
||||
virtual void requestModeSERVICE() = 0;
|
||||
|
||||
/**
|
||||
* emitted e.g. if doors are closed
|
||||
*/
|
||||
virtual void requestModeIDLE() = 0;
|
||||
|
||||
/**
|
||||
* emitted e.g. on severe errors
|
||||
*/
|
||||
virtual void requestModeOOO() = 0;
|
||||
|
||||
/**
|
||||
* emitted e.g. if service door is opened
|
||||
*/
|
||||
virtual void requestAccountResponse(const QHash<QString, QVariant> & accountData) = 0;
|
||||
|
||||
/**
|
||||
* emitted on error
|
||||
* depending on errorCode:
|
||||
* -> interrupt selling process
|
||||
* -> machine can go to state OOO
|
||||
* -> send error event to ISMAS
|
||||
* -> ...
|
||||
*/
|
||||
virtual void Error(
|
||||
/* additional variables? */
|
||||
const QString & errorCode,
|
||||
const QString & errorDescription) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Q_DECLARE_INTERFACE(DeviceControllerInterface,
|
||||
"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. */
|
||||
};
|
||||
}
|
||||
|
||||
#endif // DEVICECONTROLLERINTERFACE_H
|
18
src/ATBAPP/Utils.cpp
Normal file
18
src/ATBAPP/Utils.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "Utils.h"
|
||||
|
||||
Utils::Utils(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Utils::compare(const void* a, const void* b)
|
||||
{
|
||||
int int_a = * ( (int*) a );
|
||||
int int_b = * ( (int*) b );
|
||||
|
||||
if ( int_a == int_b ) return 0;
|
||||
else if ( int_a < int_b ) return -1;
|
||||
else return 1;
|
||||
}
|
23
src/ATBAPP/Utils.h
Normal file
23
src/ATBAPP/Utils.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class Utils : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static int compare(const void* a, const void* b);
|
||||
|
||||
private:
|
||||
explicit Utils(QObject *parent = nullptr);
|
||||
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // UTILS_H
|
Reference in New Issue
Block a user