Compare commits
	
		
			23 Commits
		
	
	
		
			changes-fo
			...
			pu/coinInt
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						ca5e43e0d7
	
				 | 
					
					
						|||
| 
						
						
							
						
						3ac91305d4
	
				 | 
					
					
						|||
| 
						
						
							
						
						d0445949d2
	
				 | 
					
					
						|||
| 
						
						
							
						
						91d9280a4a
	
				 | 
					
					
						|||
| 
						
						
							
						
						48d6a34b16
	
				 | 
					
					
						|||
| 
						
						
							
						
						e32142cd62
	
				 | 
					
					
						|||
| 
						
						
							
						
						f611e07dcf
	
				 | 
					
					
						|||
| 
						
						
							
						
						6478eda581
	
				 | 
					
					
						|||
| 
						
						
							
						
						1663d09d3a
	
				 | 
					
					
						|||
| 
						
						
							
						
						080c00eda1
	
				 | 
					
					
						|||
| 
						
						
							
						
						bbce2b02e3
	
				 | 
					
					
						|||
| 
						
						
							
						
						8ff17a2e00
	
				 | 
					
					
						|||
| 
						
						
							
						
						c6574280ac
	
				 | 
					
					
						|||
| 
						
						
							
						
						f0f0493d19
	
				 | 
					
					
						|||
| 
						
						
							
						
						9bf99c5515
	
				 | 
					
					
						|||
| 
						
						
							
						
						8ff8faf007
	
				 | 
					
					
						|||
| 
						
						
							
						
						09a80498e4
	
				 | 
					
					
						|||
| 
						
						
							
						
						21fb07b81c
	
				 | 
					
					
						|||
| 
						
						
							
						
						01f8c1e49c
	
				 | 
					
					
						|||
| 
						
						
							
						
						3029b8da04
	
				 | 
					
					
						|||
| 
						
						
							
						
						2143801900
	
				 | 
					
					
						|||
| 
						
						
							
						
						6f6d3b7491
	
				 | 
					
					
						|||
| 
						
						
							
						
						4cfb8f1804
	
				 | 
					
					
						
							
								
								
									
										42
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										42
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1 +1,41 @@
 | 
			
		||||
*.user
 | 
			
		||||
# 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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										40
									
								
								DCPlugin.pro
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								DCPlugin.pro
									
									
									
									
									
								
							@@ -14,6 +14,8 @@ QMAKE_CXXFLAGS += -Wno-deprecated-copy
 | 
			
		||||
# default
 | 
			
		||||
ARCH = PTU5
 | 
			
		||||
 | 
			
		||||
include(DCPlugin.pri)
 | 
			
		||||
 | 
			
		||||
contains( CONFIG, DesktopLinux ) {
 | 
			
		||||
    QMAKE_CC = ccache $$QMAKE_CC
 | 
			
		||||
    QMAKE_CXX = ccache $$QMAKE_CXX
 | 
			
		||||
@@ -21,7 +23,6 @@ contains( CONFIG, DesktopLinux ) {
 | 
			
		||||
    # QMAKE_CXXFLAGS += -Wno-deprecated-ctor
 | 
			
		||||
    linux-clang {  QMAKE_CXXFLAGS += -Qunused-arguments   }
 | 
			
		||||
    ARCH = DesktopLinux
 | 
			
		||||
    include(DCPlugin.pri)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contains( CONFIG, PTU5 ) {
 | 
			
		||||
@@ -31,22 +32,23 @@ contains( CONFIG, PTU5 ) {
 | 
			
		||||
    linux-clang {  QMAKE_CXXFLAGS += -Qunused-arguments   }
 | 
			
		||||
    CONFIG += link_pkgconfig
 | 
			
		||||
    ARCH = PTU5
 | 
			
		||||
 | 
			
		||||
    # NOTE: include contents of DCPlugin.pri. Also used by ATBQT.
 | 
			
		||||
    # Add new files in DCPlugin.pri.
 | 
			
		||||
    include(DCPlugin.pri)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
contains( CONFIG, PTU5_YOCTO ) {
 | 
			
		||||
    greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
 | 
			
		||||
    PTU5BASEPATH = /opt/devel/ptu5
 | 
			
		||||
    ARCH = PTU5
 | 
			
		||||
 | 
			
		||||
    # add qmqtt lib
 | 
			
		||||
    #LIBS += -lQt5Qmqtt
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TARGET   = CashAgentLib
 | 
			
		||||
DESTDIR  = ../plugins
 | 
			
		||||
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
 | 
			
		||||
@@ -66,3 +68,27 @@ DEFINES += QT_DEPRECATED_WARNINGS
 | 
			
		||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
 | 
			
		||||
#!isEmpty(target.path): INSTALLS += target
 | 
			
		||||
 | 
			
		||||
# ATBAPP interface
 | 
			
		||||
HEADERS += \
 | 
			
		||||
    src/ATBAPP/ATBAPPplugin.h \
 | 
			
		||||
    src/ATBAPP/DeviceControllerInterface.h \
 | 
			
		||||
    src/ATBAPP/ATBHealthEvent.h \
 | 
			
		||||
    src/ATBAPP/ATBDeviceControllerPlugin.h
 | 
			
		||||
 | 
			
		||||
SOURCES += \
 | 
			
		||||
    src/ATBAPP/ATBHealthEvent.cpp \
 | 
			
		||||
    src/ATBAPP/ATBDeviceControllerPlugin.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}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -308,6 +308,8 @@ class T_datif : public QMainWindow
 | 
			
		||||
    QTimer *datif_trigger;
 | 
			
		||||
    uint8_t selectedSlaveAddr;
 | 
			
		||||
 | 
			
		||||
    int datif_noResponseCtr;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
    char datif_cycleSend();
 | 
			
		||||
    void StoredRecData();
 | 
			
		||||
@@ -324,6 +326,7 @@ public:
 | 
			
		||||
        // Sende Schreibbefehle die bereits vorher asynchron gespeichert wurden
 | 
			
		||||
    void send_requests(uint16_t nextWrCmd);
 | 
			
		||||
    void sendHighLevel(uint16_t nxtHLCmd);
 | 
			
		||||
    bool areDataValid(void);
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void ResponseRecieved();
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										35
									
								
								include/hwChk.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										35
									
								
								include/hwChk.h
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
 | 
			
		||||
#ifndef hwchk_H
 | 
			
		||||
#define hwchk_H
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <QTabWidget>
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include "interfaces.h"
 | 
			
		||||
//#include "datIf.h"
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QSharedMemory>
 | 
			
		||||
#include "hwapi.h"
 | 
			
		||||
 | 
			
		||||
//class QSharedMemory;
 | 
			
		||||
class hwChk :   public QObject,
 | 
			
		||||
                public hwinf
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
//    Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" )   //FILE "HWapi.json")
 | 
			
		||||
//    Q_INTERFACES(hwinf)
 | 
			
		||||
//private:
 | 
			
		||||
//    QSharedMemory *m_sharedMem;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    explicit hwChk(QWidget *parent = nullptr);
 | 
			
		||||
    virtual ~hwChk();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    hwinf *HWaccess;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										166
									
								
								include/hwapi.h
									
									
									
									
									
								
							
							
						
						
									
										166
									
								
								include/hwapi.h
									
									
									
									
									
								
							@@ -17,78 +17,14 @@ matching interfaces.h:
 | 
			
		||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
 | 
			
		||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.1"
 | 
			
		||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
PSA1259 hardware control using the DeviceController DC2
 | 
			
		||||
 | 
			
		||||
covering enclosure (switches and doors) and money devices,
 | 
			
		||||
controls mifare card to access or program
 | 
			
		||||
optional it can control printer, modem, bar code reader and credit card
 | 
			
		||||
 | 
			
		||||
 * API to the PSA1259 Hardware
 | 
			
		||||
 * All data come in from device controller via serial interface and will be stored
 | 
			
		||||
 * in "PI" = peripheral image
 | 
			
		||||
 * PI is updated every 100ms (up to 30ms possible)
 | 
			
		||||
 * This api uses stored pi data and returns them in the following functions
 | 
			
		||||
 * created: Q1/2020 TS
 | 
			
		||||
 *
 | 
			
		||||
 | 
			
		||||
The devices, connected to device controller2 (DC2) can be controlled in different access levels.
 | 
			
		||||
Level 1:
 | 
			
		||||
    direct connection to DC2, check versions, state and parameters
 | 
			
		||||
    control serial interfaces
 | 
			
		||||
    digital/analog IO's
 | 
			
		||||
    read and write to connected devices on lowest level, this is a kind of fall-back-level
 | 
			
		||||
    in case higher levels fail or do not support the needed (new) function
 | 
			
		||||
    Example: send a specific printer command, several bytes that need to be conform to
 | 
			
		||||
            printer manual. This command is routed to the printer through the DC2 without
 | 
			
		||||
            any action of the DC. You can write your own device driver that way.
 | 
			
		||||
    Level 1 is flexible but complicated
 | 
			
		||||
 | 
			
		||||
Level 2:
 | 
			
		||||
   The DC controls the connected devices containing a device driver. The DC offers
 | 
			
		||||
   usage of the device by simple commands,
 | 
			
		||||
   Example: "Printer on", "set Font size 3" "print "hello world"", "cut"
 | 
			
		||||
   In opposite to level 1 where you had to send a set of numbers and letters.
 | 
			
		||||
   In other words: you "talk" to the device controller, not to the device itself.
 | 
			
		||||
 | 
			
		||||
Level 3:
 | 
			
		||||
    start/stop complete processes.
 | 
			
		||||
    Example: 1) print (predefined) document nr 3 with Text, letter size, font set, cut.
 | 
			
		||||
                Also power up/down the printer, check if paper ok and so on.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Another access example: control the coin unit
 | 
			
		||||
 | 
			
		||||
Level 1): read digital inputs to detect coin,
 | 
			
		||||
          switch digital output which opens coin slot
 | 
			
		||||
          communicate with coin checker by certain mdb-commands (manual conform)
 | 
			
		||||
          poll coin checker for inserted coins
 | 
			
		||||
          close coin slot after 3seconds by setting DO to 0....
 | 
			
		||||
 | 
			
		||||
Level 2): get message of attached coin from DC
 | 
			
		||||
          send command "initialize coin checker" to DC
 | 
			
		||||
          send command "open slot for 3s"
 | 
			
		||||
          poll DC for inserted coins, DC polls coin checker in right way, no need
 | 
			
		||||
                to know the data sheet of the coin checker or mdb-bus
 | 
			
		||||
          command to DC "open coin escrow's return flap for 1s"
 | 
			
		||||
 | 
			
		||||
Level 3): send command: "start payment process"
 | 
			
		||||
          all coin devices are started up
 | 
			
		||||
          coin blocker opens for 3s if a coin is attached
 | 
			
		||||
          coin checker summarizes inserted value and reports sum
 | 
			
		||||
          later send command "stop payment process" (puts coins to vault) or
 | 
			
		||||
          send command "cancel payment process" (returns coins to user)
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef hwapi_H
 | 
			
		||||
