Compare commits
35 Commits
5e6e6017b3
...
master
Author | SHA1 | Date | |
---|---|---|---|
60726093df | |||
777fabe95d | |||
a03df50881 | |||
06333c792f
|
|||
1ee1242a4c
|
|||
e318e606c6
|
|||
a67ff36c68
|
|||
21fb07b81c
|
|||
d992ee3fad | |||
b7d8fabfd0 | |||
7129805f4e | |||
01140c523b | |||
c99d0730ce | |||
81c610c48b | |||
6ae7c06d42 | |||
1eb2ac3a1d | |||
f3adba2f0f | |||
652ad9b43d | |||
c85b090306 | |||
87a6ed0795 | |||
99c88c7825 | |||
712ea0fc6e | |||
86311de486 | |||
cb4412779f | |||
a95e174356 | |||
c724b5b9fb | |||
ef7932102f | |||
a7aa75ae5f | |||
dc00c69b82 | |||
eeb35190e1 | |||
30338e24cc | |||
58fdea45f0 | |||
df760f1a52 | |||
3e3e1efe7d | |||
e5a8cfd1cd |
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
|
||||||
|
@@ -2,6 +2,7 @@ INCLUDEPATH += $${PWD}/include
|
|||||||
DEPENDPATH += $${PWD}
|
DEPENDPATH += $${PWD}
|
||||||
|
|
||||||
HEADERS += $${PWD}/include/com.h \
|
HEADERS += $${PWD}/include/com.h \
|
||||||
|
$$PWD/include/datei.h \
|
||||||
$${PWD}/include/controlBus.h \
|
$${PWD}/include/controlBus.h \
|
||||||
$${PWD}/include/datIf.h \
|
$${PWD}/include/datIf.h \
|
||||||
$${PWD}/include/dcBL.h \
|
$${PWD}/include/dcBL.h \
|
||||||
@@ -10,9 +11,12 @@ HEADERS += $${PWD}/include/com.h \
|
|||||||
$${PWD}/include/prot.h \
|
$${PWD}/include/prot.h \
|
||||||
$${PWD}/include/sendWRcmd.h \
|
$${PWD}/include/sendWRcmd.h \
|
||||||
$${PWD}/include/storeINdata.h \
|
$${PWD}/include/storeINdata.h \
|
||||||
$${PWD}/include/tslib.h
|
$${PWD}/include/tslib.h \
|
||||||
|
$${PWD}/include/shared_mem_buffer.h
|
||||||
|
|
||||||
SOURCES += $${PWD}/src/com.cpp \
|
SOURCES += $${PWD}/src/com.cpp \
|
||||||
|
$$PWD/src/datei.cpp \
|
||||||
|
$$PWD/src/main.cpp \
|
||||||
$${PWD}/src/controlBus.cpp \
|
$${PWD}/src/controlBus.cpp \
|
||||||
$${PWD}/src/datIf.cpp \
|
$${PWD}/src/datIf.cpp \
|
||||||
$${PWD}/src/dcBL.cpp \
|
$${PWD}/src/dcBL.cpp \
|
||||||
@@ -20,4 +24,5 @@ SOURCES += $${PWD}/src/com.cpp \
|
|||||||
$${PWD}/src/prot.cpp \
|
$${PWD}/src/prot.cpp \
|
||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp
|
$${PWD}/src/tslib.cpp \
|
||||||
|
$${PWD}/src/shared_mem_buffer.cpp
|
||||||
|
32
DCPlugin.pro
32
DCPlugin.pro
@@ -15,9 +15,9 @@ QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
|||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
|
|
||||||
contains( CONFIG, DesktopLinux ) {
|
contains( CONFIG, DesktopLinux ) {
|
||||||
QMAKE_CC = ccache $$QMAKE_CC
|
# QMAKE_CC = ccache $$QMAKE_CC
|
||||||
QMAKE_CXX = ccache $$QMAKE_CXX
|
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++17
|
||||||
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
# QMAKE_CXXFLAGS += -Wno-deprecated-ctor
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
ARCH = DesktopLinux
|
ARCH = DesktopLinux
|
||||||
@@ -27,7 +27,7 @@ contains( CONFIG, DesktopLinux ) {
|
|||||||
contains( CONFIG, PTU5 ) {
|
contains( CONFIG, PTU5 ) {
|
||||||
# QMAKE_CC = ccache $$QMAKE_CC
|
# QMAKE_CC = ccache $$QMAKE_CC
|
||||||
# QMAKE_CXX = ccache $$QMAKE_CXX
|
# QMAKE_CXX = ccache $$QMAKE_CXX
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++17
|
||||||
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
linux-clang { QMAKE_CXXFLAGS += -Qunused-arguments }
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
@@ -38,6 +38,8 @@ contains( CONFIG, PTU5 ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contains( CONFIG, PTU5_YOCTO ) {
|
contains( CONFIG, PTU5_YOCTO ) {
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += serialport
|
||||||
|
PTU5BASEPATH = /opt/devel/ptu5
|
||||||
ARCH = PTU5
|
ARCH = PTU5
|
||||||
|
|
||||||
# add qmqtt lib
|
# add qmqtt lib
|
||||||
@@ -45,7 +47,9 @@ contains( CONFIG, PTU5_YOCTO ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TARGET = CashAgentLib
|
TARGET = CashAgentLib
|
||||||
DESTDIR = ../plugins
|
#DESTDIR = ../plugins
|
||||||
|
INTERFACE = DeviceController
|
||||||
|
INTERFACE_DEFINITION = $${PWD}/include/ATBAPP/DeviceControllerInterface.h
|
||||||
|
|
||||||
|
|
||||||
# The following define makes your compiler emit warnings if you use
|
# The following define makes your compiler emit warnings if you use
|
||||||
@@ -66,3 +70,21 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
|||||||
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
#else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
#!isEmpty(target.path): INSTALLS += target
|
#!isEmpty(target.path): INSTALLS += target
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
HEADERS +=
|
||||||
|
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}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -303,6 +303,7 @@ class T_datif : public QMainWindow
|
|||||||
// docNr =transmitted in WRITEADDRESS high byte
|
// docNr =transmitted in WRITEADDRESS high byte
|
||||||
// blockNr=transmitted in WRITEADDRESS low byte
|
// blockNr=transmitted in WRITEADDRESS low byte
|
||||||
|
|
||||||
|
int datif_noResponseCtr;
|
||||||
|
|
||||||
T_prot *myDCIF;
|
T_prot *myDCIF;
|
||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
@@ -315,9 +316,6 @@ private slots:
|
|||||||
public:
|
public:
|
||||||
T_datif(QWidget *parent = nullptr);
|
T_datif(QWidget *parent = nullptr);
|
||||||
|
|
||||||
T_prot *getProt() { return myDCIF; }
|
|
||||||
T_prot const *getProt() const { return myDCIF; }
|
|
||||||
|
|
||||||
void resetChain(void);
|
void resetChain(void);
|
||||||
char isPortOpen(void);
|
char isPortOpen(void);
|
||||||
void sendWRcommand(uint16_t nxtAsCmd);
|
void sendWRcommand(uint16_t nxtAsCmd);
|
||||||
@@ -330,6 +328,11 @@ signals:
|
|||||||
//the requested data are stored in peripheral image
|
//the requested data are stored in peripheral image
|
||||||
// can be loaded with epi
|
// can be loaded with epi
|
||||||
|
|
||||||
|
void datif_templatePrintFinished_OK();
|
||||||
|
void datif_templatePrintFinished_Err();
|
||||||
|
|
||||||
|
void datif_gotNewCoin();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CI_H
|
#endif // CI_H
|
||||||
|
202
include/datei.h
Normal file
202
include/datei.h
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
#ifndef DATEI_H
|
||||||
|
#define DATEI_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDebug>
|
||||||
|
#include "tslib.h"
|
||||||
|
#include <QString>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QJsonArray>
|
||||||
|
#include <QJsonParseError>
|
||||||
|
|
||||||
|
// create csv file with:
|
||||||
|
#define FILESEPERATOR ','
|
||||||
|
|
||||||
|
// pasre csv with:
|
||||||
|
#define FILESEP1 ','
|
||||||
|
#define FILESEP2 ';'
|
||||||
|
|
||||||
|
#define NEWLINEINFILE '\n'
|
||||||
|
#define MAXNUMBEROFSEQUENCES 200
|
||||||
|
// only for csv files
|
||||||
|
|
||||||
|
|
||||||
|
// all generated files located in sudirectory "dynamic machine data - dmd"
|
||||||
|
|
||||||
|
#define FILENAME_SHAREDDATA "../dmd/DCshare.csv"
|
||||||
|
#define FILENAME_SHARED_UID "../dmd/DC_UID.csv"
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ create csv file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// create array with strings and values (to be written to file)
|
||||||
|
void csv_startCreatingFile(void);
|
||||||
|
void csv_addTextToFile(QString myText);
|
||||||
|
void csv_addIntToFile(int myValue);
|
||||||
|
void csv_addUintToFile(uint myValue);
|
||||||
|
void csv_addLongvalToFile(qlonglong myValue);
|
||||||
|
void csv_addUlongvalToFile(qulonglong myValue);
|
||||||
|
//void csv_addCurrentTimeToFile(void);
|
||||||
|
//void csv_addCurrentDateToFile(void);
|
||||||
|
void csv_addNewlineToFile(void);
|
||||||
|
QByteArray csv_readbackArray(void);
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ parse csv file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// return number of entries in the just read file (entries are seperated by
|
||||||
|
// comma or line-feed)
|
||||||
|
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile);
|
||||||
|
|
||||||
|
// before: QByteArray sourceFile=datei_readFromFile(filename);
|
||||||
|
|
||||||
|
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// not needed, just for test // sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
// get single entries of of the just read file:
|
||||||
|
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr);
|
||||||
|
// sequNr: 0....(size-1)
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ create Json Record -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void json_startRecord(void);
|
||||||
|
// clear buffer and write opening curly bracket {
|
||||||
|
|
||||||
|
void json_enterIntToRecord(QString attribute, ulong i_value);
|
||||||
|
// example: "parameter":1234567890
|
||||||
|
|
||||||
|
void json_enterTextToRecord(QString attribute, QString txt_value);
|
||||||
|
// example: "parameter":"slow"
|
||||||
|
|
||||||
|
//void json_addCurrentTimeToRecord(QString attribute);
|
||||||
|
// example: if attribute=myTime: "myTime":"hh_mm_ss"
|
||||||
|
|
||||||
|
//void json_addCurrentDateToRecord(QString attribute);
|
||||||
|
// example: if attribute=myDate: "myDate":"dd.mm.yyyy"
|
||||||
|
// also / possible as seperator
|
||||||
|
// further possible forms:
|
||||||
|
// format= 0: dd.mm.yyyy (deutsch)
|
||||||
|
// 1: mm.dd.yyyy (amerika)
|
||||||
|
// 2: yyyy.mm.dd (Iran, Dubai)
|
||||||
|
// 3: dd.yyyy.mm
|
||||||
|
// 4: mm.yyyy.dd
|
||||||
|
// 5: yyyy.dd.mm
|
||||||
|
|
||||||
|
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals);
|
||||||
|
// add array of numbers with "nrofVals" elements
|
||||||
|
|
||||||
|
void json_enterStructToRecord(QString attribute);
|
||||||
|
// every call must be concluded with an extra "json_finishFile()"
|
||||||
|
// example: "sname":{
|
||||||
|
|
||||||
|
void json_finishStruct(void);
|
||||||
|
|
||||||
|
void json_finishRecord(void);
|
||||||
|
// close curly bracket
|
||||||
|
|
||||||
|
|
||||||
|
QString json_readbackRecordStr(void);
|
||||||
|
|
||||||
|
QByteArray json_readbackRecordBa(void);
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ parse Json file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// first: QByteArray datei_readFromFile(QString filename);
|
||||||
|
|
||||||
|
//void datei_json_readTestFile(QString filename);
|
||||||
|
|
||||||
|
int json_nrOfPairsInFile(QByteArray filename);
|
||||||
|
|
||||||
|
bool json_exists(QByteArray filename, QString searchForKey);
|
||||||
|
// look for "searchForKey" =name of the pair (left of : )
|
||||||
|
// retval true if exists
|
||||||
|
|
||||||
|
bool json_remove(QByteArray filename, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
||||||
|
// retval true if removed
|
||||||
|
|
||||||
|
QString json_searchForStringInFile(QByteArray filename, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
int json_searchForIntInFile(QByteArray filename, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
//.......................
|
||||||
|
|
||||||
|
QJsonObject json_searchForObjectInFile(QByteArray filename, QString searchFor);
|
||||||
|
// return an object from the json file
|
||||||
|
|
||||||
|
int json_nrOfPairsInObject(QJsonObject objname);
|
||||||
|
|
||||||
|
QString json_searchForStringInObject(QJsonObject objname, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
int json_searchForIntInObject(QJsonObject objname, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
//.......................
|
||||||
|
|
||||||
|
QJsonArray json_searchForArrayInFile(QByteArray filename, QString searchFor);
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
int json_nrOfValuesInArray(QJsonArray arrayname);
|
||||||
|
|
||||||
|
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize);
|
||||||
|
// assuming that the array consists of integers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ read, write, copy files -------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void datei_closeFile(QString filename);
|
||||||
|
|
||||||
|
// read content of an exiting file:
|
||||||
|
QByteArray datei_readFromFile(QString filename);
|
||||||
|
|
||||||
|
bool datei_ifFileExists(QString filename);
|
||||||
|
|
||||||
|
char datei_writeToFile(QString filename, QByteArray content);
|
||||||
|
// retval=0 if successful 1: no write access allowed
|
||||||
|
// 2:cannot open to append 3:cannot create new file
|
||||||
|
|
||||||
|
bool datei_copyFile(QString currentFileName, QString newFileName);
|
||||||
|
// retval=true if successful
|
||||||
|
|
||||||
|
bool datei_clearFile(QString filename);
|
||||||
|
// retval=true if successful
|
||||||
|
|
||||||
|
#endif // DATEI_H
|
257
include/hwapi.h
257
include/hwapi.h
@@ -17,71 +17,8 @@ matching interfaces.h:
|
|||||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
|
//#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.1"
|
||||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
#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
|
#ifndef hwapi_H
|
||||||
#define hwapi_H
|
#define hwapi_H
|
||||||
@@ -89,8 +26,9 @@ Level 3): send command: "start payment process"
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
|
#include <QTimer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "interfaces.h"
|
#include <../plugins/interfaces.h>
|
||||||
#include "datIf.h"
|
#include "datIf.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -101,19 +39,10 @@ class hwapi : public QObject,
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json")
|
Q_PLUGIN_METADATA(IID "Atb.Psa2020.software.HWapi/1.0" ) //FILE "HWapi.json")
|
||||||
Q_INTERFACES(hwinf)
|
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;
|
|
||||||
DownloadResult sendStatus(int ret) const;
|
|
||||||
DownloadResult dc_downloadBinary(QByteArray const &binary) const;
|
|
||||||
|
|
||||||
bool startBootloader() const;
|
|
||||||
bool stopBootloader() const;
|
|
||||||
bool openSerial(int br, QString baudrate, QString comPort) const;
|
|
||||||
bool closeSerial(QString comport) const;
|
|
||||||
bool resetDeviceController() const;
|
|
||||||
QByteArray loadBinaryDCFile(QString filename) const;
|
|
||||||
bool downloadBinaryToDC(QString const &bFile) const;
|
|
||||||
public:
|
public:
|
||||||
explicit hwapi(QWidget *parent = nullptr);
|
explicit hwapi(QWidget *parent = nullptr);
|
||||||
|
|
||||||
@@ -121,7 +50,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 0 commands, interface
|
// commands, interface
|
||||||
// open, close, change serial interface
|
// open, close, change serial interface
|
||||||
// actually not neccessary as it is opened automatically on program start
|
// actually not neccessary as it is opened automatically on program start
|
||||||
// start automatic READ requests
|
// start automatic READ requests
|
||||||
@@ -133,7 +62,7 @@ public:
|
|||||||
// ComName: for example "COM48"
|
// ComName: for example "COM48"
|
||||||
// connect: 0, 1
|
// connect: 0, 1
|
||||||
|
|
||||||
bool dc_closeSerial(void) const override;
|
void dc_closeSerial(void) const override;
|
||||||
|
|
||||||
bool dc_isPortOpen(void) const override ;
|
bool dc_isPortOpen(void) const override ;
|
||||||
|
|
||||||
@@ -141,21 +70,10 @@ public:
|
|||||||
// select if READ-Requests are sent manually one by one or automatically
|
// select if READ-Requests are sent manually one by one or automatically
|
||||||
// automatically request ALL digital and analog sensors, get time/date, get status information
|
// automatically request ALL digital and analog sensors, get time/date, get status information
|
||||||
|
|
||||||
bool dc_updateDC(QString binFileName, QString baudrate,
|
|
||||||
QString comPort) const override;
|
|
||||||
|
|
||||||
bool dc_updatePrinterTemplate(enum FileTypeJson type,
|
|
||||||
QVector<int> templateIdx,
|
|
||||||
QVector<QString> fnames,
|
|
||||||
QString br,
|
|
||||||
QString serial) const override;
|
|
||||||
|
|
||||||
bool dc_printTemplate(enum FileTypeJson type,
|
|
||||||
QVector<int> templateIdx,
|
|
||||||
QString br,
|
|
||||||
QString serial) const override;
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 1, control device-controller (functions of µC)
|
// control device-controller (functions of µC)
|
||||||
// check serial connection to deviceController
|
// check serial connection to deviceController
|
||||||
// read response from DC2 (input data)
|
// read response from DC2 (input data)
|
||||||
// some test function for serial communication
|
// some test function for serial communication
|
||||||
@@ -242,8 +160,15 @@ public:
|
|||||||
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
uint8_t bl_exitBL(uint8_t *sendData) const override;
|
||||||
// minimum size of sendData-buffer: 5byte retval: length
|
// minimum size of sendData-buffer: 5byte retval: length
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 2 DC2-onboard devices
|
// DC2-onboard devices
|
||||||
// WR: set time
|
// WR: set time
|
||||||
// RD. get time, get measure, get test results
|
// RD. get time, get measure, get test results
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
@@ -317,7 +242,7 @@ public:
|
|||||||
bool dc_mainFuseIsOk(void) const override;
|
bool dc_mainFuseIsOk(void) const override;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 3: digital outputs and simple switching of connected devices
|
// igital outputs and simple switching of connected devices
|
||||||
// simple processes like flashing a led or open flap for 1s
|
// simple processes like flashing a led or open flap for 1s
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -373,7 +298,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Level 3: digital inputs of connected devices
|
// digital inputs of connected devices
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
|
||||||
bool door_isContactPowerOn(void) const override;
|
bool door_isContactPowerOn(void) const override;
|
||||||
@@ -735,29 +660,29 @@ public:
|
|||||||
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
||||||
// example: print current time at this point (the time of printing not the storage time!!)
|
// example: print current time at this point (the time of printing not the storage time!!)
|
||||||
|
|
||||||
void pri_startTicketDesign(void) const override;
|
//void pri_startTicketDesign(void) const override;
|
||||||
// start for every new printer document, reseting collecting buffer
|
// start for every new printer document, reseting collecting buffer
|
||||||
|
|
||||||
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
||||||
// return val of the appending functions: true=ok false=too long, buffer full
|
// return val of the appending functions: true=ok false=too long, buffer full
|
||||||
|
|
||||||
int pri_TD_getCurrentSize(void) const override;
|
//int pri_TD_getCurrentSize(void) const override;
|
||||||
// retval: 0...1278
|
// retval: 0...1278
|
||||||
|
|
||||||
bool pri_TD_addText(QByteArray text) const override;
|
//bool pri_TD_addText(QByteArray text) const override;
|
||||||
// example: pri_TD_addText("Hello") const override;
|
// example: pri_TD_addText("Hello") const override;
|
||||||
// example: pri_TD_addText(tempStr) const override;
|
// example: pri_TD_addText(tempStr) const override;
|
||||||
// retval: true=ok false=too long, buffer full
|
// retval: true=ok false=too long, buffer full
|
||||||
|
|
||||||
bool pri_TD_addValue(int val) const override;
|
//bool pri_TD_addValue(int val) const override;
|
||||||
// +/- 0...2^(31)
|
// +/- 0...2^(31)
|
||||||
|
|
||||||
bool pri_TD_addNewLine(void) const override;
|
//bool pri_TD_addNewLine(void) const override;
|
||||||
|
|
||||||
bool pri_TD_addSign(char sign) const override;
|
//bool pri_TD_addSign(char sign) const override;
|
||||||
// example: '.' ' ' 0x20 'W' '$'
|
// example: '.' ' ' 0x20 'W' '$'
|
||||||
|
|
||||||
bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const override;
|
//bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const override;
|
||||||
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
||||||
/* complete list of possible commands:
|
/* complete list of possible commands:
|
||||||
group 50 : paper
|
group 50 : paper
|
||||||
@@ -798,11 +723,11 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char prn_clearDocument(uint8_t documentNumber) const override;
|
//char prn_clearDocument(uint8_t documentNumber) const override;
|
||||||
// clear memory buffer for ONE document
|
// clear memory buffer for ONE document
|
||||||
// function takes a second! don't send right before "store doc"
|
// function takes a second! don't send right before "store doc"
|
||||||
|
|
||||||
bool prn_store_Document(uint8_t documentNumber ) const override;
|
//bool prn_store_Document(uint8_t documentNumber ) const override;
|
||||||
|
|
||||||
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
||||||
// documentNumber=0...15
|
// documentNumber=0...15
|
||||||
@@ -814,7 +739,7 @@ public:
|
|||||||
// the place in the ticket layout is predefined (already in DC memory)
|
// the place in the ticket layout is predefined (already in DC memory)
|
||||||
// the dynamics are first calculated at printing time
|
// the dynamics are first calculated at printing time
|
||||||
|
|
||||||
bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const override;
|
//bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -918,7 +843,7 @@ public:
|
|||||||
void bl_rebootDC(void) const override;
|
void bl_rebootDC(void) const override;
|
||||||
|
|
||||||
void bl_startBL(void) const override;
|
void bl_startBL(void) const override;
|
||||||
bool bl_checkBL(void) const override;
|
void bl_checkBL(void) const override;
|
||||||
bool bl_isUp(void) const override;
|
bool bl_isUp(void) const override;
|
||||||
// return true is bl is up and running
|
// return true is bl is up and running
|
||||||
// also initializes "sendFile"
|
// also initializes "sendFile"
|
||||||
@@ -990,25 +915,14 @@ public:
|
|||||||
// uint16_t borough, uint16_t zone,
|
// uint16_t borough, uint16_t zone,
|
||||||
// uint16_t alias, char *location) const override;
|
// uint16_t alias, char *location) const override;
|
||||||
|
|
||||||
/*
|
|
||||||
uint8_t emp_getInsertedCoinSignal(void) const override;
|
|
||||||
// can be called one time after each coin
|
|
||||||
// emp_chkIfCoinInserted() must be called before!
|
|
||||||
|
|
||||||
uint16_t emp_getInsertedCoinValue(void) const override;
|
|
||||||
// can be called one time after each coin
|
|
||||||
// emp_chkIfCoinInserted() must be called before!
|
|
||||||
|
|
||||||
uint8_t emp_getCoinError(void) const override;
|
|
||||||
// can be called one time after each coin
|
|
||||||
// emp_chkIfCoinInserted() must be called before!
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const override;
|
bool rtc_setTimeDateDirect(struct Trtc_DateTime *DateTime) const override;
|
||||||
// return true if successful. could fail if more the 8 commands are waiting
|
// return true if successful. could fail if more the 8 commands are waiting
|
||||||
|
|
||||||
bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override;
|
bool rtc_getExtendedTime(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
|
bool rtc_getExtendedTime(struct T_extTime *exTime) const override;
|
||||||
|
|
||||||
bool sys_runCompleteTest(void) const override;
|
bool sys_runCompleteTest(void) const override;
|
||||||
// warning: lasts 20s in one pace
|
// warning: lasts 20s in one pace
|
||||||
|
|
||||||
@@ -1032,15 +946,18 @@ public:
|
|||||||
// nr = 1..32
|
// nr = 1..32
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
|
||||||
void log_getHoldAccountNumbers(uint32_t *accNr ) const override;
|
void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const override;
|
||||||
// returns all acc nrs of the backuped vault records
|
// returns all acc nrs of the backuped vault records
|
||||||
// use: uint32_t backupedAccNumbers[8]
|
// use: uint16_t backupedAccNumbers[8]
|
||||||
|
|
||||||
bool log_selectVaultRecord(uint16_t accountNr ) const override;
|
bool log_selectVaultRecord(uint16_t accountNr ) const override;
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
// and trigger transfer
|
||||||
|
|
||||||
//request, isAvailable
|
bool log_chkIfVaultRecordAvailable(void) const override;
|
||||||
void log_getVaultRecord(struct T_vaultRecord *retVR) const override;
|
// return true if completly received
|
||||||
|
|
||||||
|
bool log_getVaultRecord(struct T_vaultRecord *retVR) const override;
|
||||||
// which was selected by: log_selectVaultRecord()
|
// which was selected by: log_selectVaultRecord()
|
||||||
// to be forwarded to Ismas
|
// to be forwarded to Ismas
|
||||||
|
|
||||||
@@ -1050,7 +967,22 @@ public:
|
|||||||
bool prn_printTestTicket(void) const override;
|
bool prn_printTestTicket(void) const override;
|
||||||
// return true if sending to DC OK, false if cmd-stack is full
|
// return true if sending to DC OK, false if cmd-stack is full
|
||||||
|
|
||||||
bool cash_startPayment(uint16_t amount) const override;
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
bool cash_cancelPayment(void) const override;
|
||||||
// and return coins
|
// and return coins
|
||||||
@@ -1078,31 +1010,100 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t mif_getCardType(QString cardholder) const override;
|
uint8_t mif_getCardType(QString *cardholder) const override;
|
||||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||||
// cardholder: 7byte Name-String
|
// cardholder: 7byte Name-String
|
||||||
|
|
||||||
uint64_t sys_getWakeSource(void) const override;
|
uint64_t sys_getWakeSource(void) const override;
|
||||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||||
|
|
||||||
//void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
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(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
//void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
void sys_getDeviceConditions(struct T_moduleCondition *devCond) const override;
|
||||||
|
|
||||||
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const override;
|
||||||
|
|
||||||
|
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t cash_getAmountInVault(void) const override;
|
||||||
|
|
||||||
|
uint16_t cash_getNrCoinsInVault(void) const override;
|
||||||
|
|
||||||
|
uint8_t prn_getPrintResult() const override;
|
||||||
|
|
||||||
|
uint8_t prn_getCurrentPrinterState() const override;
|
||||||
|
// 0: printer OK
|
||||||
|
// bit0: near paper end bit1: no paper
|
||||||
|
// bit2: temperature error bit3: error head open
|
||||||
|
// bit4: paper jam in cutter
|
||||||
|
// bit6: no response bit7: serial rec. error
|
||||||
|
// bit5: printer not ready
|
||||||
|
|
||||||
|
|
||||||
private:
|
void sys_sendDeviceParameter(struct T_devices *deviceSettings) const override;
|
||||||
void sub_storeSendingText(QByteArray *buf) const;
|
|
||||||
|
void sys_restoreDeviceParameter(struct T_devices *deviceSettings) const override;
|
||||||
|
|
||||||
|
bool sys_areDCdataValid(void) const override;
|
||||||
|
|
||||||
|
bool sys_sendingTest(void) const override;
|
||||||
|
|
||||||
|
void prn_requestCurrentDynData(void) const override;
|
||||||
|
|
||||||
|
bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const override;
|
||||||
|
// which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override;
|
||||||
|
|
||||||
|
bool prn_dynDataAreEqual(uint8_t *buf) const override;
|
||||||
|
|
||||||
|
bool prn_printKombiticket(uint8_t nrOfKombi) const override;
|
||||||
|
// print four of the templates loaded by Json prior
|
||||||
|
// nr = 1..8
|
||||||
|
|
||||||
|
void lock_triggerUpperSolenoid(void) const override;
|
||||||
|
|
||||||
|
void lock_triggerLowerSolenoid(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_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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
1585
include/interfaces.h
1585
include/interfaces.h
File diff suppressed because it is too large
Load Diff
@@ -93,9 +93,6 @@ private slots:
|
|||||||
void analyseRecData(void);
|
void analyseRecData(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_com *getSerialPort() { return mySerialPort; }
|
|
||||||
T_com const *getSerialPort() const { return mySerialPort; }
|
|
||||||
|
|
||||||
T_prot();
|
T_prot();
|
||||||
bool isPortOpen(void);
|
bool isPortOpen(void);
|
||||||
bool isSerialFree(void);
|
bool isSerialFree(void);
|
||||||
|
@@ -211,25 +211,50 @@ uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *
|
|||||||
// user=1: Text-Print is using this buffer
|
// user=1: Text-Print is using this buffer
|
||||||
// 2: QR-code-Printer is using this buffer
|
// 2: QR-code-Printer is using this buffer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define FDCMD_STACKDEPTH 16
|
#define FDCMD_STACKDEPTH 16
|
||||||
void sendFDcmd_clrStack(void);
|
void sendFDcmd_clrStack(void);
|
||||||
|
|
||||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
|
||||||
// write Command to memory, wait for transport
|
// write Command to memory, wait for transport
|
||||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
|
||||||
|
|
||||||
uint8_t check4FDshortCmd(void);
|
uint8_t check4FDshortCmd(void);
|
||||||
// returns number of waiting command
|
// returns number of waiting command, maxFDCMD_STACKDEPTH
|
||||||
|
|
||||||
#define FDLONG_STACKDEPTH 16
|
uint8_t checkNextFDcmd(void);
|
||||||
void longFDcmd_clrStack(void);
|
// return 0: no command waiting
|
||||||
|
// 1: short cmd
|
||||||
|
// 2: long cmd
|
||||||
|
|
||||||
|
uint8_t check4freeFDshortCmd(void);
|
||||||
|
// returns number of free places in short-command stack
|
||||||
|
|
||||||
|
//#define FDLONG_STACKDEPTH 16
|
||||||
|
//void longFDcmd_clrStack(void);
|
||||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data);
|
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data);
|
||||||
// write Command to memory, wait for transport
|
// write Command to memory, wait for transport
|
||||||
// data buffer size always 64! data[64], padded with 0
|
// data buffer size always 64! data[64], padded with 0
|
||||||
|
//bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data);
|
||||||
|
|
||||||
uint8_t check4FDlongCmd(void);
|
//uint8_t check4FDlongCmd(void);
|
||||||
// returns number of waiting command
|
// returns number of waiting command
|
||||||
|
|
||||||
|
//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
|
#endif
|
||||||
|
|
||||||
|
301
include/shared_mem_buffer.h
Normal file
301
include/shared_mem_buffer.h
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <QSharedMemory>
|
||||||
|
|
||||||
|
struct SharedMemBuffer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct rs {
|
||||||
|
char comportName[16]; // z.B. "COM48"
|
||||||
|
char baudStr[16]; // z.B. "19200"
|
||||||
|
int baudNr; // 0...5 oder -1
|
||||||
|
uint8_t connect; // 0,1
|
||||||
|
bool portIsOpen;
|
||||||
|
} rs;
|
||||||
|
|
||||||
|
char AutoEmissionOn; // 1: zyklisch Anfragen zum Slave senden
|
||||||
|
|
||||||
|
struct datif {
|
||||||
|
uint16_t sendingPeriod;
|
||||||
|
bool sendingPer_changed;
|
||||||
|
} datif;
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// controlBus.cpp
|
||||||
|
char txt4comStateLine[32];
|
||||||
|
char txt4HsStateLine[32];
|
||||||
|
char txt4masterStateLine[32];
|
||||||
|
char txt4resultStateLine[32];
|
||||||
|
char txt4dataLine[32];
|
||||||
|
char txt4datifReceive[32];
|
||||||
|
char txt4diagWindow[32];
|
||||||
|
char sndTxt4diagWindow[32];
|
||||||
|
bool Sdata_serialTestResult[32];
|
||||||
|
uint8_t Sdata_pProtResultOk[32];
|
||||||
|
uint16_t Sdata_receivedDataLength[32];
|
||||||
|
uint8_t Sdata_receivedDataBlock[64];
|
||||||
|
|
||||||
|
// datif.cpp
|
||||||
|
uint8_t dif_dataStep;
|
||||||
|
uint8_t dif_scanStep;
|
||||||
|
uint8_t RDBLKNR;
|
||||||
|
uint8_t datif_OutCmdpara1;
|
||||||
|
uint8_t datif_OutCmdpara2;
|
||||||
|
uint8_t datif_OutCmdpara3;
|
||||||
|
uint8_t datif_OutCmdpara4;
|
||||||
|
|
||||||
|
uint16_t datif_OutCmdpara5;
|
||||||
|
uint32_t datif_OutCmdpara6;
|
||||||
|
uint8_t cycl_running;
|
||||||
|
|
||||||
|
// dcBL.cpp
|
||||||
|
uint8_t dcBL_LastBLcmd; // stored the last sent cmd in order to analys response
|
||||||
|
uint8_t dcBL_AtbBinFile[300000];
|
||||||
|
uint32_t dcBL_fileSize;
|
||||||
|
uint16_t dcBL_nrOfBlocks;
|
||||||
|
uint16_t dcBL_fileCrc;
|
||||||
|
uint8_t dcBL_myBuf[300000]; // same content like "dcBL_AtbBinFile" but bytewise
|
||||||
|
|
||||||
|
char BlResp[50][32];
|
||||||
|
uint8_t dcBL_step;
|
||||||
|
uint8_t dcBL_state;
|
||||||
|
uint16_t dcBL_BlkCtr;
|
||||||
|
uint16_t dcBL_cyclCtr;
|
||||||
|
uint16_t repeatCtr;
|
||||||
|
uint8_t Sdata_rawData[150];
|
||||||
|
uint8_t Sdata_LengthRawData;
|
||||||
|
|
||||||
|
// hwapi.cpp
|
||||||
|
uint16_t hwapi_shutterTime;
|
||||||
|
char ticketTemplate[1024];
|
||||||
|
|
||||||
|
// sendWRcmd.cpp
|
||||||
|
uint16_t nextAsynchsendCmd0[16];
|
||||||
|
uint8_t nrOfCmdsInQueue;
|
||||||
|
uint16_t nextAsynchsendCmd4[8];
|
||||||
|
uint8_t nextCmd4para1[8];
|
||||||
|
uint8_t nextCmd4para2[8];
|
||||||
|
uint8_t nextCmd4para3[8];
|
||||||
|
uint8_t nextCmd4para4[8];
|
||||||
|
uint8_t nrOfCmds4InQueue;
|
||||||
|
uint16_t nextAsynchsendCmd8[4];
|
||||||
|
uint8_t nextCmd8para1[4];
|
||||||
|
uint8_t nextCmd8para2[4];
|
||||||
|
uint16_t nextCmd8para3[4];
|
||||||
|
uint32_t nextCmd8para4[4];
|
||||||
|
uint8_t nrOfCmds8InQueue;
|
||||||
|
uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
|
||||||
|
uint8_t sendAsyDatLen;
|
||||||
|
uint8_t Sdata_mdbSendBuffer[64];
|
||||||
|
uint8_t Sdata_mdbSendLen;
|
||||||
|
uint8_t prnDataParameters[4];
|
||||||
|
uint8_t prnDataBufferUser;
|
||||||
|
char Sdata_PRN_TEXT[20][64];
|
||||||
|
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||||
|
uint8_t nextFDwrCmd[16];
|
||||||
|
uint8_t nextFDrdCmd[16];
|
||||||
|
uint8_t nextFDblkNr[16];
|
||||||
|
|
||||||
|
uint8_t nextFDpara1[16];
|
||||||
|
uint8_t nextFDpara2[16];
|
||||||
|
uint8_t nextFDpara3[16];
|
||||||
|
uint8_t nextFDpara4[16];
|
||||||
|
uint8_t p_nextFDcmdsInQueue;
|
||||||
|
uint8_t longFDwrCmd[16];
|
||||||
|
uint8_t longFDrdCmd[16];
|
||||||
|
uint8_t longFDblkNr[16];
|
||||||
|
uint8_t longFDlength[16];
|
||||||
|
|
||||||
|
uint8_t longFDpara[16][64];
|
||||||
|
uint8_t p_longFDcmdsInQueue;
|
||||||
|
|
||||||
|
// storeInData.cpp
|
||||||
|
bool indat_savePrnPwr;
|
||||||
|
bool indat_saveMifPwr;
|
||||||
|
bool indat_MdbIsOn;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t ndbs;
|
||||||
|
uint8_t pari;
|
||||||
|
uint8_t nsb;
|
||||||
|
uint8_t br;
|
||||||
|
|
||||||
|
#define MAXNROF_GENSTR 16
|
||||||
|
char genStrings[MAXNROF_GENSTR][64];
|
||||||
|
|
||||||
|
#define MAXNROF_AI 4
|
||||||
|
uint16_t AI_val[MAXNROF_AI];
|
||||||
|
|
||||||
|
struct DigitalInputs {
|
||||||
|
uint8_t doorSwitch;
|
||||||
|
uint8_t vaultSwitch;
|
||||||
|
uint8_t lockSwitch;
|
||||||
|
uint8_t opto;
|
||||||
|
uint8_t aux;
|
||||||
|
bool wakeFromPtu;
|
||||||
|
bool wakeFromMdb;
|
||||||
|
bool wakeFromModem;
|
||||||
|
bool PrnReady;
|
||||||
|
bool CoinAttach;
|
||||||
|
bool CoinEscrowOpen;
|
||||||
|
bool mifCardTap;
|
||||||
|
bool contactPwrOn;
|
||||||
|
bool mifarePwrOn;
|
||||||
|
bool rdbk_mdbTxd;
|
||||||
|
bool AuxPwrOn;
|
||||||
|
bool gsmPwrOn;
|
||||||
|
bool creditPwrOn;
|
||||||
|
bool printerPwrOn;
|
||||||
|
bool mdbPwrOn;
|
||||||
|
bool rejMot_home;
|
||||||
|
uint8_t npe_sensor;
|
||||||
|
} din;
|
||||||
|
|
||||||
|
struct DigitalOutputs {
|
||||||
|
uint8_t mbdRxTst;
|
||||||
|
uint8_t motorBits;
|
||||||
|
uint8_t serialSwitch; // serial drv on/off, Serial mux1, Serial mux2
|
||||||
|
uint8_t ledsAndFan;
|
||||||
|
uint8_t laermUndRelay;
|
||||||
|
uint8_t ptuWake;
|
||||||
|
uint8_t auxPower;
|
||||||
|
uint8_t coinShutter;
|
||||||
|
uint8_t coinEscrow;
|
||||||
|
uint8_t printerPower;
|
||||||
|
} dout;
|
||||||
|
|
||||||
|
struct Sdata {
|
||||||
|
#define NROFMIFSTATEBYTES 40
|
||||||
|
#define PRN_STATE_ARRAY_SIZE 20
|
||||||
|
#define PRN_STATE_FONT_SIZE 20
|
||||||
|
uint8_t MIF_STATE[NROFMIFSTATEBYTES];
|
||||||
|
uint8_t MIF_DATA[12][64];
|
||||||
|
uint8_t PRN_STATE[PRN_STATE_ARRAY_SIZE];
|
||||||
|
uint8_t PRN_FONTS[PRN_STATE_FONT_SIZE];
|
||||||
|
bool mdb_busRdy;
|
||||||
|
bool mdb_V12on;
|
||||||
|
bool mdb_V5on;
|
||||||
|
uint8_t mdbNrOfRecData;
|
||||||
|
uint8_t RecBuff[40];
|
||||||
|
uint8_t empNrOfsettings;
|
||||||
|
uint8_t emp_settingsBuff[66];
|
||||||
|
uint8_t NrOfDeviceSetting;
|
||||||
|
uint8_t DeviceSettingBuff[66];
|
||||||
|
uint8_t NrOfMachineIDSetting;
|
||||||
|
uint8_t NrOfMachineIDBuff[66];
|
||||||
|
uint64_t slaveUID;
|
||||||
|
uint8_t UIDstr[8];
|
||||||
|
#define MAXNROF_MEASURE 4
|
||||||
|
uint32_t measurement[MAXNROF_MEASURE];
|
||||||
|
bool serialTestResult;
|
||||||
|
uint8_t pProtResultOk;
|
||||||
|
uint16_t receivedDataLength;
|
||||||
|
uint8_t receivedDataBlock[64];
|
||||||
|
} Sdata;
|
||||||
|
|
||||||
|
uint8_t mif_cardType;
|
||||||
|
uint8_t mif_cardHolder[8];
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define MEMDEPTH_GOTCOINS (16)
|
||||||
|
struct T_coin {
|
||||||
|
uint8_t valid;
|
||||||
|
uint8_t signal;
|
||||||
|
uint8_t error;
|
||||||
|
uint8_t pad;
|
||||||
|
uint16_t value;
|
||||||
|
} gotCoin[MEMDEPTH_GOTCOINS];
|
||||||
|
uint8_t ctr_gotCoin;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct store {
|
||||||
|
uint32_t insertedAmount;
|
||||||
|
uint16_t lastCoinType[64];
|
||||||
|
uint16_t lastCoinValue[64];
|
||||||
|
uint64_t wakeSrc;
|
||||||
|
uint8_t rbDevParamLen;
|
||||||
|
uint8_t rbDevParams[66];
|
||||||
|
uint8_t deviceCondLen;
|
||||||
|
uint8_t deviceCond[66];
|
||||||
|
uint8_t machCondLen;
|
||||||
|
uint8_t machCond[66];
|
||||||
|
uint8_t DcBackupNrOfAccNr;
|
||||||
|
uint16_t DcBackupAccNr[16]; // z.Z. nur 8
|
||||||
|
uint8_t gotNrBlocksOfVaultRec;
|
||||||
|
uint8_t vaultrecord[360];
|
||||||
|
uint32_t amount;
|
||||||
|
uint16_t nrOfCoins;
|
||||||
|
} store;
|
||||||
|
|
||||||
|
struct T_globTime {
|
||||||
|
// Reihenfolge nicht vertauschen!!!!!
|
||||||
|
uint8_t hour;
|
||||||
|
uint8_t minute;
|
||||||
|
uint8_t second;
|
||||||
|
uint8_t Year;
|
||||||
|
uint8_t Month;
|
||||||
|
uint8_t DayOfMonth;
|
||||||
|
uint8_t DayOfWeek; // 1=monday...7
|
||||||
|
uint8_t reserve1;
|
||||||
|
|
||||||
|
uint16_t MinutesOfToday;
|
||||||
|
uint16_t reserve2;
|
||||||
|
|
||||||
|
uint32_t SecondsOfToday;
|
||||||
|
|
||||||
|
uint8_t IsLeapyear;
|
||||||
|
uint8_t nextLeap;
|
||||||
|
uint8_t lastLeap;
|
||||||
|
uint8_t hoursOfWeek;
|
||||||
|
|
||||||
|
uint16_t minOfWeek;
|
||||||
|
uint16_t hoursOfMonth;
|
||||||
|
uint16_t minOfMonth;
|
||||||
|
uint16_t dayOfYear;
|
||||||
|
uint16_t hoursOfYear;
|
||||||
|
uint16_t reserve3;
|
||||||
|
|
||||||
|
uint32_t minOfYear;
|
||||||
|
|
||||||
|
uint8_t squareOutMode;
|
||||||
|
uint8_t free1;
|
||||||
|
uint16_t reserve4;
|
||||||
|
uint32_t minOfMillenium;
|
||||||
|
// bis hierher 44byts
|
||||||
|
uint32_t free2;
|
||||||
|
uint32_t free3;
|
||||||
|
uint32_t free4;
|
||||||
|
} getGlobalTime;
|
||||||
|
|
||||||
|
static QSharedMemory *getShm(std::size_t s = 0);
|
||||||
|
static SharedMemBuffer *getData() {
|
||||||
|
return (SharedMemBuffer *)getShm()->data();
|
||||||
|
}
|
||||||
|
static SharedMemBuffer const *getDataConst() {
|
||||||
|
return (SharedMemBuffer const *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static std::atomic<bool> __sharedMemLocked;
|
||||||
|
|
||||||
|
static bool sharedMemLocked() {
|
||||||
|
return __sharedMemLocked;
|
||||||
|
}
|
||||||
|
static void setSharedMemLocked() {
|
||||||
|
__sharedMemLocked = true;
|
||||||
|
}
|
||||||
|
static void setSharedMemUnlocked() {
|
||||||
|
__sharedMemLocked = false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@@ -54,7 +54,13 @@ QString epi_loadGenerals(uint8_t genNr);
|
|||||||
// genNr=0=HW 1=SW 2=State
|
// genNr=0=HW 1=SW 2=State
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeUID(uint8_t *buf8byteUid);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeUID(uint8_t const *buf8byteUid);
|
||||||
|
//void gpi_storeUID(uint8_t *buf8byteUid);
|
||||||
// buffer size: 8 byte
|
// buffer size: 8 byte
|
||||||
|
|
||||||
void epi_getUIDdec(uint8_t *buf8byteUid);
|
void epi_getUIDdec(uint8_t *buf8byteUid);
|
||||||
@@ -502,6 +508,8 @@ void gpi_storeWakeSources(uint8_t *receivedData);
|
|||||||
|
|
||||||
uint64_t epi_getWakeSources(void);
|
uint64_t epi_getWakeSources(void);
|
||||||
|
|
||||||
|
uint8_t epi_getWakeReason(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data);
|
void gpi_storeExtendedTime(uint8_t leng, uint8_t *data);
|
||||||
@@ -520,9 +528,47 @@ void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data);
|
|||||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data);
|
||||||
|
|
||||||
|
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs);
|
||||||
|
// return accNrs[0..7]
|
||||||
|
|
||||||
|
|
||||||
|
void epi_iniVRstorage(void);
|
||||||
|
|
||||||
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data );
|
||||||
|
|
||||||
|
bool epi_checkIfVaultRecordAvailable(void);
|
||||||
|
|
||||||
|
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf );
|
||||||
|
// true if completly received
|
||||||
|
|
||||||
|
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins );
|
||||||
|
|
||||||
|
uint32_t epi_getCashBoxContent(void);
|
||||||
|
|
||||||
|
uint16_t epi_getNrOfCoinsInCashBox(void);
|
||||||
|
|
||||||
|
void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder );
|
||||||
|
|
||||||
|
uint8_t epi_mifGetCardType(uint8_t *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 epi_areDcDataValid();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void epi_clearDynData(void);
|
||||||
|
|
||||||
|
void gpi_storeDynData(uint8_t *DCdynDat);
|
||||||
|
// buffer size: 64 byte
|
||||||
|
|
||||||
|
bool epi_getDynPrnData(uint8_t *DCdynDat);
|
||||||
|
// buffer size: 64 byte
|
||||||
|
// return true if data are new and valid
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -13,6 +13,9 @@ uint32_t uchar2ulong(uint8_t Highbyte, uint8_t MHbyte, uint8_t MLbyte, uint8_t L
|
|||||||
|
|
||||||
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
uint8_t uint2uchar(uint16_t uival, bool getHighB);
|
||||||
|
|
||||||
|
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr);
|
||||||
|
// getBytNr: 0=LSB 3=MSB
|
||||||
|
|
||||||
|
|
||||||
void delay(uint16_t MilliSec);
|
void delay(uint16_t MilliSec);
|
||||||
|
|
||||||
|
@@ -24,13 +24,21 @@ struct T_emp
|
|||||||
|
|
||||||
// dynamic:
|
// dynamic:
|
||||||
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
||||||
// 0=Emp & Bus power off, 1=powered, poll off 2=polling on
|
// 0=start command
|
||||||
// 3=device responded, requesting status
|
// 1=powered, do emp ini, send reset
|
||||||
// 4=waiting for status 5=have status,
|
// 2=delay
|
||||||
// 6: IDLE, have paramters from master, polling running, ready for payment
|
// 3=wait for response, requesting status after response
|
||||||
// Master can stop/start polling and acceptance
|
// 4,5 through, startup
|
||||||
// 7: end of transaction, polling on, accept off, reporting coins, (wait for last coin)
|
// 6: wait for status
|
||||||
// 8: transaction running, polling on, acceptance on, reporting coins,
|
// 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
|
||||||
|
|
||||||
|
|
||||||
uint8_t pollingRunning;
|
uint8_t pollingRunning;
|
||||||
uint8_t paymentRunning;
|
uint8_t paymentRunning;
|
||||||
@@ -80,6 +88,7 @@ struct Tprn_hw_state
|
|||||||
bool nowAligned;
|
bool nowAligned;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// obsolete
|
||||||
struct T_dynDat
|
struct T_dynDat
|
||||||
{
|
{
|
||||||
uint8_t licensePlate[8];
|
uint8_t licensePlate[8];
|
||||||
@@ -167,30 +176,29 @@ struct T_moduleCondition
|
|||||||
// 100..150 = WARNING
|
// 100..150 = WARNING
|
||||||
// 200..250 = ERROR
|
// 200..250 = ERROR
|
||||||
|
|
||||||
uint8_t structStart; // always first!!!
|
uint8_t ram;
|
||||||
uint8_t ram; // v
|
uint8_t intEe;
|
||||||
uint8_t intEe; // v
|
uint8_t extEe;
|
||||||
uint8_t extEe; // v
|
|
||||||
|
|
||||||
uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error
|
uint8_t rtc; // 1: time/date OK 100: time not plausible 200: hardware error
|
||||||
uint8_t boardHw; // v
|
uint8_t boardHw;
|
||||||
uint8_t printer; // v
|
uint8_t printer;
|
||||||
uint8_t modem; // v
|
uint8_t modem;
|
||||||
|
|
||||||
uint8_t signal; // 1...99
|
uint8_t signal; // 1...99
|
||||||
uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime
|
uint8_t regist; // 100:not 1:reg 2:ping OK 3:gotTime
|
||||||
uint8_t mdbBus;
|
uint8_t mdbBus;
|
||||||
uint8_t coinChecker; // EMP, OMP or mei-cashflow
|
uint8_t coinChecker; // EMP, OMP or mei-cashflow
|
||||||
|
|
||||||
uint8_t coinEscrow; // v
|
uint8_t coinEscrow;
|
||||||
uint8_t mifareReader; // v
|
uint8_t mifareReader;
|
||||||
uint8_t creditTerm; // not available
|
uint8_t creditTerm;
|
||||||
uint8_t coinReject; // v
|
uint8_t coinReject;
|
||||||
|
|
||||||
uint8_t coinSafe; // v
|
uint8_t coinSafe;
|
||||||
uint8_t billSafe; // v
|
uint8_t billSafe;
|
||||||
uint8_t voltage; // v // 1:11..14V
|
uint8_t voltage; // 1:11..14V
|
||||||
uint8_t temper; // v
|
uint8_t temper;
|
||||||
|
|
||||||
uint8_t poweronTest;
|
uint8_t poweronTest;
|
||||||
uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB)
|
uint8_t doorState; // 1: alles zu 200: t?r offen + bit1(S) +bit2(CB) + bit3(CB)
|
||||||
@@ -211,61 +219,132 @@ struct T_moduleCondition
|
|||||||
|
|
||||||
struct T_dynamicCondition
|
struct T_dynamicCondition
|
||||||
{
|
{
|
||||||
// dynamic conditions, change rapidly and frequently
|
char allDoorsDebounced;
|
||||||
// these are values for the Heartbeat
|
char openedAuthorized;
|
||||||
|
uint8_t CBinDebounced; // 0:fehlt 1:drin
|
||||||
// T?rschalter entprellt:
|
char upperDoor; // 99: undefined 0:closed 1:open
|
||||||
char upperDoor; // 0:fehlt 1:drin
|
char middleDoor; // 99: undefined 0:closed 1:open
|
||||||
char middleDoor;
|
char lowerDoor; // 99: undefined 0:closed 1:open
|
||||||
char lowerDoor;
|
char reserve;
|
||||||
char coinBox;
|
|
||||||
|
|
||||||
char billBox;
|
char billBox;
|
||||||
char modeAbrech;
|
char modeAbrech;
|
||||||
char onAlarm;
|
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
|
||||||
char nowCardTest;
|
char nowCardTest;
|
||||||
|
char nowPayment; // not used, always 0
|
||||||
char nowPayment;
|
|
||||||
char lastMifCardType;
|
char lastMifCardType;
|
||||||
char openedAuthorized;
|
|
||||||
char allDoorsDebounced;
|
|
||||||
|
|
||||||
uint8_t lastSDoorState;
|
uint8_t lastSDoorState;
|
||||||
uint8_t lastVDoorState;
|
uint8_t lastVDoorState;
|
||||||
uint8_t CBinDebounced;
|
|
||||||
uint8_t lastCBstate;
|
uint8_t lastCBstate;
|
||||||
|
char 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
|
||||||
|
|
||||||
char paymentInProgress;
|
|
||||||
char res1;
|
|
||||||
char res2;
|
|
||||||
char res3;
|
|
||||||
|
|
||||||
uint16_t U_Batt;
|
char res1;
|
||||||
|
uint16_t U_Batt;
|
||||||
uint16_t Temperatur;
|
uint16_t Temperatur;
|
||||||
|
|
||||||
uint16_t cash_storedaccNumbers[8]; // List all stored accounting numbers in ext. eeprom
|
|
||||||
|
|
||||||
uint16_t nrCoinsInBox;
|
uint16_t nrCoinsInBox;
|
||||||
uint16_t resui1;
|
|
||||||
|
|
||||||
uint32_t amountInBox;
|
uint32_t amountInBox;
|
||||||
uint32_t amountJustPaid;
|
|
||||||
|
|
||||||
uint16_t lastInsCoinType; // wahrscheinlich uchar
|
|
||||||
uint16_t resui2;
|
|
||||||
|
|
||||||
uint32_t totalTransVolume;
|
uint32_t totalTransVolume;
|
||||||
uint32_t totalNrOfVends;
|
uint32_t totalNrOfVends;
|
||||||
|
char jsonValid_config;
|
||||||
|
char jsonValid_device;
|
||||||
|
char jsonValid_cash;
|
||||||
|
char jsonValid_print;
|
||||||
|
char jsonValid_serial;
|
||||||
|
char jsonValid_time;
|
||||||
|
char lastFileType;
|
||||||
|
// 44
|
||||||
|
uint8_t MifCardHolder[8];
|
||||||
|
uint8_t resultOfLastTemplPrint;
|
||||||
|
// 0: unknown or printing in progress
|
||||||
|
// 1: OK, doc was printed 2: error, doc was not printed
|
||||||
|
uint8_t lastPrinterStatus;
|
||||||
|
// 0: printer OK
|
||||||
|
// bit0: near paper end bit1: no paper
|
||||||
|
// bit2: temperature error bit3: error head open
|
||||||
|
// bit4: paper jam in cutter
|
||||||
|
// bit6: no response bit7: serial rec. error
|
||||||
|
// bit5: printer not ready
|
||||||
|
uint8_t startupTestIsRunning;
|
||||||
|
|
||||||
|
//54
|
||||||
|
};
|
||||||
|
|
||||||
|
struct T_extTime
|
||||||
|
{
|
||||||
|
uint8_t Hours;
|
||||||
|
uint8_t Min;
|
||||||
|
uint8_t Sec;
|
||||||
|
uint8_t Year;
|
||||||
|
uint8_t Month;
|
||||||
|
uint8_t Day;
|
||||||
|
uint8_t DOW;
|
||||||
|
uint8_t res1;
|
||||||
|
uint16_t MinOfDay;
|
||||||
|
uint16_t res2;
|
||||||
|
uint32_t SecOfDay;
|
||||||
|
uint8_t isLeapYear;
|
||||||
|
uint8_t nxtLeapYear;
|
||||||
|
uint8_t lastLeapYear;
|
||||||
|
uint8_t hoursOfThisWeek;
|
||||||
|
uint16_t minutesOfThisWeek;
|
||||||
|
uint16_t hoursOfThisMonth;
|
||||||
|
uint16_t daysOfThisYear;
|
||||||
|
uint16_t GetHoursOfYear;
|
||||||
|
uint16_t res3;
|
||||||
|
uint32_t GetMinutesOfYear;
|
||||||
|
uint8_t getWakeIntvSec;
|
||||||
|
uint8_t res4;
|
||||||
|
uint16_t res5;
|
||||||
|
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
|
class hwinf
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
|
||||||
|
|
||||||
virtual ~hwinf() {}
|
virtual ~hwinf() {}
|
||||||
|
|
||||||
|
|
||||||
@@ -278,18 +357,18 @@ public:
|
|||||||
// Furthermore the Cashagent-Library answers with status strings about sending and reading result
|
// Furthermore the Cashagent-Library answers with status strings about sending and reading result
|
||||||
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
||||||
|
|
||||||
virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const = 0;
|
virtual bool dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect) const =0;
|
||||||
// Command: open serial interface
|
// Command: open serial interface
|
||||||
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
||||||
// BaudStr: for exapmle "19200"
|
// BaudStr: for exapmle "19200"
|
||||||
// ComName: for example "COM48"
|
// ComName: for example "COM48"
|
||||||
// connect: 0, 1
|
// connect: 0, 1
|
||||||
|
|
||||||
virtual bool dc_closeSerial(void) const = 0;
|
virtual void dc_closeSerial(void) const =0;
|
||||||
// Command: close serial interface in order to save power while power down
|
// Command: close serial interface in order to save power while power down
|
||||||
// or if another port must be used
|
// or if another port must be used
|
||||||
|
|
||||||
virtual bool dc_isPortOpen(void) const =0;
|
virtual bool dc_isPortOpen(void) const =0;
|
||||||
// returns true if port open (don't send unless open. Sending to closed port will crash program)
|
// returns true if port open (don't send unless open. Sending to closed port will crash program)
|
||||||
|
|
||||||
|
|
||||||
@@ -300,10 +379,7 @@ public:
|
|||||||
|
|
||||||
virtual bool test_serialIsOn(void) const =0;
|
virtual bool test_serialIsOn(void) const =0;
|
||||||
|
|
||||||
virtual bool dc_updateDC(QString binFileName,
|
|
||||||
QString baudrate,
|
|
||||||
QString comPort) const = 0;
|
|
||||||
// download binary file down into device controller
|
|
||||||
|
|
||||||
virtual void dc_autoRequest(bool on) const =0;
|
virtual void dc_autoRequest(bool on) const =0;
|
||||||
// on = true: select that all READ-Requests are sent automatically
|
// on = true: select that all READ-Requests are sent automatically
|
||||||
@@ -763,29 +839,36 @@ public:
|
|||||||
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
// up to 8 dynamic values can be defined in the template ("print val3 here") and will be sent with printing command
|
||||||
// example: print current time at this point (the time of printing not the storage time!!)
|
// example: print current time at this point (the time of printing not the storage time!!)
|
||||||
|
|
||||||
virtual void pri_startTicketDesign(void) const =0;
|
// obsolete
|
||||||
|
//virtual void pri_startTicketDesign(void) const =0;
|
||||||
// start for every new printer document, reseting collecting buffer
|
// start for every new printer document, reseting collecting buffer
|
||||||
|
|
||||||
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
// all further functions write/append text, numbers and command to the ticket-buffer, up to 1278 bytes allowed
|
||||||
// return val of the appending functions: true=ok false=too long, buffer full
|
// return val of the appending functions: true=ok false=too long, buffer full
|
||||||
|
|
||||||
virtual int pri_TD_getCurrentSize(void) const =0;
|
// obsolete
|
||||||
|
//virtual int pri_TD_getCurrentSize(void) const =0;
|
||||||
// retval: 0...1278
|
// retval: 0...1278
|
||||||
|
|
||||||
virtual bool pri_TD_addText(QByteArray text) const =0;
|
// obsolete
|
||||||
|
//virtual bool pri_TD_addText(QByteArray text) const =0;
|
||||||
// example: pri_TD_addText("Hello") const =0;
|
// example: pri_TD_addText("Hello") const =0;
|
||||||
// example: pri_TD_addText(tempStr) const =0;
|
// example: pri_TD_addText(tempStr) const =0;
|
||||||
// retval: true=ok false=too long, buffer full
|
// retval: true=ok false=too long, buffer full
|
||||||
|
|
||||||
virtual bool pri_TD_addValue(int val) const =0;
|
// obsolete
|
||||||
|
//virtual bool pri_TD_addValue(int val) const =0;
|
||||||
// +/- 0...2^(31)
|
// +/- 0...2^(31)
|
||||||
|
|
||||||
virtual bool pri_TD_addNewLine(void) const =0;
|
// obsolete
|
||||||
|
//virtual bool pri_TD_addNewLine(void) const =0;
|
||||||
|
|
||||||
virtual bool pri_TD_addSign(char sign) const =0;
|
// obsolete
|
||||||
|
//virtual bool pri_TD_addSign(char sign) const =0;
|
||||||
// example: '.' ' ' 0x20 'W' '$'
|
// example: '.' ' ' 0x20 'W' '$'
|
||||||
|
|
||||||
virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
|
// obsolete
|
||||||
|
//virtual bool pri_TD_addCommand(char group, char attribute, char p1, char p2, char p3, char p4, char p5) const =0;
|
||||||
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
// always add 8 byte to the ticket layout: ESC & group & attribute & parameter1...5
|
||||||
/* complete list of possible commands:
|
/* complete list of possible commands:
|
||||||
group 50 : paper
|
group 50 : paper
|
||||||
@@ -826,11 +909,13 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virtual char prn_clearDocument(uint8_t documentNumber) const =0;
|
// obsolete
|
||||||
|
//virtual char prn_clearDocument(uint8_t documentNumber) const =0;
|
||||||
// clear memory buffer for ONE document
|
// clear memory buffer for ONE document
|
||||||
// function takes a second! don't send right before "store doc"
|
// function takes a second! don't send right before "store doc"
|
||||||
|
|
||||||
virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
|
// obsolete
|
||||||
|
//virtual bool prn_store_Document(uint8_t documentNumber ) const =0;
|
||||||
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
// send the predefined Layout (generated with above TD functions) to DeviceController to save
|
||||||
// documentNumber=0...15
|
// documentNumber=0...15
|
||||||
// maximal 1280 bytes each
|
// maximal 1280 bytes each
|
||||||
@@ -841,7 +926,8 @@ public:
|
|||||||
// the place in the ticket layout is predefined (already in DC memory)
|
// the place in the ticket layout is predefined (already in DC memory)
|
||||||
// the dynamics are first calculated at printing time
|
// the dynamics are first calculated at printing time
|
||||||
|
|
||||||
virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
|
// obsolete
|
||||||
|
//virtual bool prn_printDocument(uint8_t documentNumber, struct T_dynDat *dynTicketData) const =0;
|
||||||
|
|
||||||
|
|
||||||
// 36
|
// 36
|
||||||
@@ -1233,10 +1319,10 @@ public:
|
|||||||
|
|
||||||
virtual void bl_rebootDC(void) const =0;
|
virtual void bl_rebootDC(void) const =0;
|
||||||
|
|
||||||
virtual void bl_startBL(void) const = 0;
|
virtual void bl_startBL(void) const =0;
|
||||||
// send command within 4s after DC power-on, otherwise bl is left
|
// send command within 4s after DC power-on, otherwise bl is left
|
||||||
|
|
||||||
virtual bool bl_checkBL(void) const = 0;
|
virtual void bl_checkBL(void) const =0;
|
||||||
// send command to verify if bl is up
|
// send command to verify if bl is up
|
||||||
|
|
||||||
virtual bool bl_isUp(void) const =0;
|
virtual bool bl_isUp(void) const =0;
|
||||||
@@ -1359,6 +1445,8 @@ public:
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
virtual bool rtc_getExtendedTime(struct T_extTime *exTime) const=0;
|
||||||
|
|
||||||
virtual bool sys_runCompleteTest(void) const=0;
|
virtual bool sys_runCompleteTest(void) const=0;
|
||||||
// warning: lasts 20s in one pace
|
// warning: lasts 20s in one pace
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
@@ -1383,15 +1471,18 @@ public:
|
|||||||
// nr = 1..32
|
// nr = 1..32
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
|
||||||
virtual void log_getHoldAccountNumbers(uint32_t *accNr ) const=0;
|
virtual void log_getHoldAccountNumbers(uint8_t *nrOfVals, uint16_t *accNr ) const=0;
|
||||||
// returns all acc nrs of the backuped vault records
|
// returns all acc nrs of the backuped vault records
|
||||||
// use: uint32_t backupedAccNumbers[8]
|
// use: uint16_t backupedAccNumbers[8]
|
||||||
|
|
||||||
virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0;
|
virtual bool log_selectVaultRecord(uint16_t accountNr ) const=0;
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
// and trigger transfer
|
||||||
|
|
||||||
//request, isAvailable
|
virtual bool log_chkIfVaultRecordAvailable(void) const=0;
|
||||||
virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
// return true if completly received
|
||||||
|
|
||||||
|
virtual bool log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
||||||
// which was selected by: log_selectVaultRecord()
|
// which was selected by: log_selectVaultRecord()
|
||||||
// to be forwarded to Ismas
|
// to be forwarded to Ismas
|
||||||
|
|
||||||
@@ -1401,7 +1492,19 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|||||||
virtual bool prn_printTestTicket(void) const=0;
|
virtual bool prn_printTestTicket(void) const=0;
|
||||||
// return true if sending to DC OK, false if cmd-stack is full
|
// return true if sending to DC OK, false if cmd-stack is full
|
||||||
|
|
||||||
virtual bool cash_startPayment(uint16_t amount) const=0;
|
virtual bool cash_startPayment(uint32_t amount) const=0;
|
||||||
|
// 17.4.23TS: extended to 32bit
|
||||||
|
|
||||||
|
virtual uint8_t cash_paymentProcessing(void) const=0;
|
||||||
|
// 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
|
||||||
|
|
||||||
|
|
||||||
virtual uint32_t getInsertedAmount(void) const=0;
|
virtual uint32_t getInsertedAmount(void) const=0;
|
||||||
|
|
||||||
@@ -1425,18 +1528,23 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|||||||
// conclude payment process and return all inserted coins
|
// conclude payment process and return all inserted coins
|
||||||
|
|
||||||
|
|
||||||
|
virtual uint8_t mif_getCardType(QString *cardholder) const=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual uint8_t mif_getCardType(QString cardholder) const=0;
|
|
||||||
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
// return 1,2,3,4 = upper, lower access card, printer test, coin test
|
||||||
// cardholder: 7byte Name-String
|
// cardholder: 7byte Name-String
|
||||||
|
|
||||||
virtual uint64_t sys_getWakeSource(void) const =0;
|
virtual uint64_t sys_getWakeSource(void) const =0;
|
||||||
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
// retval: 6 bytes, bit coded, 1=event keeps DC awake
|
||||||
|
|
||||||
//virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
|
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;
|
virtual void sys_getDeviceConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -1473,8 +1581,9 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
virtual void sys_getDeviceConditions(struct T_moduleCondition *devCond) const=0;
|
||||||
|
|
||||||
|
|
||||||
//virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
|
||||||
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
|
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const=0;
|
||||||
/*
|
/*
|
||||||
|
|
||||||
@@ -1540,6 +1649,70 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
virtual void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const=0;
|
||||||
|
|
||||||
|
// content of Cashbox
|
||||||
|
virtual uint32_t cash_getAmountInVault(void) const=0;
|
||||||
|
|
||||||
|
virtual uint16_t cash_getNrCoinsInVault(void) const=0;
|
||||||
|
|
||||||
|
virtual uint8_t prn_getPrintResult() const=0;
|
||||||
|
// return: 0: unknown
|
||||||
|
// 1: OK - last template was printed succesful
|
||||||
|
// 2: error - last template was not printed
|
||||||
|
|
||||||
|
// in case of print-error get detailed error:
|
||||||
|
virtual uint8_t prn_getCurrentPrinterState() const=0;
|
||||||
|
// 0: printer OK
|
||||||
|
// bit0: near paper end bit1: no paper
|
||||||
|
// bit2: temperature error bit3: error head open
|
||||||
|
// bit4: paper jam in cutter
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
virtual bool sys_sendingTest(void) const =0;
|
||||||
|
|
||||||
|
virtual void prn_requestCurrentDynData(void) const =0;
|
||||||
|
|
||||||
|
virtual bool prn_getCurrentDynamicPrnValuesFromDC(uint8_t *dynPrnVal ) const =0;
|
||||||
|
// which was sent with: bool prn_sendDynamicPrnValues(uint8_t *dynPrnVal ) const override;
|
||||||
|
|
||||||
|
virtual bool prn_dynDataAreEqual(uint8_t *buf) const =0;
|
||||||
|
|
||||||
|
virtual bool prn_printKombiticket(uint8_t nrOfKombi) const=0;
|
||||||
|
// print four of the templates loaded by Json prior
|
||||||
|
// nr = 1..8
|
||||||
|
|
||||||
|
|
||||||
|
virtual void lock_triggerUpperSolenoid(void) const =0;
|
||||||
|
|
||||||
|
virtual void lock_triggerLowerSolenoid(void) const =0;
|
||||||
|
|
||||||
|
|
||||||
|
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_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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1557,10 +1730,22 @@ virtual void log_getVaultRecord(struct T_vaultRecord *retVR) const=0;
|
|||||||
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
|
// 29.03.2023: V3.1 some extensions for PSA1256_ptu5,
|
||||||
// V3.2 Bootloader improvement
|
// V3.2 Bootloader improvement
|
||||||
// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging
|
// 12.04.2023: V3.3 new features extended: loading and using Json-files, cash-collection, cash-data-logging
|
||||||
|
// 14.04.2023: V3.4 new features extended: sys_getDynMachineConditions, sys_getDeviceConditions and
|
||||||
|
// rtc_getExtendedTime return struct in addition. New function to select and get VaultRecord
|
||||||
|
//
|
||||||
|
// 19.04.2023: V3.5 new function: sys_getWakeReason();
|
||||||
|
// 17.05.2023: V3.6 new function: cash_isCollectionActive(), cash_isPayProcessActive()
|
||||||
|
// new signals: hwapi_coinCollectionJustStopped, hwapi_coinCollectionJustStarted
|
||||||
|
// getAllInsertedCoins() fixed, also in datif and storeINdata
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#define HWINF_iid "Atb.Psa2020.software.HWapi/3.1"
|
//#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.1"
|
||||||
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.3"
|
||||||
|
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.4"
|
||||||
|
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.5"
|
||||||
|
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/3.6"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
34
src/com.cpp
34
src/com.cpp
@@ -93,34 +93,29 @@ T_com::~T_com()
|
|||||||
|
|
||||||
void T_com::ser_ISR100ms()
|
void T_com::ser_ISR100ms()
|
||||||
{
|
{
|
||||||
//qDebug() << "~~>LIB" << "ENTER...";
|
|
||||||
// call every 100ms to check if user(HMI) wants to connect or disconnect
|
// call every 100ms to check if user(HMI) wants to connect or disconnect
|
||||||
|
|
||||||
|
//qDebug() << "~~>LIB" << "checking connect button... " ;
|
||||||
|
|
||||||
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
|
uint8_t chkConn = gpi_getSerialConn(); // from global GUI buffer (Sdata)
|
||||||
|
|
||||||
//qDebug() << "~~>LIB" << "checking connect button... " << chkConn;
|
|
||||||
|
|
||||||
switch (chkConn)
|
switch (chkConn)
|
||||||
{
|
{
|
||||||
case 0: // 0 button "connect" was just released
|
case 0: // 0 button "connect" was just released
|
||||||
//qDebug() << "close serial port" << chkConn;
|
|
||||||
closeSerialPort();
|
closeSerialPort();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
case 1: // 1 button "connect" was just pressed
|
case 1: // 1 button "connect" was just pressed
|
||||||
//qDebug() << "open serial port" << chkConn;
|
|
||||||
open_Serial_Port();
|
open_Serial_Port();
|
||||||
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
gpi_serialChanged(); // set chkConn to 2, thus getting edge
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (CatSerial->isOpen()) {
|
if (CatSerial->isOpen())
|
||||||
gpi_serialIsOpen(true);
|
gpi_serialIsOpen(true);
|
||||||
} else {
|
else
|
||||||
gpi_serialIsOpen(false);
|
gpi_serialIsOpen(false);
|
||||||
}
|
|
||||||
|
|
||||||
//qDebug() << "LEAVE " << chkConn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------------------------------
|
||||||
@@ -129,24 +124,17 @@ void T_com::ser_ISR100ms()
|
|||||||
|
|
||||||
char T_com::open_Serial_Port()
|
char T_com::open_Serial_Port()
|
||||||
{
|
{
|
||||||
//qDebug() << "ENTER";
|
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
QString myString=nullptr, myPortName=nullptr, myBaudStr=nullptr;
|
||||||
int myBaudNr;
|
int myBaudNr;
|
||||||
|
|
||||||
if (CatSerial->isOpen()) {
|
if (CatSerial->isOpen())
|
||||||
qDebug() << "!!!IS OPEN!!!";
|
|
||||||
return 0; // opening twice is not allowed
|
return 0; // opening twice is not allowed
|
||||||
}
|
|
||||||
|
|
||||||
//qDebug() << "connecting..." << myPortName;
|
//qDebug() << "connecting..." << myPortName;
|
||||||
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
myPortName=gpi_getComPortName(); // was selected and stored from GUI
|
||||||
CatSerial->setPortName(myPortName);
|
CatSerial->setPortName(myPortName);
|
||||||
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
myBaudNr=gpi_getBaudNr(); // was selected and stored from GUI
|
||||||
|
|
||||||
//qDebug() << "myPortName" << myPortName << ", myBaudNr" << myBaudNr;
|
|
||||||
|
|
||||||
switch (myBaudNr)
|
switch (myBaudNr)
|
||||||
{
|
{
|
||||||
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
// 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
|
||||||
@@ -179,9 +167,6 @@ char T_com::open_Serial_Port()
|
|||||||
myString.append(CatSerial->errorString());
|
myString.append(CatSerial->errorString());
|
||||||
qDebug() << myString;
|
qDebug() << myString;
|
||||||
gpi_setTxt4comStateLine(myString);
|
gpi_setTxt4comStateLine(myString);
|
||||||
|
|
||||||
//qDebug() << "LEAVE";
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -197,14 +182,11 @@ char T_com::open_Serial_Port()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "LEAVE";
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_com::closeSerialPort()
|
void T_com::closeSerialPort()
|
||||||
{
|
{
|
||||||
//qDebug() << "ENTER";
|
|
||||||
|
|
||||||
if (CatSerial->isOpen())
|
if (CatSerial->isOpen())
|
||||||
{
|
{
|
||||||
qDebug() << "closing connection";
|
qDebug() << "closing connection";
|
||||||
@@ -213,8 +195,6 @@ void T_com::closeSerialPort()
|
|||||||
gpi_setTxt4RsDiagWin("closed");
|
gpi_setTxt4RsDiagWin("closed");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "LEAVE";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,20 +15,16 @@ static uint8_t rs_connect; // 0,1
|
|||||||
|
|
||||||
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
void epi_setSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
|
||||||
{
|
{
|
||||||
// qDebug() << "ENTER" << BaudNr << BaudStr << ComName << connect;
|
|
||||||
|
|
||||||
rs_comportName = ComName;
|
rs_comportName = ComName;
|
||||||
rs_baudStr = BaudStr;
|
rs_baudStr = BaudStr;
|
||||||
rs_baudNr = BaudNr; // 0=1200 1=9600 2=19200 3=38400 4=57600 5=115200 oder -1
|
rs_baudNr = BaudNr; // 0=1200 1=9600 2=19200 3=38400 4=57600 5=115200 oder -1
|
||||||
rs_connect = connect; // 0/1
|
rs_connect = connect; // 0/1
|
||||||
|
|
||||||
// qDebug() << "LEAVE" << rs_baudNr << rs_baudStr << rs_comportName << rs_connect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_closeSerial(void)
|
void epi_closeSerial(void)
|
||||||
{
|
{
|
||||||
rs_connect=0;
|
rs_connect=0;
|
||||||
// qDebug() << "ENTER/LEAVE rc_connect=0";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +32,6 @@ void gpi_serialChanged(void)
|
|||||||
{
|
{
|
||||||
// serial confirms that port was closed or opened
|
// serial confirms that port was closed or opened
|
||||||
rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
rs_connect=2; // Flanke, nur 1x öffnen/schließen
|
||||||
//qDebug() << "ENTER/LEAVE rc_connect=2";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t gpi_getSerialConn(void)
|
uint8_t gpi_getSerialConn(void)
|
||||||
@@ -59,14 +54,12 @@ static bool rs_portIsOpen;
|
|||||||
|
|
||||||
void gpi_serialIsOpen(bool offen)
|
void gpi_serialIsOpen(bool offen)
|
||||||
{
|
{
|
||||||
//qDebug() << "ENTER/LEAVE offen=" << offen;
|
|
||||||
rs_portIsOpen=offen;
|
rs_portIsOpen=offen;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool epi_isSerialPortOpen()
|
bool epi_isSerialPortOpen()
|
||||||
{
|
{
|
||||||
// true: port is open false: port is closed
|
// true: port is open false: port is closed
|
||||||
//qDebug() << "ENTER/LEAVE offen=" << rs_portIsOpen;
|
|
||||||
return rs_portIsOpen;
|
return rs_portIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,4 +412,88 @@ uint16_t epi_getLastPayLoad(uint16_t plBufSiz, uint8_t *payLoad)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t ndbs, pari, nsb, br;
|
||||||
|
|
||||||
|
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
||||||
|
uint8_t parity, uint8_t NrStopBits)
|
||||||
|
{
|
||||||
|
// store numbers
|
||||||
|
ndbs=NrDataBits;
|
||||||
|
pari=parity;
|
||||||
|
nsb=NrStopBits;
|
||||||
|
br=slaveBaudRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
||||||
|
uint8_t *parity, uint8_t *NrStopBits)
|
||||||
|
{
|
||||||
|
*NrDataBits=ndbs;
|
||||||
|
*parity=pari;
|
||||||
|
*NrStopBits=nsb;
|
||||||
|
*slaveBaudRate=br;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
||||||
|
uint8_t parity, uint8_t NrStopBits) {
|
||||||
|
// store numbers
|
||||||
|
SharedMemBuffer::write()->ndbs = NrDataBits;
|
||||||
|
SharedMemBuffer::write()->pari = parity;
|
||||||
|
SharedMemBuffer::write()->nsb = NrStopBits;
|
||||||
|
SharedMemBuffer::write()->br = slaveBaudRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
||||||
|
uint8_t *parity, uint8_t *NrStopBits) {
|
||||||
|
|
||||||
|
*NrDataBits = SharedMemBuffer::read()->ndbs;
|
||||||
|
*parity = SharedMemBuffer::read()->pari;
|
||||||
|
*NrStopBits = SharedMemBuffer::read()->nsb;
|
||||||
|
*slaveBaudRate = SharedMemBuffer::read()->br;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString epi_getSlaveParamSTR()
|
||||||
|
{
|
||||||
|
QString mySt;
|
||||||
|
char ctmp;
|
||||||
|
// uint8_t ndbs;
|
||||||
|
// uint8_t pari;
|
||||||
|
// uint8_t nsb;
|
||||||
|
// uint8_t br;
|
||||||
|
|
||||||
|
mySt.clear();
|
||||||
|
// br=SharedMemBuffer::read()->br;
|
||||||
|
// ndbs=SharedMemBuffer::read()->ndbs;
|
||||||
|
// pari =SharedMemBuffer::read()->pari;
|
||||||
|
// nsb=SharedMemBuffer::read()->nsb;
|
||||||
|
|
||||||
|
switch (br)
|
||||||
|
{
|
||||||
|
case 1: mySt="1200 ";break;
|
||||||
|
case 2: mySt="9600 ";break;
|
||||||
|
case 3: mySt="19200 ";break;
|
||||||
|
case 4: mySt="38400 ";break;
|
||||||
|
case 5: mySt="57600 ";break;
|
||||||
|
case 6: mySt="115200 ";break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ctmp=ndbs;
|
||||||
|
ctmp+=0x30;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
ctmp=pari;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
ctmp=nsb;
|
||||||
|
ctmp+=0x30;
|
||||||
|
mySt.append(ctmp);
|
||||||
|
//mySt="Hallo";
|
||||||
|
return mySt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
192
src/datIf.cpp
192
src/datIf.cpp
@@ -3,13 +3,16 @@
|
|||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <datei.h>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
// called from MainWindow()
|
// called from MainWindow()
|
||||||
|
|
||||||
|
|
||||||
#define DATIF_MAXCMDS 16
|
#define DATIF_MAXCMDS 16
|
||||||
static uint8_t dif_dataStep;
|
static uint8_t dif_dataStep;
|
||||||
static uint8_t dif_scanStep, RDBLKNR;
|
static uint8_t dif_scanStep; //, RDBLKNR;
|
||||||
|
|
||||||
|
|
||||||
static uint8_t datif_OutCmdpara1, datif_OutCmdpara2, datif_OutCmdpara3, datif_OutCmdpara4;
|
static uint8_t datif_OutCmdpara1, datif_OutCmdpara2, datif_OutCmdpara3, datif_OutCmdpara4;
|
||||||
@@ -19,6 +22,11 @@ static uint8_t cycl_running;
|
|||||||
|
|
||||||
T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
|
T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
|
||||||
{
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
QDir myDir("../dmd");
|
||||||
|
|
||||||
|
if (!myDir.exists())
|
||||||
|
myDir.mkdir("../dmd");
|
||||||
|
|
||||||
myDCIF = new T_prot();
|
myDCIF = new T_prot();
|
||||||
|
|
||||||
@@ -32,7 +40,7 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
|
|||||||
datif_trigger = new QTimer();
|
datif_trigger = new QTimer();
|
||||||
connect(datif_trigger, SIGNAL(timeout()), this, SLOT(datif_cycleSend()));
|
connect(datif_trigger, SIGNAL(timeout()), this, SLOT(datif_cycleSend()));
|
||||||
datif_trigger->setSingleShot(false);
|
datif_trigger->setSingleShot(false);
|
||||||
datif_trigger->start(10); // in ms, 80 gut, default 100 50....200
|
datif_trigger->start(10); // in ms,
|
||||||
|
|
||||||
// passing Signal through
|
// passing Signal through
|
||||||
//connect(myDCIF, SIGNAL(framerecieved()), this, SLOT( ResponseRecieved() ));
|
//connect(myDCIF, SIGNAL(framerecieved()), this, SLOT( ResponseRecieved() ));
|
||||||
@@ -46,6 +54,30 @@ T_datif::T_datif(QWidget *parent) : QMainWindow(parent)
|
|||||||
dif_scanStep=0;
|
dif_scanStep=0;
|
||||||
selectedSlaveAddr=FIX_SLAVE_ADDR;
|
selectedSlaveAddr=FIX_SLAVE_ADDR;
|
||||||
cycl_running=0;
|
cycl_running=0;
|
||||||
|
gpi_storeDcDataValid(0);
|
||||||
|
datif_noResponseCtr=0;
|
||||||
|
|
||||||
|
|
||||||
|
// neu, 24.5.23: Alle Daten zusätzlich in Datei speichern
|
||||||
|
// if (datei_ifFileExists(FILENAME_SHAREDDATA))
|
||||||
|
// {
|
||||||
|
// myBA.clear();
|
||||||
|
// myBA=datei_readFromFile(FILENAME_SHAREDDATA);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Testfile ereugen:
|
||||||
|
csv_startCreatingFile();
|
||||||
|
csv_addUintToFile(0);
|
||||||
|
csv_addUintToFile(1);
|
||||||
|
csv_addUintToFile(2);
|
||||||
|
csv_addUintToFile(3);
|
||||||
|
csv_addUintToFile(4);
|
||||||
|
csv_addUintToFile(5);
|
||||||
|
myBA=csv_readbackArray();
|
||||||
|
datei_clearFile(FILENAME_SHAREDDATA);
|
||||||
|
datei_writeToFile(FILENAME_SHAREDDATA, myBA);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void T_datif::resetChain(void)
|
void T_datif::resetChain(void)
|
||||||
@@ -65,6 +97,11 @@ char T_datif::datif_cycleSend()
|
|||||||
uint8_t length, data[66];
|
uint8_t length, data[66];
|
||||||
bool b_ret;
|
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);
|
||||||
|
|
||||||
|
|
||||||
if (cycl_running)
|
if (cycl_running)
|
||||||
{
|
{
|
||||||
// request is still running, wait for response before next sending
|
// request is still running, wait for response before next sending
|
||||||
@@ -95,7 +132,23 @@ char T_datif::datif_cycleSend()
|
|||||||
|
|
||||||
//void myDCIF->sendUserData(uint16_t slaveAdr);
|
//void myDCIF->sendUserData(uint16_t slaveAdr);
|
||||||
|
|
||||||
if (check4FDshortCmd())
|
if (checkNextFDcmd()==2)
|
||||||
|
{
|
||||||
|
b_ret=longFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &length, data);
|
||||||
|
if (b_ret)
|
||||||
|
{
|
||||||
|
myDCIF->setUserWriteData(nextWrCmd, blockNum, length, data);
|
||||||
|
myDCIF->setUserReadData(nextRdCmd);
|
||||||
|
myDCIF->sendUserData(selectedSlaveAddr);
|
||||||
|
//qDebug()<<"Datif send long cmd "<<nextWrCmd<< " " <<nextRdCmd<< " " <<length << " " << data[0]<< " " << data[1]
|
||||||
|
// << " " << data[2]<< " " << data[3]<< " " << data[4]<< " " << data[5]<< " " << data[6]<< " " << data[7]
|
||||||
|
// << " " << data[8]<< " " << data[9]<< " " << data[10]<< " " << data[11]<< " " << data[12];
|
||||||
|
}
|
||||||
|
cycl_running=1;
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (checkNextFDcmd()==1)
|
||||||
{
|
{
|
||||||
b_ret=sendFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &dat1, &dat2, &dat3, &dat4);
|
b_ret=sendFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &dat1, &dat2, &dat3, &dat4);
|
||||||
if (b_ret)
|
if (b_ret)
|
||||||
@@ -104,19 +157,18 @@ char T_datif::datif_cycleSend()
|
|||||||
myDCIF->setUserWriteData(nextWrCmd, blockNum, 4, data);
|
myDCIF->setUserWriteData(nextWrCmd, blockNum, 4, data);
|
||||||
myDCIF->setUserReadData(nextRdCmd);
|
myDCIF->setUserReadData(nextRdCmd);
|
||||||
myDCIF->sendUserData(selectedSlaveAddr);
|
myDCIF->sendUserData(selectedSlaveAddr);
|
||||||
|
//qDebug()<<"Datif send short cmd "<<nextWrCmd<< " " <<nextRdCmd;
|
||||||
}
|
}
|
||||||
|
cycl_running=1;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check4FDlongCmd())
|
|
||||||
{
|
|
||||||
b_ret=longFDcmd_get(&nextWrCmd, &nextRdCmd, &blockNum, &length, data);
|
|
||||||
if (b_ret)
|
|
||||||
{
|
|
||||||
myDCIF->setUserWriteData(nextWrCmd, blockNum, length, data);
|
|
||||||
myDCIF->setUserReadData(nextRdCmd);
|
|
||||||
myDCIF->sendUserData(selectedSlaveAddr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// direct commands have highest prio (setting OUTPUTS)
|
// direct commands have highest prio (setting OUTPUTS)
|
||||||
nxtAsCmd=sendWRcmd_getSendCommand0(); // command was stored by Gui
|
nxtAsCmd=sendWRcmd_getSendCommand0(); // command was stored by Gui
|
||||||
@@ -210,7 +262,10 @@ char T_datif::datif_cycleSend()
|
|||||||
sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential
|
sendINrequestsAutomatic(); // sendCyclicCmd(); // request all cyclic data sequential
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
dif_scanStep=0; // always start from beginning
|
dif_scanStep=0; // always start from beginning
|
||||||
|
gpi_storeDcDataValid(0); // fehlt in SysCont
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifdef USEHANDSHAKES
|
#ifdef USEHANDSHAKES
|
||||||
else
|
else
|
||||||
@@ -221,6 +276,7 @@ char T_datif::datif_cycleSend()
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
|
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
|
||||||
|
gpi_storeDcDataValid(0); // fehlt in SysCont
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -306,6 +362,7 @@ void T_datif::sendWRcommand(uint16_t nextWrCmd)
|
|||||||
datif_sendIOrequest(CMD2DC_FAN, CMD2DC_RdBkAllOutputs, 1);
|
datif_sendIOrequest(CMD2DC_FAN, CMD2DC_RdBkAllOutputs, 1);
|
||||||
break;
|
break;
|
||||||
case SENDDIRCMD_LAERM:
|
case SENDDIRCMD_LAERM:
|
||||||
|
//qDebug()<<"datif switch siren";
|
||||||
datif_sendIOrequest(CMD2DC_SIREN, CMD2DC_RdBkAllOutputs, 1);
|
datif_sendIOrequest(CMD2DC_SIREN, CMD2DC_RdBkAllOutputs, 1);
|
||||||
break;
|
break;
|
||||||
case SENDDIRCMD_REL1:
|
case SENDDIRCMD_REL1:
|
||||||
@@ -728,7 +785,7 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 12:
|
case 12:
|
||||||
if (indat_isPrinterOn())
|
//if (indat_isPrinterOn())
|
||||||
datif_sendIOrequest(0, CMD2DC_RdBk_AllPrnData, 0); // 27
|
datif_sendIOrequest(0, CMD2DC_RdBk_AllPrnData, 0); // 27
|
||||||
// datif_sendIOrequest(0, CMD2DC_RdBk_PrnState, 0);
|
// datif_sendIOrequest(0, CMD2DC_RdBk_PrnState, 0);
|
||||||
break;
|
break;
|
||||||
@@ -738,7 +795,7 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 14:
|
case 14:
|
||||||
if (indat_isMifareOn())
|
//if (indat_isMifareOn())
|
||||||
{
|
{
|
||||||
datif_sendIOrequest(0, CMD2DC_RdBk_MifState, 0); // 109
|
datif_sendIOrequest(0, CMD2DC_RdBk_MifState, 0); // 109
|
||||||
//qDebug()<<"requesting MIF reader state";
|
//qDebug()<<"requesting MIF reader state";
|
||||||
@@ -751,6 +808,7 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 16:
|
case 16:
|
||||||
|
/*
|
||||||
if (indat_isMifareOn())
|
if (indat_isMifareOn())
|
||||||
{
|
{
|
||||||
datif_OutCmdpara1=0; // data block number 0 contains the Mifare-ID
|
datif_OutCmdpara1=0; // data block number 0 contains the Mifare-ID
|
||||||
@@ -760,7 +818,8 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
RDBLKNR=0;
|
RDBLKNR=0;
|
||||||
datif_OutCmdpara1=RDBLKNR;
|
datif_OutCmdpara1=RDBLKNR;
|
||||||
|
|
||||||
} break;
|
}*/
|
||||||
|
break;
|
||||||
|
|
||||||
case 17:
|
case 17:
|
||||||
//datif_sendIOrequest(0, CMD2DC_GetAllInputs, 0);
|
//datif_sendIOrequest(0, CMD2DC_GetAllInputs, 0);
|
||||||
@@ -768,7 +827,7 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 18:
|
case 18:
|
||||||
if (indat_isMdbOn())
|
//if (indat_isMdbOn())
|
||||||
datif_sendIOrequest(0, CMD2DC_MDB_GET_STATE, 0); // 107
|
datif_sendIOrequest(0, CMD2DC_MDB_GET_STATE, 0); // 107
|
||||||
//else
|
//else
|
||||||
// dif_scanStep=24; unsinn
|
// dif_scanStep=24; unsinn
|
||||||
@@ -815,7 +874,7 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
|
|
||||||
dif_scanStep++;
|
dif_scanStep++;
|
||||||
if (dif_scanStep>26)
|
if (dif_scanStep>26)
|
||||||
dif_scanStep=5;
|
dif_scanStep=0; // dif_scanStep=5;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -838,6 +897,7 @@ char T_datif::isPortOpen(void)
|
|||||||
|
|
||||||
void T_datif::StoredRecData()
|
void T_datif::StoredRecData()
|
||||||
{
|
{
|
||||||
|
datif_noResponseCtr=0;
|
||||||
//qDebug() << "StoreRecData called";
|
//qDebug() << "StoreRecData called";
|
||||||
// call automatically by T_prot
|
// call automatically by T_prot
|
||||||
//if (myDCIF->ifDataReceived())
|
//if (myDCIF->ifDataReceived())
|
||||||
@@ -847,7 +907,10 @@ void T_datif::StoredRecData()
|
|||||||
// "neu" is the same as "INdataValid"
|
// "neu" is the same as "INdataValid"
|
||||||
loadRecDataFromFrame();
|
loadRecDataFromFrame();
|
||||||
}
|
}
|
||||||
cycl_running=0;
|
//cycl_running=0; // send next cmd immediately
|
||||||
|
cycl_running=9; // send next cmd after 10ms
|
||||||
|
// wichtig! bei 0 werden Telegramme verschluckt! 24.5.2023
|
||||||
|
// 9 ergibt 16ms Formel: gap = 110ms (Zeile 80) - cycl_running*10ms
|
||||||
}
|
}
|
||||||
|
|
||||||
char T_datif::loadRecDataFromFrame()
|
char T_datif::loadRecDataFromFrame()
|
||||||
@@ -863,6 +926,11 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
//int portNr;
|
//int portNr;
|
||||||
bool ret;
|
bool ret;
|
||||||
uint8_t uctmp; // maxai
|
uint8_t uctmp; // maxai
|
||||||
|
char ctmp;
|
||||||
|
static uint8_t lastResult;
|
||||||
|
uint8_t prnResult;
|
||||||
|
static uint32_t lastInsertedAmount;
|
||||||
|
uint32_t newInsertedAmount;
|
||||||
|
|
||||||
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
|
ret=myDCIF->getReceivedInData(&SlaveAdr, &readSource, &readAddress, &RdDleng, receivedData);
|
||||||
// retval: data valid, only one time true, true if CommandState OK and readState OK
|
// retval: data valid, only one time true, true if CommandState OK and readState OK
|
||||||
@@ -902,7 +970,8 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
for (int ii=0; ii<RdDleng; ii++)
|
for (int ii=0; ii<RdDleng; ii++)
|
||||||
{
|
{
|
||||||
localStr.append(receivedData[ii]);
|
ctmp=receivedData[ii];
|
||||||
|
localStr.append(ctmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "got HW version: " << localStr;
|
//qDebug() << "got HW version: " << localStr;
|
||||||
@@ -936,7 +1005,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
case CMD2DC_RdBkDCstate: //101
|
case CMD2DC_RdBkDCstate: //101
|
||||||
//qDebug() << "got DC state " << localStr;
|
//qDebug() << "got DC state " << localStr;
|
||||||
localStr[8]=0;
|
//localStr[8]=0;
|
||||||
gpi_storeGenerals(2, localStr);
|
gpi_storeGenerals(2, localStr);
|
||||||
// 0=HW 1=SW 2=State
|
// 0=HW 1=SW 2=State
|
||||||
break;
|
break;
|
||||||
@@ -1015,7 +1084,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
//<< receivedData[3] << " " << receivedData[4] << " " << receivedData[5];
|
//<< receivedData[3] << " " << receivedData[4] << " " << receivedData[5];
|
||||||
|
|
||||||
uctmp=receivedData[0];
|
uctmp=receivedData[0];
|
||||||
// qDebug()<<"datif single bits: "<< (uctmp&1) << (uctmp&2) << (uctmp&4);
|
//qDebug()<<"datif DOOR bits: "<< (uctmp&1) << (uctmp&2) << (uctmp&4);
|
||||||
gpi_storeDI_doorSwitches(uctmp&1, uctmp&2, uctmp&4);
|
gpi_storeDI_doorSwitches(uctmp&1, uctmp&2, uctmp&4);
|
||||||
|
|
||||||
gpi_storeDI_vaultSwitches(uctmp&8, uctmp&16);
|
gpi_storeDI_vaultSwitches(uctmp&8, uctmp&16);
|
||||||
@@ -1044,8 +1113,6 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
gpi_storeDI_GsmPowerIsOn(uctmp&16);
|
gpi_storeDI_GsmPowerIsOn(uctmp&16);
|
||||||
gpi_storeDI_CreditPowerIsOn(uctmp&32);
|
gpi_storeDI_CreditPowerIsOn(uctmp&32);
|
||||||
gpi_storeDI_PrinterPowerIsOn(uctmp&64);
|
gpi_storeDI_PrinterPowerIsOn(uctmp&64);
|
||||||
|
|
||||||
//gpi_storeMdbState(uctmp&4, uctmp&128, uctmp&4); // hat ein eigenes Cmd weiter unten!
|
|
||||||
gpi_storeDI_MdbPowerIsOn(uctmp&128);
|
gpi_storeDI_MdbPowerIsOn(uctmp&128);
|
||||||
|
|
||||||
gpi_storeDI_paperLow(receivedData[5]);
|
gpi_storeDI_paperLow(receivedData[5]);
|
||||||
@@ -1112,7 +1179,9 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
case CMD2DC_RdBk_MifState: //109
|
case CMD2DC_RdBk_MifState: //109
|
||||||
// get reader status and card type
|
// get reader status and card type
|
||||||
|
|
||||||
gpi_storeMifReaderStateAndCardType(receivedData);
|
//gpi_storeMifReaderStateAndCardType(receivedData);
|
||||||
|
gpi_storeNewMifareCard(receivedData[0], &receivedData[1]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD2DC_RdBk_MifData: //24
|
case CMD2DC_RdBk_MifData: //24
|
||||||
@@ -1171,10 +1240,11 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
case CMD2DC_MDB_GET_STATE: //107
|
case CMD2DC_MDB_GET_STATE: //107
|
||||||
// DB0: mdb_bus_ready (switched on)
|
// DB0: mdb_bus_ready (switched on)
|
||||||
// DB1: rdBackV12devicePower
|
// DB1: rdBackV12devicePower
|
||||||
// DB2: rdBackV5busPwr
|
// DB2: rdBackV5busPwr kommt immer mit 1
|
||||||
|
|
||||||
//qDebug() << "got MDB state " << receivedData[0] << " " << receivedData[1] << " " << receivedData[2];
|
//qDebug() << "got MDB state " << receivedData[0] << " " << receivedData[1] << " " << receivedData[2];
|
||||||
gpi_storeMdbState(receivedData[0],receivedData[1],receivedData[2]);
|
gpi_storeMdbState(receivedData[0],receivedData[1],receivedData[2]);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD2DC_MDB_GETRESP: //22
|
case CMD2DC_MDB_GETRESP: //22
|
||||||
@@ -1198,6 +1268,15 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
// DB1: last coin signal (value / scale)
|
// DB1: last coin signal (value / scale)
|
||||||
// DB2,3: last coin value
|
// DB2,3: last coin value
|
||||||
// DB4: lastError from Emp
|
// 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]);
|
gpi_storeEmpCoinSignal(receivedData[0], &receivedData[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1216,7 +1295,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ab hier neu: XXX
|
// ab hier neu: 12.4.23
|
||||||
|
|
||||||
case CMD2DC_RDBK_DEV_PARA: //14
|
case CMD2DC_RDBK_DEV_PARA: //14
|
||||||
/*
|
/*
|
||||||
@@ -1350,10 +1429,22 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
|
|
||||||
case 112: // get inserted amount in cent in sum
|
case 112: // get inserted amount in cent in sum
|
||||||
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
|
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
|
||||||
ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
|
newInsertedAmount=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
|
||||||
uitmp=uchar2uint(receivedData[5],receivedData[4]);
|
uitmp=uchar2uint(receivedData[5],receivedData[4]);
|
||||||
uit2=uchar2uint(receivedData[7],receivedData[6]);
|
uit2=uchar2uint(receivedData[7],receivedData[6]);
|
||||||
gpi_storeCurrentPayment(ultmp, uitmp, uit2);
|
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;
|
break;
|
||||||
|
|
||||||
case 113: // get wake source, 8byte
|
case 113: // get wake source, 8byte
|
||||||
@@ -1463,19 +1554,40 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
outBuf[pBuf++]=0;
|
outBuf[pBuf++]=0;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
if (RdDleng>40)
|
||||||
|
//datif_DCdataValid=1; // das hier sind die wichtigsten Daten, deshalb hierrein!
|
||||||
|
gpi_storeDcDataValid(1);
|
||||||
|
|
||||||
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
||||||
|
|
||||||
|
prnResult=receivedData[52];
|
||||||
|
if (prnResult != lastResult)
|
||||||
|
{
|
||||||
|
// new result
|
||||||
|
if (prnResult==1)
|
||||||
|
{
|
||||||
|
emit datif_templatePrintFinished_OK();
|
||||||
|
} else
|
||||||
|
if (prnResult==2)
|
||||||
|
{
|
||||||
|
emit datif_templatePrintFinished_Err();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastResult=prnResult;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 32: // Get current cash level (in vault)
|
case 32: // Get current cash level (in vault)
|
||||||
// bytes 0..3: amount bytes 4,5=Nr.ofCoins in vault
|
// bytes 0..3: amount bytes 4,5=Nr.ofCoins in vault
|
||||||
|
ultmp=uchar2ulong(receivedData[3],receivedData[2],receivedData[1],receivedData[0]);
|
||||||
|
uitmp=uchar2uint(receivedData[5],receivedData[4]);
|
||||||
|
gpi_storeCBlevel(ultmp, uitmp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 33: // Get all backuped acc. Numbers
|
case 33: // Get all backuped acc. Numbers
|
||||||
// 8 UINTs with acc-nr
|
// 8 UINTs with acc-nr
|
||||||
|
gpi_storeDCbackupAccNr(RdDleng, receivedData);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 38: // Get stored account record backup
|
case 38: // Get stored account record backup
|
||||||
@@ -1541,10 +1653,17 @@ struct T_vaultRecord
|
|||||||
UCHAR endofblock[4]; // end>
|
UCHAR endofblock[4]; // end>
|
||||||
// 316 byte Block im Speicher
|
// 316 byte Block im Speicher
|
||||||
*/
|
*/
|
||||||
|
// readAddress, &RdDleng, receivedData
|
||||||
|
gpi_storeVaultRecord(readAddress, receivedData ); // always 64byte
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 39:
|
||||||
|
gpi_storeDynData(receivedData);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
readSource=0; // 17.05.2023: to avoid multiple recording
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1644,11 +1763,15 @@ bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
|
|||||||
if (RdDlen < 16)
|
if (RdDlen < 16)
|
||||||
return false;
|
return false;
|
||||||
QString myStr;
|
QString myStr;
|
||||||
|
char ctmp;
|
||||||
|
|
||||||
myStr.clear();
|
myStr.clear();
|
||||||
myStr.append("< Slave Response");
|
myStr.append("< Slave Response");
|
||||||
|
|
||||||
for (int nn=0; nn<16; nn++)
|
for (int nn=0; nn<16; nn++)
|
||||||
if (myStr[nn] !=receivedData[nn])
|
{
|
||||||
|
ctmp=receivedData[nn];
|
||||||
|
if (myStr[nn] != ctmp)
|
||||||
{
|
{
|
||||||
//qDebug() << " datif cmd 10: got wrong string ";
|
//qDebug() << " datif cmd 10: got wrong string ";
|
||||||
//qDebug() << myStr;
|
//qDebug() << myStr;
|
||||||
@@ -1656,6 +1779,7 @@ bool T_datif::verifyLineTestresponse(uint8_t RdDlen, uint8_t *receivedData)
|
|||||||
//qDebug() << nn;
|
//qDebug() << nn;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
943
src/datei.cpp
Normal file
943
src/datei.cpp
Normal file
@@ -0,0 +1,943 @@
|
|||||||
|
// written by Thomas Sax, Jan.2022
|
||||||
|
#include "datei.h"
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ create csv file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
QByteArray datei_writeArray, datei_tempArray;
|
||||||
|
|
||||||
|
void csv_startCreatingFile(void)
|
||||||
|
{
|
||||||
|
datei_writeArray.clear();
|
||||||
|
datei_tempArray.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void csv_addTextToFile(QString myText)
|
||||||
|
{
|
||||||
|
datei_writeArray.append(myText.toLatin1());
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void csv_addIntToFile(int myValue)
|
||||||
|
{
|
||||||
|
//qulonglong ullt=12345678901234567890; // max 1,844 x10^19
|
||||||
|
datei_tempArray.setNum(myValue,10); // accepted types: short, ushort, int, uint,
|
||||||
|
// qlonglong, qulonglong, float, double
|
||||||
|
// numerbase can be 2...36(!),10=dec
|
||||||
|
|
||||||
|
datei_writeArray.append(datei_tempArray);
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void csv_addUintToFile(uint myValue)
|
||||||
|
{
|
||||||
|
datei_tempArray.setNum(myValue,10);
|
||||||
|
datei_writeArray.append(datei_tempArray);
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void csv_addLongvalToFile(qlonglong myValue)
|
||||||
|
{
|
||||||
|
datei_tempArray.setNum(myValue,10);
|
||||||
|
datei_writeArray.append(datei_tempArray);
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void csv_addUlongvalToFile(qulonglong myValue)
|
||||||
|
{
|
||||||
|
datei_tempArray.setNum(myValue,10);
|
||||||
|
datei_writeArray.append(datei_tempArray);
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void csv_addCurrentTimeToFile(void)
|
||||||
|
{
|
||||||
|
uint8_t hour, minute, sec, ui8buf[20];
|
||||||
|
char buf[20];
|
||||||
|
|
||||||
|
config_getSysTime(&hour, &minute, &sec);
|
||||||
|
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<20; nn++)
|
||||||
|
buf[nn]=char(ui8buf[nn]);
|
||||||
|
datei_writeArray.append(buf,8); // time string
|
||||||
|
datei_writeArray.append(FILESEPERATOR);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void csv_addCurrentDateToFile(void)
|
||||||
|
{
|
||||||
|
uint16_t year;
|
||||||
|
uint8_t month, day, ui8buf[20];
|
||||||
|
char buf[20];
|
||||||
|
|
||||||
|
config_getSystemDate(&year, &month, &day);
|
||||||
|
//qDebug()<<"date year: "<<year;
|
||||||
|
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<20; nn++)
|
||||||
|
buf[nn]=char(ui8buf[nn]);
|
||||||
|
datei_writeArray.append(buf, 10); // date string
|
||||||
|
datei_writeArray.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void csv_addNewlineToFile(void)
|
||||||
|
{
|
||||||
|
datei_writeArray.chop(1); // Komma weg
|
||||||
|
datei_writeArray.append(NEWLINEINFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray csv_readbackArray(void)
|
||||||
|
{
|
||||||
|
return datei_writeArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
QByteArray csv_writeContent_testValues(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA, tmpBA;
|
||||||
|
uint8_t modCount=5, modAddr=23;
|
||||||
|
uint8_t hour, minute, sec, month, day, ui8buf[20];
|
||||||
|
uint16_t year, modType=45678;
|
||||||
|
char buf[20];
|
||||||
|
uint32_t modNrDIs=1234567890;
|
||||||
|
uint8_t modNrAIs=4, modNrCtr=2, modNrDOs=8;
|
||||||
|
int modNrAOs=-2;
|
||||||
|
|
||||||
|
myBA.clear();
|
||||||
|
tmpBA.clear();
|
||||||
|
myBA.append("scan time");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
|
||||||
|
datei_getSysTime(&hour, &minute, &sec);
|
||||||
|
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<20; nn++)
|
||||||
|
buf[nn]=char(ui8buf[nn]);
|
||||||
|
myBA.append(buf,8); // time string
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
|
||||||
|
datei_getSystemDate(&year, &month, &day);
|
||||||
|
//qDebug()<<"date year: "<<year;
|
||||||
|
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<20; nn++)
|
||||||
|
buf[nn]=char(ui8buf[nn]);
|
||||||
|
myBA.append(buf, 10); // date string
|
||||||
|
myBA.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
myBA.append("number of modules");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modCount,10); //2nd para = number base 2, 8, 10 or 16 (bin, oct, dec, hex)
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
myBA.append("busaddr");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("type");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("NrOfDI");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("NrOfAI");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("NrOfCtrIn");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("NrOfDO");
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
myBA.append("NrOfAO");
|
||||||
|
myBA.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
tmpBA.setNum(modAddr,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modType,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modNrDIs,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modNrAIs,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modNrCtr,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modNrDOs,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(FILESEPERATOR);
|
||||||
|
tmpBA.setNum(modNrAOs,10);
|
||||||
|
myBA.append(tmpBA);
|
||||||
|
myBA.append(NEWLINEINFILE);
|
||||||
|
return myBA;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ parse csv file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// first: QByteArray datei_readFromFile(QString filename);
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t csv_nrOfEntriesInFile(QByteArray readFromFile)
|
||||||
|
{
|
||||||
|
// count sequences between FILESEPERATOR and NEWLINEINFILE
|
||||||
|
uint32_t filSize=0, pp=0;
|
||||||
|
char oneByt=0;
|
||||||
|
|
||||||
|
int filLen=readFromFile.size();
|
||||||
|
if(filLen>1)
|
||||||
|
filSize=uint32_t(filLen);
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// 1) find position of seperators
|
||||||
|
for (uint32_t ii=0; ii<filSize; ii++)
|
||||||
|
{
|
||||||
|
oneByt=readFromFile[ii];
|
||||||
|
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
||||||
|
pp++;
|
||||||
|
}
|
||||||
|
// now: pp = number of seperators
|
||||||
|
// oneByt = last byte in file. If it's not a seperator then
|
||||||
|
// there's one more entry (last entry without termination)
|
||||||
|
if (oneByt !=FILESEP1 && oneByt !=FILESEP2 && oneByt !=NEWLINEINFILE)
|
||||||
|
pp++;
|
||||||
|
//qDebug()<<"csv: nr of sequences="<< pp;
|
||||||
|
return pp;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray csv_getOneFileSequence(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
// seperate file content in single sequences between FILESEPERATOR and NEWLINEINFILE
|
||||||
|
// and return "entryNr" - entry
|
||||||
|
// for this first step leave data type QByteArray
|
||||||
|
// 2nd step can change in numbers and strings
|
||||||
|
QByteArray sequence;
|
||||||
|
uint32_t sepPos[MAXNUMBEROFSEQUENCES];
|
||||||
|
uint32_t filSize=0, pp=0, ii, start=0, ende=0;
|
||||||
|
char oneByt;
|
||||||
|
int filLen, mm;
|
||||||
|
|
||||||
|
filLen=sourceFile.size();
|
||||||
|
//qDebug()<<"fillen="<< filLen;
|
||||||
|
if(filLen<10)
|
||||||
|
return "";
|
||||||
|
filSize=uint32_t(filLen);
|
||||||
|
|
||||||
|
if (sequNr>MAXNUMBEROFSEQUENCES)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// 1) find position of seperators
|
||||||
|
for (ii=0; ii<filSize; ii++)
|
||||||
|
{
|
||||||
|
oneByt=sourceFile[ii];
|
||||||
|
if (oneByt==FILESEP1 || oneByt==FILESEP2 || oneByt==NEWLINEINFILE)
|
||||||
|
{
|
||||||
|
sepPos[pp++]=ii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// now: pp = number of entries
|
||||||
|
//qDebug()<<"nr of seperators="<< pp;
|
||||||
|
|
||||||
|
if (sequNr>=pp)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// 2) get sequence
|
||||||
|
if (sequNr==0)
|
||||||
|
{
|
||||||
|
start=0;
|
||||||
|
ende=sepPos[sequNr];
|
||||||
|
} else
|
||||||
|
if (sequNr>0)
|
||||||
|
{
|
||||||
|
start=sepPos[sequNr-1]+1;
|
||||||
|
ende=sepPos[sequNr];
|
||||||
|
}
|
||||||
|
|
||||||
|
//qDebug()<<"datei getOneFileSequence start/ende: "<<start << " " << ende;
|
||||||
|
if (start>=ende)
|
||||||
|
return "";
|
||||||
|
//return "-err3-";
|
||||||
|
sequence.clear();
|
||||||
|
//batmp.clear();
|
||||||
|
pp=0;
|
||||||
|
for (ii=start; ii<ende; ii++)
|
||||||
|
{
|
||||||
|
mm=int(ii);
|
||||||
|
if (mm>=int(filSize))
|
||||||
|
mm=0;
|
||||||
|
oneByt=sourceFile.at(mm);
|
||||||
|
sequence.append(oneByt);
|
||||||
|
}
|
||||||
|
return sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
int csv_getEntryAsInt(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA, myVA;
|
||||||
|
int entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
myVA.clear();
|
||||||
|
myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
//qDebug()<<"datei getEntryAsInt, sequence: " << myBA;
|
||||||
|
|
||||||
|
entry=myBA.toInt(&ok,16);
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
//qDebug()<<"datei getEntryAsInt, number: " << entry;
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
//qDebug()<<"datei getEntryAsInt, error " << myBA;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t csv_getEntryAsLong(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
long entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
entry=myBA.toLong(&ok,10);
|
||||||
|
if (ok)
|
||||||
|
return entry;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t csv_getEntryAsUshort(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
uint8_t entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
entry=uint8_t(myBA.toUShort(&ok,10));
|
||||||
|
if (ok)
|
||||||
|
return entry;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t csv_getEntryAsUint(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
uint16_t entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
entry=uint16_t(myBA.toUInt(&ok,10));
|
||||||
|
if (ok)
|
||||||
|
return entry;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t csv_getEntryAsUlong(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
uint32_t entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
entry=myBA.toULong(&ok,10);
|
||||||
|
if (ok)
|
||||||
|
return entry;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t csv_getEntryAs2Ulong(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
uint64_t entry=0;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
entry=myBA.toULongLong(&ok,10);
|
||||||
|
if (ok)
|
||||||
|
return entry;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QString csv_getEntryAsString(QByteArray sourceFile, uint32_t sequNr)
|
||||||
|
{
|
||||||
|
QByteArray myBA = csv_getOneFileSequence(sourceFile, sequNr);
|
||||||
|
QString entry;
|
||||||
|
|
||||||
|
//qDebug()<<"datei getEntryAsString, sequence: " << myBA;
|
||||||
|
entry=myBA.toStdString().c_str();
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ create Json file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
example
|
||||||
|
QString str = "{"
|
||||||
|
" \"Herausgeber\": \"Xema\","
|
||||||
|
" \"Nummer\": \"1234-5678-9012-3456\","
|
||||||
|
" \"Deckung\": 2e+6,"
|
||||||
|
" \"Währung\": \"EURO\","
|
||||||
|
" \"Inhaber\": {"
|
||||||
|
" \"Name\": \"Mustermann\","
|
||||||
|
" \"Vorname\": \"Max\","
|
||||||
|
" \"männlich\": true,"
|
||||||
|
" \"Hobbys\": [ \"Reiten\", \"Golfen\", \"Lesen\" ],"
|
||||||
|
" \"Alter\": 42,"
|
||||||
|
" \"Kinder\": [],"
|
||||||
|
" \"Partner\": null"
|
||||||
|
" }"
|
||||||
|
"}";
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
QString myJsonCon;
|
||||||
|
QString tmpStr;
|
||||||
|
|
||||||
|
void json_startRecord(void)
|
||||||
|
{
|
||||||
|
myJsonCon.clear();
|
||||||
|
tmpStr.clear();
|
||||||
|
myJsonCon.append('{');
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_enterIntToRecord(QString attribute, ulong i_value)
|
||||||
|
{
|
||||||
|
tmpStr.clear();
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
tmpStr.setNum(i_value);
|
||||||
|
myJsonCon.append(tmpStr);
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_enterTextToRecord(QString attribute, QString txt_value)
|
||||||
|
{
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(txt_value);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void json_addCurrentTimeToRecord(QString attribute)
|
||||||
|
{
|
||||||
|
uint8_t hour, minute, sec, ui8buf[20];
|
||||||
|
//char buf[20];
|
||||||
|
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
myJsonCon.append('"');
|
||||||
|
|
||||||
|
datei_getSysTime(&hour, &minute, &sec);
|
||||||
|
GetTimeString(hour, minute, sec, 0, 1, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<8; nn++)
|
||||||
|
myJsonCon.append(ui8buf[nn]);
|
||||||
|
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_addCurrentDateToRecord(QString attribute)
|
||||||
|
{
|
||||||
|
uint16_t year;
|
||||||
|
uint8_t month, day, ui8buf[20];
|
||||||
|
//char buf[20];
|
||||||
|
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
myJsonCon.append('"');
|
||||||
|
|
||||||
|
datei_getSystemDate(&year, &month, &day);
|
||||||
|
GetDateString(day, month, 0x20, uint8_t(year%100), 0, 0, ui8buf);
|
||||||
|
for (uint8_t nn=0; nn<10; nn++)
|
||||||
|
myJsonCon.append(ui8buf[nn]);
|
||||||
|
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
void json_enterArrayToRecord(QString attribute, uint8_t *buf, ulong nrofVals)
|
||||||
|
{
|
||||||
|
// add array of numbers with "nrofVals" elements
|
||||||
|
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
myJsonCon.append('['); // eckig!!!
|
||||||
|
for (ulong ul=0; ul<nrofVals; ul++)
|
||||||
|
{
|
||||||
|
tmpStr.setNum(buf[ul]);
|
||||||
|
myJsonCon.append(tmpStr);
|
||||||
|
myJsonCon.append(',');
|
||||||
|
}
|
||||||
|
myJsonCon.chop(1); // Komma weg
|
||||||
|
myJsonCon.append(']'); // eckig!!!
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_enterStructToRecord(QString attribute)
|
||||||
|
{
|
||||||
|
// every call must be concluded with "json_finishFile()"
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(attribute);
|
||||||
|
myJsonCon.append('"');
|
||||||
|
myJsonCon.append(':');
|
||||||
|
myJsonCon.append('{'); // geschweift!!
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_finishStruct(void)
|
||||||
|
{
|
||||||
|
myJsonCon.chop(2); // remove , and \r from the end
|
||||||
|
myJsonCon.append('}');
|
||||||
|
myJsonCon.append(',');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void json_finishRecord(void)
|
||||||
|
{
|
||||||
|
myJsonCon.chop(2); // remove , and \r from the end
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
myJsonCon.append('}');
|
||||||
|
myJsonCon.append(NEWLINEINFILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString json_readbackRecordStr(void)
|
||||||
|
{
|
||||||
|
return myJsonCon;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray json_readbackRecordBa(void)
|
||||||
|
{
|
||||||
|
return myJsonCon.toLatin1();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ parse Json file -------------------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
|
example Json File:
|
||||||
|
{"temperature":28,
|
||||||
|
"snow":"no",
|
||||||
|
"Zeit":"16_21_45",
|
||||||
|
"sunny":"12h",
|
||||||
|
"humidity":75,
|
||||||
|
"wann ":"24.01.2022",
|
||||||
|
"unterstruktur":{
|
||||||
|
"day of week":"tuesday",
|
||||||
|
"year":22,
|
||||||
|
"month":1,
|
||||||
|
"day":24},
|
||||||
|
"fast am":"Ende",
|
||||||
|
"Puffer":[8,3,9,2,10]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// first: QByteArray datei_readFromFile(QString filename);
|
||||||
|
|
||||||
|
|
||||||
|
int json_nrOfPairsInFile(QByteArray filename)
|
||||||
|
{
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
// key value pair consisting of key (unique string) and value (QJsonValue)
|
||||||
|
int nrOfPairs=jobj.size();
|
||||||
|
|
||||||
|
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
||||||
|
return nrOfPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_exists(QByteArray filename, QString searchForKey)
|
||||||
|
{
|
||||||
|
// look for "searchForKey" =name of the pair (left of : )
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchForKey))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_remove(QByteArray filename, QString searchFor)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and remove the record from file
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchFor))
|
||||||
|
{
|
||||||
|
jobj.remove(searchFor);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString json_searchForStringInFile(QByteArray filename, QString searchFor)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchFor))
|
||||||
|
{
|
||||||
|
return jobj[searchFor].toString(); // toObject(); toArray();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "pairname not found in Json file";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int json_searchForIntInFile(QByteArray filename, QString searchFor)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchFor))
|
||||||
|
{
|
||||||
|
return jobj[searchFor].toInt(); // toObject(); toArray();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "number not found in Json file";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_searchForObjectInFile(QByteArray filename, QString searchFor, QJsonObject *oneObject)
|
||||||
|
{
|
||||||
|
// return an object from the json file
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchFor))
|
||||||
|
{
|
||||||
|
*oneObject = jobj[searchFor].toObject();
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "Object not found in Json file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int json_nrOfPairsInObject(QJsonObject objname)
|
||||||
|
{
|
||||||
|
int nrOfPairs=objname.size();
|
||||||
|
qDebug() << "my Json Object has got: " << nrOfPairs<< "pairs";
|
||||||
|
return nrOfPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString json_searchForStringInObject(QJsonObject objname, QString searchFor)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
if (objname.contains(searchFor))
|
||||||
|
{
|
||||||
|
return objname[searchFor].toString();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "string not found in Json object";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int json_searchForIntInObject(QJsonObject objname, QString searchFor)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
|
||||||
|
if (objname.contains(searchFor))
|
||||||
|
{
|
||||||
|
return objname[searchFor].toInt();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "number not found in Json file";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool json_searchForArrayInFile(QByteArray filename, QString searchFor, QJsonArray *oneArray)
|
||||||
|
{
|
||||||
|
// look for "searchFor" =name of the pair (left of : ) and return value of this pair (right of : ) as String
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(filename);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
|
||||||
|
if (jobj.contains(searchFor))
|
||||||
|
{
|
||||||
|
*oneArray = jobj[searchFor].toArray();
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug() << "Array not found in Json file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int json_nrOfValuesInArray(QJsonArray arrayname)
|
||||||
|
{
|
||||||
|
int nrOfPairs=arrayname.size();
|
||||||
|
qDebug() << "my Json Array has got: " << nrOfPairs<< "values";
|
||||||
|
return nrOfPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool json_getValuesOfArray(QJsonArray arrayname, int *buf, int MaxBufferSize)
|
||||||
|
{
|
||||||
|
// assuming that the array consists of integers
|
||||||
|
|
||||||
|
/* copy to local buffer:
|
||||||
|
#define MAXNROFARRAYVALUES 100
|
||||||
|
int buf[MAXNROFARRAYVALUES], ii;
|
||||||
|
int nrOfPairs=arrayname.size();
|
||||||
|
|
||||||
|
if (nrOfPairs>MAXNROFARRAYVALUES)
|
||||||
|
nrOfPairs=MAXNROFARRAYVALUES;
|
||||||
|
|
||||||
|
for (ii=0; ii<nrOfPairs; ii++)
|
||||||
|
buf[ii]=arrayname[ii].toInt();
|
||||||
|
*/
|
||||||
|
// copy to host buffer:
|
||||||
|
bool ok=true;
|
||||||
|
int nrOfPairs=arrayname.size();
|
||||||
|
|
||||||
|
if (nrOfPairs>MaxBufferSize)
|
||||||
|
{
|
||||||
|
ok=false; // got not all
|
||||||
|
nrOfPairs=MaxBufferSize;
|
||||||
|
}
|
||||||
|
for (int ii=0; ii<nrOfPairs; ii++)
|
||||||
|
buf[ii]=arrayname[ii].toInt();
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void datei_json_readTestFile(QString filename)
|
||||||
|
{
|
||||||
|
QByteArray my2Ba;
|
||||||
|
QString my2Str;
|
||||||
|
|
||||||
|
my2Str.clear();
|
||||||
|
my2Ba=datei_readFromFile(filename);
|
||||||
|
|
||||||
|
QJsonDocument jdoc = QJsonDocument::fromJson(my2Ba);
|
||||||
|
QJsonObject jobj = jdoc.object();
|
||||||
|
//QJsonParseError jerror;
|
||||||
|
QJsonObject myObj;
|
||||||
|
QJsonArray myArray;
|
||||||
|
|
||||||
|
// key value pair consisting of key (unique string) and value (QJsonValue)
|
||||||
|
int nrOfPairs=jobj.size();
|
||||||
|
qDebug() << "my Json file has got: " << nrOfPairs<< "pairs";
|
||||||
|
|
||||||
|
if (jobj.contains("Zeit"))
|
||||||
|
qDebug() << "my Json file: " << jobj["Zeit"].toString(); // toObject(); toArray();
|
||||||
|
else
|
||||||
|
qDebug() << "my Json file contains no Zeit";
|
||||||
|
|
||||||
|
if (jobj.contains("Humidity"))
|
||||||
|
qDebug() << "my Json file: " << jobj["humidity"].toInt();
|
||||||
|
else
|
||||||
|
qDebug() << "my Json file contains no Humidity";
|
||||||
|
|
||||||
|
if (jobj.contains("month"))
|
||||||
|
qDebug() << "my Json file: " << jobj["month"].toObject(); // anzeige QJsonObject()
|
||||||
|
else
|
||||||
|
qDebug() << "my Json file contains no month";
|
||||||
|
|
||||||
|
|
||||||
|
myObj=jobj["unterstruktur"].toObject();
|
||||||
|
qDebug() << "my unterstruktur: " << myObj["month"].toInt();
|
||||||
|
qDebug() << "my unterstruktur: " << myObj["day of week"].toString();
|
||||||
|
//if (jerror.error == QJsonParseError::NoError)
|
||||||
|
// qDebug() << "no error";
|
||||||
|
|
||||||
|
qDebug() << "my Month: " << myObj["Month"].toInt();
|
||||||
|
//if (myObj["Month"] == QJsonValue::Undefined)
|
||||||
|
// qDebug() << "no found"; geht nicht
|
||||||
|
|
||||||
|
//if (jerror.error != QJsonParseError::NoError)
|
||||||
|
// qDebug() << "no found";
|
||||||
|
|
||||||
|
myArray=jobj["Puffer"].toArray();
|
||||||
|
qDebug() << "my array " <<myArray[2].toInt();
|
||||||
|
//if (jerror.error != QJsonParseError::NoError)
|
||||||
|
// qDebug() << "no found";
|
||||||
|
|
||||||
|
if ( !jobj.contains("Puffer"))
|
||||||
|
qDebug() << "no Puffer found";
|
||||||
|
|
||||||
|
if ( !myArray.contains(20))
|
||||||
|
qDebug() << "no entry found";
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
// ------------------------------------------------------ read, write, copy files -------------------
|
||||||
|
// -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void datei_closeFile(QString filename)
|
||||||
|
{
|
||||||
|
QFile file(filename);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray datei_readFromFile(QString filename)
|
||||||
|
{
|
||||||
|
//QFile file("/own/H2B/dc2.hex");
|
||||||
|
//QFile file(FILENAME_STRUCTURE);
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(filename);
|
||||||
|
QByteArray myBA;
|
||||||
|
|
||||||
|
myBA.clear();
|
||||||
|
if (!file.exists())
|
||||||
|
{
|
||||||
|
qDebug()<<"file not exists";
|
||||||
|
return myBA;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (!file.open(QIODevice::ReadOnly) )
|
||||||
|
{
|
||||||
|
qDebug()<<"cannot open";
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//qDebug()<<"loading file with " << file.size() <<"byte";
|
||||||
|
myBA = file.readAll();
|
||||||
|
//qDebug()<<"datei read: " << myBA;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return myBA;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool datei_ifFileExists(QString filename)
|
||||||
|
{
|
||||||
|
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(filename);
|
||||||
|
|
||||||
|
if (file.exists())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char datei_writeToFile(QString filename, QByteArray content)
|
||||||
|
{
|
||||||
|
// retval=0 if successful 1: no write access allowed 2:cannot open to append 3:cannot create new file
|
||||||
|
QFile file(filename);
|
||||||
|
QFileInfo myFI(filename);
|
||||||
|
|
||||||
|
//if (!myFI.isWritable()) //geht nur bei NTFS, weg.
|
||||||
|
//{
|
||||||
|
//file.setPermissions(filename, QFile::WriteOther); geht nicht :(
|
||||||
|
// qDebug()<<"datei_writeToFile: writing not allowed. set attributes first!";
|
||||||
|
// return 1;
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (file.exists())
|
||||||
|
{
|
||||||
|
if (!file.open(QIODevice::Append))
|
||||||
|
{
|
||||||
|
qDebug()<<"datei_writeToFile cannot open to append";
|
||||||
|
return 2;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// add new object to the end of the file
|
||||||
|
file.write(content);
|
||||||
|
file.close();
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
qDebug()<<"datei_writeToFile cannot open new";
|
||||||
|
return 3;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
qDebug()<<"create new file";
|
||||||
|
// write first lines into file
|
||||||
|
file.write(content);
|
||||||
|
file.close();
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool datei_copyFile(QString currentFileName, QString newFileName)
|
||||||
|
{
|
||||||
|
// retval=true if successful
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(currentFileName);
|
||||||
|
return file.copy(newFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool datei_clearFile(QString filename)
|
||||||
|
{
|
||||||
|
// retval=true if successful
|
||||||
|
QFile file;
|
||||||
|
file.setFileName(filename);
|
||||||
|
|
||||||
|
file.remove(); // 3.2.22 erst ganz löschen wegen Schreibrechten
|
||||||
|
if (!file.open(QIODevice::WriteOnly))
|
||||||
|
{
|
||||||
|
qDebug()<<"datei_clearFile cannot open file to delete";
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
file.write(0);
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1204
src/hwapi.cpp
1204
src/hwapi.cpp
File diff suppressed because it is too large
Load Diff
9
src/main.cpp
Normal file
9
src/main.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <QCoreApplication>
|
||||||
|
#include "tslib.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
@@ -14,7 +14,7 @@ void sendWRcmd_INI(void)
|
|||||||
sendWRcmd_clrCmdStack();
|
sendWRcmd_clrCmdStack();
|
||||||
sendWRcmd_clrCmd4Stack();
|
sendWRcmd_clrCmd4Stack();
|
||||||
sendFDcmd_clrStack();
|
sendFDcmd_clrStack();
|
||||||
longFDcmd_clrStack();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command Stack for commands without parameters
|
// Command Stack for commands without parameters
|
||||||
@@ -456,18 +456,23 @@ uint8_t gpi_chk4remainingText(void)
|
|||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
|
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
// header
|
||||||
|
|
||||||
// short command, 4 data bytes
|
|
||||||
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||||
static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
static uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||||
static uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
static uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||||
|
|
||||||
|
// short data
|
||||||
static uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
static uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||||
static uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
static uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||||
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||||
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||||
|
// lon data:
|
||||||
|
static uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||||
|
static uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||||
|
|
||||||
static uint8_t p_nextFDcmdsInQueue;
|
static uint8_t p_nextFDcmdsInQueue;
|
||||||
|
|
||||||
/* convention: use simple (not rotating) FIFO Stack:
|
/* convention: use simple (not rotating) FIFO Stack:
|
||||||
Example: nrOfCmdsInQueue=4 then
|
Example: nrOfCmdsInQueue=4 then
|
||||||
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
nextAsynchsendCmd0[0]=cmd1 // was stored as first
|
||||||
@@ -492,16 +497,21 @@ void sendFDcmd_clrStack(void)
|
|||||||
nextFDwrCmd[nn]=0;
|
nextFDwrCmd[nn]=0;
|
||||||
nextFDrdCmd[nn]=0;
|
nextFDrdCmd[nn]=0;
|
||||||
nextFDblkNr[nn]=0;
|
nextFDblkNr[nn]=0;
|
||||||
|
nextFDshort[nn]=0;
|
||||||
nextFDpara1[nn]=0;
|
nextFDpara1[nn]=0;
|
||||||
nextFDpara2[nn]=0;
|
nextFDpara2[nn]=0;
|
||||||
nextFDpara3[nn]=0;
|
nextFDpara3[nn]=0;
|
||||||
nextFDpara4[nn]=0;
|
nextFDpara4[nn]=0;
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
memset(&longFDpara[nn][0],0,64);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_nextFDcmdsInQueue=0;
|
p_nextFDcmdsInQueue=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
|
bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
|
||||||
{
|
{
|
||||||
|
|
||||||
// write Command to memory, wait for transport
|
// write Command to memory, wait for transport
|
||||||
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
||||||
{
|
{
|
||||||
@@ -518,13 +528,68 @@ bool sendFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8
|
|||||||
//qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue;
|
//qDebug() << "data with 4 data byte saved, pp=" << nrOfCmds4InQueue;
|
||||||
//qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue]
|
//qDebug() << " dat1=" << nextCmd4para1[nrOfCmds4InQueue] << " dat2=" << nextCmd4para2[nrOfCmds4InQueue]
|
||||||
// << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue];
|
// << " dat3=" << nextCmd4para3[nrOfCmds4InQueue] << " dat4=" << nextCmd4para4[nrOfCmds4InQueue];
|
||||||
|
nextFDshort[p_nextFDcmdsInQueue]=1; // 1=short
|
||||||
|
p_nextFDcmdsInQueue++;
|
||||||
|
/*
|
||||||
|
int nn;
|
||||||
|
if (p_nextFDcmdsInQueue==2)
|
||||||
|
{
|
||||||
|
qDebug() << "sendFDcmd_set, stack has 2 elements: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDshort[nn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if (p_nextFDcmdsInQueue>15)
|
||||||
|
{
|
||||||
|
qDebug() << "sendFDcmd_set, stack is full now: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDpara1[nn] << " / " << nextFDpara2[nn] << " / " << nextFDpara3[nn] << " / " << nextFDpara4[nn];
|
||||||
|
|
||||||
|
qDebug() << " long data: " << nextFDshort[nn] << " / "<< longFDlength[nn] << " / "<< longFDpara[nn][0] << " / "<< longFDpara[nn][1]
|
||||||
|
<< " / "<< longFDpara[nn][2] << " / "<< longFDpara[nn][3] << " / "<< longFDpara[nn][4];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return true; // ok, will be sent
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data)
|
||||||
|
{
|
||||||
|
// write Command to memory, wait for transport
|
||||||
|
// data buffer size always 64! data[64], padded with 0
|
||||||
|
uint8_t nn;
|
||||||
|
if (p_nextFDcmdsInQueue>=FDCMD_STACKDEPTH)
|
||||||
|
{
|
||||||
|
qDebug() << "cannot save cmd because stack is full";
|
||||||
|
return false; // not possible
|
||||||
|
}
|
||||||
|
nextFDwrCmd[p_nextFDcmdsInQueue]=nextWrCmd;
|
||||||
|
nextFDrdCmd[p_nextFDcmdsInQueue]=nextRdCmd;
|
||||||
|
nextFDblkNr[p_nextFDcmdsInQueue]=blockNum;
|
||||||
|
|
||||||
|
longFDlength[p_nextFDcmdsInQueue]=length;
|
||||||
|
|
||||||
|
for (nn=0; nn<64; nn++)
|
||||||
|
longFDpara[p_nextFDcmdsInQueue][nn]=data[nn];
|
||||||
|
|
||||||
|
nextFDshort[p_nextFDcmdsInQueue]=2;
|
||||||
|
|
||||||
p_nextFDcmdsInQueue++;
|
p_nextFDcmdsInQueue++;
|
||||||
return true; // ok, will be sent
|
return true; // ok, will be sent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
|
||||||
{
|
{
|
||||||
uint8_t nn, ll;
|
uint8_t nn, ll, mm;
|
||||||
|
|
||||||
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
||||||
return false; // not possible
|
return false; // not possible
|
||||||
@@ -536,7 +601,7 @@ bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, ui
|
|||||||
*dat2=nextFDpara2[0];
|
*dat2=nextFDpara2[0];
|
||||||
*dat3=nextFDpara3[0];
|
*dat3=nextFDpara3[0];
|
||||||
*dat4=nextFDpara4[0];
|
*dat4=nextFDpara4[0];
|
||||||
//qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue;
|
//qDebug() << "sendFDcmd_get [0]; pp=" << p_nextFDcmdsInQueue;
|
||||||
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
|
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
|
||||||
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
|
||||||
|
|
||||||
@@ -550,35 +615,98 @@ bool sendFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, ui
|
|||||||
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
||||||
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
||||||
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
||||||
|
|
||||||
nextFDpara1[nn]=nextFDpara1[nn+1];
|
nextFDpara1[nn]=nextFDpara1[nn+1];
|
||||||
nextFDpara2[nn]=nextFDpara2[nn+1];
|
nextFDpara2[nn]=nextFDpara2[nn+1];
|
||||||
nextFDpara3[nn]=nextFDpara3[nn+1];
|
nextFDpara3[nn]=nextFDpara3[nn+1];
|
||||||
nextFDpara4[nn]=nextFDpara4[nn+1];
|
nextFDpara4[nn]=nextFDpara4[nn+1];
|
||||||
|
|
||||||
|
nextFDshort[nn] = nextFDshort[nn+1];
|
||||||
|
|
||||||
|
longFDlength[nn] = longFDlength[nn+1];
|
||||||
|
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_nextFDcmdsInQueue>0)
|
if (p_nextFDcmdsInQueue>0)
|
||||||
p_nextFDcmdsInQueue--;
|
p_nextFDcmdsInQueue--;
|
||||||
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
|
||||||
|
|
||||||
|
// clear released buffer:
|
||||||
|
for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=0;
|
||||||
|
nextFDrdCmd[nn]=0;
|
||||||
|
nextFDblkNr[nn]=0;
|
||||||
|
|
||||||
|
nextFDpara1[nn]=0;
|
||||||
|
nextFDpara2[nn]=0;
|
||||||
|
nextFDpara3[nn]=0;
|
||||||
|
nextFDpara4[nn]=0;
|
||||||
|
|
||||||
|
nextFDshort[nn]=0;
|
||||||
|
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
qDebug() << "sendFDcmd_set, stack now: " << p_nextFDcmdsInQueue;
|
||||||
|
for (nn=0; nn<16; nn++)
|
||||||
|
{
|
||||||
|
qDebug() << "header: " << nextFDwrCmd[nn] << " / " << nextFDrdCmd[nn] << " / "<< nextFDblkNr[nn] << " / " << nextFDshort[nn];
|
||||||
|
|
||||||
|
qDebug() << " short data: " << nextFDpara1[nn] << " / "<< nextFDpara2[nn] << " / "<< nextFDpara3[nn]<< " / "<< nextFDpara4[nn];
|
||||||
|
|
||||||
|
qDebug() << " long data: " << longFDlength[nn] << " / "<< longFDpara[nn][0] << " / "<< longFDpara[nn][1]
|
||||||
|
<< " / "<< longFDpara[nn][2] << " / "<< longFDpara[nn][3] << " / "<< longFDpara[nn][4];
|
||||||
|
}
|
||||||
|
*/
|
||||||
return true; // ok, will be sent
|
return true; // ok, will be sent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t checkNextFDcmd(void)
|
||||||
|
{
|
||||||
|
// return 0: no command waiting
|
||||||
|
// 1: short cmd
|
||||||
|
// 2: long cmd
|
||||||
|
//qDebug() << "chk nxt fd cmd: "<<p_nextFDcmdsInQueue<<" "<<nextFDshort[0]<<" "<<nextFDshort[1]<<" "<<nextFDshort[2]<<" "<<nextFDshort[3];
|
||||||
|
if (p_nextFDcmdsInQueue==0)
|
||||||
|
return 0;
|
||||||
|
if (nextFDshort[0]==1)
|
||||||
|
return 1;
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t check4FDshortCmd(void)
|
uint8_t check4FDshortCmd(void)
|
||||||
{
|
{
|
||||||
// returns number of waiting command
|
// returns number of waiting command, max FDCMD_STACKDEPTH
|
||||||
return p_nextFDcmdsInQueue;
|
return p_nextFDcmdsInQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t check4freeFDshortCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of free places in short-command stack
|
||||||
|
return FDCMD_STACKDEPTH - p_nextFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// long command, 64 data bytes
|
// long command, 64 data bytes
|
||||||
static uint8_t longFDwrCmd[FDLONG_STACKDEPTH];
|
//static uint8_t longFDwrCmd[FDLONG_STACKDEPTH];
|
||||||
static uint8_t longFDrdCmd[FDLONG_STACKDEPTH];
|
//static uint8_t longFDrdCmd[FDLONG_STACKDEPTH];
|
||||||
static uint8_t longFDblkNr[FDLONG_STACKDEPTH];
|
//static uint8_t longFDblkNr[FDLONG_STACKDEPTH];
|
||||||
static uint8_t longFDlength[FDLONG_STACKDEPTH];
|
//static uint8_t longFDlength[FDLONG_STACKDEPTH];
|
||||||
|
|
||||||
static uint8_t longFDpara[FDLONG_STACKDEPTH][64];
|
|
||||||
static uint8_t p_longFDcmdsInQueue;
|
|
||||||
|
|
||||||
|
//static uint8_t longFDpara[FDLONG_STACKDEPTH][64];
|
||||||
|
//static uint8_t p_longFDcmdsInQueue;
|
||||||
|
|
||||||
|
/*
|
||||||
void longFDcmd_clrStack(void)
|
void longFDcmd_clrStack(void)
|
||||||
{
|
{
|
||||||
uint8_t nn, mm;
|
uint8_t nn, mm;
|
||||||
@@ -592,72 +720,112 @@ void longFDcmd_clrStack(void)
|
|||||||
longFDpara[nn][mm]=0;
|
longFDpara[nn][mm]=0;
|
||||||
}
|
}
|
||||||
p_longFDcmdsInQueue=0;
|
p_longFDcmdsInQueue=0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
bool longFDcmd_set(uint8_t nextWrCmd, uint8_t nextRdCmd, uint8_t blockNum, uint8_t length, uint8_t *data)
|
|
||||||
{
|
|
||||||
// write Command to memory, wait for transport
|
|
||||||
// data buffer size always 64! data[64], padded with 0
|
|
||||||
uint8_t nn;
|
|
||||||
if (p_longFDcmdsInQueue>=FDLONG_STACKDEPTH)
|
|
||||||
{
|
|
||||||
qCritical() << "cannot save cmd because stack is full";
|
|
||||||
return false; // not possible
|
|
||||||
}
|
|
||||||
longFDwrCmd[p_longFDcmdsInQueue]=nextWrCmd;
|
|
||||||
longFDrdCmd[p_longFDcmdsInQueue]=nextRdCmd;
|
|
||||||
longFDblkNr[p_longFDcmdsInQueue]=blockNum;
|
|
||||||
longFDlength[p_longFDcmdsInQueue]=length;
|
|
||||||
for (nn=0; nn<64; nn++)
|
|
||||||
longFDpara[p_longFDcmdsInQueue][nn]=data[nn];
|
|
||||||
|
|
||||||
p_longFDcmdsInQueue++;
|
|
||||||
|
|
||||||
return true; // ok, will be sent
|
|
||||||
}
|
|
||||||
|
|
||||||
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
|
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
|
||||||
{
|
{
|
||||||
uint8_t nn, mm, ll;
|
uint8_t nn, mm, ll;
|
||||||
|
//p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH
|
||||||
if (p_longFDcmdsInQueue==0 || p_longFDcmdsInQueue>FDLONG_STACKDEPTH)
|
if (p_nextFDcmdsInQueue==0 || p_nextFDcmdsInQueue>FDCMD_STACKDEPTH)
|
||||||
return false; // not possible
|
return false; // not possible
|
||||||
|
|
||||||
*nextWrCmd= longFDwrCmd[0];
|
*nextWrCmd=nextFDwrCmd[0];
|
||||||
*nextRdCmd= longFDrdCmd[0];
|
*nextRdCmd=nextFDrdCmd[0];
|
||||||
*blockNum = longFDblkNr[0];
|
*blockNum=nextFDblkNr[0];
|
||||||
|
|
||||||
*length = longFDlength[0];
|
*length = longFDlength[0];
|
||||||
for (mm=0; mm<64; mm++)
|
for (mm=0; mm<64; mm++)
|
||||||
data[mm] = longFDpara[0][mm];
|
data[mm] = longFDpara[0][mm];
|
||||||
|
|
||||||
// move Puffer down by one element
|
// move Puffer down by one element
|
||||||
if (FDLONG_STACKDEPTH>0)
|
if (FDCMD_STACKDEPTH>0)
|
||||||
ll=FDLONG_STACKDEPTH-1;
|
ll=FDCMD_STACKDEPTH-1;
|
||||||
else
|
else
|
||||||
ll=0;
|
ll=0;
|
||||||
for (nn=0; nn<ll; nn++)
|
for (nn=0; nn<ll; nn++)
|
||||||
{
|
{
|
||||||
longFDwrCmd[nn] = longFDwrCmd[nn+1];
|
nextFDwrCmd[nn]=nextFDwrCmd[nn+1];
|
||||||
longFDrdCmd[nn] = longFDrdCmd[nn+1];
|
nextFDrdCmd[nn]=nextFDrdCmd[nn+1];
|
||||||
longFDblkNr[nn] = longFDblkNr[nn+1];
|
nextFDblkNr[nn]=nextFDblkNr[nn+1];
|
||||||
|
|
||||||
|
nextFDpara1[nn]=nextFDpara1[nn+1];
|
||||||
|
nextFDpara2[nn]=nextFDpara2[nn+1];
|
||||||
|
nextFDpara3[nn]=nextFDpara3[nn+1];
|
||||||
|
nextFDpara4[nn]=nextFDpara4[nn+1];
|
||||||
|
|
||||||
|
nextFDshort[nn] = nextFDshort[nn+1];
|
||||||
|
|
||||||
longFDlength[nn] = longFDlength[nn+1];
|
longFDlength[nn] = longFDlength[nn+1];
|
||||||
|
|
||||||
for (mm=0; mm<64; mm++)
|
for (mm=0; mm<64; mm++)
|
||||||
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
longFDpara[nn][mm] = longFDpara[nn+1][mm];
|
||||||
|
|
||||||
}
|
}
|
||||||
if (p_longFDcmdsInQueue>0)
|
if (p_nextFDcmdsInQueue>0)
|
||||||
p_longFDcmdsInQueue--;
|
p_nextFDcmdsInQueue--;
|
||||||
|
|
||||||
|
// clear released buffer:
|
||||||
|
for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
|
||||||
|
{
|
||||||
|
nextFDwrCmd[nn]=0;
|
||||||
|
nextFDrdCmd[nn]=0;
|
||||||
|
nextFDblkNr[nn]=0;
|
||||||
|
|
||||||
|
nextFDpara1[nn]=0;
|
||||||
|
nextFDpara2[nn]=0;
|
||||||
|
nextFDpara3[nn]=0;
|
||||||
|
nextFDpara4[nn]=0;
|
||||||
|
|
||||||
|
nextFDshort[nn]=0;
|
||||||
|
|
||||||
|
longFDlength[nn]=0;
|
||||||
|
for (mm=0; mm<64; mm++)
|
||||||
|
longFDpara[nn][mm] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true; // ok, will be sent
|
return true; // ok, will be sent
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
uint8_t check4FDlongCmd(void)
|
uint8_t check4FDlongCmd(void)
|
||||||
{
|
{
|
||||||
// returns number of waiting command
|
// returns number of waiting command
|
||||||
return p_longFDcmdsInQueue;
|
return p_longFDcmdsInQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t check4freeFDlongCmd(void)
|
||||||
|
{
|
||||||
|
// returns number of free places in command stack
|
||||||
|
return FDLONG_STACKDEPTH - p_longFDcmdsInQueue;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
46
src/shared_mem_buffer.cpp
Normal file
46
src/shared_mem_buffer.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#ifdef QT_POSIX_IPC
|
||||||
|
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||||
|
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
|
||||||
|
// macro will be defined. -> we use SystemV shared memory
|
||||||
|
#error "QT_POSIX_IPC defined"
|
||||||
|
#else
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/ipc.h> // ftok
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||||
|
|
||||||
|
QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
|
static QSharedMemory shMem;
|
||||||
|
if (size > 0) {
|
||||||
|
#ifdef __linux__
|
||||||
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
|
#else
|
||||||
|
static const QString fkey = "0123456?000=9";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shMem.setKey(fkey);
|
||||||
|
if (!shMem.isAttached()) {
|
||||||
|
if (shMem.create(size)) {
|
||||||
|
return &shMem;
|
||||||
|
} else {
|
||||||
|
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||||
|
if (shMem.attach()) {
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||||
|
<< shMem.error() << shMem.errorString();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &shMem;
|
||||||
|
}
|
@@ -3,11 +3,15 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
#include "datei.h"
|
||||||
|
|
||||||
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
// gpi: grafical access to PI: access from external devices over device controller FOR GUI
|
||||||
// epi: external access from GUI to PI: FOR external devices (DC)
|
// epi: external access from GUI to PI: FOR external devices (DC)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// store power on/off condition of the devices to control the data request
|
// store power on/off condition of the devices to control the data request
|
||||||
|
|
||||||
static bool indat_savePrnPwr;
|
static bool indat_savePrnPwr;
|
||||||
@@ -15,6 +19,9 @@ static bool indat_savePrnPwr;
|
|||||||
void indat_storePrinterPower(bool isOn)
|
void indat_storePrinterPower(bool isOn)
|
||||||
{
|
{
|
||||||
indat_savePrnPwr=isOn;
|
indat_savePrnPwr=isOn;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool indat_isPrinterOn()
|
bool indat_isPrinterOn()
|
||||||
@@ -49,55 +56,6 @@ bool indat_isMdbOn()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// //////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t ndbs, pari, nsb, br;
|
|
||||||
|
|
||||||
void gpi_storeSlaveSerParams(uint8_t slaveBaudRate, uint8_t NrDataBits,
|
|
||||||
uint8_t parity, uint8_t NrStopBits)
|
|
||||||
{
|
|
||||||
// store numbers
|
|
||||||
ndbs=NrDataBits;
|
|
||||||
pari=parity;
|
|
||||||
nsb=NrStopBits;
|
|
||||||
br=slaveBaudRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
void epi_getSlaveSerParams(uint8_t *slaveBaudRate, uint8_t *NrDataBits,
|
|
||||||
uint8_t *parity, uint8_t *NrStopBits)
|
|
||||||
{
|
|
||||||
*NrDataBits=ndbs;
|
|
||||||
*parity=pari;
|
|
||||||
*NrStopBits=nsb;
|
|
||||||
*slaveBaudRate=br;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString epi_getSlaveParamSTR()
|
|
||||||
{
|
|
||||||
QString mySt;
|
|
||||||
mySt.clear();
|
|
||||||
switch (br)
|
|
||||||
{
|
|
||||||
case 1: mySt="1200 ";break;
|
|
||||||
case 2: mySt="9600 ";break;
|
|
||||||
case 3: mySt="19200 ";break;
|
|
||||||
case 4: mySt="38400 ";break;
|
|
||||||
case 5: mySt="57600 ";break;
|
|
||||||
case 6: mySt="115200 ";break;
|
|
||||||
}
|
|
||||||
mySt.append(ndbs+0x30);
|
|
||||||
|
|
||||||
mySt.append(pari);
|
|
||||||
mySt.append(nsb+0x30);
|
|
||||||
//mySt="Hallo";
|
|
||||||
return mySt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static QString genStrings[MAXNROF_GENSTR];
|
static QString genStrings[MAXNROF_GENSTR];
|
||||||
// 0=HW 1=SW 2=State
|
// 0=HW 1=SW 2=State
|
||||||
@@ -131,12 +89,39 @@ QString epi_loadGenerals(uint8_t genNr)
|
|||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
static uint64_t Sdata_slaveUID;
|
static uint64_t Sdata_slaveUID;
|
||||||
static uint8_t Sdata_UIDstr[8];
|
static uint8_t Sdata_UIDstr[8];
|
||||||
|
static QString Sdata_DcUidStr;
|
||||||
|
|
||||||
|
|
||||||
|
void write2file_UID(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
csv_startCreatingFile();
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[0]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[1]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[2]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[3]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[4]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[5]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[6]);
|
||||||
|
csv_addUintToFile(Sdata_UIDstr[7]);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
csv_addUlongvalToFile(Sdata_slaveUID);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
csv_addTextToFile(Sdata_DcUidStr);
|
||||||
|
csv_addNewlineToFile();
|
||||||
|
myBA=csv_readbackArray();
|
||||||
|
datei_clearFile(FILENAME_SHARED_UID);
|
||||||
|
datei_writeToFile(FILENAME_SHARED_UID, myBA);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void gpi_storeUID(uint8_t *buf8byteUid)
|
void gpi_storeUID(uint8_t *buf8byteUid)
|
||||||
{
|
{
|
||||||
uint64_t udltmp=0;
|
uint64_t udltmp=0;
|
||||||
|
QString myStr;
|
||||||
|
|
||||||
//qDebug()<< "store UID ";
|
//qDebug()<< "store UID ";
|
||||||
|
|
||||||
@@ -149,6 +134,16 @@ void gpi_storeUID(uint8_t *buf8byteUid)
|
|||||||
udltmp<<=8;
|
udltmp<<=8;
|
||||||
}
|
}
|
||||||
Sdata_slaveUID=udltmp;
|
Sdata_slaveUID=udltmp;
|
||||||
|
|
||||||
|
Sdata_DcUidStr.clear();
|
||||||
|
for (int ii=0;ii<8; ii++)
|
||||||
|
{
|
||||||
|
|
||||||
|
Sdata_DcUidStr+=QString::number(Sdata_UIDstr[ii],16);
|
||||||
|
Sdata_DcUidStr+=" ";
|
||||||
|
}
|
||||||
|
|
||||||
|
write2file_UID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void epi_getUIDdec(uint8_t *buf8byteUid)
|
void epi_getUIDdec(uint8_t *buf8byteUid)
|
||||||
@@ -175,14 +170,70 @@ QString epi_getUIDstr()
|
|||||||
}
|
}
|
||||||
return myStr;
|
return myStr;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* read from file:
|
||||||
|
void epi_getUIDfromFile(uint8_t *buf8byteUid)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
int nn;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
for (nn=0; nn<8; nn++)
|
||||||
|
buf8byteUid[nn]=csv_getEntryAsUshort(myBA, nn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t epi_getUIDnumberFromFile(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
return csv_getEntryAs2Ulong(myBA, 8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString epi_getUIDstrFromFile(void)
|
||||||
|
{
|
||||||
|
QByteArray myBA;
|
||||||
|
|
||||||
|
myBA=datei_readFromFile(FILENAME_SHARED_UID);
|
||||||
|
return csv_getEntryAsString(myBA, 9);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// the same with shared memory :
|
||||||
|
|
||||||
|
|
||||||
|
void gpi_storeUID(uint8_t const *buf8byteUid) {
|
||||||
|
uint64_t udltmp=0;
|
||||||
|
|
||||||
|
for (int ii=0; ii<8; ii++) {
|
||||||
|
SharedMemBuffer::getData()->Sdata.UIDstr[ii] = buf8byteUid[ii];
|
||||||
|
udltmp |= buf8byteUid[ii];
|
||||||
|
udltmp <<= 8;
|
||||||
|
}
|
||||||
|
SharedMemBuffer::getData()->Sdata.slaveUID = udltmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_getUIDdec(uint8_t *buf8byteUid) {
|
||||||
|
for (int ii=0; ii<8; ii++) {
|
||||||
|
buf8byteUid[ii] = SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString epi_getUIDstr() {
|
||||||
|
// die UID besteht aus 8 bytes (8 dezimalzahlen)
|
||||||
|
// -> umformen in hexstring
|
||||||
|
|
||||||
|
QString myStr;
|
||||||
|
for (int ii=0;ii<8; ii++) {
|
||||||
|
myStr += QString::number(SharedMemBuffer::getDataConst()->Sdata.UIDstr[ii], 16);
|
||||||
|
myStr += " ";
|
||||||
|
}
|
||||||
|
return myStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1307,6 +1358,27 @@ uint8_t epi_restoreMifData(uint8_t blkNr, uint8_t *buf, uint8_t maxBufferSize)
|
|||||||
return 0; // ois OK
|
return 0; // ois OK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint8_t mif_cardType;
|
||||||
|
static uint8_t mif_cardHolder[8];
|
||||||
|
|
||||||
|
void gpi_storeNewMifareCard(uint8_t typ, uint8_t *holder )
|
||||||
|
{
|
||||||
|
mif_cardType=typ;
|
||||||
|
tslib_strcpy(holder, mif_cardHolder, 7);
|
||||||
|
mif_cardHolder[7]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t epi_mifGetCardType(uint8_t *holder)
|
||||||
|
{
|
||||||
|
//holder[8] = name of card holder
|
||||||
|
// retval Type of MifareCard, 1=upper door, 2=lower door 3=test printer 4=test coins
|
||||||
|
|
||||||
|
tslib_strcpy(mif_cardHolder, holder, 7);
|
||||||
|
holder[7]=0;
|
||||||
|
return mif_cardType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -1564,12 +1636,23 @@ static uint32_t store_insertedAmount;
|
|||||||
static uint16_t store_lastCoinType[64];
|
static uint16_t store_lastCoinType[64];
|
||||||
static uint16_t store_lastCoinValue[64];
|
static uint16_t store_lastCoinValue[64];
|
||||||
static uint8_t p_lastCoin;
|
static uint8_t p_lastCoin;
|
||||||
|
static char store_curPayNewCoin;
|
||||||
|
|
||||||
void epi_clearCurrentPayment(void)
|
void epi_clearCurrentPayment(void)
|
||||||
{
|
{
|
||||||
// call at beginning of coin collection
|
// call at beginning of coin collection
|
||||||
|
int nn;
|
||||||
|
|
||||||
store_insertedAmount=0;
|
store_insertedAmount=0;
|
||||||
p_lastCoin=0;
|
p_lastCoin=0;
|
||||||
|
|
||||||
|
// 17.5.23TS: ergänzt:
|
||||||
|
for (nn=0; nn<64; nn++)
|
||||||
|
{
|
||||||
|
store_lastCoinType[nn]=0;
|
||||||
|
store_lastCoinValue[nn]=0;
|
||||||
|
}
|
||||||
|
store_curPayNewCoin=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
|
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
|
||||||
@@ -1578,6 +1661,7 @@ void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uin
|
|||||||
store_lastCoinType[p_lastCoin]=lastCoinType;
|
store_lastCoinType[p_lastCoin]=lastCoinType;
|
||||||
store_lastCoinValue[p_lastCoin]=lastCoinValue;
|
store_lastCoinValue[p_lastCoin]=lastCoinValue;
|
||||||
p_lastCoin++;
|
p_lastCoin++;
|
||||||
|
store_curPayNewCoin++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t epi_CurrentPaymentGetAmount(void)
|
uint32_t epi_CurrentPaymentGetAmount(void)
|
||||||
@@ -1588,11 +1672,17 @@ uint32_t epi_CurrentPaymentGetAmount(void)
|
|||||||
uint16_t epi_CurrentPaymentGetLastCoin(void)
|
uint16_t epi_CurrentPaymentGetLastCoin(void)
|
||||||
{
|
{
|
||||||
uint8_t pp;
|
uint8_t pp;
|
||||||
pp=p_lastCoin;
|
|
||||||
if (pp==0)
|
//if (store_curPayNewCoin)
|
||||||
return 0; // noch keine Münze erhalten
|
//{
|
||||||
if (pp>0) pp--;
|
pp=p_lastCoin;
|
||||||
return store_lastCoinValue[pp];
|
if (pp==0)
|
||||||
|
return 0; // noch keine Münze erhalten
|
||||||
|
if (pp>0) pp--;
|
||||||
|
//store_curPayNewCoin=0; // nur 1x melden
|
||||||
|
return store_lastCoinValue[pp];
|
||||||
|
//} else
|
||||||
|
// return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values)
|
bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values)
|
||||||
@@ -1612,18 +1702,21 @@ bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values)
|
|||||||
|
|
||||||
|
|
||||||
uint64_t stor_wakSrc;
|
uint64_t stor_wakSrc;
|
||||||
|
uint8_t stor_reason;
|
||||||
|
|
||||||
|
|
||||||
void gpi_storeWakeSources(uint8_t *receivedData)
|
void gpi_storeWakeSources(uint8_t *receivedData)
|
||||||
{
|
{
|
||||||
uint8_t uctmp;
|
uint8_t uctmp;
|
||||||
int nn;
|
int nn;
|
||||||
stor_wakSrc=0;
|
stor_wakSrc=0;
|
||||||
for (nn=7; nn>=0; nn--)
|
for (nn=5; nn>=0; nn--)
|
||||||
{
|
{
|
||||||
uctmp=receivedData[nn];
|
uctmp=receivedData[nn];
|
||||||
stor_wakSrc |=uctmp;
|
stor_wakSrc |=uctmp;
|
||||||
stor_wakSrc<<=8;
|
stor_wakSrc<<=8;
|
||||||
}
|
}
|
||||||
|
stor_reason=receivedData[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t epi_getWakeSources(void)
|
uint64_t epi_getWakeSources(void)
|
||||||
@@ -1631,6 +1724,10 @@ uint64_t epi_getWakeSources(void)
|
|||||||
return stor_wakSrc;
|
return stor_wakSrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t epi_getWakeReason(void)
|
||||||
|
{
|
||||||
|
return stor_reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1682,7 +1779,8 @@ void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data)
|
|||||||
if (leng>64) leng=64;
|
if (leng>64) leng=64;
|
||||||
store_machCondLen=leng;
|
store_machCondLen=leng;
|
||||||
tslib_strcpy(data, store_machCond, leng);
|
tslib_strcpy(data, store_machCond, leng);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
|
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
|
||||||
{
|
{
|
||||||
@@ -1691,3 +1789,151 @@ void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
|
|||||||
tslib_strcpy(store_machCond, data, store_machCondLen);
|
tslib_strcpy(store_machCond, data, store_machCondLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t store_DcBackupNrOfAccNr;
|
||||||
|
static uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||||
|
|
||||||
|
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data)
|
||||||
|
{
|
||||||
|
if (leng>32) leng=32;
|
||||||
|
store_DcBackupAccNr[0]=uchar2uint(data[1], data[0]);
|
||||||
|
store_DcBackupAccNr[1]=uchar2uint(data[3], data[2]);
|
||||||
|
store_DcBackupAccNr[2]=uchar2uint(data[5], data[4]);
|
||||||
|
store_DcBackupAccNr[3]=uchar2uint(data[7], data[6]);
|
||||||
|
store_DcBackupAccNr[4]=uchar2uint(data[9], data[8]);
|
||||||
|
store_DcBackupAccNr[5]=uchar2uint(data[11], data[10]);
|
||||||
|
store_DcBackupAccNr[6]=uchar2uint(data[13], data[12]);
|
||||||
|
store_DcBackupAccNr[7]=uchar2uint(data[15], data[14]);
|
||||||
|
store_DcBackupNrOfAccNr=8;
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_restoreDCbackupAccNr(uint8_t *leng, uint16_t *accNrs)
|
||||||
|
{
|
||||||
|
// return accNrs[0..7]
|
||||||
|
uint8_t nn;
|
||||||
|
|
||||||
|
*leng=store_DcBackupNrOfAccNr;
|
||||||
|
for (nn=0; nn<8; nn++)
|
||||||
|
accNrs[nn]=store_DcBackupAccNr[nn];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t store_gotNrBlocksOfVaultRec;
|
||||||
|
static uint8_t store_vaultrecord[360];
|
||||||
|
|
||||||
|
void epi_iniVRstorage(void)
|
||||||
|
{
|
||||||
|
tslib_strclr(store_vaultrecord, 0, 360);
|
||||||
|
store_gotNrBlocksOfVaultRec=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
|
||||||
|
{
|
||||||
|
uint16_t start=blkNr, ii;
|
||||||
|
|
||||||
|
store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...4
|
||||||
|
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
|
||||||
|
start<<=6;
|
||||||
|
for (ii=0; ii<64; ii++)
|
||||||
|
store_vaultrecord[start+ii]=data[ii];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_checkIfVaultRecordAvailable(void)
|
||||||
|
{
|
||||||
|
if (store_gotNrBlocksOfVaultRec==0x1F)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool epi_restoreVaultRecord(uint16_t *length, uint8_t *buf )
|
||||||
|
{
|
||||||
|
*length=0;
|
||||||
|
if (store_gotNrBlocksOfVaultRec==0x1F)
|
||||||
|
{
|
||||||
|
*length=320;
|
||||||
|
tslib_strcpy(store_vaultrecord, buf, 320);
|
||||||
|
} else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t store_amount;
|
||||||
|
static uint16_t store_nrOfCoins;
|
||||||
|
|
||||||
|
void gpi_storeCBlevel(uint32_t amount, uint16_t nrOfCoins )
|
||||||
|
{
|
||||||
|
store_amount=amount;
|
||||||
|
store_nrOfCoins=nrOfCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t epi_getCashBoxContent(void)
|
||||||
|
{
|
||||||
|
return store_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t epi_getNrOfCoinsInCashBox(void)
|
||||||
|
{
|
||||||
|
return store_nrOfCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool store_DcDataAreValid;
|
||||||
|
|
||||||
|
void gpi_storeDcDataValid(bool isVal)
|
||||||
|
{
|
||||||
|
store_DcDataAreValid = isVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool epi_areDcDataValid()
|
||||||
|
{
|
||||||
|
return store_DcDataAreValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ....................................................................................
|
||||||
|
// 24.5.2023
|
||||||
|
|
||||||
|
static uint8_t storeDCdynPrinterData[64];
|
||||||
|
static uint8_t DCdynPrinterDataActual;
|
||||||
|
|
||||||
|
void epi_clearDynData(void)
|
||||||
|
{
|
||||||
|
DCdynPrinterDataActual=0;
|
||||||
|
memset(storeDCdynPrinterData,0, sizeof(storeDCdynPrinterData));
|
||||||
|
}
|
||||||
|
|
||||||
|
void gpi_storeDynData(uint8_t *DCdynDat)
|
||||||
|
{
|
||||||
|
// buffer size: 64 byte
|
||||||
|
memcpy(storeDCdynPrinterData, DCdynDat, 64);
|
||||||
|
DCdynPrinterDataActual=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool epi_getDynPrnData(uint8_t *DCdynDat)
|
||||||
|
{
|
||||||
|
// buffer size: 64 byte
|
||||||
|
// return true if data are new and valid
|
||||||
|
|
||||||
|
if (DCdynPrinterDataActual)
|
||||||
|
{
|
||||||
|
memcpy(DCdynDat, storeDCdynPrinterData, 64);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,6 +76,23 @@ uint8_t uint2uchar(uint16_t uival, bool getHighB)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t ulong2uchar(uint32_t ulval, uint8_t getBytNr)
|
||||||
|
{
|
||||||
|
// getBytNr: 0=LSB 3=MSB
|
||||||
|
uint32_t ultmp=ulval;
|
||||||
|
if (getBytNr==0)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
if (getBytNr==1)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
if (getBytNr==2)
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
ultmp>>=8;
|
||||||
|
return uint8_t(ultmp);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void delay(uint16_t MilliSec)
|
void delay(uint16_t MilliSec)
|
||||||
{
|
{
|
||||||
QThread::msleep(uint32_t(MilliSec));
|
QThread::msleep(uint32_t(MilliSec));
|
||||||
|
Reference in New Issue
Block a user