#define hwapi_H
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <QTabWidget>
 | 
			
		||||
#include <QtPlugin>
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include "interfaces.h"
 | 
			
		||||
#include "datIf.h"
 | 
			
		||||
@@ -98,10 +34,10 @@ class hwapi :   public QObject,
 | 
			
		||||
                public hwinf
 | 
			
		||||
{
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
    Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" )   //FILE "HWapi.json")
 | 
			
		||||
    Q_INTERFACES(hwinf)
 | 
			
		||||
private:
 | 
			
		||||
    void sub_storeSendingText(QByteArray *buf) const;
 | 
			
		||||
    QTimer *hwapi_TimerPayment;
 | 
			
		||||
 | 
			
		||||
    DownloadResult sendNextAddress(int bNum) const;
 | 
			
		||||
    DownloadResult sendNextDataBlock(QByteArray const &b, int bNum) const;
 | 
			
		||||
@@ -118,13 +54,13 @@ private:
 | 
			
		||||
 | 
			
		||||
    QSharedMemory *m_sharedMem;
 | 
			
		||||
public:
 | 
			
		||||
    explicit hwapi(QWidget *parent = nullptr);
 | 
			
		||||
    explicit hwapi(QObject *parent = nullptr);
 | 
			
		||||
    virtual ~hwapi();
 | 
			
		||||
 | 
			
		||||
    T_datif *myDatif;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    virtual QStringList dc_getStatus() const;
 | 
			
		||||
    virtual QStringList dc_getStatus() const override;
 | 
			
		||||
 | 
			
		||||
    // ------------------------------------------------------------------------------
 | 
			
		||||
    // Level 0 commands, interface
 | 
			
		||||
@@ -248,6 +184,13 @@ public:
 | 
			
		||||
    uint8_t bl_exitBL(uint8_t *sendData) const override;
 | 
			
		||||
        // minimum size of sendData-buffer: 5byte  retval: length
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // ------------------------------------------------------------------------------
 | 
			
		||||
    // Level 2  DC2-onboard devices
 | 
			
		||||
    //          WR: set time
 | 
			
		||||
@@ -1050,6 +993,17 @@ public:
 | 
			
		||||
    bool cash_startPayment(uint32_t amount) const override;
 | 
			
		||||
        // 17.4.23TS: extended to 32bit
 | 
			
		||||
 | 
			
		||||
    uint8_t cash_paymentProcessing(void) const override;
 | 
			
		||||
        // run this function periodically while coin payment process to generate necessary signals
 | 
			
		||||
        // return value:
 | 
			
		||||
        // 0: stopped   1: starting up   2: coin collection
 | 
			
		||||
        // 3: finished by User (Push button)  4: finished, Max-Value collected
 | 
			
		||||
        // 5: finished by escrow
 | 
			
		||||
        // 10,11: error cannot start
 | 
			
		||||
        // 12: timeout while payment, coins returned
 | 
			
		||||
        // 13: stopped by unexpected error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    bool cash_cancelPayment(void) const override;
 | 
			
		||||
        // and return coins
 | 
			
		||||
 | 
			
		||||
@@ -1083,6 +1037,16 @@ public:
 | 
			
		||||
    uint64_t sys_getWakeSource(void) const override;
 | 
			
		||||
        // retval: 6 bytes, bit coded, 1=event keeps DC awake
 | 
			
		||||
 | 
			
		||||
    uint8_t sys_getWakeReason(void) const override;
 | 
			
		||||
         // Master was woken by following reason:
 | 
			
		||||
         // 1: MDB Event
 | 
			
		||||
         // 2: Coin Event
 | 
			
		||||
         // ( 3: Master Event) - will not set the wake line
 | 
			
		||||
         // ( 4: 32s pulse) - will not set the wake line
 | 
			
		||||
         // 5: Door Event
 | 
			
		||||
         // ( 6: Diag Event) - will not set the wake line
 | 
			
		||||
         // 7: 30min-Pulse for HB
 | 
			
		||||
 | 
			
		||||
    void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const override;
 | 
			
		||||
 | 
			
		||||
    void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
 | 
			
		||||
@@ -1105,18 +1069,80 @@ public:
 | 
			
		||||
        //          bit6: no response             bit7: serial rec. error
 | 
			
		||||
        //			bit5: printer not ready
 | 
			
		||||
 | 
			
		||||
    void sys_sendDeviceParameter(struct T_devices *deviceSettings) const override;
 | 
			
		||||
 | 
			
		||||
    void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override;
 | 
			
		||||
 | 
			
		||||
    bool sys_areDCdataValid(void) const override;
 | 
			
		||||
 | 
			
		||||
    /* ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ------------   supervise  all hardware components
 | 
			
		||||
    // ------------    assess the machine state
 | 
			
		||||
 | 
			
		||||
    1. check if DC startup test is through, retrigger if not
 | 
			
		||||
    2. get results and find errors
 | 
			
		||||
    3. in case of error check if component is used (e.g. billreader is seldom used)
 | 
			
		||||
    4: check doors
 | 
			
		||||
    5. return value: 0: no response from DC
 | 
			
		||||
                     1: no Test results and Test not running. need retrigger!
 | 
			
		||||
                     2: state not clear by now, test ongoing, wait
 | 
			
		||||
                     3: Service or battery door is open, goto INTRUSION MODE
 | 
			
		||||
                            from here: after valid ID-card goto SERVICE MODE
 | 
			
		||||
                     4: vault door is open, goto INTRUSION MODE
 | 
			
		||||
                            from here: after valid ID-card and vault door closed goto TEST MODE
 | 
			
		||||
                            in TEST MODE: complete system check decides if vending mode allowed
 | 
			
		||||
                     5: All doors are closed but errors found,
 | 
			
		||||
                            goto OOO MODE (out-of-order)
 | 
			
		||||
                            from here: run system test until problem is fixed
 | 
			
		||||
                     6: All doors are closed, no error, maybe warnings,
 | 
			
		||||
                            goto VENDING MODE (normal operation)
 | 
			
		||||
                    (priority sinks from 0 to 6)
 | 
			
		||||
 | 
			
		||||
     --------------------------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
    uint8_t sys_componentAssessment(void) const override;
 | 
			
		||||
    // this function decides if vending mode is possible, independant from door
 | 
			
		||||
    // return >0 in case of error
 | 
			
		||||
    // is inncluded in sys_superviseSystem
 | 
			
		||||
 | 
			
		||||
    uint8_t sys_superviseSystem(void) const override;
 | 
			
		||||
    // this function proofs if vending is possible depending of doors state
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    uint8_t sys_getSystemErrors(void) const override;
 | 
			
		||||
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    void hwapi_templatePrintFinished_OK(void) const override;
 | 
			
		||||
    void hwapi_templatePrintFinished_Err(void) const override;
 | 
			
		||||
 | 
			
		||||
    void hwapi_coinCollectionJustStarted(void) const override;
 | 
			
		||||
    void hwapi_coinCollectionAborted(void) const override;
 | 
			
		||||
 | 
			
		||||
    void hwapi_gotNewCoin(void) const override;
 | 
			
		||||
    void hwapi_vendStopByMax(void) const override;
 | 
			
		||||
    void hwapi_vendStopByPushbutton(void) const override;
 | 
			
		||||
    void hwapi_payStopByMax(void) const override;
 | 
			
		||||
    void hwapi_payStopByPushbutton(void) const override;
 | 
			
		||||
 | 
			
		||||
    void hwapi_payStopByEscrow(void) const override;
 | 
			
		||||
    void hwapi_payStopByError(void) const override;
 | 
			
		||||
    void hwapi_payStopByTimeout(void) const override;
 | 
			
		||||
    void hwapi_payCancelled(void) const override;
 | 
			
		||||
 | 
			
		||||
    void hwapi_coinProcessJustStopped(void) const override;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 private slots:
 | 
			
		||||
    void hwapi_slotPrintFinished_OK(void);
 | 
			
		||||
    void hwapi_slotPrintFinished_Err(void);
 | 
			
		||||
    void hwapi_slotGotCoin(void);
 | 
			
		||||
    void hwapi_slotPayProc(void);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -76,8 +76,8 @@ struct Tprn_currentSettings {
 | 
			
		||||
struct T_dynDat {
 | 
			
		||||
    uint8_t licensePlate[8];
 | 
			
		||||
    uint8_t vendingPrice[8];
 | 
			
		||||
    uint8_t parkingEnd[8];
 | 
			
		||||
    uint8_t currentTime[8];
 | 
			
		||||
    uint8_t parkingEndTime[8];
 | 
			
		||||
    uint8_t parkingEndDate[8];
 | 
			
		||||
    uint8_t currentDate[8];
 | 
			
		||||
    uint8_t dynDat5[8];
 | 
			
		||||
    uint8_t dynDat6[8];
 | 
			
		||||
@@ -182,29 +182,25 @@ struct T_moduleCondition {
 | 
			
		||||
    uint8_t   ResetReason;
 | 
			
		||||
    uint8_t	allModulesChecked;
 | 
			
		||||
 | 
			
		||||
    uint8_t   alarmState;
 | 
			
		||||
    uint8_t   res11;
 | 
			
		||||
    uint8_t   res12;
 | 
			
		||||
    uint8_t   res13;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct T_dynamicCondition {
 | 
			
		||||
    char allDoorsDebounced;
 | 
			
		||||
    char allDoorsDebounced;     // 99: undefined, 0=all closed, bit1=upper door open  2=midlle door open 3=lower door open
 | 
			
		||||
    char openedAuthorized;
 | 
			
		||||
    uint8_t CBinDebounced;
 | 
			
		||||
    char upperDoor;		// 0:fehlt  1:drin
 | 
			
		||||
    char middleDoor;
 | 
			
		||||
    char lowerDoor;
 | 
			
		||||
    char coinBox;
 | 
			
		||||
    char upperDoor;		// 99: undefined  0:closed  1:open
 | 
			
		||||
    char middleDoor;    // 99: undefined  0:closed  1:open
 | 
			
		||||
    char lowerDoor;     // 99: undefined  0:closed  1:open
 | 
			
		||||
    char reserve;       // not used, always 0
 | 
			
		||||
    char billBox;
 | 
			
		||||
    char modeAbrech;
 | 
			
		||||
    char onAlarm;
 | 
			
		||||
    char onAlarm;       // 0:alarm aus  1:alarm  2:alarm mit Sirene   3: Sirenentest
 | 
			
		||||
    char nowCardTest;
 | 
			
		||||
    char nowPayment;
 | 
			
		||||
    char lastMifCardType;
 | 
			
		||||
    uint8_t lastSDoorState;
 | 
			
		||||
    uint8_t lastVDoorState;
 | 
			
		||||
    uint8_t lastCBstate;
 | 
			
		||||
    uint8_t lastCBstate;        // 99: undefined  0:not there   1:insered
 | 
			
		||||
    char        paymentInProgress;
 | 
			
		||||
    char        res1;
 | 
			
		||||
    uint16_t    U_Batt;
 | 
			
		||||
@@ -232,7 +228,8 @@ struct T_dynamicCondition {
 | 
			
		||||
                //          bit4: paper jam in cutter
 | 
			
		||||
                //          bit6: no response             bit7: serial rec. error
 | 
			
		||||
                //			bit5: printer not ready
 | 
			
		||||
//54
 | 
			
		||||
    uint8_t     startupTestIsRunning;
 | 
			
		||||
    //54
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct T_extTime {
 | 
			
		||||
@@ -263,6 +260,39 @@ struct T_extTime {
 | 
			
		||||
    uint32_t    MinutesOfMillenium;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef uint8_t UCHAR;
 | 
			
		||||
typedef uint16_t UINT;
 | 
			
		||||
 | 
			
		||||
struct T_devices
 | 
			
		||||
{
 | 
			
		||||
    // set by master, used(1) or notused (0) or type 2....20
 | 
			
		||||
 | 
			
		||||
    UCHAR   kindOfPrinter;			// 0:off   1:Gebe
 | 
			
		||||
    UCHAR	kindOfCoinChecker;		// 0: without  1=EMP820   2=EMP900    3=currenza c²	(MW)
 | 
			
		||||
    UCHAR	kindOfMifareReader;		// by now only stronglink SL025 =1
 | 
			
		||||
    UCHAR   suppressSleepMode;		// 0:sleep allowed   1: no sleep
 | 
			
		||||
 | 
			
		||||
    UCHAR	kindOfModem;			// 0:off    1:Sunlink
 | 
			
		||||
    UCHAR	kindOfCreditcard;		// 0:off    1:Feig NFC
 | 
			
		||||
    UCHAR	CoinEscrow;
 | 
			
		||||
    UCHAR   CoinRejectUnit;
 | 
			
		||||
 | 
			
		||||
    UCHAR	CoinShutter;
 | 
			
		||||
    UCHAR	BillAcceptor;
 | 
			
		||||
    UCHAR	usevaultLock;
 | 
			
		||||
    UCHAR	autoAlarm;				// 1: switch on siren for 1min in doors opened unauthorized
 | 
			
		||||
 | 
			
		||||
    UCHAR	autoOpen;				// 1: open door covers after valid ATBcard
 | 
			
		||||
    UCHAR	printAccReceipt;		// 0/1
 | 
			
		||||
    UCHAR   printDoorReceipt;
 | 
			
		||||
    UCHAR   printTokenTicket;
 | 
			
		||||
 | 
			
		||||
    UINT	VaultFullWarnLevel;
 | 
			
		||||
    UINT	VaultFullErrorLevel;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class hwinf {
 | 
			
		||||
public:
 | 
			
		||||
    enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
 | 
			
		||||
@@ -1422,6 +1452,8 @@ public:
 | 
			
		||||
    virtual bool cash_startPayment(uint32_t amount) const=0;
 | 
			
		||||
        // 17.4.23TS: extended to 32bit
 | 
			
		||||
 | 
			
		||||
    virtual uint8_t cash_paymentProcessing(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual uint32_t getInsertedAmount(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual uint16_t getLastInsertedCoin(void) const=0;
 | 
			
		||||
@@ -1451,6 +1483,16 @@ public:
 | 
			
		||||
    virtual uint64_t sys_getWakeSource(void) const =0;
 | 
			
		||||
        // retval: 6 bytes, bit coded, 1=event keeps DC awake
 | 
			
		||||
 | 
			
		||||
    virtual uint8_t sys_getWakeReason(void) const=0;
 | 
			
		||||
         // Master was woken by following reason:
 | 
			
		||||
         // 1: MDB Event
 | 
			
		||||
         // 2: Coin Event
 | 
			
		||||
         // ( 3: Master Event) - will not set the wake line
 | 
			
		||||
         // ( 4: 32s pulse) - will not set the wake line
 | 
			
		||||
         // 5: Door Event
 | 
			
		||||
         // ( 6: Diag Event) - will not set the wake line
 | 
			
		||||
         // 7: 30min-Pulse for HB
 | 
			
		||||
 | 
			
		||||
    virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0;
 | 
			
		||||
    /*
 | 
			
		||||
 | 
			
		||||
@@ -1572,12 +1614,79 @@ public:
 | 
			
		||||
        //          bit6: no response             bit7: serial rec. error
 | 
			
		||||
        //			bit5: printer not ready
 | 
			
		||||
 | 
			
		||||
    virtual void sys_sendDeviceParameter(struct T_devices *deviceSettings) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual bool sys_areDCdataValid(void) const=0;
 | 
			
		||||
 | 
			
		||||
    /* ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ------------   supervise  all hardware components
 | 
			
		||||
    // ------------    assess the machine state
 | 
			
		||||
 | 
			
		||||
    1. check if DC startup test is through, retrigger if not
 | 
			
		||||
    2. get results and find errors
 | 
			
		||||
    3. in case of error check if component is used (e.g. billreader is seldom used)
 | 
			
		||||
    4: check doors
 | 
			
		||||
    5. return value: 0: no response from DC
 | 
			
		||||
                     1: no Test results and Test not running. need retrigger!
 | 
			
		||||
                     2: state not clear by now, test ongoing, wait
 | 
			
		||||
                     3: Service or battery door is open, goto INTRUSION MODE
 | 
			
		||||
                            from here: after valid ID-card goto SERVICE MODE
 | 
			
		||||
                     4: vault door is open, goto INTRUSION MODE
 | 
			
		||||
                            from here: after valid ID-card and vault door closed goto TEST MODE
 | 
			
		||||
                            in TEST MODE: complete system check decides if vending mode allowed
 | 
			
		||||
                     5: All doors are closed but errors found,
 | 
			
		||||
                            goto OOO MODE (out-of-order)
 | 
			
		||||
                            from here: run system test until problem is fixed
 | 
			
		||||
                     6: All doors are closed, no error, maybe warnings,
 | 
			
		||||
                            goto VENDING MODE (normal operation)
 | 
			
		||||
                    (priority sinks from 0 to 6)
 | 
			
		||||
 | 
			
		||||
     --------------------------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
    virtual uint8_t sys_componentAssessment(void) const=0;
 | 
			
		||||
    // this function decides if vending mode is possible, independant from door
 | 
			
		||||
    // return >0 in case of error
 | 
			
		||||
    // is inncluded in sys_superviseSystem
 | 
			
		||||
 | 
			
		||||
    virtual uint8_t sys_superviseSystem(void) const=0;
 | 
			
		||||
    // this function proofs if vending is possible depending of doors state
 | 
			
		||||
 | 
			
		||||
    virtual uint8_t sys_getSystemErrors(void) const=0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // retrigger System-Check with:
 | 
			
		||||
    // bool hwapi::sys_runCompleteTest(void) const
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
    // ---------------------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
    virtual void hwapi_templatePrintFinished_OK(void) const=0;
 | 
			
		||||
    virtual void hwapi_templatePrintFinished_Err(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual void hwapi_coinCollectionJustStarted(void) const=0;
 | 
			
		||||
    virtual void hwapi_coinCollectionAborted(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual void hwapi_gotNewCoin(void) const=0;
 | 
			
		||||
    virtual void hwapi_vendStopByMax(void) const=0;
 | 
			
		||||
    virtual void hwapi_vendStopByPushbutton(void) const=0;
 | 
			
		||||
    virtual void hwapi_payStopByMax(void) const=0;
 | 
			
		||||
    virtual void hwapi_payStopByPushbutton(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual void hwapi_payStopByEscrow(void) const=0;
 | 
			
		||||
    virtual void hwapi_payStopByError(void) const=0;
 | 
			
		||||
    virtual void hwapi_payStopByTimeout(void) const=0;
 | 
			
		||||
    virtual void hwapi_payCancelled(void) const=0;
 | 
			
		||||
 | 
			
		||||
    virtual void hwapi_coinProcessJustStopped(void) const=0;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -237,6 +237,14 @@ uint8_t check4freeFDlongCmd(void);
 | 
			
		||||
    // returns number of free places in long-command stack
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf);
 | 
			
		||||
    // HWapi writes data to be stored
 | 
			
		||||
 | 
			
		||||
uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -225,6 +225,9 @@ struct SharedMemBuffer {
 | 
			
		||||
        uint8_t vaultrecord[360];
 | 
			
		||||
        uint32_t amount;
 | 
			
		||||
        uint16_t nrOfCoins;
 | 
			
		||||
        bool    dcDataValid;
 | 
			
		||||
        uint8_t wakeReason;
 | 
			
		||||
        char    curPayNewCoin;
 | 
			
		||||
    } store;
 | 
			
		||||
 | 
			
		||||
    struct T_globTime {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
#define STOREINDATA_H
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "tslib.h"
 | 
			
		||||
//#include "tslib.h"
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -384,6 +384,7 @@ bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values);
 | 
			
		||||
 | 
			
		||||
void gpi_storeWakeSources(uint8_t const *receivedData);
 | 
			
		||||
uint64_t epi_getWakeSources(void);
 | 
			
		||||
uint8_t epi_getWakeReason(void);
 | 
			
		||||
 | 
			
		||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data);
 | 
			
		||||
void epi_restoreExtendedTime(uint8_t *leng, uint8_t *data);
 | 
			
		||||
@@ -415,6 +416,12 @@ uint8_t epi_mifGetCardType(uint8_t const *holder);
 | 
			
		||||
    //holder[8] = name of card holder
 | 
			
		||||
    // retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
 | 
			
		||||
 | 
			
		||||
void gpi_storeDcDataValid(bool isVal);
 | 
			
		||||
bool gpi_areDcDataValid();
 | 
			
		||||
bool epi_areDcDataValid();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1585
									
								
								plugins/interfaces.h
									
									
									
									
									
								
							
							
						
						
									
										1585
									
								
								plugins/interfaces.h
									
									
									
									
									
								
							
										
											
												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
 | 
			
		||||
							
								
								
									
										316
									
								
								src/ATBAPP/ATBDeviceControllerPlugin.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										316
									
								
								src/ATBAPP/ATBDeviceControllerPlugin.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,316 @@
 | 
			
		||||
#include "src/ATBAPP/ATBDeviceControllerPlugin.h"
 | 
			
		||||
#include "src/ATBAPP/ATBHealthEvent.h"
 | 
			
		||||
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
#include <QTextCodec>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ATBDeviceControllerPlugin::ATBDeviceControllerPlugin(QObject *parent) : QObject(parent),
 | 
			
		||||
    pluginState(PLUGIN_STATE::NOT_INITIALIZED)
 | 
			
		||||
{
 | 
			
		||||
    this->pluginInfo = QString::fromUtf8(pluginInfoString.c_str());
 | 
			
		||||
 | 
			
		||||
    this->hw = new hwapi();
 | 
			
		||||
 | 
			
		||||
    connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_OK()),  this, SLOT(onPrintFinishedOK()));
 | 
			
		||||
    connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_templatePrintFinished_Err()), this, SLOT(onPrintFinishedERR()));
 | 
			
		||||
    connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_gotNewCoin()),    this, SLOT(onCashGotCoin()));
 | 
			
		||||
    connect(dynamic_cast<QObject*>(hw), SIGNAL(hwapi_vendStopByMax()), this, SLOT(onCashVendStopByMax()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // text encoding for printer
 | 
			
		||||
    this->codec = QTextCodec::codecForName(printerEncoding);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    this->pluginState = PLUGIN_STATE::INITIALIZED;
 | 
			
		||||
 | 
			
		||||
    return pluginState;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 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());
 | 
			
		||||
 | 
			
		||||
    hw->cash_startPayment(amountInt);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::requestStopCashInput()
 | 
			
		||||
{
 | 
			
		||||
    hw->cash_stopPayment();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::cashCollect()
 | 
			
		||||
{
 | 
			
		||||
    hw->vend_success();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::cashAbort()
 | 
			
		||||
{
 | 
			
		||||
    hw->vend_failed();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 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->parkingEndTime,  ba_parkingEndTime.data(), std::min(ba_parkingEndTime.size(),8));
 | 
			
		||||
 | 
			
		||||
    QByteArray ba_parkingEndDate = codec->fromUnicode(parkingEndDateTime.toString("dd.MM.yy"));
 | 
			
		||||
    memcpy((char*)dynTicketData->parkingEndDate,  ba_parkingEndDate.data(), std::min(ba_parkingEndDate.size(),8));
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    QTimer::singleShot(500, this, SLOT(onPrinterDataPrepared()));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ATBDeviceControllerPlugin::onPrinterDataPrepared()
 | 
			
		||||
{
 | 
			
		||||
    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(1000, this, SLOT(onPrinterPrintNextTemplate()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/************************************************************************************************
 | 
			
		||||
 * private slots, interface to low level hwapi
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
void ATBDeviceControllerPlugin::onPrintFinishedOK()
 | 
			
		||||
{
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "ATBDeviceControllerPlugin::onPrintFinishedOK()";
 | 
			
		||||
 | 
			
		||||
    emit this->printTicketFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
 | 
			
		||||
                                   "",
 | 
			
		||||
                                   "");
 | 
			
		||||
}
 | 
			
		||||
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()";
 | 
			
		||||
 | 
			
		||||
    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::onCashVendStopByMax()
 | 
			
		||||
{
 | 
			
		||||
    // DEBUG
 | 
			
		||||
    qCritical() << "ATBDeviceControllerPlugin::onCashVendStopByMax()";
 | 
			
		||||
 | 
			
		||||
    uint32_t amountInt = this->hw->getInsertedAmount();
 | 
			
		||||
 | 
			
		||||
    QString amountString = QString::number(amountInt);
 | 
			
		||||
 | 
			
		||||
    emit this->cashInputFinished(nsDeviceControllerInterface::RESULT_STATE::SUCCESS,
 | 
			
		||||
                              amountString,
 | 
			
		||||
                              "",
 | 
			
		||||
                              "");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/************************************************************************************************
 | 
			
		||||
 * 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
 | 
			
		||||
							
								
								
									
										125
									
								
								src/ATBAPP/ATBDeviceControllerPlugin.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										125
									
								
								src/ATBAPP/ATBDeviceControllerPlugin.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,125 @@
 | 
			
		||||
#ifndef ATBDEVICECONTROLLERPLUGIN_H
 | 
			
		||||
#define ATBDEVICECONTROLLERPLUGIN_H
 | 
			
		||||
 | 
			
		||||
#include <QObject>
 | 
			
		||||
 | 
			
		||||
#include "src/ATBAPP/DeviceControllerInterface.h"
 | 
			
		||||
#include "src/ATBAPP/ATBAPPplugin.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "hwapi.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);
 | 
			
		||||
 | 
			
		||||
    // 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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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 requestServiceMode();
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
 | 
			
		||||
private slots:
 | 
			
		||||
   // printer
 | 
			
		||||
 | 
			
		||||
   void onPrinterDataPrepared();
 | 
			
		||||
   void onPrinterPrintNextTemplate();
 | 
			
		||||
 | 
			
		||||
   void onPrintFinishedOK();
 | 
			
		||||
   void onPrintFinishedERR();
 | 
			
		||||
 | 
			
		||||
   // cash payment
 | 
			
		||||
   void onCashGotCoin();
 | 
			
		||||
   void onCashVendStopByMax();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
							
								
								
									
										142
									
								
								src/ATBAPP/DeviceControllerInterface.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								src/ATBAPP/DeviceControllerInterface.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,142 @@
 | 
			
		||||
#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: 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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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 requestServiceMode() = 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
 | 
			
		||||
@@ -19,7 +19,7 @@ void T_com::writeToSerial(const QByteArray &data, uint16_t sendLength)
 | 
			
		||||
    sendLen=sendLength;
 | 
			
		||||
    if (CatSerial->isOpen())
 | 
			
		||||
    {
 | 
			
		||||
        //qDebug() << "sending..." << sendBuffer;
 | 
			
		||||
        qCritical() << "sending..." << sendBuffer;
 | 
			
		||||
        CatSerial->write(sendBuffer);
 | 
			
		||||
    } else
 | 
			
		||||
        qDebug() << "error sending, port is not open";
 | 
			
		||||
 
 | 
			
		||||
@@ -17,6 +17,8 @@ static uint16_t datif_OutCmdpara5;
 | 
			
		||||
static uint32_t datif_OutCmdpara6;
 | 
			
		||||
static uint8_t cycl_running;
 | 
			
		||||
 | 
			
		||||
//static bool     datif_DCdataValid;
 | 
			
		||||
 | 
			
		||||
T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@@ -46,6 +48,9 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
 | 
			
		||||
    dif_scanStep=0;
 | 
			
		||||
    selectedSlaveAddr=FIX_SLAVE_ADDR;
 | 
			
		||||
    cycl_running=0;
 | 
			
		||||
    //datif_DCdataValid=0;
 | 
			
		||||
    gpi_storeDcDataValid(0);
 | 
			
		||||
    datif_noResponseCtr=0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void T_datif::resetChain(void)
 | 
			
		||||
@@ -65,6 +70,11 @@ char T_datif::datif_cycleSend()
 | 
			
		||||
    uint8_t length, data[66];
 | 
			
		||||
    bool b_ret;
 | 
			
		||||
 | 
			
		||||
    datif_noResponseCtr++;         // inc every 10ms    fehlt noch in SysCont
 | 
			
		||||
    if (datif_noResponseCtr>500)    // seit 5s kein Lebenszeichen von DC2
 | 
			
		||||
        gpi_storeDcDataValid(0);    // fehlt in SysCont
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (cycl_running)
 | 
			
		||||
    {
 | 
			
		||||
        // request is still running, wait for response before next sending
 | 
			
		||||
@@ -210,7 +220,10 @@ char T_datif::datif_cycleSend()
 | 
			
		||||
                sendINrequestsAutomatic();  // sendCyclicCmd();       // request all cyclic data sequential
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                dif_scanStep=0;         // always start from beginning
 | 
			
		||||
                gpi_storeDcDataValid(0);    // fehlt in SysCont
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        #ifdef USEHANDSHAKES
 | 
			
		||||
        else
 | 
			
		||||
@@ -221,6 +234,7 @@ char T_datif::datif_cycleSend()
 | 
			
		||||
    } else
 | 
			
		||||
    {
 | 
			
		||||
        //qDebug()  << "com port not available";    // wird ununterbrochen ausgegeben
 | 
			
		||||
        gpi_storeDcDataValid(0);    // fehlt in SysCont
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
@@ -838,6 +852,7 @@ char T_datif::isPortOpen(void)
 | 
			
		||||
 | 
			
		||||
void T_datif::StoredRecData()
 | 
			
		||||
{
 | 
			
		||||
    datif_noResponseCtr=0;
 | 
			
		||||
    //qDebug() << "StoreRecData called";
 | 
			
		||||
    // call automatically by T_prot
 | 
			
		||||
    //if (myDCIF->ifDataReceived())
 | 
			
		||||
@@ -872,14 +887,20 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
    ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress,  &RdDleng, receivedData);
 | 
			
		||||
        // retval: data valid, only one time true, true if CommandState OK and readState OK
 | 
			
		||||
    gpi_storeResultOfLastRequest(ret);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    qCritical() << "loadRecDataFromFrame() readSource = " << readSource;
 | 
			
		||||
 | 
			
		||||
    if (ret==false)
 | 
			
		||||
    {
 | 
			
		||||
     //   qDebug() << "datif: rec data not valid";
 | 
			
		||||
        qCritical() << "datif: rec data not valid";
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    gpi_storeRecPayLoad(RdDleng, receivedData); //  save for host (user of hwapi)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    qCritical() << "loadRecDataFromFrame() readSource = " << readSource;
 | 
			
		||||
    //qDebug() << "\n datif: got valid data, rdsrc:" << readSource << "  rdadd:" << readAddress
 | 
			
		||||
     //        << "  rdlen:" << RdDleng;
 | 
			
		||||
//    qDebug("datif_recData: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d ",
 | 
			
		||||
@@ -1197,7 +1218,7 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    case CMD2DC_EMP_GET_ALL:        //23
 | 
			
		||||
        //qDebug() << "got emp parameters "<< receivedData[1];
 | 
			
		||||
        qCritical() << "got emp parameters "<< receivedData[1];
 | 
			
		||||
        gpi_storeEmpSettings(64, receivedData);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
@@ -1206,6 +1227,15 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
        // DB1: last coin signal (value / scale)
 | 
			
		||||
        // DB2,3: last coin value
 | 
			
		||||
        // DB4: lastError from Emp
 | 
			
		||||
 | 
			
		||||
        // 0: nr of stored coins
 | 
			
		||||
        // 1: got  2:type  3:err  4=valL  5=valH
 | 
			
		||||
 | 
			
		||||
//        qDebug() << "got emp coin "<< " " << receivedData[0] <<" " << receivedData[1]
 | 
			
		||||
//                 << " " << receivedData[2]<< " " << receivedData[3]
 | 
			
		||||
//                 << " " << receivedData[4]<< " " << receivedData[5]
 | 
			
		||||
//                 << " " << receivedData[6]<< " " << receivedData[7];
 | 
			
		||||
 | 
			
		||||
        gpi_storeEmpCoinSignal(receivedData[0], &receivedData[1]);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
@@ -1361,12 +1391,19 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
        newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
 | 
			
		||||
        uitmp=uchar2uint(receivedData[5],receivedData[4]);
 | 
			
		||||
        uit2=uchar2uint(receivedData[7],receivedData[6]);
 | 
			
		||||
        if (uitmp>0) // nur 1x bei neuer Münze
 | 
			
		||||
        {
 | 
			
		||||
            gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
 | 
			
		||||
            //void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
 | 
			
		||||
            if (newInsertedAmount != lastInsertedAmount)
 | 
			
		||||
            {
 | 
			
		||||
                emit datif_gotNewCoin();
 | 
			
		||||
//qDebug()<<"emit new coin";
 | 
			
		||||
 | 
			
		||||
                lastInsertedAmount=newInsertedAmount;
 | 
			
		||||
            }
 | 
			
		||||
qDebug()<<"   store new coin"<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
@@ -1478,6 +1515,10 @@ char T_datif::loadRecDataFromFrame()
 | 
			
		||||
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
        if (RdDleng>40)
 | 
			
		||||
            //datif_DCdataValid=1;    // das hier sind die wichtigsten Daten, deshalb hierrein!
 | 
			
		||||
            gpi_storeDcDataValid(1);
 | 
			
		||||
 | 
			
		||||
        gpi_storeDynMachineConditions(RdDleng, receivedData);
 | 
			
		||||
 | 
			
		||||
        prnResult=receivedData[52];
 | 
			
		||||
@@ -1578,6 +1619,7 @@ struct T_vaultRecord
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    readSource=0;   // 17.05.2023: to avoid multiple recording
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										25
									
								
								src/hwChk.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										25
									
								
								src/hwChk.cpp
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "hwChk.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
hwChk::hwChk(QWidget *parent) : QObject(parent)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
//    myDCIF = new T_prot();
 | 
			
		||||
// h: T_prot *myDCIF;
 | 
			
		||||
 | 
			
		||||
    //myDatif = new T_datif();
 | 
			
		||||
    HWaccess = new hwinf();
 | 
			
		||||
 | 
			
		||||
    struct T_moduleCondition dcModCond;
 | 
			
		||||
    sys_getDeviceConditions(dcModCond);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hwChk::~hwChk()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										439
									
								
								src/hwapi.cpp
									
									
									
									
									
								
							
							
						
						
									
										439
									
								
								src/hwapi.cpp
									
									
									
									
									
								
							@@ -24,17 +24,18 @@
 | 
			
		||||
#include "shared_mem_buffer.h"
 | 
			
		||||
#include <QDebug>
 | 
			
		||||
#include <QSharedMemory>
 | 
			
		||||
 | 
			
		||||
#include "interfaces.h"
 | 
			
		||||
 | 
			
		||||
static uint32_t hwapi_lastStartAmount;
 | 
			
		||||
static uint8_t  hwapi_cash_lastCollectionState;
 | 
			
		||||
static uint8_t  hwapi_paymentStarted;
 | 
			
		||||
 | 
			
		||||
static const QMap<QString, int> baudrateMap = {
 | 
			
		||||
  {"1200"   ,   0}, {"9600"   ,   1}, {"19200"  ,   2}, {"38400"  ,   3},
 | 
			
		||||
  {"57600"  ,   4}, {"115200" ,   5}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
hwapi::hwapi(QWidget *parent) : QObject(parent) {
 | 
			
		||||
hwapi::hwapi(QObject *parent) : QObject(parent) {
 | 
			
		||||
    // create or attach shared memory segment
 | 
			
		||||
    // !!! The compoment creating the shared memory MUST be ATBQT !!!
 | 
			
		||||
    m_sharedMem = SharedMemBuffer::getShm(sizeof(SharedMemBuffer));
 | 
			
		||||
@@ -52,6 +53,18 @@ hwapi::hwapi(QWidget *parent) : QObject(parent) {
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_templatePrintFinished_OK()), this, SLOT(hwapi_slotPrintFinished_OK()));
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_templatePrintFinished_Err()), this, SLOT(hwapi_slotPrintFinished_Err()));
 | 
			
		||||
    connect(myDatif, SIGNAL(datif_gotNewCoin()), this, SLOT(hwapi_slotGotCoin()));
 | 
			
		||||
 | 
			
		||||
    hwapi_TimerPayment = new QTimer();
 | 
			
		||||
    hwapi_TimerPayment->setSingleShot(true);
 | 
			
		||||
 | 
			
		||||
    QTimer *hwapi_callPayProc = new QTimer();
 | 
			
		||||
    connect(hwapi_callPayProc, SIGNAL(timeout()), this, SLOT(hwapi_slotPayProc()));
 | 
			
		||||
    hwapi_callPayProc->setSingleShot(false);
 | 
			
		||||
    hwapi_callPayProc->start(100);     // in ms
 | 
			
		||||
 | 
			
		||||
    hwapi_lastStartAmount=0;
 | 
			
		||||
    hwapi_cash_lastCollectionState=0;
 | 
			
		||||
    hwapi_paymentStarted=0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hwapi::~hwapi() {
 | 
			
		||||
@@ -60,6 +73,12 @@ hwapi::~hwapi() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void hwapi::hwapi_slotPayProc(void)
 | 
			
		||||
{
 | 
			
		||||
    cash_paymentProcessing();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::hwapi_slotPrintFinished_OK(void) {
 | 
			
		||||
    emit hwapi_templatePrintFinished_OK();
 | 
			
		||||
}
 | 
			
		||||
@@ -75,7 +94,7 @@ void hwapi::hwapi_slotGotCoin(void) {
 | 
			
		||||
    uint32_t newSum=epi_CurrentPaymentGetAmount();
 | 
			
		||||
 | 
			
		||||
    if (newSum>=hwapi_lastStartAmount)
 | 
			
		||||
        emit hwapi_vendStopByMax();
 | 
			
		||||
        emit hwapi_payStopByMax();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -3516,6 +3535,7 @@ bool hwapi::prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
 | 
			
		||||
    // print one of the templates loaded by Json prior
 | 
			
		||||
    // nr = 1..32
 | 
			
		||||
@@ -3618,11 +3638,192 @@ bool hwapi::cash_startPayment(uint32_t amount) const
 | 
			
		||||
    dat2=ulong2uchar(amount, 1);
 | 
			
		||||
    dat3=ulong2uchar(amount, 2);
 | 
			
		||||
    dat4=ulong2uchar(amount, 3);
 | 
			
		||||
    hwapi_cash_lastCollectionState=0;
 | 
			
		||||
    sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4);
 | 
			
		||||
 | 
			
		||||
    return sendFDcmd_set(155, 0,0, dat1,dat2,dat3,dat4);
 | 
			
		||||
    hwapi_paymentStarted=1;
 | 
			
		||||
    hwapi_TimerPayment->start(5000);     // in ms
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::cash_paymentProcessing(void) const
 | 
			
		||||
{
 | 
			
		||||
    // run this function periodically while coin payment process to generate necessary signals:
 | 
			
		||||
    //    virtual void hwapi_coinCollectionJustStarted(void) const=0;
 | 
			
		||||
    //    virtual void hwapi_coinCollectionAborted(void) const=0;
 | 
			
		||||
    //    virtual void hwapi_gotNewCoin(void) const=0;              // comes from: hwapi_slotGotCoin()
 | 
			
		||||
    //    virtual void hwapi_payStopByMax(void) const=0;            // comes from: hwapi_slotGotCoin()
 | 
			
		||||
    //    virtual void hwapi_payStopByPushbutton(void) const=0;     // comes from cash_stopPayment()
 | 
			
		||||
    //    virtual void hwapi_payStopByEscrow(void) const=0;
 | 
			
		||||
    //    virtual void hwapi_payStopByError(void) const=0;
 | 
			
		||||
    //    virtual void hwapi_payStopByTimeout(void) const=0;
 | 
			
		||||
    //    virtual void hwapi_payCancelled(void) const=0;
 | 
			
		||||
 | 
			
		||||
    //    virtual void hwapi_coinProcessJustStopped(void) const=0;
 | 
			
		||||
 | 
			
		||||
    // return value:
 | 
			
		||||
    // 0: stopped   1: starting up   2: coin collection
 | 
			
		||||
    // 3: finished by User (Push button)  4: finished, Max-Value collected
 | 
			
		||||
    // 5: finished by escrow
 | 
			
		||||
    // 6: money encashed
 | 
			
		||||
    // 7: cancelled
 | 
			
		||||
    // 10,11: error cannot start
 | 
			
		||||
    // 12: timeout while payment, coins returned
 | 
			
		||||
    // 13: stopped by unexpected error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    struct T_emp empStat;
 | 
			
		||||
    struct T_dynamicCondition myDynMachCond;
 | 
			
		||||
    uint8_t collActiv=0, payInProg, empState;
 | 
			
		||||
 | 
			
		||||
    if (hwapi_paymentStarted<1)
 | 
			
		||||
        return 0;       // off
 | 
			
		||||
 | 
			
		||||
    collActiv=1;    // starting up payment
 | 
			
		||||
    emp_getAllParameters(&empStat);
 | 
			
		||||
    //collActiv=empStat.paymentRunning;
 | 
			
		||||
 | 
			
		||||
    empState=empStat.state;
 | 
			
		||||
        // 0=start command
 | 
			
		||||
        // 1=powered, do emp ini, send reset
 | 
			
		||||
        // 2=delay
 | 
			
		||||
        // 3=wait for response, requesting status after response
 | 
			
		||||
        // 4,5 through, startup
 | 
			
		||||
        // 6: wait for status
 | 
			
		||||
        // 7: through, startup
 | 
			
		||||
        // 8: IDLE state.   EMP is up and ready, polling is running
 | 
			
		||||
        // 9: polling on, payment not yet on
 | 
			
		||||
        // 10: payment, check coins
 | 
			
		||||
        // 11: through
 | 
			
		||||
        // 12: wait 1s for last coin
 | 
			
		||||
        // 90: stop all, 1s delay
 | 
			
		||||
        // 99: off, all stopped
 | 
			
		||||
 | 
			
		||||
    //qCritical() << "empState = " << empState;
 | 
			
		||||
 | 
			
		||||
    sys_getDynMachineConditions(&myDynMachCond);
 | 
			
		||||
    payInProg= myDynMachCond.paymentInProgress;
 | 
			
		||||
    //	0: stopped by timeout
 | 
			
		||||
    //  1: running  2: wait4lastCoin
 | 
			
		||||
    //				3: payment stopped manually, coins in Escrow
 | 
			
		||||
    //			    4: payment stopped autom, amount collected, coins in Escrow
 | 
			
		||||
    //			    5: payment stopped, escrow full, coins in Escrow
 | 
			
		||||
    //			    6: coins encashed   7:coins returned
 | 
			
		||||
    //				8: CoinChecker or MDB on Error
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (payInProg==8)
 | 
			
		||||
    {
 | 
			
		||||
        // coin checker faulty, cannot start
 | 
			
		||||
        if (hwapi_paymentStarted==1)
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted=90;    // stop due to error
 | 
			
		||||
            emit hwapi_coinCollectionAborted();
 | 
			
		||||
            //sendFDcmd_set(156, 0,0, 2,0,0,0);       // cancel payment
 | 
			
		||||
            collActiv=10;    // error cannot start
 | 
			
		||||
        }
 | 
			
		||||
    } else
 | 
			
		||||
 | 
			
		||||
    if (empState>=10 && empState<=12)
 | 
			
		||||
    {
 | 
			
		||||
        // coin acceptance is active now:
 | 
			
		||||
        hwapi_TimerPayment->stop();     // to avoid error signal
 | 
			
		||||
        if (hwapi_paymentStarted==1)    // 1=wait for coin checker being ready
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted=2;     // coins can be inserted no
 | 
			
		||||
            emit hwapi_coinCollectionJustStarted();
 | 
			
		||||
        }
 | 
			
		||||
    } else
 | 
			
		||||
    {
 | 
			
		||||
        // EMP not (yet) ready
 | 
			
		||||
 | 
			
		||||
        if (!hwapi_TimerPayment->isActive())
 | 
			
		||||
        {
 | 
			
		||||
            // 5s after start-payment the coin-checker is still not ready
 | 
			
		||||
            hwapi_TimerPayment->stop();
 | 
			
		||||
            if (hwapi_paymentStarted==1)
 | 
			
		||||
            {
 | 
			
		||||
                hwapi_paymentStarted=90;    // stop due to error
 | 
			
		||||
                emit hwapi_coinCollectionAborted();     // error cannot start
 | 
			
		||||
                //sendFDcmd_set(156, 0,0, 2,0,0,0);       // cancel payment
 | 
			
		||||
                collActiv=11;    // error cannot start
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (hwapi_paymentStarted==2)
 | 
			
		||||
    {
 | 
			
		||||
        collActiv=2;    // coin collection active
 | 
			
		||||
 | 
			
		||||
        // coins can be inserted now, wait for end
 | 
			
		||||
        if (payInProg==0)   // timeout
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=12;   // stop by timeout
 | 
			
		||||
            emit hwapi_payStopByTimeout();
 | 
			
		||||
        } else
 | 
			
		||||
        if (payInProg==3)   // user pressed "Next/Continue"
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=3;
 | 
			
		||||
            emit hwapi_payStopByPushbutton();
 | 
			
		||||
        } else
 | 
			
		||||
        if (payInProg==4)   // max achieved
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=4;
 | 
			
		||||
            emit hwapi_payStopByMax();
 | 
			
		||||
        } else
 | 
			
		||||
        if (payInProg==5)   // escrow full
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=5;
 | 
			
		||||
            emit hwapi_payStopByEscrow();
 | 
			
		||||
        } else
 | 
			
		||||
        if (payInProg==6)   // encashed
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=6;
 | 
			
		||||
 | 
			
		||||
        } else
 | 
			
		||||
        if (payInProg==7)   // returned, user pressed Cancel button
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=7;
 | 
			
		||||
            emit hwapi_payCancelled();
 | 
			
		||||
        } else
 | 
			
		||||
 | 
			
		||||
        if (empState<9 || payInProg==8)
 | 
			
		||||
        {
 | 
			
		||||
            hwapi_paymentStarted++;
 | 
			
		||||
            collActiv=13;       // stopped by unexpected error
 | 
			
		||||
            emit hwapi_payStopByError();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (empState<8 || empState>12)
 | 
			
		||||
        epi_clearCurrentPayment();      // to avoid wrong "got-coin" messages
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    if (hwapi_paymentStarted==90 || hwapi_paymentStarted==3 )
 | 
			
		||||
    {
 | 
			
		||||
        // EMP error, wait till process finished
 | 
			
		||||
        if (empState==99 && (payInProg==0 || payInProg>5) )
 | 
			
		||||
        {
 | 
			
		||||
            // everything stopped, no more coins in escrow
 | 
			
		||||
            hwapi_paymentStarted=0;
 | 
			
		||||
            emit hwapi_coinProcessJustStopped();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return collActiv;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint32_t hwapi::getInsertedAmount(void) const
 | 
			
		||||
{
 | 
			
		||||
    return epi_CurrentPaymentGetAmount();
 | 
			
		||||
@@ -3653,7 +3854,7 @@ bool hwapi::cash_stopPayment(void) const
 | 
			
		||||
{
 | 
			
		||||
    // DB1: 1=encash    2=cancel & return coins
 | 
			
		||||
    //      3=stop and keep coins in escrow
 | 
			
		||||
    emit hwapi_vendStopByPushbutton();
 | 
			
		||||
    emit hwapi_payStopByPushbutton();
 | 
			
		||||
    return sendFDcmd_set(156, 0,0, 3,0,0,0);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -3676,6 +3877,11 @@ bool hwapi::vend_failed(void) const
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::mif_getCardType(QString *cardholder) const
 | 
			
		||||
    // return 1,2,3,4 = upper, lower access card, printer test, coin test
 | 
			
		||||
    // cardholder: 7byte Name-String
 | 
			
		||||
@@ -3702,6 +3908,20 @@ uint64_t hwapi::sys_getWakeSource(void) const
 | 
			
		||||
     return epi_getWakeSources();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::sys_getWakeReason(void) const
 | 
			
		||||
{
 | 
			
		||||
     // Master was woken by following reason:
 | 
			
		||||
     // 1: MDB Event
 | 
			
		||||
     // 2: Coin Event
 | 
			
		||||
     // ( 3: Master Event) - will not set the wake line
 | 
			
		||||
     // ( 4: 32s pulse) - will not set the wake line
 | 
			
		||||
     // 5: Door Event
 | 
			
		||||
     // ( 6: Diag Event) - will not set the wake line
 | 
			
		||||
     // 7: 30min-Pulse for HB
 | 
			
		||||
 | 
			
		||||
     return epi_getWakeReason();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void hwapi::sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const
 | 
			
		||||
{
 | 
			
		||||
@@ -3837,3 +4057,212 @@ uint8_t hwapi::prn_getCurrentPrinterState() const
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices"
 | 
			
		||||
void hwapi::sys_sendDeviceParameter(struct T_devices *deviceSettings) const
 | 
			
		||||
{
 | 
			
		||||
    // same as "sendDeviceSettings()" but with much more data
 | 
			
		||||
    uint8_t buf[64];
 | 
			
		||||
    uint16_t LL, nn;
 | 
			
		||||
    tslib_strclr(buf,0,64);
 | 
			
		||||
    uint8_t *start;
 | 
			
		||||
 | 
			
		||||
    // den gesamten struct in einen Puffer kopieren
 | 
			
		||||
    LL=sizeof(struct T_devices);
 | 
			
		||||
    start = &deviceSettings->kindOfPrinter;
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        buf[nn] = *start;
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
 | 
			
		||||
    epi_store64BdevParameter(LL,buf);   // this buffer holds the device settings to be used here in hwapi
 | 
			
		||||
    epi_store64ByteSendData(LL, buf);   // this buffer holds sending data temporarely
 | 
			
		||||
    sendWRcmd_setSendCommand0(SENDDIRCMD_DEVICE_PARA);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[64];
 | 
			
		||||
    uint8_t LL, nn;
 | 
			
		||||
    tslib_strclr(buf,0,64);
 | 
			
		||||
    uint8_t *start;
 | 
			
		||||
 | 
			
		||||
    epi_restore64BdevParameter(&LL, buf);
 | 
			
		||||
 | 
			
		||||
    // Puffer in struct eintragen:
 | 
			
		||||
    start = &deviceSettings->kindOfPrinter;
 | 
			
		||||
    nn=0;
 | 
			
		||||
    do
 | 
			
		||||
    {
 | 
			
		||||
        *start = buf[nn];
 | 
			
		||||
        start++;
 | 
			
		||||
    } while(++nn<LL);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool hwapi::sys_areDCdataValid(void) const
 | 
			
		||||
{
 | 
			
		||||
    return epi_areDcDataValid();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* ---------------------------------------------------------------------------------------------
 | 
			
		||||
// ------------   supervise  all hardware components
 | 
			
		||||
// ------------    assess the machine state
 | 
			
		||||
 | 
			
		||||
1. check if DC startup test is through, retrigger if not
 | 
			
		||||
2. get results and find errors
 | 
			
		||||
3. in case of error check if component is used (e.g. billreader is seldom used)
 | 
			
		||||
4: check doors
 | 
			
		||||
5. return value: 0: no response from DC
 | 
			
		||||
                 1: no Test results and Test not running. need retrigger!
 | 
			
		||||
                 2: state not clear by now, test ongoing, wait
 | 
			
		||||
                 3: Service or battery door is open, goto INTRUSION MODE
 | 
			
		||||
                        from here: after valid ID-card goto SERVICE MODE
 | 
			
		||||
                 4: vault door is open, goto INTRUSION MODE
 | 
			
		||||
                        from here: after valid ID-card and vault door closed goto TEST MODE
 | 
			
		||||
                        in TEST MODE: complete system check decides if vending mode allowed
 | 
			
		||||
                 5: All doors are closed but errors found,
 | 
			
		||||
                        goto OOO MODE (out-of-order)
 | 
			
		||||
                        from here: run system test until problem is fixed
 | 
			
		||||
                 6: All doors are closed, no error, maybe warnings,
 | 
			
		||||
                        goto VENDING MODE (normal operation)
 | 
			
		||||
                (priority sinks from 0 to 6)
 | 
			
		||||
 | 
			
		||||
 --------------------------------------------------------------------------------------------- */
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::sys_componentAssessment(void) const
 | 
			
		||||
{
 | 
			
		||||
    // this function decides if vending mode is possible, independant from door
 | 
			
		||||
    // return >0 in case of error
 | 
			
		||||
    // is inncluded in sys_superviseSystem
 | 
			
		||||
 | 
			
		||||
    struct T_moduleCondition *modCond=0;
 | 
			
		||||
    sys_getDeviceConditions(modCond);
 | 
			
		||||
 | 
			
		||||
    struct T_dynamicCondition *dynMaCond=0;
 | 
			
		||||
    sys_getDynMachineConditions(dynMaCond);
 | 
			
		||||
 | 
			
		||||
    struct T_devices *devPara=0;
 | 
			
		||||
    sys_restoreDeviceParameter(devPara);
 | 
			
		||||
 | 
			
		||||
    if (modCond->rtc>=200)
 | 
			
		||||
        return 1;
 | 
			
		||||
    if (modCond->printer==200 || modCond->printer==201)   // 200: not connected  201: printer-HW-error  202: no paper
 | 
			
		||||
        return 2;
 | 
			
		||||
    if (modCond->printer==202)
 | 
			
		||||
        return 3;
 | 
			
		||||
 | 
			
		||||
    if (modCond->coinBlocker>=200)
 | 
			
		||||
        return 4;
 | 
			
		||||
    if (modCond->mdbBus>=200)
 | 
			
		||||
        return 5;
 | 
			
		||||
    if (modCond->intEe>=200)
 | 
			
		||||
        return 6;
 | 
			
		||||
 | 
			
		||||
    if (devPara->kindOfCoinChecker==1 || devPara->kindOfCoinChecker==2)  // 0: without  1=EMP820   2=EMP900    3=currenza c²	(MW)
 | 
			
		||||
    {
 | 
			
		||||
        if (modCond->coinChecker>=200 || modCond->coinEscrow>=200)
 | 
			
		||||
        {
 | 
			
		||||
            // Fehler Münzver.
 | 
			
		||||
            return 7;
 | 
			
		||||
        }
 | 
			
		||||
        if (modCond->coinSafe>200)           // 200: kasse fehlt 201: voll  100:fast voll  1:ok
 | 
			
		||||
        {
 | 
			
		||||
            return 8;
 | 
			
		||||
        }
 | 
			
		||||
    } else
 | 
			
		||||
    if (devPara->kindOfCoinChecker==3)
 | 
			
		||||
    {
 | 
			
		||||
        if (modCond->changer>=200)
 | 
			
		||||
        {
 | 
			
		||||
            // Fehler Münzver.
 | 
			
		||||
            return 7;
 | 
			
		||||
        }
 | 
			
		||||
        if (modCond->coinSafe>200)           // 200: kasse fehlt 201: voll  100:fast voll  1:ok
 | 
			
		||||
        {
 | 
			
		||||
            return 8;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ( modCond->billReader>=200 && devPara->BillAcceptor>0)
 | 
			
		||||
    {
 | 
			
		||||
        // Fehler BNA
 | 
			
		||||
        return 9;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (dynMaCond->onAlarm>0)
 | 
			
		||||
        return 10;
 | 
			
		||||
 | 
			
		||||
    if (dynMaCond->modeAbrech>0)
 | 
			
		||||
        return 11;
 | 
			
		||||
 | 
			
		||||
    if (dynMaCond->nowCardTest>0)
 | 
			
		||||
        return 12;
 | 
			
		||||
 | 
			
		||||
    if (dynMaCond->startupTestIsRunning>0)
 | 
			
		||||
        return 13;
 | 
			
		||||
 | 
			
		||||
    if (modCond->voltage>=200)
 | 
			
		||||
        return 14;
 | 
			
		||||
    if (modCond->temper>=200)
 | 
			
		||||
        return 15;
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// retrigger System-Check with:
 | 
			
		||||
// bool hwapi::sys_runCompleteTest(void) const
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::sys_superviseSystem(void) const
 | 
			
		||||
{
 | 
			
		||||
    // this function proofs if vending is possible depending of doors state
 | 
			
		||||
 | 
			
		||||
    struct T_dynamicCondition *dynMaCond=0;
 | 
			
		||||
    struct T_moduleCondition *modCond=0;
 | 
			
		||||
 | 
			
		||||
    if (!gpi_areDcDataValid())
 | 
			
		||||
    {
 | 
			
		||||
        // es gibt keinerlei gültige Daten vom DC
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // jetzt sind die DC-Daten aktuell, also reinholen:
 | 
			
		||||
    sys_getDynMachineConditions(dynMaCond);
 | 
			
		||||
    sys_getDeviceConditions(modCond);
 | 
			
		||||
 | 
			
		||||
    if (!modCond->allModulesChecked)
 | 
			
		||||
    {
 | 
			
		||||
        // noch keine Testergebnisse
 | 
			
		||||
        if (dynMaCond->startupTestIsRunning)
 | 
			
		||||
            return 2;    // Starttest läuft gerade
 | 
			
		||||
        else
 | 
			
		||||
            return 1;    // Starttest ist noch nicht gelaufen
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // all doors: 99: undefined  0:closed  1:open
 | 
			
		||||
    if (dynMaCond->lowerDoor || dynMaCond->upperDoor)
 | 
			
		||||
        return 3;
 | 
			
		||||
    if (dynMaCond->middleDoor)
 | 
			
		||||
        return 4;
 | 
			
		||||
 | 
			
		||||
    if (sys_componentAssessment() >0)
 | 
			
		||||
        return 5;       // errors found
 | 
			
		||||
 | 
			
		||||
    return 6;   // everything fine
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
uint8_t hwapi::sys_getSystemErrors(void) const
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    return sys_componentAssessment();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -433,7 +433,8 @@ uint8_t recBuffer[FRAME_MAXLEN];
 | 
			
		||||
 | 
			
		||||
    // read from "VCP":
 | 
			
		||||
    mySerialPort->readFromSerial(Indata, recLength);
 | 
			
		||||
//qDebug()<<"prot: got data " << recLength;
 | 
			
		||||
    qCritical()<<"prot: got data "  << recLength;
 | 
			
		||||
    qCritical()<<"        Indata: " << Indata;
 | 
			
		||||
    if (recLength>FRAME_MAXLEN)
 | 
			
		||||
        recLength=FRAME_MAXLEN;
 | 
			
		||||
    for (int nn=0; nn<recLength; nn++)
 | 
			
		||||
@@ -443,6 +444,9 @@ uint8_t recBuffer[FRAME_MAXLEN];
 | 
			
		||||
    tempStr.clear();
 | 
			
		||||
    //uint8_t result=FramecheckInData(recBuffer, recLength);  // check input data (response from slave)
 | 
			
		||||
    uint8_t result=FastCheckInData(recBuffer, recLength);  // check input data (response from slave)
 | 
			
		||||
 | 
			
		||||
    qCritical()<<"    FastCheckInData() result = " << result;
 | 
			
		||||
 | 
			
		||||
    if (result>0)
 | 
			
		||||
    {
 | 
			
		||||
        // dann anzeige
 | 
			
		||||
 
 | 
			
		||||
@@ -671,3 +671,34 @@ uint8_t check4freeFDlongCmd(void)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static uint8_t Sdata_DeviceParameter[64];
 | 
			
		||||
static uint8_t Sdata_DevParaLen;
 | 
			
		||||
 | 
			
		||||
uint8_t epi_store64BdevParameter(uint8_t length, uint8_t *buf)
 | 
			
		||||
{
 | 
			
		||||
    // HWapi writes data to be stored
 | 
			
		||||
    uint8_t nn;
 | 
			
		||||
    for (nn=0; nn<length; nn++)
 | 
			
		||||
        Sdata_DeviceParameter[nn]=buf[nn];
 | 
			
		||||
    for (nn=length; nn<64; nn++)
 | 
			
		||||
        Sdata_DeviceParameter[nn]=0;
 | 
			
		||||
 | 
			
		||||
    Sdata_DevParaLen=length;
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t epi_restore64BdevParameter(uint8_t *length, uint8_t *buf)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    for (uint8_t nn=0; nn<Sdata_DevParaLen; nn++)
 | 
			
		||||
        buf[nn]=Sdata_DeviceParameter[nn];
 | 
			
		||||
    *length=Sdata_DevParaLen;
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ bool indat_isPrinterOn() {
 | 
			
		||||
    return indat_savePrnPwr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static bool indat_saveMifPwr;
 | 
			
		||||
 | 
			
		||||
void indat_storeMifarePower(bool isOn) {
 | 
			
		||||
@@ -34,6 +35,7 @@ bool indat_isMifareOn() {
 | 
			
		||||
    return indat_saveMifPwr;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static bool indat_MdbIsOn;
 | 
			
		||||
 | 
			
		||||
void indat_storeMDBisOn(bool isOn) {
 | 
			
		||||
@@ -44,6 +46,11 @@ bool indat_isMdbOn() {
 | 
			
		||||
    return indat_MdbIsOn;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// //////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
 | 
			
		||||
                             uint8_t parity, uint8_t NrStopBits) {
 | 
			
		||||
    // store numbers
 | 
			
		||||
@@ -95,6 +102,7 @@ void gpi_storeGenerals(uint8_t genNr, QString text) {
 | 
			
		||||
                text.toStdString().c_str(),
 | 
			
		||||
                sizeof(SharedMemBuffer::getDataConst()->genStrings[0]));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString epi_loadGenerals(uint8_t genNr) {
 | 
			
		||||
@@ -108,6 +116,9 @@ QString epi_loadGenerals(uint8_t genNr) {
 | 
			
		||||
    return " ";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// -------------------------------
 | 
			
		||||
 | 
			
		||||
void gpi_storeUID(uint8_t const *buf8byteUid) {
 | 
			
		||||
@@ -282,6 +293,7 @@ QString epi_getSlaveTimeDateStr() {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//          analog values
 | 
			
		||||
// ///////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
@@ -310,6 +322,7 @@ uint16_t epi_loadAIs(uint8_t aiNr) {
 | 
			
		||||
// ADC0: temp
 | 
			
		||||
// 1: voltage
 | 
			
		||||
// 2: brightness
 | 
			
		||||
#define MAXNROF_MEASURE         4
 | 
			
		||||
 | 
			
		||||
uint32_t epi_loadMeasureValue(uint8_t ValueNr) {
 | 
			
		||||
    // ValueNr 0=ADC0, 1=ADC1 aso...
 | 
			
		||||
@@ -989,6 +1002,15 @@ void gpi_storePrinterFonts(uint8_t const *buf) {
 | 
			
		||||
           sizeof(SharedMemBuffer::getData()->Sdata.PRN_FONTS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
    qDebug()<<"printer fonts stored " <<Sdata_PRN_FONTS[0]<<" "<<Sdata_PRN_FONTS[1]<<" " \
 | 
			
		||||
           <<Sdata_PRN_FONTS[2]<<" "<<Sdata_PRN_FONTS[3]<<" " \
 | 
			
		||||
          <<Sdata_PRN_FONTS[4]<<" "<<Sdata_PRN_FONTS[5]<<" "  \
 | 
			
		||||
            <<Sdata_PRN_FONTS[6]<<" "<<Sdata_PRN_FONTS[7]<<" " \
 | 
			
		||||
           <<Sdata_PRN_FONTS[8]<<" "<<Sdata_PRN_FONTS[9]<<" "  \
 | 
			
		||||
          <<Sdata_PRN_FONTS[10]<<" "<<Sdata_PRN_FONTS[11];
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// DB0: mdb_bus_ready (switched on)
 | 
			
		||||
// DB1: rdBackV12devicePower
 | 
			
		||||
// DB2: rdBackV5busPwr
 | 
			
		||||
@@ -1072,6 +1094,10 @@ void gpi_storeEmpCoinSignal(uint8_t leng, uint8_t const *data) {
 | 
			
		||||
    {
 | 
			
		||||
        vv=uchar2uint(data[pp+4], data[pp+3]);
 | 
			
		||||
        sub_enterData(data[pp], data[pp+1], data[pp+2], vv );
 | 
			
		||||
 | 
			
		||||
//qDebug()<< "emp IN data: " << data[pp] << " " << data[pp+1]
 | 
			
		||||
//        << " " <<data[pp+2] <<" " <<data[pp+3] <<" " <<data[pp+4] <<" ";
 | 
			
		||||
 | 
			
		||||
        pp+=5;
 | 
			
		||||
        LL--;
 | 
			
		||||
    }
 | 
			
		||||
@@ -1133,6 +1159,11 @@ void epi_clearCurrentPayment(void) {
 | 
			
		||||
    // call at beginning of coin collection
 | 
			
		||||
    SharedMemBuffer::getData()->store.insertedAmount = 0;
 | 
			
		||||
    p_lastCoin = 0;
 | 
			
		||||
    memset((char *)&SharedMemBuffer::getData()->store.lastCoinType[0],
 | 
			
		||||
            0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinType));
 | 
			
		||||
    memset((char *)&SharedMemBuffer::getData()->store.lastCoinValue[0],
 | 
			
		||||
            0x00, sizeof(SharedMemBuffer::getData()->store.lastCoinValue));
 | 
			
		||||
    SharedMemBuffer::getData()->store.curPayNewCoin = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void gpi_storeCurrentPayment(uint32_t insertedAmount,
 | 
			
		||||
@@ -1140,7 +1171,9 @@ void gpi_storeCurrentPayment(uint32_t insertedAmount,
 | 
			
		||||
    SharedMemBuffer::getData()->store.insertedAmount = insertedAmount;
 | 
			
		||||
    SharedMemBuffer::getData()->store.lastCoinType[p_lastCoin] = lastCoinType;
 | 
			
		||||
    SharedMemBuffer::getData()->store.lastCoinValue[p_lastCoin] = lastCoinValue;
 | 
			
		||||
 | 
			
		||||
    p_lastCoin++;
 | 
			
		||||
    SharedMemBuffer::getData()->store.curPayNewCoin++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint32_t epi_CurrentPaymentGetAmount(void) {
 | 
			
		||||
@@ -1172,17 +1205,26 @@ bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values) {
 | 
			
		||||
 | 
			
		||||
void gpi_storeWakeSources(uint8_t const *receivedData) {
 | 
			
		||||
    SharedMemBuffer::getData()->store.wakeSrc = 0;
 | 
			
		||||
    for (int nn=7; nn>=0; nn--) {
 | 
			
		||||
    for (int nn=5; nn>=0; nn--) {
 | 
			
		||||
        uint8_t const uctmp = receivedData[nn];
 | 
			
		||||
        SharedMemBuffer::getData()->store.wakeSrc |= uctmp;
 | 
			
		||||
        SharedMemBuffer::getData()->store.wakeSrc <<= 8;
 | 
			
		||||
    }
 | 
			
		||||
    SharedMemBuffer::getData()->store.wakeReason = receivedData[6];
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint64_t epi_getWakeSources(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->store.wakeSrc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t epi_getWakeReason(void)
 | 
			
		||||
{
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->store.wakeReason;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t const *data) {
 | 
			
		||||
    leng = std::min(leng, (uint8_t)(64));
 | 
			
		||||
    SharedMemBuffer::getData()->store.rbDevParamLen = leng;
 | 
			
		||||
@@ -1216,6 +1258,8 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data) {
 | 
			
		||||
            *leng);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// store dynamic machine conditions
 | 
			
		||||
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t const *data) {
 | 
			
		||||
    SharedMemBuffer::getData()->store.machCondLen = leng;
 | 
			
		||||
@@ -1303,3 +1347,24 @@ uint32_t epi_getCashBoxContent(void) {
 | 
			
		||||
uint16_t epi_getNrOfCoinsInCashBox(void) {
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->store.nrOfCoins;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void gpi_storeDcDataValid(bool isVal)
 | 
			
		||||
{
 | 
			
		||||
    SharedMemBuffer::getData()->store.dcDataValid = isVal;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool gpi_areDcDataValid()
 | 
			
		||||
{
 | 
			
		||||
    return SharedMemBuffer::getDataConst()->store.dcDataValid;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool epi_areDcDataValid()
 | 
			
		||||
{
 | 
			
		||||
    return SharedMemBuffer::getData()->store.dcDataValid;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user