Compare commits

..

101 Commits

Author SHA1 Message Date
91ce1c84d8 be sure to copy not too much data to buf 2024-06-27 13:23:15 +02:00
dda9e4ad8f void epi_clearDynMachineConditions(void)
void gpi_storeDynMachineConditions(void const *data)
void epi_restoreDynMachineConditions(void *data)
	use T_dynamicConditions directly.
2024-06-27 12:48:39 +02:00
81cba7e615 void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCond):
Use T_dynamicCondition directly.
2024-06-27 12:46:51 +02:00
b4a6d4a073 void hwapi::sys_getDynMachineConditions(): no length info anymore.
void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const:
	no loop, just write to shared mem using struct T_dynamicCondition.
uint8_t hwapi::prn_getCurrentPrinterState() const:
	use struct T_dynamicCondition.lastPrinterStatus.
2024-06-27 12:42:35 +02:00
c8d7f2f904 When receiving dynamic machine data, check if not too much data has been
received: copy only as much data as possible.
2024-06-27 12:40:50 +02:00
0dc38d8908 Changed declarations of
void gpi_storeDynMachineConditions(void const *data);
void epi_restoreDynMachineConditions(void *data);
2024-06-27 12:39:58 +02:00
f28f102ca0 Add struct T_dynamicMachCond directly into shared-mem 2024-06-27 12:39:32 +02:00
d04e9ead89 Changes declaration
virtual void sys_getDynMachineConditions(void *data) const;
2024-06-27 12:38:11 +02:00
9a584713e9 Changed declaration:
void sys_getDynMachineConditions(void *data) const override;
2024-06-27 12:37:02 +02:00
0fca448c53 Added dynamic-machine-conditions.h 2024-06-27 12:36:23 +02:00
a4afc4ced7 To be used later, to replace some parts of interfaces.h 2024-06-27 12:35:46 +02:00
06d43009ad Merge branch 'CoinInputFix' 2024-05-22 12:55:32 +02:00
bed98c2c0e Fix: reset 'lastInsertedAmount' ...
affects direct coin input / cash-payment.
2024-05-22 12:54:00 +02:00
f6cc40c8f9 Merge branch 'master' of git.mimbach49.de:GerhardHoffmann/DCLibraries 2024-03-21 16:07:08 +01:00
6be24fe9ff Merge branch 'master' of https://git.mimbach49.de/GerhardHoffmann/DCLibraries 2024-03-21 15:57:23 +01:00
3612fc28ee bugfix: banknotes have been summed with the coins. Now they are handled separately. 2024-03-21 15:55:50 +01:00
c59de6cad8 bugfix: banknotes have been summed with the coins. Now they are handled separately. 2024-03-21 15:54:58 +01:00
4b0e8ec5f6 Merge branch 'master' of git.mimbach49.de:GerhardHoffmann/DCLibraries 2024-03-14 15:53:44 +01:00
3486c4ccaf Added cash_isCollectionStarted() 2024-03-14 15:17:40 +01:00
ea462ba5c8 call gpi_storeDI_CoinAttach to speed up coin attach detection 2024-03-14 15:16:27 +01:00
961fc6b5dc Fill several struct to align on proper address 2024-03-14 15:14:47 +01:00
6f920604b7 Add cash_isCashCollectionSTarted(). 2024-03-14 15:12:33 +01:00
d5021c8269 Merge branch 'carun_removeWidgets' 2024-03-02 12:16:02 +01:00
7abe8ae419 Libraries: remove dependency to gui/widgets 2024-03-02 12:15:15 +01:00
b8089c443c CArun: remove dependency to qt gui/widgets 2024-03-02 12:14:02 +01:00
3bbd3e4e19 Proposal: final version for new CArun class 2024-03-02 12:12:49 +01:00
c902bd9a54 Proposal: remove Widgets 2024-03-02 08:36:06 +01:00
25e7bf056b remove unused variable 2024-03-02 07:15:12 +01:00
8f8947482a Fix: add source-files to project 2024-02-22 08:44:34 +01:00
42c817ddce Merge branch 'coin-attach' 2024-02-21 16:20:17 +01:00
2c799e1cd2 Merge branch 'coin-attach' of git.mimbach49.de:GerhardHoffmann/DCLibraries into coin-attach 2024-02-21 10:50:41 +01:00
9cac6a6461 Added comment for std::atomic<bool>::exchange() 2024-02-21 10:46:34 +01:00
aa10d3b275 Add atomic<bool> variable m_coinAttached to check for state change:
send signal runProc_coinAttached only if state changes from false true.
2024-02-21 10:39:03 +01:00
790c2fd031 add coin-attach signal 2024-02-19 15:59:41 +01:00
7130d052e7 Merge branch 'SiegfriedSiegert-pu/FixGetDeviceConditions' 2024-02-06 09:55:57 +01:00
ad84464bf4 Merge branch 'pu/FixGetDeviceConditions' of https://git.mimbach49.de/SiegfriedSiegert/DCLibraries into SiegfriedSiegert-pu/FixGetDeviceConditions 2024-02-06 09:55:38 +01:00
69d0420e7d sys_restoreDeviceParameter() check size of struct T_devices 2024-02-06 09:39:21 +01:00
9b2433c2cd Fix: check size of struct T_devices 2024-02-05 17:36:53 +01:00
Thomas
c5054fe4a0 removed lines for turning so-file into executable binary 2024-02-01 15:01:18 +01:00
02f15421ba Add sources for download/reporting thread 2023-12-20 17:06:37 +01:00
3c9cd16144 Add headers for download/reporting thread 2023-12-20 17:05:47 +01:00
760f4018b5 Merge branch 'master' of https://git.mimbach49.de/GerhardHoffmann/DCLibraries 2023-12-20 16:52:13 +01:00
a344ba1b7d Add implementations for helpers for downloading device controller.
NOTE : They are not called at the moment.
2023-12-20 16:50:50 +01:00
490fdd9209 Minor: add some debug output (versions, build times) 2023-12-20 16:50:23 +01:00
0c417c6940 Add headers for download/reporting thread. 2023-12-20 16:50:00 +01:00
fafea93a62 Add reporting thread and defines for output of versions and build dates/times. 2023-12-20 16:48:57 +01:00
ba99795bf3 Add download thread and define macros to output versions and build times. 2023-12-20 16:47:59 +01:00
135c508320 Add struct DCDownload for downloading the device controller. 2023-12-20 16:46:54 +01:00
f9dfc2b5e7 define git commnds only for linux 2023-12-20 16:46:21 +01:00
fc2abd3e89 Add helers and signals for downloading the device controller. 2023-12-20 16:44:03 +01:00
15671e3a37 Add helpers and signals for downloading the device controller. 2023-12-20 16:42:56 +01:00
54993ac592 Test for commit. 2023-12-18 12:28:43 +01:00
2c67638c34 Add some debug output in case the dc-data-valid flag is reset to false. 2023-12-18 12:12:30 +01:00
e7538ae5df Set compiler check: make sure MASTER and SLAVE defines are not set at the same time. 2023-12-18 12:11:45 +01:00
cb403b5dbb Remove references to com, datif and prot components. 2023-12-18 12:10:33 +01:00
f226179e24 Add com, datif and prot components. 2023-12-18 12:09:59 +01:00
3eff32b45c Fix: remove lines from TEMPLATE=lib on. This will completely confuse Qt creator 2023-12-18 12:09:24 +01:00
075a9d9316 Remove com, datif and prot, and add them in lib_ca_master.pro 2023-12-18 12:08:04 +01:00
8c261af1a7 Remove com, datif and prot (so we cannot link). 2023-12-18 10:44:08 +01:00
e0346e0a9b Explicitlz remove define THIS_IS_CA_SLAVE. 2023-12-18 10:43:01 +01:00
16b6ea8087 Add COMPILER-CHECKS: datif is only valid inside the master-lib. 2023-12-18 10:41:56 +01:00
9bdc08f6fc no change 2023-12-16 09:39:51 +01:00
a3bc3d53cd diagnosis 2023-12-16 09:39:36 +01:00
9971b7ac2e diagnosis 2023-12-16 09:38:29 +01:00
15ada1ad26 diagnosis 2023-12-16 09:37:50 +01:00
1811842082 no more define 2023-12-16 09:36:53 +01:00
13ff32b108 no change 2023-12-16 09:36:19 +01:00
cea817cbcb // minor add comment for function bna_getCurrentNotes 2023-12-13 15:21:04 +01:00
e50871cf9f // made connection to DC more reliable, tries to open until succeeded 2023-12-13 15:20:28 +01:00
f6f90fe770 // made connection to DC more reliable, tries to open until succeeded 2023-12-13 15:17:14 +01:00
7b1ea963e2 Merge https://git.mimbach49.de/GerhardHoffmann/DCLibraries 2023-12-08 12:05:53 +01:00
8163be5022 Fix: correct order of steps in cash_paymentProcessing (NOTE: not compatible with Szeged at the moment.
This will require an update of the firmware device controller).
2023-12-08 12:02:25 +01:00
1fdbf3b9ca Minor: add some comments. 2023-12-08 11:58:55 +01:00
d380bcafe8 Check if THIS_IS_CA_MASTER is already defined.
Thomas has some issues in his environment.
2023-12-06 14:57:01 +01:00
27c0aa56ee Prepare new implementation of downloading the bootloader. 2023-12-06 14:45:22 +01:00
6377c6c18f Include previous main for windows. 2023-12-06 14:42:57 +01:00
e906213441 Change as for cash_cancelPayment(). 2023-12-06 14:37:37 +01:00
57b4ade2e5 cashCancelPayment(): while printing quick request while printing and changing. 2023-12-06 14:35:57 +01:00
f817d07e8c Extend sendINrequestsAutomatic(): add several requests. 2023-12-06 14:33:30 +01:00
fc2bc6bafc Mark hwapi-functions as overridden. 2023-12-06 14:30:45 +01:00
7f672db841 Add new timer myTO. 2023-12-06 14:28:24 +01:00
d8232e0163 Change hwapi_functions as pure virtual signals due to compiler problems. 2023-12-06 14:26:06 +01:00
fc2132184e Minor: add header. 2023-12-06 14:20:02 +01:00
78700e7bea Fix: return value prn_getPrintResult() 2023-11-30 14:27:17 +01:00
3d3bc88269 Merge branch 'yoctoIntegration' 2023-11-21 10:14:18 +01:00
ae9a5b0920 Revert "Project: remove DESTFILE definition (disrupts yocto build)"
This reverts commit 3cdd11cc36.
2023-11-21 10:11:18 +01:00
3cdd11cc36 Project: remove DESTFILE definition (disrupts yocto build) 2023-11-21 10:06:00 +01:00
7746f22d01 Project: set TEMPLATE for apps 2023-11-21 09:25:04 +01:00
27f1a47e23 Project: remove rules for deployment 2023-11-20 17:01:02 +01:00
eed4c278f8 csv loaded by dCArun: contains standard settings for serial connection 2023-11-20 11:32:45 +01:00
1dd368dad3 Use /usr/lib as path for the CA-libraries on the PTU5. 2023-11-15 10:17:45 +01:00
Thomas Sax
53054ca2d0 Add file 2023-11-14 08:48:48 +01:00
Thomas Sax
ca067b0246 Extended with bna-functionality. 2023-11-14 08:47:37 +01:00
Thomas
7c4fcab33c remove obsolete file 2023-11-14 08:45:57 +01:00
Thomas
7628ec0d5f remove unused file 2023-11-14 08:45:05 +01:00
Thomas
c89decdeae Implemented bna-functionality 2023-11-14 08:40:54 +01:00
Thomas
40848344f5 Changes for BNAÖ case 41, 42, 16. 2023-11-14 08:39:15 +01:00
Thomas
4eabff268e Added bna-function declarations 2023-11-14 08:37:39 +01:00
Thomas
226f6d91c2 Added some variables for bna 2023-11-14 08:36:44 +01:00
Thomas
447d1ceb54 Removed obsolete comments 2023-11-14 08:35:53 +01:00
Thomas
79868787cf Filled struct T_bna and added new version number. 2023-11-14 08:34:32 +01:00
38 changed files with 2210 additions and 4870 deletions

View File

@@ -4,6 +4,8 @@ QT +=network
# for TCP-IP # for TCP-IP
TARGET = CArunGui TARGET = CArunGui
TEMPLATE = app
VERSION = "1.0.0" VERSION = "1.0.0"
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build
@@ -19,14 +21,15 @@ INCLUDEPATH += ../include
win32 { win32 {
BUILD_DATE=$$system("date /t") BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t") BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
} else { } else {
BUILD_DATE=$$system("date +%d-%m-%y") BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S") BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
} }
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
DEFINES+=APP_VERSION=\\\"$$VERSION\\\" DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
@@ -50,7 +53,3 @@ HEADERS += \
datei.h \ datei.h \
plugin.h plugin.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@@ -9,7 +9,8 @@ char MainWindow::loadPlugIn(char lade1_entlade2)
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse //pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5 //pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows //pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
pluginLoader->setFileName("CAmaster.dll"); // for windows //pluginLoader->setFileName("CAmaster.dll"); // for windows
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
if (lade1_entlade2==2) if (lade1_entlade2==2)
{ {

View File

@@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// bit0,1: enable/disable button "next" // bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home" // bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back" // bit4,5: enable/disable button "back"
QString bs, cn;
int br, ci;
this->updateGui(); this->updateGui();
*nextScreen=0; // 0=no change *nextScreen=0; // 0=no change
@@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
// load and use last settings: -------------------- // load and use last settings: --------------------
QByteArray myBA; QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT); myBA=datei_readFromFile(FILENAME_COMPORT);
if (myBA.length()>0)
{
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
HWaccess->dc_openSerial(br,bs,cn,1);
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
} else
{
// open with default settings
qDebug()<<"CArunGui: open serial with default values";
//uint32_t len= datei_nrOfEntriesInFile(myBA); bs="115200";
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0); br=5;
//qDebug()<<"win_startup load long numer: "<<ulltmp; //cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!?? ci=2;
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste) HWaccess->dc_openSerial(br,bs,cn,1);
bs=csv_getEntryAsString(myBA,2); // z.B 115200
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
HWaccess->dc_openSerial(br,bs,cn,1);
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
}
myTO->start(100); // restart myTO->start(100); // restart
myStep++; myStep++;
} else } else
@@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (!myTO->isActive()) if (!myTO->isActive())
{ {
if (HWaccess->dc_isPortOpen()) if (HWaccess->dc_isPortOpen())
{
myStep++; myStep++;
else } else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: port is still closed, restarting..";
}
myTO->start(100); myTO->start(100);
} }
} else } else
@@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (HWaccess->dc_readAnswTestResponse()) if (HWaccess->dc_readAnswTestResponse())
myStep++; // response was correct myStep++; // response was correct
else else
myStep=99; // stop automatic connection and wait for manual start {
myStep=6; // 13.12.23: start Autoconnect cycle
qDebug()<<"CArunGui: got no answer from DC, retry..";
}
myTO->start(100); myTO->start(100);
} }
@@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
HWaccess->dc_autoRequest(1); HWaccess->dc_autoRequest(1);
AutSendButton->setChecked(true); // taste "druecken" AutSendButton->setChecked(true); // taste "druecken"
myStep++; myStep++;
myTO->start(2000);
} else } else
if (myStep==5) if (myStep==5)
{ {
// got next screen: if (!myTO->isActive())
//myNextStep=2; // nicht bei CArun {
myStep++; if (HWaccess->sys_areDCdataValid())
{
qDebug()<<"CArunGui: DC is connected";
myStep=7; // OK, connection is up and running
} else
{
qDebug()<<"CArunGui: auto request is not running, retry...";
myStep++;
myTO->start(100);
}
}
} else } else
if (myStep==6) if (myStep==6)
{ {
// stop here, everything done // restart autoconnect cycle
myTO->start(100); // restart
myStep=0;
} else } else
if (myStep==7) if (myStep==7)
{ {
// stay here, DC connection is up and running
} else } else
{ {
@@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
if (myNextStep) if (myNextStep)
{ {
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep; *nextScreen=myNextStep;
myNextStep=0; myNextStep=0;
} }

View File

@@ -1,6 +1,6 @@
CONFIG += plugin CONFIG += plugin
QT -= gui QT -= gui
QT += widgets serialport QT += serialport
win32 { win32 {
@@ -81,33 +81,32 @@ contains( CONFIG, PTU5_YOCTO ) {
} }
HEADERS += \ HEADERS += \
$${PWD}/include/com.h \
$${PWD}/include/datei.h \ $${PWD}/include/datei.h \
$${PWD}/include/runProc.h \ $${PWD}/include/runProc.h \
$${PWD}/include/controlBus.h \ $${PWD}/include/controlBus.h \
$${PWD}/include/datIf.h \
$${PWD}/include/dcBL.h \ $${PWD}/include/dcBL.h \
$${PWD}/include/hwapi.h \ $${PWD}/include/hwapi.h \
$${PWD}/include/interfaces.h \ $${PWD}/include/interfaces.h \
$${PWD}/include/prot.h \ $${PWD}/include/dynamic-machine-conditions.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 $${PWD}/include/shared_mem_buffer.h \
$${PWD}/include/reporting_thread.h \
$${PWD}/include/download_thread.h
SOURCES += \ SOURCES += \
$${PWD}/src/com.cpp \
$${PWD}/src/datei.cpp \ $${PWD}/src/datei.cpp \
$${PWD}/src/runProc.cpp \ $${PWD}/src/runProc.cpp \
$${PWD}/src/controlBus.cpp \ $${PWD}/src/controlBus.cpp \
$${PWD}/src/datIf.cpp \
$${PWD}/src/dcBL.cpp \ $${PWD}/src/dcBL.cpp \
$${PWD}/src/hwapi.cpp \ $${PWD}/src/hwapi.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 $${PWD}/src/shared_mem_buffer.cpp \
$${PWD}/src/reporting_thread.cpp \
$${PWD}/src/download_thread.cpp
# INTERFACE = DeviceController # INTERFACE = DeviceController
@@ -126,9 +125,3 @@ SOURCES += \
# version.variable_out = HEADERS # version.variable_out = HEADERS
# QMAKE_EXTRA_COMPILERS += version # QMAKE_EXTRA_COMPILERS += version
# QMAKE_CLEAN += $${PWD}/include/version.h # QMAKE_CLEAN += $${PWD}/include/version.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@@ -1,4 +1,5 @@
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun

1
config/comport.csv Normal file
View File

@@ -0,0 +1 @@
s,5,115200,ttymxc2,2,
1 s 5 115200 ttymxc2 2

170
dCArun/CArun.cpp Normal file
View File

@@ -0,0 +1,170 @@
#include "CArun.h"
#include "datei.h"
CArun::CArun(QObject *parent)
: QObject(parent)
, setupStep(SETUP_STEP::INIT)
{
this->timerChainCtrl = new QTimer(this);
this->connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
this->timerChainCtrl->setSingleShot(true);
this->timerChainCtrl->setInterval(100);
loadPlugIn(1);
// Start setup-steps:
qCritical() << "CArun: start setup...";
this->timerChainCtrl->start();
}
char CArun::loadPlugIn(char lade1_entlade2)
{
plugInDir.cd("plugins");
QPluginLoader *pluginLoader = new QPluginLoader();
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
if (lade1_entlade2==2)
{
pluginLoader->unload();
return 0;
}
if (!pluginLoader->load())
{
qCritical() << "CArun: cannot load plugin";
} else
qCritical() << "CArun: plugin loaded: " << pluginLoader->fileName();
if (!pluginLoader->isLoaded())
{
qCritical() << "CArun: ERROR loading plugin: " << pluginLoader->errorString();;
return 0;
}
QObject *plugin = pluginLoader->instance();
if ( plugin == nullptr)
{
// make instance of the root component (which can hold more then one clases)
// also loads the lib if not yet done
qCritical() << "CArun: ERROR cannot start instance";
return 0;
}
this->HWaccess = qobject_cast<hwinf *>(plugin);
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
return 0;
}
void CArun::openSerialPort()
{
#define FILENAME_COMPORT "../comport.csv" // TODO: use absolute path
// use settings (ini-file)
// comport.csv wird mit installiert in: /opt/app/
// k.A., ob "../comport.csv" gefunden wird.
qCritical() << "CArun: open serial port...";
QString bs, cn;
int br, ci;
// load and use last settings: --------------------
QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT);
if (myBA.length()>0)
{
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
this->HWaccess->dc_openSerial(br,bs,cn,1);
} else
{
// vermutlich wird dies hier ausgeführt?
// open with default settings
qCritical() << "CArun: open serial with default values";
bs="115200";
br=5;
//cn="COM14"; // Windows
cn="ttymxc2"; // PTU5
ci=2;
HWaccess->dc_openSerial(br,bs,cn,1);
}
}
void CArun::chainControl(void)
{
switch (this->setupStep) {
case SETUP_STEP::INIT:
qCritical() << "CArun: SETUP_STEP::INIT";
this->setupStep = SETUP_STEP::OPEN_SERIAL_PORT;
this->timerChainCtrl->start();
break;
case SETUP_STEP::OPEN_SERIAL_PORT:
qCritical() << "CArun: SETUP_STEP::OPEN_SERIAL_PORT";
this->openSerialPort();
this->setupStep = SETUP_STEP::CHECK_VALID_DATA;
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_OPEN_PORT:
qCritical() << "CArun: SETUP_STEP::TEST_OPEN_PORT";
if (this->HWaccess->dc_isPortOpen()) {
this->setupStep = SETUP_STEP::TEST_RESPONSE_REQUEST;
}
else {
qCritical() << "CArun: port is still closed, restarting..";
this->setupStep = SETUP_STEP::INIT;
}
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_RESPONSE_REQUEST:
qCritical() << "CArun: SETUP_STEP::TEST_RESPONSE_REQUEST";
this->HWaccess->dc_requTestResponse();
this->setupStep = SETUP_STEP::TEST_RESPONSE_CHECK;
this->timerChainCtrl->start();
break;
case SETUP_STEP::TEST_RESPONSE_CHECK:
qCritical() << "CArun: SETUP_STEP::TEST_RESPONSE_CHECK";
if (this->HWaccess->dc_readAnswTestResponse()) {
// response was correct
this->setupStep = SETUP_STEP::SETUP_AUTOREQEUST;
}
else {
qCritical() << "CArun: got no answer from DC, retry..";
this->setupStep = SETUP_STEP::INIT;
}
this->timerChainCtrl->start();
break;
case SETUP_STEP::SETUP_AUTOREQEUST:
qCritical() << "CArun: SETUP_STEP::SETUP_AUTOREQEUST";
this->HWaccess->dc_autoRequest(1);
this->setupStep = SETUP_STEP::CHECK_VALID_DATA;
this->timerChainCtrl->start();
break;
case SETUP_STEP::CHECK_VALID_DATA:
qCritical() << "CArun: SETUP_STEP::CHECK_VALID_DATA";
if (this->HWaccess->sys_areDCdataValid()) {
qCritical() << "CArun: DC is connected";
// do not start timer again
}
else {
qCritical() << "CArun: auto request is not running, retry...";
this->setupStep = SETUP_STEP::INIT;
this->timerChainCtrl->start();
}
break;
default:
qCritical() << "CArun: invalid setup step";
break;
}
}

56
dCArun/CArun.h Normal file
View File

@@ -0,0 +1,56 @@
#ifndef CARUN_H
#define CARUN_H
#include <QObject>
#include <QTimer>
#include <QDebug>
#include <QDateTime>
#include <QPluginLoader>
#include <QDir>
#include "plugin.h"
enum class SETUP_STEP {
INIT,
OPEN_SERIAL_PORT,
TEST_OPEN_PORT,
TEST_RESPONSE_REQUEST,
TEST_RESPONSE_CHECK,
SETUP_AUTOREQEUST,
CHECK_VALID_DATA
};
class CArun : public QObject
{
Q_OBJECT
public:
explicit CArun(QObject *parent = nullptr);
QTimer *timerChainCtrl;
char loadPlugIn(char lade1_entlade2);
QDir plugInDir;
private:
hwinf *HWaccess=nullptr; // global pointer to plugin-class
SETUP_STEP setupStep;
void openSerialPort();
signals:
private slots:
void chainControl();
};
#endif // CARUN_H

View File

@@ -1,16 +1,16 @@
QT += core gui QT += core
QT +=widgets serialport QT += serialport
QT +=network QT +=network
# for TCP-IP # for TCP-IP
TARGET = dCArun TARGET = dCArun
TEMPLATE = app
VERSION = "1.0.0" VERSION = "1.0.0"
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 CONFIG += c++11
CONFIG += PTU5 CONFIG += PTU5
@@ -23,38 +23,31 @@ INCLUDEPATH += ../include
win32 { win32 {
BUILD_DATE=$$system("date /t") BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t") BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
} else { } else {
BUILD_DATE=$$system("date +%d-%m-%y") BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S") BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
} }
GIT_COMMIT=$$system("git log -1 --format=oneline | cut -d' ' -f1")
EXTENDED_VERSION="$${VERSION}-$${GIT_COMMIT}"
DEFINES+=APP_VERSION=\\\"$$VERSION\\\" DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\" DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\" DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
SOURCES += \ SOURCES += \
CArun.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \
tslib.cpp \ tslib.cpp \
win01_com.cpp \
datei.cpp datei.cpp
HEADERS += \ HEADERS += \
CArun.h \
guidefs.h \ guidefs.h \
mainwindow.h \
stepList.h \
tslib.h \ tslib.h \
versionHistory.txt \ versionHistory.txt \
win01_com.h \
datei.h \ datei.h \
plugin.h plugin.h
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

View File

@@ -1,15 +1,14 @@
#include "mainwindow.h" #include "CArun.h"
//#include "message_handler.h" //#include "message_handler.h"
#include <QApplication> #include <QCoreApplication>
int thisisglobal;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret; QCoreApplication myapp(argc, argv);
QApplication myapp(argc, argv);
QApplication::setApplicationName("CArunGui"); QCoreApplication::setOrganizationName("ATB");
QApplication::setApplicationVersion(APP_VERSION); QCoreApplication::setApplicationName("CArun");
QCoreApplication::setApplicationVersion(APP_VERSION);
/* /*
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
@@ -18,16 +17,9 @@ int main(int argc, char *argv[])
//setDebugLevel(QtMsgType::QtDebugMsg); //setDebugLevel(QtMsgType::QtDebugMsg);
} }
*/ */
MainWindow myMainWin; CArun carun;
QSize myMainSize={800, 480}; // breite, höhe, PTU: 800x440
myMainWin.setMinimumSize(myMainSize);
myMainWin.setMaximumSize(myMainSize);
myMainWin.setWindowTitle("CArun_V4.2 run cash agent master lib");
//myMainWin.show();
ret=myapp.exec(); return myapp.exec();
return ret;
} }

View File

@@ -1,438 +0,0 @@
#include "mainwindow.h"
char MainWindow::loadPlugIn(char lade1_entlade2)
{
plugInDir.cd("plugins");
QPluginLoader *pluginLoader = new QPluginLoader();
// select system:
//pluginLoader->setFileName("../MasterPlug/libCAmaster.so"); // for suse
//pluginLoader->setFileName("../SlavePlug/libCAslave.so"); // for ptu5
//pluginLoader->setFileName("../../MasterPlug/CAmaster.dll"); // for windows
pluginLoader->setFileName("CAmaster.dll"); // for windows
if (lade1_entlade2==2)
{
pluginLoader->unload();
return 0;
}
if (!pluginLoader->load())
{
qDebug()<<"cannot load plugin";
} else
qDebug() <<"loaded plugin: " << pluginLoader->fileName();
if (!pluginLoader->isLoaded())
{
qDebug()<<pluginLoader->errorString();
return 0;
}
QObject *plugin = pluginLoader->instance();
if ( plugin == nullptr)
{
// make instance of the root component (which can hold more then one clases)
// also loads the lib if not yet done
qDebug()<<"cannot start instance";
return 0;
}
//int rr=hwapi->giveVal(2); funktioniert :))
//qDebug()<<"got value from plugin"<<rr; funktioniert :))
// aber besser globaler pointer:
// im h-file
// hwinf *hwapi=nullptr; // pointer to plugin-class
HWaccess= qobject_cast<hwinf *>(plugin);
// make instance to class "hwinf" in dll_HWapi.h over "interfaces.h"
qDebug()<<"loadPlugIn, HWAccess: " << HWaccess;
return 0;
}
#define WINCTRMIN 0
// 0 is always the home screen
#define WINCTRMAX 30
// number of needed application screens, up to 255
// All screens must be defined below in mainwindow-class first before increasing the nr
// numbers must be consecutively from 0 always, 0 is the home screen always
#define FORMWIDTH 725
//#define FORMWIDTH 690
// this width is the same for ALL windows
#define FORMHEIGHT 440
// this height is the same for ALL windows
#define NAVIBUTTONHEIGHT 70
#define NAVIBUTTONWIDHT 50
#define HOMEPAGE_BACKGROUND_COLOR "background-color: lightgrey"
#define BUTTON_COLOR "background-color: rgb(160,250,190)"
#define ACTIVE_NAVI_COLOR "background-color: rgb(160,250,190)"
#define DISABL_NAVI_COLOR "background-color: grey"
#define APPPAGE_BACKGROUND_COLOR "background-color: lightgrey"
#define UPDATE_PERIOD_MS 100
// period to call chain steps
#define VENDINGTIMEOUT_MS 30000
// after this time without any operation the program returns to idle state
// time in ms, that means 30.000 gives 30seconds
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
loadPlugIn(1);
// define all working moduls (besides gui) here, call ini and working in chainControl() (~Line 1000)
//mifCard = new T_Mifare(HWaccess); // ganz wichtig: HWaccess an sub-Konstruktor übergeben
// sonst crash bei HW-Zugriff!!!!
//diary = new T_lib_diary(); absturz!!!!!!
//conf = new T_lib_config(HWaccess);
timerChainCtrl = new QTimer(this);
connect(timerChainCtrl, SIGNAL(timeout()), this, SLOT(chainControl()));
timerChainCtrl->setSingleShot(0);
timerChainCtrl->start(UPDATE_PERIOD_MS); // 1000: call every 1000ms
timerVendingTimeout = new QTimer(this);
connect(timerVendingTimeout, SIGNAL(timeout()), this, SLOT(vendingTimeout()));
timerVendingTimeout->setSingleShot(true);
timerVendingTimeout->start(VENDINGTIMEOUT_MS); // in ms
// ##########################################################################################
// für jedes anzuzeigende Fenster eine eigene Groupbox mit eigenem Grid anlegen:
frame01 = new QGroupBox;
frame01->setStyleSheet(APPPAGE_BACKGROUND_COLOR);
frame01->setMinimumSize(FORMWIDTH,FORMHEIGHT);
QVBoxLayout *smallLay01 = new QVBoxLayout;
frame01->setLayout(smallLay01);
// Fensterinhalt aus externer Klasse einfügen:
myFenster01 = new T_winComPort(HWaccess); // HWaccess damit auf das HW-Plugin zugegriffen werden kann, sonst crash
smallLay01->addWidget(myFenster01);
// ##########################################################################################
// draw Mainwindow:
bigGroupbox = new QGroupBox;
bigGroupbox->setStyleSheet("background-color: grey");
bigGroupbox->setMinimumSize(800,480);
// bigLayout = new QVBoxLayout; // navi buttons on bottom side
bigLayout = new QHBoxLayout; // navi buttons right hand
// ##########################################################################################
// add all windows (but display only one)
// display only one: then all windows are shown at the same place
// display more then one: the windows are listed in vertical order
bigLayout->addWidget(frame01);
bigGroupbox->setLayout(bigLayout);
switchScreen(1);
//HideAllWindows();
// ##########################################################################################
// Steuer Leiste
//QHBoxLayout *ButtonLayout = new QHBoxLayout();
QVBoxLayout *ButtonLayout = new QVBoxLayout();
QFont myTabFont;
myTabFont.setPixelSize(26);
pBback = new QPushButton("<"); //b\na\nc\nk");
pBback->setFont(myTabFont);
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
pBback->setMinimumHeight(NAVIBUTTONHEIGHT);
pBback->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBback, SIGNAL( clicked() ), myFenster01, SLOT( Nav_back()));
myTabFont.setPixelSize(22);
pBhome = new QPushButton("<<"); //h\no\nm\ne");
pBhome->setFont(myTabFont);
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
pBhome->setMinimumHeight(NAVIBUTTONHEIGHT);
pBhome->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBhome, SIGNAL( clicked() ), myFenster01, SLOT( Nav_home()));
myTabFont.setPixelSize(26);
pBforward = new QPushButton(">"); //n\ne\nx\nt");
pBforward->setFont(myTabFont);
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
pBforward->setMinimumHeight(NAVIBUTTONHEIGHT);
pBforward->setMaximumWidth(NAVIBUTTONWIDHT);
connect(pBforward, SIGNAL( clicked() ), myFenster01, SLOT( Nav_next()));
QLabel *buttonSpace = new QLabel(" ");
ButtonLayout->addWidget(pBback);
ButtonLayout->addWidget(buttonSpace);
//ButtonLayout->addWidget(buttonSpace);
ButtonLayout->addWidget(pBhome);
ButtonLayout->addWidget(buttonSpace);
//ButtonLayout->addWidget(buttonSpace);
ButtonLayout->addWidget(pBforward);
QLabel *bottomSpace = new QLabel(" ");
ButtonLayout->addWidget(bottomSpace);
bigLayout->addLayout(ButtonLayout);
setCentralWidget(bigGroupbox);
// AUTOSTART serial transmission
//HWaccess->dc_openSerial(5,"115200","ttyS0",1); // my suse computer
//HWaccess->dc_openSerial(1,"9600","COM5",1); // my suse computer
//HWaccess->dc_openSerial(5,"115200","ttymxc2",1); // ptu5
//HWaccess->dc_autoRequest(true);
//myFenster01->setButtons4autoStart();
//HWaccess->alarm_switchSiren(0); // test
enableNaviButtons(BACKBUTTON,true);
enableNaviButtons(HOMEBUTTON,true);
enableNaviButtons(FORWBUTTON,true);
this->chainIni();
//connect(myFenster02, SIGNAL(quitMyApp()), this, SLOT(close()));
}
MainWindow::~MainWindow()
{
loadPlugIn(2);
}
void MainWindow::HideAllWindows()
{
// vorsicht: Fenster muss oben definiert sein sonst Programmabsturz ohne Kommentar
frame01->setEnabled(false);
frame01->setVisible(false);
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Call Windows
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void MainWindow::switchScreen(uint16_t winNr) // 0...30
{
HideAllWindows();
//qDebug()<<"switch screen to " << winNr;
switch (winNr)
{
case 1:
frame01->setEnabled(true);
frame01->setVisible(true);
break;
default:
break;
}
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Navigation buttons
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void MainWindow::enableNaviButtons(uint8_t switchBitwise)
{
// switchBitwise=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
if (switchBitwise &1)
{
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBforward->setText("next");
pBforward->setEnabled(true);
} else
if (switchBitwise &2)
{
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
//pBforward->setText(" ");
pBforward->setEnabled(false);
}
if (switchBitwise &4)
{
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBhome->setText("home");
pBhome->setEnabled(true);
} else
if (switchBitwise &8)
{
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
//pBhome->setText(" ");
pBhome->setEnabled(false);
}
if (switchBitwise &16)
{
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBback->setText("back");
pBback->setEnabled(true);
} else
if (switchBitwise &32)
{
pBback->setStyleSheet(DISABL_NAVI_COLOR);
//pBback->setText(" ");
pBback->setEnabled(false);
}
}
void MainWindow::enableNaviButtons(uint8_t buttonNr, bool enabled)
{
if (buttonNr==1)
{
if (enabled)
{
pBback->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBback->setText("back");
pBback->setEnabled(true);
} else
{
pBback->setStyleSheet(DISABL_NAVI_COLOR);
//pBback->setText(" ");
pBback->setEnabled(false);
}
} else
if (buttonNr==2)
{
if (enabled)
{
pBhome->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBhome->setText("home");
pBhome->setEnabled(true);
} else
{
pBhome->setStyleSheet(DISABL_NAVI_COLOR);
//pBhome->setText(" ");
pBhome->setEnabled(false);
}
} else
if (buttonNr==3)
{
if (enabled)
{
pBforward->setStyleSheet(ACTIVE_NAVI_COLOR);
//pBforward->setText("next");
pBforward->setEnabled(true);
} else
{
pBforward->setStyleSheet(DISABL_NAVI_COLOR);
//pBforward->setText(" ");
pBforward->setEnabled(false);
}
}
}
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// control work flow by Finite state machine
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
static uint16_t chainCurrentStep, chainNextStep;
static bool chain_stepIni;
void MainWindow::chainIni(void)
{
// called once after power-up by constructor
chainCurrentStep=WCS_STARTSCREEN; // start screen
chainNextStep=chainCurrentStep;
switchScreen(chainCurrentStep);
chain_stepIni=true;
//qDebug()<<"chain ini, call step "<<WCS_STARTUP << " " << chainCurrentStep;
}
void MainWindow::chainControl(void)
{
uint16_t nextScreen=0;
uint8_t useNavi=0;
bool busy=false;
// working step chain:
if (chainCurrentStep != chainNextStep)
{
if (chainNextStep!=WCS_STARTSCREEN)
{
timerVendingTimeout->stop();
timerVendingTimeout->start(VENDINGTIMEOUT_MS);
}
//qDebug()<<"found new sreen";
chainCurrentStep=chainNextStep;
switchScreen(chainCurrentStep);
chain_stepIni=true;
}
if (chainCurrentStep==1)
{
if (chain_stepIni)
busy=myFenster01->work_ini(&nextScreen, &useNavi);
else
busy=myFenster01->working(&nextScreen, &useNavi);
} else
{
// error undefined step
qDebug()<<"error main chain control, wrong step ("<<chainCurrentStep<<") selected";
}
if (chain_stepIni)
{
chain_stepIni=false;
switchScreen(chainCurrentStep); // the mainWindow frame has always the same number as the working step
}
if (nextScreen>0)
{
// call next chain step
//qDebug()<<"chain control: new step selected: "<< nextScreen;
chainNextStep=nextScreen;
}
if (useNavi>0)
{
//qDebug()<<"chain control: navi buttons "<< useNavi;
enableNaviButtons(useNavi);
}
if (busy>0)
{
// reset time-out
timerVendingTimeout->start();
}
}
void MainWindow::vendingTimeout(void)
{
// there was no user operation for 30s so return to start screen
// uint16_t nextScreen=WCS_STARTSCREEN;
// chainNextStep=nextScreen; erstmal stilllegen, stört bei IBN
//qDebug()<<"chain control: vending TO";
timerVendingTimeout->stop();
}

View File

@@ -1,72 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QTimer>
#include <QGroupBox>
#include <QStyle>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QLabel>
#include <QDebug>
#include <QPushButton>
#include <QDialog>
#include <QWidget>
#include <QApplication>
#include <QObject>
#include <QDateTime>
#include <QDate>
#include <QTime>
#include <QPluginLoader>
#include <QDir>
#include "plugin.h"
#include "stepList.h"
//#include "stepList.h" // define all working chain steps here
#include "win01_com.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
QPushButton *pBback;
QPushButton *pBhome;
QPushButton *pBforward;
QGroupBox *bigGroupbox;
QHBoxLayout *bigLayout;
QTimer *timerChainCtrl;
QTimer *timerVendingTimeout;
QGroupBox *frame01;
T_winComPort *myFenster01;
void HideAllWindows();
void switchScreen(uint16_t winNr);
char loadPlugIn(char lade1_entlade2);
QDir plugInDir;
void chainIni(void);
public:
hwinf *HWaccess=nullptr; // global pointer to plugin-class
MainWindow(QWidget *parent = nullptr);
~MainWindow();
#define BACKBUTTON 1
#define HOMEBUTTON 2
#define FORWBUTTON 3
void enableNaviButtons(uint8_t buttonNr, bool enabled);
void enableNaviButtons(uint8_t switchBitwise);
private slots:
void chainControl();
void vendingTimeout();
};
#endif // MAINWINDOW_H

View File

@@ -1,210 +0,0 @@
#ifndef STEPLIST_H
#define STEPLIST_H
// define all working chain steps
// every FSM-Step get's a frame in MainWindow with the same number and a self-designed GUI
// labels are used for switchScreen( label=nr );
// numbers are important: e.g. number 3 calls frame3 and frame3 includes subClass "T_fenster03"
// so best solution: label = same name like class (in example: Fenster03). Label is fixed bound to number, never change!
// numbers are fixed assosiated with the function (e.g. ComPort), can't be changed.
// but screen order can be called in step chain randomly
// Windownumbers for certain function, never change
#define PAGE_COMPORT 1
#define PAGE_SERVICEMAIN 2
#define PAGE_TIMEDATEVERSION 3
#define PAGE_MACHINESTATUS 4
#define PAGE_CHECKDOORS 5
#define PAGE_PRINTER 6
#define PAGE_COINMECHANIC 7
#define PAGE_MIFARE 8
#define PAGE_MODEM 9
#define PAGE_COINPAYMENT 10
#define PAGE_VAULTRECORD 11
#define PAGE_BOOTLOADER 12
#define PAGE_PROG_JSON 13
#define PAGE_COINCHANGER 14
#define PAGE_BILLREADER 15
#define PAGE_NEXT16 16
#define PAGE_NEXT17 17
#define PAGE_NEXT18 18
#define PAGE_NEXT19 19
#define PAGE_NEXT20 20
// fix: customize:
#define WCS_STARTSCREEN PAGE_COMPORT
// PAGE_COMPORT:
#define WCS_WIN01BAK PAGE_COMPORT
#define WCS_WIN01MID PAGE_SERVICEMAIN
#define WCS_WIN01FWD PAGE_SERVICEMAIN
// PAGE_SERVICEMAIN:
#define WCS_WIN02BAK PAGE_COMPORT
#define WCS_WIN02MID PAGE_SERVICEMAIN
#define WCS_WIN02FWD PAGE_TIMEDATEVERSION
// PAGE_TIMEDATEVERSION:
#define WCS_WIN03BAK PAGE_SERVICEMAIN
#define WCS_WIN03MID PAGE_SERVICEMAIN
#define WCS_WIN03FWD PAGE_MACHINESTATUS
// PAGE_MACHINESTATUS:
#define WCS_WIN04BAK PAGE_TIMEDATEVERSION
#define WCS_WIN04MID PAGE_SERVICEMAIN
#define WCS_WIN04FWD PAGE_CHECKDOORS
// PAGE_CHECKDOORS:
#define WCS_WIN05BAK PAGE_MACHINESTATUS
#define WCS_WIN05MID PAGE_SERVICEMAIN
#define WCS_WIN05FWD PAGE_COINMECHANIC
// PAGE_COINMECHANIC:
#define WCS_WIN07BAK PAGE_CHECKDOORS
#define WCS_WIN07MID PAGE_SERVICEMAIN
#define WCS_WIN07FWD PAGE_COINPAYMENT
// PAGE_COINPAYMENT:
#define WCS_WIN10BAK PAGE_COINMECHANIC
#define WCS_WIN10MID PAGE_SERVICEMAIN
#define WCS_WIN10FWD PAGE_COINCHANGER
// PAGE_COINCHANGER:
#define WCS_WIN14BAK PAGE_COINPAYMENT
#define WCS_WIN14MID PAGE_SERVICEMAIN
#define WCS_WIN14FWD PAGE_BILLREADER
// PAGE_BILLREADER:
#define WCS_WIN15BAK PAGE_COINCHANGER
#define WCS_WIN15MID PAGE_SERVICEMAIN
#define WCS_WIN15FWD PAGE_PRINTER
// PAGE_PRINTER:
#define WCS_WIN06BAK PAGE_BILLREADER
#define WCS_WIN06MID PAGE_SERVICEMAIN
#define WCS_WIN06FWD PAGE_MIFARE
// PAGE_MIFARE:
#define WCS_WIN08BAK PAGE_PRINTER
#define WCS_WIN08MID PAGE_SERVICEMAIN
#define WCS_WIN08FWD PAGE_MODEM
// PAGE_MODEM:
#define WCS_WIN09BAK PAGE_MIFARE
#define WCS_WIN09MID PAGE_SERVICEMAIN
#define WCS_WIN09FWD PAGE_VAULTRECORD
// PAGE_VAULTRECORD:
#define WCS_WIN11BAK PAGE_MODEM
#define WCS_WIN11MID PAGE_SERVICEMAIN
#define WCS_WIN11FWD PAGE_PROG_JSON
// PAGE_PROG_JSON:
#define WCS_WIN13BAK PAGE_VAULTRECORD
#define WCS_WIN13MID PAGE_SERVICEMAIN
#define WCS_WIN13FWD PAGE_BOOTLOADER
// PAGE_BOOTLOADER:
#define WCS_WIN12BAK PAGE_PROG_JSON
#define WCS_WIN12MID PAGE_SERVICEMAIN
#define WCS_WIN12FWD PAGE_NEXT16
// PAGE_NEXT16
#define WCS_WIN16BAK PAGE_BOOTLOADER
#define WCS_WIN16MID PAGE_SERVICEMAIN
#define WCS_WIN16FWD PAGE_NEXT17
// PAGE_NEXT17
#define WCS_WIN17BAK PAGE_NEXT16
#define WCS_WIN17MID PAGE_SERVICEMAIN
#define WCS_WIN17FWD PAGE_NEXT18
// PAGE_NEXT18
#define WCS_WIN18BAK PAGE_NEXT17
#define WCS_WIN18MID PAGE_SERVICEMAIN
#define WCS_WIN18FWD PAGE_NEXT19
// PAGE_NEXT19
#define WCS_WIN19BAK PAGE_NEXT18
#define WCS_WIN19MID PAGE_SERVICEMAIN
#define WCS_WIN19FWD PAGE_NEXT20
// PAGE_NEXT20
#define WCS_WIN20BAK PAGE_NEXT19
#define WCS_WIN20MID PAGE_SERVICEMAIN
#define WCS_WIN20FWD PAGE_SERVICEMAIN
// just for Template
#define WCS_WIN99BAK PAGE_SERVICEMAIN
#define WCS_WIN99MID PAGE_SERVICEMAIN
#define WCS_WIN99FWD PAGE_SERVICEMAIN
#define WIN02_LABEL_SHORT01 " Status"
#define WCS_WIN02SHORT01 PAGE_MACHINESTATUS
#define WIN02_LABEL_SHORT02 " Doors "
#define WCS_WIN02SHORT02 PAGE_CHECKDOORS
#define WIN02_LABEL_SHORT03 "Coin mech"
#define WCS_WIN02SHORT03 PAGE_COINMECHANIC
#define WIN02_LABEL_SHORT04 "Payment"
#define WCS_WIN02SHORT04 PAGE_COINPAYMENT
#define WIN02_LABEL_SHORT05 "Changer"
#define WCS_WIN02SHORT05 PAGE_COINCHANGER
#define WIN02_LABEL_SHORT06 " Bill "
#define WCS_WIN02SHORT06 PAGE_BILLREADER
#define WIN02_LABEL_SHORT07 "Printer"
#define WCS_WIN02SHORT07 PAGE_PRINTER
#define WIN02_LABEL_SHORT08 "Program"
#define WCS_WIN02SHORT08 PAGE_VAULTRECORD
#define WIN02_LABEL_SHORT09 " "
#define WCS_WIN02SHORT09 PAGE_SERVICEMAIN
#define WIN02_LABEL_SHORT10 " "
#define WCS_WIN02SHORT10 PAGE_SERVICEMAIN
// set needed navigation buttons, use | to combine more then one:
#define SWITCH_NEXT_ON 1
#define SWITCH_NEXT_OFF 2
#define SWITCH_HOME_ON 4
#define SWITCH_HOME_OFF 8
#define SWITCH_BACK_ON 16
#define SWITCH_BACK_OFF 32
// example: *useNavi=SWITCH_BACK_ON; // change only this one, or set all:
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
// some defines for Widget design:
#define TS_VALUEBOX_FRAMESTYLE 0x0032
#define TS_VALUEBOX_LINEWIDTH 3
//genDatPort->setFrameStyle(QFrame::Panel | QFrame::Sunken ); funktioniert aber gibt unverständliche Warnung
// QFrame::Panel = 0x0002 QFrame::Sunken=0x0030
//genDatPort->setFrameStyle(0x0032); // funktioniert und gibt keine Warnung
//genDatPort->setFrameStyle(TS_VALUEBOX_FRAMESTYLE); // funktioniert und gibt keine Warnung
#define TS_LED_FRAMESTYLE 0x0031
// QFrame::Box | QFrame::Sunken
#endif // STEPLIST_H

View File

@@ -1,578 +0,0 @@
#include "win01_com.h"
#include "stepList.h" // define all working chain steps here
#include "datei.h"
//#include "globVars.h"
// %%%%%%%%%%%%%%%%%%%% TabComPort
Console::Console(QWidget *parent) : QPlainTextEdit(parent)
{
document()->setMaximumBlockCount(100);
QPalette p = palette();
p.setColor(QPalette::Base, Qt::black); //geht nicht weil untergrund schon farbig
p.setColor(QPalette::Text, Qt::blue);
setPalette(p);
}
void Console::putData(const QByteArray &data)
{
insertPlainText(data);
insertPlainText("\n");
QScrollBar *bar = verticalScrollBar();
bar->setValue(bar->maximum());
}
void Console::putText(QString text)
{
insertPlainText(text);
insertPlainText("\n");
QScrollBar *bar = verticalScrollBar();
bar->setValue(bar->maximum());
}
void T_winComPort::subPortInfo()
{
// Port Info Anzeige Feld, 2. Zeile links
QStringList myStringList;
QStringList comboPortList;
const auto infos = QSerialPortInfo::availablePorts();
for (const QSerialPortInfo &info : infos)
{
myStringList.append(QObject::tr(" \n Port: ") + info.portName() );
myStringList.append(QObject::tr("Location: ") + info.systemLocation()); // + "\n");
myStringList.append(QObject::tr("Description: ") + info.description() );
myStringList.append(QObject::tr("Manufacturer: ") + info.manufacturer());
myStringList.append(QObject::tr("Serial number: ") + info.serialNumber());
myStringList.append (QObject::tr("Vendor Id: ") + QString::number(info.vendorIdentifier(), 16));
myStringList.append(QObject::tr("Product Id: ") +QString::number(info.productIdentifier(), 16));
//myStringList.append(QObject::tr("Busy: ") + (info.isBusy() ? QObject::tr("Yes") : QObject::tr("No")));
comboPortList.append(info.portName()); // wenn Comport im System vorhanden dann in die Liste eintragen
}
QListWidget *myListWidget = new QListWidget;
myListWidget->insertItems(0, myStringList);
myListWidget->setMaximumWidth(250);
myTabComLayout->addWidget(myListWidget,1,0);
// ComboBox Comport Nr:
CB_portSel = new QComboBox();
CB_portSel->addItems(comboPortList); // string Liste mit addItems (s am Schluss) !
CB_portSel->setMinimumHeight(30);
CB_portSel->setMaximumWidth(150);
QFont myCBfont;
//myCBfont.setBold(true);
myCBfont.setPixelSize(15);
CB_portSel->setFont(myCBfont);
CB_portSel->setCurrentIndex(2); // default 3. Comport in der Liste = ttymxc2 in PTU5
myTabComLayout->addWidget(CB_portSel, 4,0);
}
void T_winComPort::callOpenSerial()
{
// Taste Connect wurde gedrückt, eine Klasse/einen Slot aus einer übergeordneten Klasse:
// openSerialPort();
// kann man nicht aufrufen. deshalb: speichere ComPort, Baudrate und Startbefehl global.
// Von dort wird mit einem zyklischen Timer ausgelesen
int br, ci;
QString bs, cn;
//br=CB_baudSel->currentIndex();
//bs=CB_baudSel->currentText();
br=5;
bs="115200";
cn=CB_portSel->currentText();
ci=CB_portSel->currentIndex();
// aktuell: br=5 bs=115200 cn=0 (=Com5)
//epi_setSerial(5,"115200","COM5",1);
// epi_setSerial(br, bs, cn, 1);
// new: save values for next time
QByteArray myBA, tmpBA;
myBA.clear(); tmpBA.clear();
myBA.append('s'); // start sign, not used
myBA.append(FILESEPERATOR);
tmpBA.setNum(br,10);
myBA.append(tmpBA);
myBA.append(FILESEPERATOR);
myBA.append(bs.toLatin1());
myBA.append(FILESEPERATOR);
myBA.append(cn.toLatin1());
myBA.append(FILESEPERATOR);
tmpBA.clear();
tmpBA.setNum(ci,10);
myBA.append(tmpBA);
myBA.append(FILESEPERATOR);
datei_clearFile(FILENAME_COMPORT);
datei_writeToFile(FILENAME_COMPORT, myBA);
qDebug() << "winComPort opening serial with: " << br << " " << bs << " " << cn;
HWaccess->dc_openSerial(br, bs, cn, 1);// same function with hwapi
// void dc_openSerial(int BaudNr, QString BaudStr, QString ComName, uint8_t connect)
// BaudNr: 0:1200 1:9600 2:19200 3:38400 4:57600 5:115200
// BaudStr: for exapmle "19200"
// ComName: for example "COM48"
// connect: 0, 1
emit connectButtonPressed();
}
void T_winComPort::callCloseSerial()
{
HWaccess->dc_closeSerial();
// epi_closeSerial(); // same function without hwapi
emit closeButtonPressed();
}
void T_winComPort::callAutoSend()
{
if (AutSendButton->isChecked())
{
HWaccess->dc_autoRequest(1);
emit autoSendButtonIsOn();
} else
{
HWaccess->dc_autoRequest(0);
emit autoSendButtonIsOff();
}
}
void T_winComPort::callRefresh(void)
{
subPortInfo();
}
void T_winComPort::callConnectToggle()
{
if (connectButton->isChecked())
{
//qDebug() << "down";
callOpenSerial();
} else
{
//qDebug() << "released";
callCloseSerial();
}
}
void T_winComPort::getDcTestRS232()
{
//qDebug() << "request test response...";
HWaccess->dc_requTestResponse();
}
void T_winComPort::newBaud(void)
{
qDebug() << "new baud selected...";
}
void T_winComPort::setButtons4autoStart()
{
connectButton->setEnabled(true);
connectButton->setDown(true);
connectButton->setChecked(true);
AutSendButton->setEnabled(true);
AutSendButton->setDown(true);
AutSendButton->setChecked(true);
}
T_winComPort::T_winComPort(hwinf *HWaccess, QWidget *parent) : QWidget(parent)
{
this->HWaccess = HWaccess;
myTabComLayout = new QGridLayout;
//QGridLayout *myGridLayout = new QGridLayout();
// Überschrift linke Spalte
QLabel *portListLabel2 = new QLabel(tr("in System available Ports:"));
myTabComLayout->addWidget(portListLabel2, 0,0);
// Überschrift rechte Spalte
QLabel *lab_headlineR = new QLabel(tr("Serial traffic:"));
myTabComLayout->addWidget(lab_headlineR, 0, 1);
subPortInfo();
// sende-empfangs-Rohdaten-Fenster, 2. Zeile rechts
myDiagWindow = new Console();
myDiagWindow->setReadOnly(true);
myDiagWindow->setEnabled(true);
//myDiagWindow->setLocalEchoEnabled(p.localEchoEnabled);
//myDiagWindow->setMinimumWidth(300);
//myDiagWindow->putData("ongoing serial traffic: ");
myTabComLayout->addWidget(myDiagWindow, 1,1);
// links:
// refresh button:
refreshButton = new QPushButton(tr("&refresh"));
refreshButton->setCheckable(false); // true = toggle button
refreshButton->setAutoDefault(false); // beim start aus
//refreshButton->setMaximumWidth(90);
myTabComLayout->addWidget(refreshButton, 2,0);
//connect(refreshButton, &QAbstractButton::clicked, this, &T_fenster01::callRefresh);
connect(refreshButton, SIGNAL(clicked()), this, SLOT(callRefresh()));
QLabel *Label3 = new QLabel(tr("Port:"));
myTabComLayout->addWidget(Label3, 3,0);
QLabel *Label4 = new QLabel(tr("Baud:"));
myTabComLayout->addWidget(Label4, 5,0);
// ComboBox Baudrate:
QFont my2CBfont;
//my2CBfont.setBold(true);
my2CBfont.setPixelSize(15);
/*
CB_baudSel = new QComboBox();
CB_baudSel->addItem(tr("1200"));
CB_baudSel->addItem(tr("9600"));
CB_baudSel->addItem(tr("19200"));
CB_baudSel->addItem(tr("38400"));
CB_baudSel->addItem(tr("57600"));
CB_baudSel->addItem(tr("115200"));
CB_baudSel->setMinimumHeight(30);
CB_baudSel->setMaximumWidth(150);
CB_baudSel->setFont(my2CBfont);
CB_baudSel->setCurrentIndex(5); // default 115k baud
//CB_baudSel->setCurrentIndex(1); // default 9600 baud
myTabComLayout->addWidget(CB_baudSel, 6,0);
//connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
connect(CB_baudSel, SIGNAL(currentIndexChanged(int)), this, SLOT(newBaud()));
*/
// Statuszeile COM Port (serial Port)
LabelComState = new QLabel(tr("not connected"));
myTabComLayout->addWidget(LabelComState, 7,0);
// Connect button:
connectButton = new QPushButton(tr("&Connect"));
connectButton->setCheckable(true); // true = toggle button
connectButton->setAutoDefault(true); // beim start ein
connectButton->setMaximumWidth(90);
connectButton->setMinimumHeight(50);
myTabComLayout->addWidget(connectButton, 8,0);
//connect(connectButton, &QAbstractButton::clicked, this, &T_fenster01::callConnectToggle);
connect(connectButton, SIGNAL(clicked()), this, SLOT(callConnectToggle()));
// rechts:
// test serial line:
TestButton = new QPushButton(tr("test Connection"));
TestButton->setMaximumWidth(150);
myTabComLayout->addWidget(TestButton,2,1);
TestButton->setCheckable(false); // true = toggle button
TestButton->setAutoDefault(false); // beim start aus
// connect(TestButton, &QAbstractButton::clicked, this, &T_fenster01::getDcTestRS232);
connect(TestButton, SIGNAL(clicked()), this, SLOT(getDcTestRS232()));
// I Statuszeile Handshakes (serial Control) flow.cpp
// geht überhaupt was raus? kommt überhaupt was zurück?
//LabelHandshakes = new QLabel(tr("control line"));
LabelHandshakes = new QLabel("HS"); // not used
myTabComLayout->addWidget(LabelHandshakes, 3,1);
// II Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
LabelRecieveFrame = new QLabel(tr("slave receive"));
myTabComLayout->addWidget(LabelRecieveFrame, 4,1);
// III Anzeige der Slave-Results (Datif)
LabelResults = new QLabel(tr("results line"));
myTabComLayout->addWidget(LabelResults, 5,1);
// IV Statuszeile Sende- und Empfangsdaten brauchbar? (Datif)
LabelDataState = new QLabel(tr("datif line"));
myTabComLayout->addWidget(LabelDataState, 6,1);
// V
LabelDatif = new QLabel(tr("datif line"));
myTabComLayout->addWidget(LabelDatif, 7,1);
// Autosend:
AutSendButton = new QPushButton(tr("&Automatic reading")); // &A --> also keycode Alt-A possible
//AutSendButton->setMaximumWidth(90);
myTabComLayout->addWidget(AutSendButton,8,1);
AutSendButton->setCheckable(true); // true = toggle button
AutSendButton->setAutoDefault(true); // beim start aus
AutSendButton->setMinimumHeight(50);
// connect(AutSendButton, &QAbstractButton::clicked, this, &T_fenster01::callAutoSend);
connect(AutSendButton, SIGNAL(clicked()), this, SLOT(callAutoSend()));
setLayout(myTabComLayout);
myNextStep=0;
myStep=0;
callConnectToggle();
callAutoSend();
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(2000);
}
// not needed:
T_winComPort::~T_winComPort()
{
close();
}
void T_winComPort::Nav_back(void)
{
myNextStep=WCS_WIN01BAK;
}
void T_winComPort::Nav_home(void)
{
myNextStep=WCS_WIN01MID;
}
void T_winComPort::Nav_next(void)
{
myNextStep=WCS_WIN01FWD;
}
bool T_winComPort::work_ini(uint16_t *nextScreen, uint8_t *useNavi)
{
// one state of the vending/operating FSM
// called ONE time after selecting this state (initialization)
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
*nextScreen=0; // needed 0=no change
// *useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_ON;
*useNavi=SWITCH_BACK_OFF | SWITCH_HOME_OFF | SWITCH_NEXT_OFF; // bei CArun alle aus
return false;
}
bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
{
// one state of the vending/operating FSM
// called cyclic until this state changes intentionally to another state
// display informations for human operator, react on operators inputs or wait for payment media
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
this->updateGui();
*nextScreen=0; // 0=no change
*useNavi=0;
if (myStep==0)
{
// load and use last settings: --------------------
QByteArray myBA;
myBA=datei_readFromFile(FILENAME_COMPORT);
//uint32_t len= datei_nrOfEntriesInFile(myBA);
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0);
//qDebug()<<"win_startup load long numer: "<<ulltmp;
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
bs=csv_getEntryAsString(myBA,2); // z.B 115200
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
HWaccess->dc_openSerial(br,bs,cn,1);
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
connectButton->setChecked(true); // connect Taste "druecken"
myTO->start(100); // restart
myStep++;
} else
if (myStep==1)
{
if (!myTO->isActive())
{
if (HWaccess->dc_isPortOpen())
myStep++;
else
myStep=99; // stop automatic connection and wait for manual start
myTO->start(100);
}
} else
if (myStep==2)
{
if (!myTO->isActive())
{
HWaccess->dc_requTestResponse();
myStep++;
myTO->start(100);
}
} else
if (myStep==3)
{
if (!myTO->isActive())
{
if (HWaccess->dc_readAnswTestResponse())
myStep++; // response was correct
else
myStep=99; // stop automatic connection and wait for manual start
myTO->start(100);
}
} else
if (myStep==4)
{
HWaccess->dc_autoRequest(1);
AutSendButton->setChecked(true); // taste "druecken"
myStep++;
} else
if (myStep==5)
{
// got next screen:
//myNextStep=2; // nicht bei CArun
myStep++;
} else
if (myStep==6)
{
// stop here, everything done
} else
if (myStep==7)
{
} else
{
}
if (myNextStep)
{
//qDebug()<<"fenster1 working: "<< myNextStep;
*nextScreen=myNextStep;
myNextStep=0;
}
return false;
}
void T_winComPort::updateGui(void)
{
QByteArray myBA;
QString ms;
ms=HWaccess->dc_getTxt4RsDiagWin();
if (ms.length()>1) // sonst ständig scrolling
{
myDiagWindow->putText(ms);
HWaccess->dc_clrTxt4RsDiagWin();
}
ms=HWaccess->dc_get2ndTxt4RsDiagWin();
if (ms.length()>1) // sonst ständig scrolling
{
myDiagWindow->putText(ms);
HWaccess->dc_clr2ndTxt4RsDiagWin();
}
// state of the COM Port (open, closed)
ms=HWaccess->dc_getSerialState();
if (ms.length()>1) // sonst ständig scrolling
{
LabelComState->setText(ms);
}
// --------------------------------------------------------------------------
// I Statuszeile Handshakes (serial Control)
ms=HWaccess->dc_getTxt4HsStateLine();
if (!connectButton->isChecked())
ms="";
if (ms.length()>1) // sonst ständig scrolling
{
LabelHandshakes->setText(ms);
HWaccess->dc_clrTxt4HsStateLine();
// clear to avoid multiple displaying
}
// II Master receive state (empfangenes Telgramm OK? crc? length? )
// Statuszeile Auswertung der SlaveResponse (serial Frame, CRC usw) (prot.cpp)
ms=HWaccess->dc_getTxt4masterStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelRecieveFrame->setText(ms);
HWaccess->dc_clrTxt4masterStateLine();
}
// III Slave receive (from Master) OK? if then show results, if not then show errors
// entweder Empfangsfehler anzeigen (crc? length?) oder result OUT-OK, OUT_ERR, IN_OK, IN_ERR
// Hintergrund: wenn der Slave Fehler im Master-Telegramm gefunden hat, dann kann er es auch
// nicht verwenden und nichts ausgeben oder einlesen
ms=HWaccess->dc_getTxt4resultStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelResults->setText(ms);
HWaccess->dc_clrTxt4resultStateLine();
}
// IV Statuszeile Empfangsdaten
ms=HWaccess->dc_getdataStateLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelDataState->setText(ms);
HWaccess->dc_clrTxt4dataStateLine();
// clear to avoid multiple displaying
}
// 5. Zeile: Datif Ergebnis, Daten brauchbar?
ms=HWaccess->dc_getdatifLine();
if (!connectButton->isChecked())
ms="---";
if (ms.length()>1) // sonst ständig scrolling
{
LabelDatif->setText(ms);
HWaccess->dc_clrTxt4datifLine();
}
// -----------------------------------------------------------------------------
}

View File

@@ -1,107 +0,0 @@
#ifndef WINCOMPORT_H
#define WINCOMPORT_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QObject>
#include <QTimer>
#include <QDebug>
#include <QTabWidget>
#include <QScrollBar>
#include <QPlainTextEdit>
#include <QComboBox>
#include <QLabel>
#include <QScrollArea>
#include <QSerialPortInfo>
#include <QWidget>
#include <QListWidget>
#include <QGroupBox>
#include <QPushButton>
#include <QRadioButton>
//#include "tslib.h"
//#include "stepList.h" // define all working chain steps here
//#include "datei.h"
#include "plugin.h"
//#include "globVars.h"
class Console : public QPlainTextEdit
{
Q_OBJECT
public:
explicit Console(QWidget *parent = nullptr);
void putData(const QByteArray &data);
void putText(QString text);
};
class T_winComPort : public QWidget // former TabComport
{
Q_OBJECT
Console *myDiagWindow; // Ausgabefenster
QComboBox *CB_portSel;
//QComboBox *CB_baudSel;
QPushButton *connectButton;
QPushButton *AutSendButton;
QPushButton *TestButton;
QPushButton *refreshButton;
QLabel *LabelComState; // Statusanzeige
QLabel *LabelPort;
QLabel *LabelHandshakes;
QLabel *LabelRecieveFrame;
QLabel *LabelResults;
QLabel *LabelDataState;
QLabel *LabelDatif;
QGridLayout *myTabComLayout;
void subPortInfo();
hwinf *HWaccess;
void updateGui(void);
uint16_t myNextStep;
uint8_t myStep;
QTimer *myTO;
private slots:
void callOpenSerial();
void callCloseSerial();
void callAutoSend();
//void tabComTime100ms();
void callConnectToggle();
void getDcTestRS232();
void callRefresh(void);
public:
explicit T_winComPort(hwinf *HWaccess = nullptr, QWidget *parent = nullptr);
bool work_ini(uint16_t *nextScreen, uint8_t *useNavi);
// useNavi=0: no change
// bit0,1: enable/disable button "next"
// bit2,3: enable/disable button "home"
// bit4,5: enable/disable button "back"
bool working (uint16_t *nextScreen, uint8_t *useNavi);
~T_winComPort();
void writeRSdiagBytes(const QByteArray &bytarray);
void writeRSdiagText(QString text);
void writeComState(const QString text);
void writeDataState(const QString text);
void setButtons4autoStart();
signals:
void connectButtonPressed();
void closeButtonPressed();
void autoSendButtonIsOn();
void autoSendButtonIsOff();
private slots:
void newBaud(void); // just for test
public slots:
void Nav_back(void);
void Nav_home(void);
void Nav_next(void);
};
#endif

View File

@@ -3,7 +3,7 @@
#ifndef SER_H #ifndef SER_H
#define SER_H #define SER_H
#include <stdint.h> #include <stdint.h>
#include <QMainWindow> #include <QObject>
//#include <QString> //#include <QString>
#include <QTimer> #include <QTimer>
#include <QSerialPort> #include <QSerialPort>

View File

@@ -1,6 +1,7 @@
#ifndef DATEI_H #ifndef DATEI_H
#define DATEI_H #define DATEI_H
#include <stdint.h>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QDebug> #include <QDebug>

37
include/download_thread.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef DOWNLOAD_THREAD_H_INCLUDED
#define DOWNLOAD_THREAD_H_INCLUDED
#include <QThread>
#include <QString>
#include <QByteArray>
class hwinf;
class DownloadThread : public QThread {
Q_OBJECT
public:
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
DownloadThread(hwinf *hw);
~DownloadThread();
protected:
// download thread does not have a running event queue, and therefore
// no slots. signals work the usual way.
void run() override;
private:
DownloadResult sendStatus(int ret) const;
DownloadResult sendNextAddress(int bNum) const;
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
bool startBootloader() const;
bool stopBootloader() const;
QByteArray loadBinaryDCFile(QString dcFileName) const;
bool resetDeviceController() const;
DownloadResult dcDownloadBinary(QByteArray const &b) const;
hwinf *m_hw;
QString m_fileToDownload;
};
#endif // DOWNLOAD_THREAD_H_INCLUDED

View File

@@ -0,0 +1,84 @@
#ifndef DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED
#define DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED
struct T_dynamicCondition
{
char allDoorsDebounced;
char openedAuthorized;
uint8_t CBinDebounced; // 0:fehlt 1:drin
char upperDoor; // 99: undefined 0:closed 1:open
char middleDoor; // 99: undefined 0:closed 1:open
char lowerDoor; // 99: undefined 0:closed 1:open
char coinAttached;
char billBox;
char modeAbrech;
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
char nowCardTest;
char nowPayment; // not used, always 0
char lastMifCardType;
uint8_t lastSDoorState;
uint8_t lastVDoorState;
uint8_t lastCBstate;
char paymentInProgress;
// Version Szeged: aug2023
// 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
// since Schoenau with bill and changer, nov2023
//0 = no payment
//will be set to 1 by cash_startCollection()
//neu 1: wait for devices getting ready for payment
//2 = payment,
//3 = wait for last coin/bill
//4 = Bezahlvorgang manuell beendet
//5 = payment stopped autom, amount collected, coins in Escrow
//6 = Bezahlvorgang beendet weil ZK voll
//4,5,6: payment done, keep on polling, wait for cash or return command
//7 = encash collected money from coin escrow into cash box
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
//9 = wait for changer result
//10= print refund receipt with "amountToReturn"
char res1;
uint16_t U_Batt;
uint16_t Temperatur;
uint16_t nrCoinsInBox;
uint32_t amountInBox;
uint32_t totalTransVolume;
uint32_t totalNrOfVends;
char jsonValid_config;
char jsonValid_device;
char jsonValid_cash;
char jsonValid_print;
// 40
char jsonValid_serial;
char jsonValid_time;
char lastFileType;
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;
uint8_t padd01;
uint8_t padd02;
uint8_t padd03;
uint32_t padd04;
uint32_t padd05;
uint32_t padd06;
uint16_t padd07;
};
#endif // DYNAMIC_MACHINE_CONDITIONS_H_INCLUDED

View File

@@ -26,6 +26,7 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
#ifndef hwapi_H #ifndef hwapi_H
#define hwapi_H #define hwapi_H
#include <stdint.h>
#include <QtPlugin> #include <QtPlugin>
#include <QTimer> #include <QTimer>
#include <QObject> #include <QObject>
@@ -37,9 +38,10 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
#include "dcBL.h" #include "dcBL.h"
#include "interfaces.h" //#include <../plugins/interfaces.h>
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "runProc.h" #include "runProc.h"
#include "interfaces.h"
/* /*
@@ -69,12 +71,16 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
*/ */
//for CAslave: //for CAslave:
//#undef THIS_IS_CA_MASTER //#undef THIS_IS_CA_MASTER
//for CAmaster:
//#define THIS_IS_CA_MASTER
//for CAmaster:
class QSharedMemory; class QSharedMemory;
class DownloadThread;
class ReportingThread;
class hwapi : public QObject, class hwapi : public QObject,
public hwinf public hwinf
{ {
@@ -86,10 +92,12 @@ private:
void sub_storeSendingText(QByteArray *buf) const; void sub_storeSendingText(QByteArray *buf) const;
QTimer *hwapi_TimerPayment; QTimer *hwapi_TimerPayment;
QSharedMemory *m_sharedMem; QSharedMemory *m_sharedMem;
ReportingThread *m_reportingThread;
DownloadThread *m_downloadThread;
//QTimer *hwapi_triggerBL; //QTimer *hwapi_triggerBL;
public: public:
explicit hwapi(QWidget *parent = nullptr); explicit hwapi(QObject *parent = nullptr);
#ifdef THIS_IS_CA_MASTER #ifdef THIS_IS_CA_MASTER
@@ -1025,8 +1033,7 @@ public:
void sys_getDeviceConditions(struct T_moduleCondition *devCond) 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(void *data) const override;
void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override; void sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const override;
@@ -1293,8 +1300,15 @@ public:
uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override; uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override;
// returns number of collected bank notes since start-command (current transaction) // returns number of collected bank notes since start-command (current transaction)
// latestBill: last accepted bank note, value in cent // return value: numbers of bills or 99 in case of error
// currentNotes an array with up to 16 (further) notes collected // latestBill: not used
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
// in normal case:
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
// currentNotes[2]: total sum of bills in cent, low word (16bit)
// currentNotes[3]: total sum of bills in cent, high word (16bit)
void bna_requestStackerLevel(void) const override; void bna_requestStackerLevel(void) const override;
@@ -1303,33 +1317,76 @@ public:
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker // countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker
// countOfBills[1] for 10€ and so on // countOfBills[1] for 10€ and so on
bool cash_isCollectionStarted(void) const override;
// download device controller
bool dcDownloadRequest(QString const &fileToDownload) const override;
bool dcDownloadRequested() const override;
bool dcDownloadResetRequest() const override;
bool dcDownloadRequestAck() const override;
bool dcDownloadRunning() const override;
bool dcDownloadFinished() override;
bool dcDownloadReportStart() const override;
bool dcDownloadReportRunning() const override;
bool dcDownloadReportFinished() override;
bool dcDownloadThreadStart() override;
bool dcDownloadThreadRunning() const override;
void dcDownloadThreadFinalize(DownloadThread *) override;
bool dcDownloadThreadFinished() const override;
bool dcDownloadReportThreadStart() override;
bool dcDownloadReportThreadRunning() const override;
void dcDownloadReportThreadFinalize() override;
void dcDownloadReportThreadQuit() override;
bool dcDownloadReportThreadFinished() const override;
QString dcDownloadFileName() const override;
bool dcDownloadSetRequested(bool) override;
bool dcDownloadSetRunning(bool) override;
bool dcDownloadSetFinished(bool) override;
void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) override;
void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) override;
bool dcDownloadGetRequested() const override;
bool dcDownloadGetRunning() const override;
bool dcDownloadGetFinished() const override;
uint16_t dcDownloadGetTotalBlockNumber() const override;
uint16_t dcDownloadGetCurrentBlockNumber() const override;
virtual QObject const *getAPI() override;
signals: signals:
// already declared in interfaces.h void hwapi_reportDCDownloadStatus(QString const&) const override;
void hwapi_templatePrintFinished_OK(void) const; void hwapi_reportDCDownloadSuccess(QString const&) const override;
void hwapi_templatePrintFinished_Err(void) const; void hwapi_reportDCDownloadFailure(QString const&) const override;
void hwapi_coinCollectionJustStarted(void) const; void hwapi_templatePrintFinished_OK(void) const override;
void hwapi_coinCollectionAborted(void) const; void hwapi_templatePrintFinished_Err(void) const override;
void hwapi_gotNewCoin(void) const; void hwapi_coinCollectionJustStarted(void) const override;
void hwapi_payStopByMax(void) const; void hwapi_coinCollectionAborted(void) const override;
void hwapi_payStopByPushbutton(void) const;
void hwapi_payStopByEscrow(void) const; void hwapi_gotNewCoin(void) const override;
void hwapi_payStopByError(void) const; void hwapi_payStopByMax(void) const override;
void hwapi_payStopByTimeout(void) const; void hwapi_payStopByPushbutton(void) const override;
void hwapi_payCancelled(void) const;
void hwapi_coinProcessJustStopped(void) const; 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;
// new from 2023.06.12 // new from 2023.06.12
void hwapi_doorServiceDoorOpened(void) const; void hwapi_doorServiceDoorOpened(void) const override;
void hwapi_doorVaultDoorOpened(void) const; void hwapi_doorVaultDoorOpened(void) const override;
void hwapi_doorCoinBoxRemoved(void) const; void hwapi_doorCoinBoxRemoved(void) const override;
void hwapi_doorCoinBoxInserted(void) const; void hwapi_doorCoinBoxInserted(void) const override;
void hwapi_doorCBinAndAllDoorsClosed(void) const; void hwapi_doorCBinAndAllDoorsClosed(void) const override;
void hwapi_doorAllDoorsClosed(void) const; void hwapi_doorAllDoorsClosed(void) const override;
void hwapi_coinAttached() const override;
private slots: private slots:
//void hwapi_slotPrintFinished_OK(void); //void hwapi_slotPrintFinished_OK(void);
@@ -1357,8 +1414,7 @@ signals:
void sub_slotCoin15(void); void sub_slotCoin15(void);
void sub_slotCoin16(void); void sub_slotCoin16(void);
void coinAttached();
}; };

View File

@@ -3,8 +3,6 @@
#include <QtPlugin> #include <QtPlugin>
struct T_emp struct T_emp
{ {
@@ -24,7 +22,8 @@ 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=start command /*
// 0=start command
// 1=powered, do emp ini, send reset // 1=powered, do emp ini, send reset
// 2=delay // 2=delay
// 3=wait for response, requesting status after response // 3=wait for response, requesting status after response
@@ -39,7 +38,7 @@ struct T_emp
// 90: stop all, 1s delay // 90: stop all, 1s delay
// 99: off, all stopped // 99: off, all stopped
*/
uint8_t pollingRunning; uint8_t pollingRunning;
uint8_t paymentRunning; uint8_t paymentRunning;
@@ -169,6 +168,7 @@ struct T_vaultRecord
}; };
// ATTENTION: struct length must be 64 exactly!!!
struct T_moduleCondition struct T_moduleCondition
{ {
// store conditon of all system components, hold in RAM // store conditon of all system components, hold in RAM
@@ -181,44 +181,53 @@ struct T_moduleCondition
uint8_t ram; uint8_t ram;
uint8_t intEe; uint8_t intEe;
uint8_t extEe; uint8_t extEe;
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; uint8_t boardHw;
uint8_t printer; uint8_t printer;
uint8_t modem; 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;
// 10
uint8_t coinChecker; // EMP, OMP or mei-cashflow uint8_t coinChecker; // EMP, OMP or mei-cashflow
uint8_t coinEscrow; uint8_t coinEscrow;
uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error uint8_t mifareReader; // 0: unknown 1=OK 200=no response 201=wrong response 202: Reader reports HW-error
uint8_t creditTerm; uint8_t creditTerm;
uint8_t coinReject; uint8_t coinReject;
uint8_t coinSafe; uint8_t coinSafe;
uint8_t billSafe; uint8_t billSafe;
uint8_t voltage; // 1:11..14V uint8_t voltage; // 1:11..14V
uint8_t temper; uint8_t temper;
uint8_t poweronTest; uint8_t poweronTest;
// 20
uint8_t doorState; // 1: alles zu 200: tuer offen + bit1(S) +bit2(CB) + bit3(CB) uint8_t doorState; // 1: alles zu 200: tuer offen + bit1(S) +bit2(CB) + bit3(CB)
uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened uint8_t doorWasOpened; // 1: all doors are closed 200: any door was just opened
uint8_t changer; // can only be tested by usage uint8_t changer; // can only be tested by usage
uint8_t coinBlocker; // can only be tested by usage uint8_t coinBlocker; // can only be tested by usage
uint8_t billReader; // can only be tested by usage uint8_t billReader; // can only be tested by usage
uint8_t ResetReason; uint8_t ResetReason;
uint8_t allModulesChecked; uint8_t allModulesChecked;
uint8_t alarmState; uint8_t alarmState;
uint8_t res11; uint8_t res11;
uint8_t res12; uint8_t res12;
// 30
uint8_t res13; uint8_t res13;
// 31 uint8_t padd01;
uint8_t padd02;
uint8_t padd03;
uint32_t padd04;
uint32_t padd05;
uint32_t padd06;
uint32_t padd07;
// 50
uint32_t padd08;
uint32_t padd09;
uint32_t padd10;
uint16_t padd11;
// 64
}; };
// ATTENTION: struct length must be 64 exactly!!!
struct T_dynamicCondition struct T_dynamicCondition
{ {
char allDoorsDebounced; char allDoorsDebounced;
@@ -227,10 +236,11 @@ struct T_dynamicCondition
char upperDoor; // 99: undefined 0:closed 1:open char upperDoor; // 99: undefined 0:closed 1:open
char middleDoor; // 99: undefined 0:closed 1:open char middleDoor; // 99: undefined 0:closed 1:open
char lowerDoor; // 99: undefined 0:closed 1:open char lowerDoor; // 99: undefined 0:closed 1:open
char reserve; char coinAttached;
char billBox; char billBox;
char modeAbrech; char modeAbrech;
char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest char onAlarm; // 0:alarm aus 1:alarm 2:alarm mit Sirene 3: Sirenentest
// 10
char nowCardTest; char nowCardTest;
char nowPayment; // not used, always 0 char nowPayment; // not used, always 0
char lastMifCardType; char lastMifCardType;
@@ -238,6 +248,7 @@ struct T_dynamicCondition
uint8_t lastVDoorState; uint8_t lastVDoorState;
uint8_t lastCBstate; uint8_t lastCBstate;
char paymentInProgress; char paymentInProgress;
// Version Szeged: aug2023
// 0: stopped by timeout // 0: stopped by timeout
// 1: running 2: wait4lastCoin // 1: running 2: wait4lastCoin
// 3: payment stopped manually, coins in Escrow // 3: payment stopped manually, coins in Escrow
@@ -246,9 +257,25 @@ struct T_dynamicCondition
// 6: coins encashed 7:coins returned // 6: coins encashed 7:coins returned
// 8: CoinChecker or MDB on Error // 8: CoinChecker or MDB on Error
// since Schoenau with bill and changer, nov2023
//0 = no payment
//will be set to 1 by cash_startCollection()
//neu 1: wait for devices getting ready for payment
//2 = payment,
//3 = wait for last coin/bill
//4 = Bezahlvorgang manuell beendet
//5 = payment stopped autom, amount collected, coins in Escrow
//6 = Bezahlvorgang beendet weil ZK voll
//4,5,6: payment done, keep on polling, wait for cash or return command
//7 = encash collected money from coin escrow into cash box
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
//9 = wait for changer result
//10= print refund receipt with "amountToReturn"
char res1; char res1;
uint16_t U_Batt; uint16_t U_Batt;
// 20
uint16_t Temperatur; uint16_t Temperatur;
uint16_t nrCoinsInBox; uint16_t nrCoinsInBox;
uint32_t amountInBox; uint32_t amountInBox;
@@ -258,10 +285,10 @@ struct T_dynamicCondition
char jsonValid_device; char jsonValid_device;
char jsonValid_cash; char jsonValid_cash;
char jsonValid_print; char jsonValid_print;
// 40
char jsonValid_serial; char jsonValid_serial;
char jsonValid_time; char jsonValid_time;
char lastFileType; char lastFileType;
// 44
uint8_t MifCardHolder[8]; uint8_t MifCardHolder[8];
uint8_t resultOfLastTemplPrint; uint8_t resultOfLastTemplPrint;
// 0: unknown or printing in progress // 0: unknown or printing in progress
@@ -275,7 +302,15 @@ struct T_dynamicCondition
// bit5: printer not ready // bit5: printer not ready
uint8_t startupTestIsRunning; uint8_t startupTestIsRunning;
//54 uint8_t padd01;
uint8_t padd02;
uint8_t padd03;
//50
uint32_t padd04;
uint32_t padd05;
uint32_t padd06;
uint16_t padd07;
// 64
}; };
struct T_extTime struct T_extTime
@@ -312,6 +347,7 @@ struct T_extTime
typedef uint8_t UCHAR; typedef uint8_t UCHAR;
typedef uint16_t UINT; typedef uint16_t UINT;
// ATTENTION: struct length must be 64 exactly!!!
struct T_devices struct T_devices
{ {
// set by master, used(1) or notused (0) or type 2....20 // set by master, used(1) or notused (0) or type 2....20
@@ -320,27 +356,33 @@ struct T_devices
UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza Csquare (MW) UCHAR kindOfCoinChecker; // 0: without 1=EMP820 2=EMP900 3=currenza Csquare (MW)
UCHAR kindOfMifareReader; // by now only stronglink SL025 =1 UCHAR kindOfMifareReader; // by now only stronglink SL025 =1
UCHAR solarPower; // 1:sleep allowed 0: no sleep UCHAR solarPower; // 1:sleep allowed 0: no sleep
//UCHAR suppressSleepMode; // 0:sleep allowed 1: no sleep
UCHAR kindOfModem; // 0:off 1:Sunlink UCHAR kindOfModem; // 0:off 1:Sunlink
UCHAR kindOfCreditcard; // 0:off 1:Feig NFC UCHAR kindOfCreditcard; // 0:off 1:Feig NFC
UCHAR CoinEscrow; UCHAR CoinEscrow;
UCHAR CoinRejectUnit; UCHAR CoinRejectUnit;
UCHAR CoinShutter; UCHAR CoinShutter;
UCHAR BillAcceptor; UCHAR BillAcceptor;
// 10
UCHAR usevaultLock; UCHAR usevaultLock;
UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized UCHAR autoAlarm; // 1: switch on siren for 1min in doors opened unauthorized
UCHAR autoOpen; // 1: open door covers after valid ATBcard UCHAR autoOpen; // 1: open door covers after valid ATBcard
UCHAR printAccReceipt; // 0/1 UCHAR printAccReceipt; // 0/1
UCHAR printDoorReceipt; UCHAR printDoorReceipt;
UCHAR printTokenTicket; UCHAR printTokenTicket;
UINT VaultFullWarnLevel; UINT VaultFullWarnLevel;
UINT VaultFullErrorLevel; UINT VaultFullErrorLevel;
// 30
UINT BattEmptyWarnLevel; UINT BattEmptyWarnLevel;
UINT BattEmptyErrorLevel; UINT BattEmptyErrorLevel;
uint32_t padd01;
uint32_t padd02;
uint32_t padd03;
uint32_t padd04;
uint32_t padd05;
uint32_t padd06;
uint32_t padd07;
uint16_t padd08;
// 64
}; };
@@ -377,9 +419,27 @@ struct T_changer
struct T_bna struct T_bna
{ {
// reported with STATUS:
uint8_t setup; // 0: not 1: got valid parameters from device
uint8_t FeatureLevel;
uint16_t countryCode; // programmed in EMP
uint16_t scalingFactor; // z.B. 5
uint8_t decimalPlace;
uint8_t pad1;
uint16_t stackerCap;
uint16_t billSecureLevel;
uint8_t hasEscrow;
uint8_t accBillTypes[16]; // programmed in EMP z.B. (bit 0..7): 1 2 4 10 20 40 0 0
uint16_t currentStackerLevel; // requested number of notes in billbox
// settings from Master
uint16_t intendedAccept; // bit 0 =5€
uint16_t pad2;
uint16_t billDenomination[16];
}; };
class DownloadThread;
class hwinf class hwinf
{ {
@@ -1796,8 +1856,7 @@ public:
Q_UNUSED(devCond); Q_UNUSED(devCond);
} }
virtual void sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const { virtual void sys_getDynMachineConditions(void *data) const {
Q_UNUSED(leng);
Q_UNUSED(data); Q_UNUSED(data);
} }
@@ -1817,6 +1876,9 @@ public:
virtual uint8_t prn_getPrintResult() const { virtual uint8_t prn_getPrintResult() const {
return 0; return 0;
} }
// return: 0: just printing, wait
// 1: OK - last print was succesful
// 2: error - not printed
@@ -2215,6 +2277,7 @@ public:
Q_UNUSED(notesToAccept); Q_UNUSED(notesToAccept);
} }
// can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid) // can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid)
// only valid till next start-payment. Cannot add notes which are not activated in Json
virtual void bna_requestParameters() const {} virtual void bna_requestParameters() const {}
// send command to DC in order to get static invariable device parameters like currency // send command to DC in order to get static invariable device parameters like currency
@@ -2231,14 +2294,23 @@ public:
virtual void bna_requestCurrentNotes() const {} virtual void bna_requestCurrentNotes() const {}
// send command to DC in order to get transaction data // send command to DC in order to get transaction data
virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const { virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const
{
Q_UNUSED(latestBill); Q_UNUSED(latestBill);
Q_UNUSED(currentNotes); Q_UNUSED(currentNotes);
return 0; return 0;
} }
// returns number of collected bank notes since start-command (current transaction) // returns number of collected bank notes since start-command (current transaction)
// latestBill: last accepted bank note, value in cent // return value: numbers of bills or 99 in case of error
// currentNotes an array with up to 16 (further) notes collected // latestBill: not used
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
// in normal case:
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
// currentNotes[2]: total sum of bills in cent, low word (16bit)
// currentNotes[3]: total sum of bills in cent, high word (16bit)
virtual void bna_requestStackerLevel() const {} virtual void bna_requestStackerLevel() const {}
@@ -2251,11 +2323,104 @@ public:
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker // countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker
// countOfBills[1] for 10€ and so on // countOfBills[1] for 10€ and so on
virtual bool cash_isCollectionStarted(void) const {return false;}
// return true is coin collection in DC is running
// download device controller
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
Q_UNUSED(fileToDownload);
return false;
}
virtual bool dcDownloadRequested() const { return false; }
virtual bool dcDownloadResetRequest() const { return false; }
virtual bool dcDownloadRequestAck() const { return false; }
virtual bool dcDownloadRunning() const { return false; }
virtual bool dcDownloadFinished() { return false; }
virtual bool dcDownloadReportStart() const { return false; }
virtual bool dcDownloadReportRunning() const { return true; }
virtual bool dcDownloadReportFinished() { return true; }
virtual bool dcDownloadThreadStart() { return false; }
virtual bool dcDownloadThreadRunning() const { return true; }
virtual void dcDownloadThreadFinalize(DownloadThread *) {}
virtual bool dcDownloadThreadFinished() const { return true; }
virtual bool dcDownloadReportThreadStart() { return false; }
virtual bool dcDownloadReportThreadRunning() const { return true; }
virtual void dcDownloadReportThreadFinalize() {}
virtual void dcDownloadReportThreadQuit() {}
virtual bool dcDownloadReportThreadFinished() const { return true; }
virtual QString dcDownloadFileName() const { return ""; }
virtual bool dcDownloadSetRequested(bool requested) {
Q_UNUSED(requested); return false;
}
virtual bool dcDownloadSetRunning(bool running) {
Q_UNUSED(running); return false;
}
virtual bool dcDownloadSetFinished(bool finished) {
Q_UNUSED(finished); return false;
}
virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
Q_UNUSED(totalBlockNumber);
}
virtual void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
Q_UNUSED(currentBlockNumber);
}
virtual bool dcDownloadGetRequested() const { return false; }
virtual bool dcDownloadGetRunning() const { return false; }
virtual bool dcDownloadGetFinished() const { return false; }
virtual uint16_t dcDownloadGetTotalBlockNumber() const { return 0; }
virtual uint16_t dcDownloadGetCurrentBlockNumber() const { return 0; }
virtual QObject const *getAPI() { return nullptr; }
signals: signals:
/*
NOTE: the difference between a virtual Qt signal and a normal Qt signal:
A Qt virtual signal is a connection that is established using a pointer
or reference and is not connected to an object or data. It is therefore
not bound to a particular object, but to a specific class (object type).
Qt virtual signals are useful because they allow you to create
connections without worrying about whether an object or a specific data
element has been destroyed.
https://www.youtube.com/watch?v=HTH3VFfqsXw
*/
virtual void hwapi_reportDCDownloadStatus(QString const&) const {}
virtual void hwapi_reportDCDownloadSuccess(QString const&) const {}
virtual void hwapi_reportDCDownloadFailure(QString const&) const {}
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;
virtual void hwapi_doorServiceDoorOpened(void) const=0;
virtual void hwapi_doorVaultDoorOpened(void) const=0;
virtual void hwapi_doorCoinBoxRemoved(void) const=0;
virtual void hwapi_doorCoinBoxInserted(void) const=0;
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
virtual void hwapi_doorAllDoorsClosed(void) const=0;
virtual void hwapi_coinAttached() const = 0;
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid. // NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
/* GH Version, bringt Fehler
void hwapi_templatePrintFinished_OK() const; void hwapi_templatePrintFinished_OK() const;
void hwapi_templatePrintFinished_Err() const; void hwapi_templatePrintFinished_Err() const;
@@ -2278,6 +2443,7 @@ signals:
void hwapi_doorCoinBoxInserted() const; void hwapi_doorCoinBoxInserted() const;
void hwapi_doorCBinAndAllDoorsClosed() const; void hwapi_doorCBinAndAllDoorsClosed() const;
void hwapi_doorAllDoorsClosed() const; void hwapi_doorAllDoorsClosed() const;
*/
}; };
@@ -2335,9 +2501,17 @@ signals:
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.0" //#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.0"
// 10.10.2023: added coin changer // 10.10.2023: added coin changer
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1" //#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.1"
// 20.10.2023: added bill validator // 20.10.2023: added bill validator
// hier dazwischen: Umstellung ALLER Prototypen
// hier von =0 auf {} durch Gerhard
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2"
// 7.11.2023: bna functions activated
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.3"
// 14.3.24:new function bool hwapi::cash_isCollectionStarted(void) const
// padding three struct to 64 byte to avoid stack overflow when using
// signal coin attached is much faster now
Q_DECLARE_INTERFACE(hwinf, HWINF_iid) Q_DECLARE_INTERFACE(hwinf, HWINF_iid)

View File

@@ -1,7 +1,7 @@
#ifndef SERIAL_FRAME_H #ifndef SERIAL_FRAME_H
#define SERIAL_FRAME_H #define SERIAL_FRAME_H
#include <QMainWindow> #include <QObject>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include "tslib.h" #include "tslib.h"
@@ -43,7 +43,7 @@
#define STARTSIGN_RECEIVE_LONG 0x5D #define STARTSIGN_RECEIVE_LONG 0x5D
class T_prot : public QMainWindow class T_prot : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@@ -0,0 +1,25 @@
#ifndef REPORTING_THREAD_H_INCLUDED
#define REPORTING_THREAD_H_INCLUDED
#include <QThread>
#include <QString>
class hwapi;
class ReportingThread : public QThread {
Q_OBJECT
public:
ReportingThread(hwapi *hw);
~ReportingThread();
protected:
// reporting thread does not have a running event queue, and therefore
// no slots. signals work the usual way.
void run() override;
private:
hwapi *m_hw;
QString m_fileToDownload;
};
#endif // REPORTING_THREAD_H_INCLUDED

View File

@@ -2,7 +2,8 @@
#ifndef RUN_PROCESS_H #ifndef RUN_PROCESS_H
#define RUN_PROCESS_H #define RUN_PROCESS_H
#include <QMainWindow> #include <stdint.h>
#include <QObject>
#include <QString> #include <QString>
#include <QTimer> #include <QTimer>
#include "tslib.h" #include "tslib.h"
@@ -14,6 +15,7 @@
#include <QDebug> #include <QDebug>
#include "datIf.h" #include "datIf.h"
#include <QSharedMemory> #include <QSharedMemory>
#include <atomic>
#include "sendWRcmd.h" #include "sendWRcmd.h"
#include "controlBus.h" #include "controlBus.h"
#include "storeINdata.h" #include "storeINdata.h"
@@ -25,7 +27,7 @@
class T_runProc : public QObject class T_runProc : public QObject
{ {
Q_OBJECT Q_OBJECT
QTimer *hwapi_TimerPayment, *hwapi_triggerBL; QTimer *hwapi_TimerPayment, *hwapi_triggerBL, *myTO;
void sub_emp_getAllParameters(struct T_emp *emp); void sub_emp_getAllParameters(struct T_emp *emp);
void changer_getAllParameters(struct T_changer *mw); void changer_getAllParameters(struct T_changer *mw);
@@ -34,6 +36,10 @@ class T_runProc : public QObject
void restoreDeviceParameter(struct T_devices *deviceSettings); void restoreDeviceParameter(struct T_devices *deviceSettings);
#ifndef THIS_IS_CA_MASTER
std::atomic_bool m_coinAttached{false};
#endif
private slots: private slots:
void runProc_slotProcess(void); void runProc_slotProcess(void);
bool bl_performComplStart(void); bool bl_performComplStart(void);
@@ -79,6 +85,7 @@ signals:
void runProc_doorCBinAndAllDoorsClosed(void); void runProc_doorCBinAndAllDoorsClosed(void);
void runProc_doorAllDoorsClosed(void); void runProc_doorAllDoorsClosed(void);
void runProc_coinAttached();
}; };

View File

@@ -1,185 +1,12 @@
#ifndef SENDWRCMDS_DEFS_H #ifndef SENDWRCMDS_DEFS_H
#define SENDWRCMDS_DEFS_H #define SENDWRCMDS_DEFS_H
#include <stdint.h>
#include "tslib.h" #include "tslib.h"
#include <QString> #include <QString>
// asynch. Commands
// store OUTPUT commands until time to send
// problem: OUT commands are set if a button is pressed or a transaction event happens
// so it's never synchron with sending grid
// but sending must apply the 100ms time grid as we have to wait for the response before sending the next command!!!
// aug2023: used with setSendCommand0
//#define SENDDIRCMD_TestSerial 1
//#define SENDDIRCMD_MakeReset 2
//#define SENDDIRCMD_setTime 3
//#define SENDDIRCMD_setWakeFrequ 4
//#define SENDDIRCMD_MOVEUP_LOCK 5
//#define SENDDIRCMD_MOVEDN_LOCK 6
//#define SENDDIRCMD_OPENUP_DOOR 7
//#define SENDDIRCMD_OPENDN_DOOR 8
//#define SENDDIRCMD_LEDILLU 9
//#define SENDDIRCMD_LEDCOIN 10
//#define SENDDIRCMD_LEDTICKET 11
//#define SENDDIRCMD_LEDPAD 12
//#define SENDDIRCMD_LEDSTART 13
//#define SENDDIRCMD_LEDINSIDE 14
//#define SENDDIRCMD_LED_ALL 15
//#define SENDDIRCMD_FAN 16
//#define SENDDIRCMD_LAERM 17
//#define SENDDIRCMD_REL1 18
//#define SENDDIRCMD_WAKEPTU 20
//#define SENDDIRCMD_AUXPWR 21
//#define SENDDIRCMD_AUXDDR 22
//#define SENDDIRCMD_AUXOUT 23
//#define SENDDIRCMD_UCONTACT_ON 30
//#define SENDDIRCMD_PRN2_SWONOFF 31
//#define SENDDIRCMD_MIF_SWONOFF 32
//#define SENDDIRCMD_MIF_ATBCREATE 33
//#define SENDDIRCMD_MOD_SWONOFF 40
//#define SENDDIRCMD_MOD_WAKE 41
//#define SENDDIRCMD_MDB_POWER 42
//#define SENDDIRCMD_MDB_WAKE 43
//#define SENDDIRCMD_CRED_ON 44
//#define SENDDIRCMD_CRED_WAKE 45
//#define SENDDIRCMD_SHUT_MOV 50
//#define SENDDIRCMD_ESCRO_MOV 51
//#define SENDDIR_OPENVAULT 52
//#define SENDDIR_REJMOT_ON 53
//#define SENDDIR_REJMOT_RUN 54
// Level 2 (serial from DC to devices)
//#define SEND_REQU_SERCONF 100
//#define SEND_REQU_HWversion 101
//#define SEND_REQU_SWversion 102
//#define SEND_REQU_CONDITION 103
//#define SEND_REQU_UID 104
//#define SEND_REQU_TIME 105
// includes wake frequency
//#define SEND_REQU_ANALOGS 110
//#define SEND_REQU_DIG_INPUTS 111
//#define SEND_REQU_DIG_OUTPUTS 112
//#define SEND_REQU_PRN_STATE 120
//#define SEND_REQU_PRN_FONTS 121
//#define SEND_REQU_PRN_ALL 122
//#define SEND_REQU_MIFSTATE 123
// Type and state of reader
//#define SEND_REQU_MIFDATA 124
// Type, UID, Header of card
// read one card sector
// sectors must be addressed by RD_ADD
//#define SEND_REQU_MIF_ATB_TYPE 125
//#define SEND_REQU_MDB_GETSTAT 126
//#define SEND_REQU_MDB_GETWAK 127
//#define SEND_REQU_MDB_GETRESP 128
//#define SEND_REQU_EMP_GETALL 129
//#define SEND_REQU_EMP_GETCOIN 130
//#define SENDDIRCMD_DEVICE_PARA 131
//#define SENDDIRCMD_MACHINE_ID 132
//#define SEND_REQU_DEVICE_PARA 133
//#define SEND_REQU_MACINE_ID 134
// TODO:
//#define SENDDIRCMD_PRN_SETUP 72
//#define SENDDIRCMD_MDB_SNDMSG 92
//#define SENDDIRCMD_EMP_SETT 93
//#define SENDDIRCMD_PRN_BC 80
// further: mdb state, coinchecker state, bill state, modem state, credit_state....
/*
#define SENDDIRCMD_SHUTOPENBYTIME 60
#define SENDDIRCMD_SHUTOPENBYCOIN 61
//#define SENDDIRCMD_SHUT_SENDTIME 62
#define SENDDIRCMD_ESCRO_TAKE 63
#define SENDDIRCMD_ESCRO_GIVE 64
#define SENDDIRCMD_PRN_SYS_CMD 70
#define SENDDIRCMD_PRN_ESC_CMD 71
#define SENDDIRCMD_PRN_MOVE 73
#define SENDDIRCMD_PRN_SETFONT 74
#define SENDDIRCMD_PRN_SETLETT 75
#define SENDDIRCMD_PRN_CUT 76
//#define SENDDIRCMD_PRN_TXT // not needed
#define SENDDIRCMD_PRN_LF 78
#define SENDDIRCMD_PRN_FONTTAB 79
#define SENDDIRCMD_PRN_QR 81
#define SENDDIRCMD_PRN_STOREDQR 82
#define SENDDIRCMD_PRN_LOGO_FL 83
//#define SENDDIRCMD_PRN_LOGO_GRAF 84
//#define SENDDIRCMD_PRN_LOGODAT 85
//#define SENDDIRCMD_PRN_STORBC 86
#define SENDDIRCMD_PRN_STORQR 87
#define SENDDIRCMD_PRN_DOC 88
#define SENDDIRCMD_PRN_CLEARDOC 89
//#define SENDDIRCMD_MDB_POWER 42
//#define SENDDIRCMD_MDB_WAKE 43
#define SENDDIRCMD_MDB_RES 90
#define SENDDIRCMD_MDB_SENDCMD 91
#define SENDDIRCMD_EMP_POLL 94
#define SENDDIRCMD_EMP_STARPPAY 95
#define SENDDIRCMD_EMP_STOPPAY 96
*/
// obsolete:
/*
#define SENDDIRCMD_PRN1_SENDTEXT 54
#define SENDDIRCMD_PRN1_SENDCMD 55
#define SENDDIRCMD_PRN1_SERPAR 56
#define SENDDIRCMD_PRN_LEVEL2_4B 58
#define SENDDIRCMD_PRN_LEVEL2_64 59
*/
// highest priority
//#define CMDSTACKDEPTH 16
// means: up to 16 cmd can be stored. They are issued one by one every 100ms
//void sendWRcmd_clrCmdStack(void);
//bool sendWRcmd_setSendCommand0(uint16_t nextCmd);
// GUI or app sends a command to DC transfered by serial
//uint16_t sendWRcmd_getSendCommand0(void);
// lower priority
//#define CMD4STACKDEPTH 8
//void sendWRcmd_clrCmd4Stack(void);
//bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4);
//uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4);
//#define CMD8STACKDEPTH 4
//void sendWRcmd_clrCmd8Stack(void);
//bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4);
//uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4);
// lowest priority
// wait for resonse before send next! // wait for resonse before send next!
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf); bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf);
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf); uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
@@ -187,47 +14,6 @@ uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf);
void sendWRcmd_INI(void); void sendWRcmd_INI(void);
//uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf);
// HWapi writes data to be forwarded to DC and further to mdb-device
// not batched! don't use twice within 100ms
//uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf);
// datif reads data to forward to dc
// ONE printer doc consists of 20 x 64 byte
//#define MAXNROF_PRNBYTES 64
//#define MAXNROF_PRNBLOCKS 20
/*
void epi_resetPrinterStack(void);
uint8_t epi_storePrnText(char *buf, uint8_t leng);
// store text and binary data from Gui in next higher free memory 0....9
uint8_t gpi_restorePrnText(uint8_t *retbuf);
// read printer text and send to slave, size of retbuf== 64
uint8_t gpi_chk4remainingText(void);
// retval: 0: no more textline left (to send) >0: nr of lines
*/
//void epi_storeUserOfSendingTextBuffer(uint8_t user, uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4 );
// user=1: Text-Print is using this buffer
// 2: QR-code-Printer is using this buffer
//uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *para3, uint8_t *para4);
// user=1: Text-Print is using this buffer
// 2: QR-code-Printer is using this buffer
// #define FDCMD_STACKDEPTH 16 / 32 // #define FDCMD_STACKDEPTH 16 / 32
// short and long commands are queued into the same stack to guaranty right order // short and long commands are queued into the same stack to guaranty right order
void sendFDcmd_clrStack(void); void sendFDcmd_clrStack(void);

View File

@@ -7,6 +7,7 @@
#include <QSharedMemory> #include <QSharedMemory>
#include <QtGlobal> #include <QtGlobal>
#include "interfaces.h"
bool shdMem_firstUse(void); bool shdMem_firstUse(void);
@@ -190,8 +191,10 @@ struct SharedMem
uint8_t store_deviceCondLen; uint8_t store_deviceCondLen;
uint8_t store_deviceCond[66]; uint8_t store_deviceCond[66];
uint8_t store_machCondLen; // uint8_t store_machCondLen;
uint8_t store_machCond[66]; // uint8_t store_machCond[66];
struct T_dynamicCondition dynMachCond;
uint8_t store_DcBackupNrOfAccNr; uint8_t store_DcBackupNrOfAccNr;
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8 uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
@@ -226,6 +229,13 @@ struct SharedMem
uint32_t Sdata_changedAmount; uint32_t Sdata_changedAmount;
uint8_t store_tubeLev[64]; uint8_t store_tubeLev[64];
uint8_t store_bnaParameter[64];
uint8_t store_bnaCollect[8];
uint8_t store_bnaContent[64];
// Mitteilung von Hwapi zu Datif: // Mitteilung von Hwapi zu Datif:
bool Sdata_coinPaymentNow; bool Sdata_coinPaymentNow;
@@ -293,9 +303,26 @@ struct SharedMem
uint8_t p_nextFDcmdsInQueue; uint8_t p_nextFDcmdsInQueue;
// download of device controller and json files
struct DCDownload {
enum class FILE_INDEX {
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
};
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
std::atomic_ushort m_totalBlocks;
std::atomic_ushort m_currentblockNumber;
std::atomic_bool m_requested{false};
std::atomic_bool m_running{false};
std::atomic_bool m_finished{false};
} m_downLoadDC;
static QSharedMemory *getShm(std::size_t s = 0); static QSharedMemory *getShm(std::size_t s = 0);

View File

@@ -1,6 +1,8 @@
#ifndef STOREINDATA_H #ifndef STOREINDATA_H
#define STOREINDATA_H #define STOREINDATA_H
#include <stdint.h>
#include "tslib.h" #include "tslib.h"
#include <QString> #include <QString>
@@ -486,10 +488,8 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data);
void epi_clearDynMachineConditions(void); // new, 24.6.23 void epi_clearDynMachineConditions(void); // new, 24.6.23
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data); void gpi_storeDynMachineConditions(void const *data);
void epi_restoreDynMachineConditions(void *data);
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data);
void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data); void gpi_storeDCbackupAccNr(uint8_t leng, uint8_t *data);
@@ -525,6 +525,9 @@ void gpi_storeDcDataValid(bool isVal);
bool epi_areDcDataValid(); bool epi_areDcDataValid();
void epi_setDcDataValid(void);
void epi_resetDcDataValid(void);
void epi_clearDynData(void); void epi_clearDynData(void);
@@ -607,6 +610,27 @@ void gpi_storeTubeLevel(uint8_t *data);
void epi_restoreTubeLevel(uint8_t *data); void epi_restoreTubeLevel(uint8_t *data);
void gpi_storeBnaParams(uint8_t *data);
void epi_restoreBnaParams(uint8_t *data);
void gpi_storeBnaCollection(uint8_t *data);
void epi_restoreBnaCollection(uint8_t *data);
void gpi_storeBnaContent(uint8_t *data);
void epi_restoreBnaContent(uint8_t *data);
#endif #endif

View File

@@ -1,9 +1,39 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = CAmaster TARGET = CAmaster
VERSION="1.0.0" VERSION="1.0.1"
HEADERS += \
../include/com.h \
../include/datIf.h \
../include/prot.h
SOURCES += \
../src/com.cpp \
../src/datIf.cpp \
../src/prot.cpp
include(../DCLibraries.pri) include(../DCLibraries.pri)
win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
EXTENDED_VERSION_LIB=""
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
EXTENDED_VERSION_LIB="libCAmaster-$${VERSION}-$${GIT_COMMIT}"
}
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
DEFINES+=THIS_IS_CA_MASTER DEFINES+=THIS_IS_CA_MASTER
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build

View File

@@ -1,9 +1,29 @@
TEMPLATE = lib TEMPLATE = lib
TARGET = CAslave TARGET = CAslave
VERSION="1.0.0" VERSION="1.0.1"
include(../DCLibraries.pri) include(../DCLibraries.pri)
win32 {
BUILD_DATE=$$system("date /t")
BUILD_TIME=$$system("time /t")
GIT_COMMIT=""
EXTENDED_VERSION=""
EXTENDED_VERSION_LIB=""
} else {
BUILD_DATE=$$system("date +%d-%m-%y")
BUILD_TIME=$$system("date +%H:%M:%S")
GIT_COMMIT=$$system("git log -1 --format=oneline . | cut -d' ' -f1")
EXTENDED_VERSION_LIB_="libCAslave-$${VERSION}-$${GIT_COMMIT}"
}
DEFINES+=APP_VERSION=\\\"$$VERSION\\\"
DEFINES+=APP_BUILD_DATE=\\\"$$BUILD_DATE\\\"
DEFINES+=APP_BUILD_TIME=\\\"$$BUILD_TIME\\\"
DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\"
DEFINES+=APP_EXTENDED_VERSION_LIB=\\\"$$EXTENDED_VERSION_LIB\\\"
DEFINES+=THIS_IS_CA_SLAVE DEFINES+=THIS_IS_CA_SLAVE
DESTDIR=$${_PRO_FILE_PWD_}/../build DESTDIR=$${_PRO_FILE_PWD_}/../build

View File

@@ -1,3 +1,10 @@
/*
History:
06.12.2023: weitere IN-requests in Autorequest übernommen
Umschaltung mit/ohne Verkauf, während VK nur 12 wichtige, sonst alle 36
*/
#include "datIf.h" #include "datIf.h"
#include "sendWRcmd.h" #include "sendWRcmd.h"
#include "controlBus.h" #include "controlBus.h"
@@ -7,6 +14,7 @@
#include <QDir> #include <QDir>
#include <algorithm> // min/max
@@ -81,7 +89,8 @@ T_datif::T_datif(QObject *parent) : QObject(parent)
dif_scanStep=0; dif_scanStep=0;
selectedSlaveAddr=FIX_SLAVE_ADDR; selectedSlaveAddr=FIX_SLAVE_ADDR;
cycl_running=0; cycl_running=0;
gpi_storeDcDataValid(0); // data are not yet valid, no response from DC by now epi_resetDcDataValid(); // data are not yet valid, no response from DC by now
datif_noResponseCtr=0; datif_noResponseCtr=0;
datif_repeatCtr=0; datif_repeatCtr=0;
@@ -137,14 +146,14 @@ char T_datif::datif_cycleSend()
if ( !myDCIF->isPortOpen()) if ( !myDCIF->isPortOpen())
{ {
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben //qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
gpi_storeDcDataValid(0); // DC data not valid epi_resetDcDataValid(); // DC data not valid
return 0; return 0;
} }
// supervise if DC data are valid // supervise if DC data are valid
datif_noResponseCtr++; // inc every 20ms datif_noResponseCtr++; // inc every 20ms
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s
gpi_storeDcDataValid(0); // DC data has not updated for >=5s -> no longer valid! epi_resetDcDataValid(); // DC data has not updated for >=5s -> no longer valid!
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren // Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
if (gpi_wantToResetSupervision()) if (gpi_wantToResetSupervision())
@@ -337,7 +346,7 @@ char T_datif::datif_cycleSend()
else else
{ {
dif_scanStep=0; // always start from beginning dif_scanStep=0; // always start from beginning
gpi_storeDcDataValid(0); epi_resetDcDataValid();
} }
datif_cmdWasPerformed=0; // 0: no response by now datif_cmdWasPerformed=0; // 0: no response by now
@@ -350,9 +359,20 @@ char T_datif::datif_cycleSend()
char T_datif::sendINrequestsAutomatic(void) char T_datif::sendINrequestsAutomatic(void)
{ {
//qDebug() << "send IN request " << dif_scanStep; //qDebug() << "send IN request " << dif_scanStep;
// uint8_t datif_autoRequCommandList[50]={11, 12, 18, 104, 106, 103, 14, 27, 109, 17, 19, 23, 30, 31, 32, 33, 114, 35}; //uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30,
uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30, 31, 32, 33, 35, 102, 103, 104, 106, 107, 109, 114,0,0,0,0,0,0,0,0,0}; // 31, 32, 33, 35, 102, 103, 104, 106, 107, 109,
uint8_t datif_maxNrCommands=21, datif_sendNow; // 114,0,0,0,0,0,0,0,0,0};
// extension 6.12.23, complete list:
uint8_t datif_autoRequCommandList[40]={11, 12, 13, 14, 17, 18, 19, 21, 22, 23,
24, 25, 27, 30, 31, 32, 33, 35, 39, 40,
41, 42, 102,103,104,106,107,108,109,110,
112,113,114,115,116,0, 0, 0, 0, 0};
uint8_t datif_maxNrCommands=35, datif_sendNow;
// send quicker while transaction is ongoing:
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
uint8_t datif_maxVendingCmds=13;
// special commands: // special commands:
// 102: get IOs run constantly!!! // 102: get IOs run constantly!!!
@@ -362,40 +382,44 @@ char T_datif::sendINrequestsAutomatic(void)
// 107, 22: MDB: poll if needed // 107, 22: MDB: poll if needed
doRepeat=true; // 20.9.23 15uhr (after release) doRepeat=true; // 20.9.23 15uhr (after release)
if (datif_sendSlowCmd>0)
{
// send special command, slowly
datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
if (datif_pNextCmd >= datif_maxNrCommands)
datif_pNextCmd=0;
if (datif_sendNow>0) // never send Command 0
datif_sendIOrequest(0, datif_sendNow, 0);
else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
//qDebug()<< "datif send request " << datif_sendNow; if (gpi_getNowCoinPay())
{
// send only important commands while transaction in progress
if (datif_pNextCmd>=datif_maxVendingCmds ) datif_pNextCmd=0;
datif_sendNow=datif_vendRequCommandList[datif_pNextCmd++];
if (datif_sendNow>0) // never send Command 0
{
datif_sendIOrequest(0, datif_sendNow, 0);
//qDebug() << "datif, VEND-request: " << datif_sendNow;
} else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
} else } else
{ {
if (gpi_getNowCoinPay()) // no transaction, request all but request DI's more frequently
if (datif_sendSlowCmd>0) // send slow and fast commands alternating
{ {
// request coin input, high priority // send special command, slowly
datif_sendIOrequest(0, 112, 0); if (datif_pNextCmd>=datif_maxNrCommands ) datif_pNextCmd=0;
//qDebug()<< "datif send request 112 get coins"; datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
if (datif_sendNow>0) // never send Command 0
{
datif_sendIOrequest(0, datif_sendNow, 0);
// qDebug() << "datif, auto-requ: " << datif_sendNow;
} else
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
} else } else
{ {
// request inputs, high priority // request inputs, high priority
datif_sendIOrequest(0, 31, 0); // 102 datif_sendIOrequest(0, 31, 0); // 102
// while coin collection DIs are polled slowly with datif_autoRequCommandList[] // while coin collection DIs are polled slower
//qDebug()<< "datif send requ.31 get DIs";
//qDebug()<< "datif send request 102 get DIs";
} }
if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0....
} }
if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0....
return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!! return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!!
} }
@@ -439,7 +463,7 @@ char T_datif::loadRecDataFromFrame()
uint32_t ultmp; uint32_t ultmp;
//int portNr; //int portNr;
bool ret; bool ret;
uint8_t uctmp; //, res; // maxai uint8_t uctmp; //, nn; //, res; // maxai
char ctmp; char ctmp;
//static uint8_t lastResult; //static uint8_t lastResult;
//uint8_t prnResult; //uint8_t prnResult;
@@ -967,22 +991,24 @@ 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
newInsertedAmount=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]); // last coin type
uit2=uchar2uint(receivedData[7],receivedData[6]); uit2=uchar2uint(receivedData[7],receivedData[6]); // last coin value
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern: beim Wechsler hat die kleinste Muenze immer coin type 0! //if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern:
if (uit2>0) // beim Wechsler hat die kleinste Muenze immer coin type 0!
if (uitmp>10000 || uit2>10000)
{
uitmp=0;
uit2=0;
}
if ((newInsertedAmount != lastInsertedAmount) || uit2>0) // 22.5.2024
{ {
gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2); gpi_storeCurrentPayment(newInsertedAmount, uitmp, uit2);
//void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue) emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
if (newInsertedAmount != lastInsertedAmount) //qDebug()<<"emit new coin";
{ lastInsertedAmount=newInsertedAmount;
emit datif_gotNewCoin(); //qCritical()<<"datif 112 store and emit new coin "<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
//qDebug()<<"emit new coin";
lastInsertedAmount=newInsertedAmount;
}
// qDebug()<<"datif store new coin"<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
} }
break; break;
case 113: // get wake source, 8byte case 113: // get wake source, 8byte
@@ -1014,10 +1040,23 @@ char T_datif::loadRecDataFromFrame()
case 31: // Get dynamic machine conditions (doors, voltage, alarm….) case 31: // Get dynamic machine conditions (doors, voltage, alarm….)
if (RdDleng>50) if (RdDleng>50)
{ {
gpi_storeDcDataValid(1); // DC-Data are valid as DC responded. epi_setDcDataValid(); // DC-Data are valid as DC responded.
// Could be set to every response but this (31) // Could be set to every response but this (31)
// is a very common and very important request // is a very common and very important request
gpi_storeDynMachineConditions(RdDleng, receivedData);
if (RdDleng > sizeof(struct T_dynamicCondition)) {
qCritical() << "!!!WARNING!!! RdDlen too high" << RdDleng;
// only use as many bytes as maximally possible
char buf[sizeof(struct T_dynamicCondition)];
memset(buf, 0, sizeof(buf));
memcpy(buf, receivedData, std::min(sizeof(receivedData), sizeof(struct T_dynamicCondition)));
gpi_storeDynMachineConditions(buf);
} else {
gpi_storeDynMachineConditions(receivedData);
}
gpi_storeDI_CoinAttach(((struct T_dynamicCondition *)receivedData)->coinAttached); // new, 14.2.24 needed for direct coin insertion
} }
/* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt /* funktioniert, ist aber nicht nötig. Signal wird nach dem shared memory erzeugt
prnResult=receivedData[52]; prnResult=receivedData[52];
@@ -1058,15 +1097,15 @@ char T_datif::loadRecDataFromFrame()
//if (RdDleng>50) // 1.8.23 nach Verlängerung des Datensatzes um 20byte falsch!!! //if (RdDleng>50) // 1.8.23 nach Verlängerung des Datensatzes um 20byte falsch!!!
//{ //{
gpi_storeVaultRecord(readAddress, receivedData ); // always/max 64byte gpi_storeVaultRecord(readAddress, receivedData ); // always/max 64byte
/* /*
qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress; qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress;
if (readAddress==5) if (readAddress==0)
for (nn=0; nn<64; nn+=8) for (nn=0; nn<64; nn+=8)
{ {
qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" " qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" "
<<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7]; <<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7];
} }
*/ */
//} //}
break; break;
@@ -1085,17 +1124,33 @@ char T_datif::loadRecDataFromFrame()
} }
break; break;
case 41: // get BNA parameters
if (RdDleng>50)
{
gpi_storeBnaParams(receivedData);
}
break;
case 21: // readback version strings of all Json-File in DC case 21: // readback version strings of all Json-File in DC
// //
gpi_storeJsonVersion(readAddress, receivedData); gpi_storeJsonVersion(readAddress, receivedData);
break; break;
case 116: // get BNA current collection
if (RdDleng>7)
{
gpi_storeBnaCollection(receivedData);
}
break;
case 42: // get BNA box content and value of types
//qDebug()<< "CAslave datif_got 42";
if (RdDleng>60)
{
gpi_storeBnaContent(receivedData);
}
break;
} }
readSource=0; // 17.05.2023: to avoid multiple recording readSource=0; // 17.05.2023: to avoid multiple recording

320
src/download_thread.cpp Normal file
View File

@@ -0,0 +1,320 @@
#include "download_thread.h"
#include "shared_mem_buffer.h"
#include "hwapi.h"
#include <QDebug>
#include <QDateTime>
DownloadThread::DownloadThread(hwinf *hw)
: m_hw(hw)
, m_fileToDownload(m_hw->dcDownloadFileName()) {
// connect(this, &QThread::finished,
// dynamic_cast<QObject const *>(m_hw), &QThread::deleteLater);
}
DownloadThread::~DownloadThread() {
}
/*
///////////////////////////////////////////////////////////////////////////////
//
// USING THE DC BOOTLOADER
//
///////////////////////////////////////////////////////////////////////////////
1 : bl_reboot() // send to application, want DC2 to reset (in order to
// start the bootloader)
//
// NOTE: this function is NOT reliable !!! Sometimes it
// simply does not work, in which case bl_startBL,
// bl_checkBL and bl_isUp do not work as well.
// Alas, there is no feedback if bl_reboot worked!
//
// NOTE: this function can be called only once per
// minute, because once called again, the controller
// performs some self-checks consuming some time.
//
// NOTE: after a successful bl_reboot(), the device is
// waiting about 4 seconds in the bootloader. To stay in
// the bootloader, we have to send the command
// bl_startBL(), which is kind of a misnomer, as it
// should be bl_doNotLeaveBL().
//
2 : bl_startBL(): // send within 4s after DC power-on, otherwise
// bootloader is left.
//
// NOTE: a running bootloader is a MUST for the download
// process of a device controller firmware as it does
// the actual writing of the memory (the bl_reboot()
// from above erases the available memory).
//
3 : bl_check(): // send command to verify if bl is up
//
// NOTE: this command is kind of a request that we want
// to check if the bootloader is up. The device
// (actually the bootloader) responds with its version.
//
4 : bl_isUp(): // returns true if bl is up and running
//
// NOTE: we know what the bootloader version actually is
// as the bootloader does not change. By comparing the
// string received in the previous step with this known
// version string we know if the bootloader is up.
//
// NOTE FOR ALL PREVIOUS STEPS: execute them in their
// own slots each to be sure to receive any possible
// responds from the device.
//
5 : bl_sendAddress(blockNumber)
// send start address, nr of 64-byte block, start with 0
// will be sent only for following block-numbers:
// 0, 1024, 2048, 3072 and 4096, so basically every
// 64kByte.
// for other addresses nothing happens
6 : bl_wasSendingAddOK()
// return val: 0: no response by now
// 1: error
// 10: OK
7 : bl_sendDataBlock()
// send 64 byte from bin file
8 : bl_sendLastBlock()
// send this command after all data are transferred
9 : bl_wasSendingDataOK()
// return val: 0: no response by now
// 1: error
// 10: OK
10 : bl_stopBL() // leave bl and start (the new) application
//
// NOTE: this function MUST work under all conditions.
// Alas, there is no direct result for this command, so
// the only way of knowing it was successful is to ask
// the device if the bootloader is still running.
// There is no problem to repeat this command until the
// bootloader is really not running anymore.
*/
void DownloadThread::run() {
// download thread running in ca-master sends the dc-file down to firmware
// TODO: send the json files as well
m_hw->dcDownloadRequestAck();
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
// load binary device controller file into memory
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
if (ba.size() > 0) {
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
// fill last block of data to be sent with 0xFF
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
resetDeviceController();
if (startBootloader()) {
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
int currentBlock = 0;
DownloadResult res = DownloadResult::OK;
qCritical() << "64-byte block " << currentBlock;
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
currentBlock += 1;
}
}
}
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
int const rest = ba.size() % 64;
int const offset = ba.size() - rest;
char const *startAddress = ba.constData() + offset;
if (rest > 0) {
// SHOULD NEVER HAPPEN !!!
uint8_t local[66];
memset(local, 0xFF, sizeof(local));
memcpy(local, startAddress, rest);
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
m_hw->bl_sendDataBlock(64, local);
} else {
m_hw->bl_sendLastBlock();
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
}
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
}
stopBootloader(); // there is no harm in stopping the bootloader even
} // if it was not started at all
#if 0
// test code:
uint16_t const totalBlocks = 100;
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
QThread::msleep(100);
}
#endif
m_hw->dcDownloadSetRunning(false);
m_hw->dcDownloadSetFinished(true);
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
// the object deletes itself ! This is the last line in run().
// Never touch the object after this statement
// m_hw->dcDownloadThreadFinalize(this);
}
DownloadThread::DownloadResult DownloadThread::sendStatus(int ret) const {
switch (ret) { // return values of dc are:
case 0: // 0: no answer by now
return DownloadResult::NOP; // 1: error
case 10: // 10: success
return DownloadResult::OK;
default:;
}
return DownloadResult::ERROR;
}
DownloadThread::DownloadResult
DownloadThread::sendNextAddress(int bNum) const {
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
int noAnswerCount = 0;
int errorCount = 0;
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
// qDebug() << "addr-block" << bNum << "...";
while (noAnswerCount <= 250) {
m_hw->bl_sendAddress(bNum);
QThread::msleep(100);
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) {
if (++errorCount >= 10) {
qCritical() << "addr-block" << bNum << "...FAILED";
return res;
}
} else { // res == DownloadResult::OK
// qInfo() << "addr-block" << bNum << "...OK";
// TODO: hier ins shared-mem schreiben
return res;
}
} else {
noAnswerCount += 1; // no answer by now
}
}
// wait max. about 3 seconds
return DownloadResult::TIMEOUT;
}
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
return DownloadResult::NOP;
}
DownloadThread::DownloadResult
DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
uint8_t local[66];
int const bAddr = bNum * 64;
int noAnswerCount = 0;
int errorCount = 0;
memcpy(local, binary.constData() + bAddr, 64);
local[64] = local[65] = 0x00;
// QByteArray b((const char *)(&local[0]), 64);
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
while (noAnswerCount <= 250) {
m_hw->bl_sendDataBlock(64, local);
QThread::msleep(10);
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
if (res != DownloadResult::NOP) {
if (res == DownloadResult::ERROR) {
if (++errorCount >= 10) {
qCritical() << "data for block" << bNum << "...FAILED";
return res;
}
} else {
// qInfo() << "data for block" << bNum << "OK";
// TODO: hier ins shared mem schreiben
return res;
}
} else {
noAnswerCount += 1; // no answer by now
}
}
// wait max. about 3 seconds
return DownloadResult::TIMEOUT;
}
bool DownloadThread::startBootloader() const {
qDebug() << "starting bootloader...";
int nTry = 5;
while (--nTry >= 0) {
m_hw->bl_startBL();
QThread::msleep(5000);
m_hw->bl_checkBL();
if (m_hw->bl_isUp()) {
qInfo() << "starting bootloader...OK";
QThread::msleep(5000);
return true;
} else {
qCritical() << "bootloader not up (" << nTry << ")";
}
}
qCritical() << "starting bootloader...FAILED";
return false;
}
bool DownloadThread::stopBootloader() const {
qDebug() << "stopping bootloader...";
int nTry = 5;
while (--nTry >= 0) {
m_hw->bl_stopBL();
QThread::msleep(500);
if (!m_hw->bl_isUp()) {
qInfo() << "stopping bootloader...OK";
return true;
}
}
qCritical() << "stopping bootloader...FAILED";
return false;
}
bool DownloadThread::resetDeviceController() const {
qDebug() << "resetting device controller...";
m_hw->bl_rebootDC();
// wait maximally 3 seconds, before starting bootloader
QThread::sleep(1);
qInfo() << "resetting device controller...OK";
return true;
}
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
qDebug() << "loading dc binary" << filename << "...";
QFile file(filename); // closed in destructor call
if (!file.exists()) {
qCritical() << file.fileName() << "does not exist";
return QByteArray();
}
if (!file.open(QIODevice::ReadOnly)) {
qCritical() << "cannot open file" << file.fileName();
return QByteArray();
}
qInfo() << "loading dc binary" << filename << "...OK";
return file.readAll();
}

View File

@@ -17,9 +17,19 @@
und hier in hwapi die entprellten Werte fuer Tueren und Kasse verwenden. und hier in hwapi die entprellten Werte fuer Tueren und Kasse verwenden.
Problem war: Signal "Kasse entnommen" war zu langsam -> manchmal abr nicht gesendet Problem war: Signal "Kasse entnommen" war zu langsam -> manchmal abr nicht gesendet
14.3.24 new function bool hwapi::cash_isCollectionStarted(void) const
padding three struct to 64 byte to avoid stack overflow when using
*/ */
#include "hwapi.h" #include "hwapi.h"
#include "download_thread.h"
#include "reporting_thread.h"
#include <cstring>
#include <QThread>
#include <QDebug>
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
static uint32_t hwapi_lastTotalAmount; static uint32_t hwapi_lastTotalAmount;
@@ -30,9 +40,15 @@ static uint8_t bl_startupStep;
hwapi::hwapi(QWidget *parent) : QObject(parent) hwapi::hwapi(QObject *parent) : QObject(parent)
{ {
// constructor // constructor
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;
qCritical() << " hwapi::hwapi() APP_BUILD_DATE:" << APP_BUILD_DATE;
qCritical() << " hwapi::hwapi() APP_BUILD_TIME:" << APP_BUILD_TIME;
qCritical() << " hwapi::hwapi() APP_EXTENDED_VERSION:" << APP_EXTENDED_VERSION;
qCritical() << "hwapi::hwapi() APP_EXTENDED_VERSION_LIB:" << APP_EXTENDED_VERSION_LIB;
// create or attach shared memory segment // create or attach shared memory segment
m_sharedMem = SharedMem::getShm(sizeof(SharedMem)); m_sharedMem = SharedMem::getShm(sizeof(SharedMem));
@@ -49,9 +65,21 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
// { // {
#ifdef THIS_IS_CA_MASTER #ifdef THIS_IS_CA_MASTER
#ifdef THIS_IS_CA_SLAVE
#error "SLAVE LIB COMPILED INTO MASTER"
#endif
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren! myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
#else
qCritical()<<"hwapi: error CAslave cannot include T_datif"; #endif
#ifdef THIS_IS_CA_SLAVE
#ifdef THIS_IS_CA_MASTER
#error "MASTER LIB COMPILED INTO MASTER"
#endif
#endif #endif
// } // }
@@ -103,16 +131,11 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
connect(runProcess, SIGNAL(runProc_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted())); connect(runProcess, SIGNAL(runProc_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted()));
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed())); connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed()));
connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed())); connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
} }
void hwapi::hwapi_slotPayProc(void) void hwapi::hwapi_slotPayProc(void)
{ {
//cash_paymentProcessing();
//doors_supervise();
//dcBL_cycle();
} }
@@ -206,6 +229,9 @@ void hwapi::sub_slotCoin16(void)
emit hwapi_doorAllDoorsClosed(); emit hwapi_doorAllDoorsClosed();
} }
void hwapi::coinAttached() {
emit hwapi_coinAttached();
}
/* /*
@@ -501,6 +527,8 @@ uint8_t hwapi::rtc_setDateTime(void) const
} }
void hwapi::rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const void hwapi::rtc_getTime(uint8_t *hh, uint8_t *mm, uint8_t *ss) const
{ {
epi_getTime(hh, mm, ss); epi_getTime(hh, mm, ss);
@@ -1784,6 +1812,8 @@ void hwapi::prn_sendText(QByteArray *buf) const
uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak; uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak;
uint8_t tmp66[66]; uint8_t tmp66[66];
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -2888,6 +2918,8 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
{ {
// return true if sending, false if cmd-stack is full // return true if sending, false if cmd-stack is full
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -2968,7 +3000,7 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
// 14.9.23 neu: Datensatz erst pruefen, [0..3] enthaelt "Psa>" und [4,5 =Abr.Nr] // 14.9.23 neu: Datensatz erst pruefen, [0..3] enthaelt "Psa>" und [4,5 =Abr.Nr]
uint16_t ds_acc_nr=uchar2uint(buf[5], buf[4]); uint16_t ds_acc_nr=uchar2uint(buf[5], buf[4]);
if (buf[0]=='P' && buf[1]=='S' && buf[2]=='A' && buf[3]=='>' && ds_acc_nr<60000) if (buf[0]=='P' && buf[1]=='s' && buf[2]=='a' && buf[3]=='>' && ds_acc_nr<60000)
{ {
// valid data, copy data to struct // valid data, copy data to struct
do do
@@ -2992,6 +3024,8 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
bool hwapi::prn_printAccountReceipt(void) const bool hwapi::prn_printAccountReceipt(void) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
return sendFDcmd_set(154, 0,0, 0,0,0,0); return sendFDcmd_set(154, 0,0, 0,0,0,0);
@@ -2999,6 +3033,8 @@ bool hwapi::prn_printAccountReceipt(void) const
bool hwapi::prn_printTestTicket(void) const bool hwapi::prn_printTestTicket(void) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
// 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
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -3054,7 +3090,9 @@ bool hwapi::cash_cancelPayment(void) const
{ {
// DB1: 1=encash 2=cancel & return coins // DB1: 1=encash 2=cancel & return coins
// 3=stop and keep coins in escrow // 3=stop and keep coins in escrow
epi_setNowCoinPay(false); // new since 20.9.23 //epi_setNowCoinPay(false); // new since 20.9.23
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
//qCritical() << "cash cancel payment and return coins"; //qCritical() << "cash cancel payment and return coins";
return sendFDcmd_set(156, 0,0, 2,0,0,0); return sendFDcmd_set(156, 0,0, 2,0,0,0);
} }
@@ -3064,7 +3102,8 @@ bool hwapi::cash_stopPayment(void) const
{ {
// DB1: 1=encash 2=cancel & return coins // DB1: 1=encash 2=cancel & return coins
// 3=stop and keep coins in escrow // 3=stop and keep coins in escrow
epi_setNowCoinPay(false); // new since 20.9.23 //epi_setNowCoinPay(false); // new since 20.9.23
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
//qCritical() << "cash stop payment and keep coins in escrow"; //qCritical() << "cash stop payment and keep coins in escrow";
// qCritical() << "emitting signal StopByPushbutton 2"; // qCritical() << "emitting signal StopByPushbutton 2";
emit hwapi_payStopByPushbutton(); emit hwapi_payStopByPushbutton();
@@ -3190,29 +3229,14 @@ void hwapi::sys_getDeviceConditions(struct T_moduleCondition *devCond) const
void hwapi::sys_getDynMachineConditions(uint8_t *leng, uint8_t *data) const void hwapi::sys_getDynMachineConditions(void *data) const
{ {
epi_restoreDynMachineConditions(leng, data); epi_restoreDynMachineConditions(data);
} }
void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const void hwapi::sys_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) const
{ {
epi_restoreDynMachineConditions(dynMachCond);
uint16_t LL, nn;
char *start;
uint8_t buf[70], leng;
epi_restoreDynMachineConditions(&leng, buf);
// Puffer in struct eintragen:
LL=sizeof(struct T_dynamicCondition);
start = &dynMachCond->allDoorsDebounced;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
} }
@@ -3228,10 +3252,17 @@ uint16_t hwapi::cash_getNrCoinsInVault(void) const
uint8_t hwapi::prn_getPrintResult() const uint8_t hwapi::prn_getPrintResult() const
{ {
// return: 0: unknown // return: 0: just printing, wait
// 1: OK - last template was printed succesful // 1: OK - last print was succesful
// 2: error - last template was not printed // 2: error - not printed
return 1;
struct T_dynamicCondition myDynMachCond;
sys_getDynMachineConditions(&myDynMachCond);
return myDynMachCond.resultOfLastTemplPrint;
// 0: unknown or printing in progress
// 1: OK, doc was printed 2: error, doc was not printed
} }
uint8_t hwapi::prn_getCurrentPrinterState() const uint8_t hwapi::prn_getCurrentPrinterState() const
@@ -3242,19 +3273,21 @@ uint8_t hwapi::prn_getCurrentPrinterState() const
// bit4: paper jam in cutter // bit4: paper jam in cutter
// bit6: no response bit7: serial rec. error // bit6: no response bit7: serial rec. error
// bit5: printer not ready // bit5: printer not ready
struct T_dynamicCondition dynCond;
memset(&dynCond, 0, sizeof(dynCond));
uint8_t lastPrinterStatus;
uint8_t buf[70], leng;
if (!epi_areDcDataValid()) // was set to 0 with print command if (!epi_areDcDataValid()) // was set to 0 with print command
return 0x40; // no response return 0x40; // no response
// 2nd way to get dyn.conditions: // 2nd way to get dyn.conditions:
epi_restoreDynMachineConditions(&leng, buf); epi_restoreDynMachineConditions(&dynCond);
lastPrinterStatus=buf[52]; return dynCond.lastPrinterStatus;
// oder mit:
//struct T_dynamicCondition myDynMachCond;
//sys_getDynMachineConditions(&myDynMachCond);
//myDynMachCond.lastPrinterStatus
return lastPrinterStatus;
} }
// 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices" // 21.4.23TS: change function "sendDeviceSettings()" to use this struct: "struct T_devices"
@@ -3285,22 +3318,15 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
// attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before // attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before
// cannot be used to see settings programmed by JsonFile // cannot be used to see settings programmed by JsonFile
uint8_t buf[64]; uint8_t buf[64];
uint8_t LL, nn; uint8_t LL;
tslib_strclr(buf,0,64); tslib_strclr(buf,0,64);
uint8_t *start;
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die??? //runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
// Puffer in struct eintragen: Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf));
start = &deviceSettings->kindOfPrinter;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
memcpy(deviceSettings, buf, sizeof(*deviceSettings));
} }
bool hwapi::sys_areDCdataValid(void) const bool hwapi::sys_areDCdataValid(void) const
@@ -3412,6 +3438,8 @@ bool hwapi::prn_printKombiticket(uint8_t nrOfKombi) const
if ((nrOfKombi<1) || (nrOfKombi>8)) if ((nrOfKombi<1) || (nrOfKombi>8))
return false; return false;
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
gpi_storeDcDataValid(0); gpi_storeDcDataValid(0);
@@ -3542,6 +3570,8 @@ bool hwapi::log_getVaultData(uint8_t *data) const
// new from 1.8.23 // new from 1.8.23
bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const
{ {
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
// print one out of eight stored last accounting receipts // print one out of eight stored last accounting receipts
// function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts // function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts
epi_clearDynMachineConditions(); // 24.6.23 epi_clearDynMachineConditions(); // 24.6.23
@@ -4176,22 +4206,55 @@ void hwapi::bna_sendSettings(uint16_t notesToAccept, uint16_t parameters,
// acceptanceLimit: device will stop acceptance once this amount is reached and // acceptanceLimit: device will stop acceptance once this amount is reached and
// optionally keep last bill in escrow until vend_success() // optionally keep last bill in escrow until vend_success()
// is called (put bill to stacker) or vend_failed() is called (return bill) // is called (put bill to stacker) or vend_failed() is called (return bill)
Q_UNUSED(notesToAccept);
Q_UNUSED(parameters); uint16_t noteAcc=notesToAccept;
Q_UNUSED(billDenomination); uint16_t para=parameters;
Q_UNUSED(acceptanceLimit); uint16_t denom[16];
uint32_t limit=acceptanceLimit;
uint8_t buf[64], nn, pp;
for (nn=0; nn<16; nn++)
denom[nn]=billDenomination[nn];
buf[0]=uint2uchar(noteAcc, LOWBYTE);
buf[1]=uint2uchar(noteAcc, HIGHBYTE);
buf[2]=uint2uchar(para, LOWBYTE);
buf[3]=uint2uchar(para, HIGHBYTE);
pp=4;
for (nn=0; nn<16; nn++)
{
buf[pp++]=uint2uchar(denom[nn], LOWBYTE);
buf[pp++]=uint2uchar(denom[nn], HIGHBYTE);
}
buf[pp++]=ulong2uchar(limit, 0);
buf[pp++]=ulong2uchar(limit, 1);
buf[pp++]=ulong2uchar(limit, 2);
buf[pp++]=ulong2uchar(limit, 3);
longFDcmd_set(35, 41, 0, pp, buf);
} }
void hwapi::bna_setCurrentAcceptance(uint16_t notesToAccept) const void hwapi::bna_setCurrentAcceptance(uint16_t notesToAccept) const
{ {
// can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid) // can be used to block notes dynamically, example: from now only 5€ bills are allowed (if only 3€ are to be paid)
Q_UNUSED(notesToAccept); uint8_t LB, HB;
uint16_t val=notesToAccept;
LB=uint2uchar(val, LOWBYTE);
HB=uint2uchar(val, HIGHBYTE);
sendFDcmd_set(170, 0, 0, LB, HB, LB, HB);
} }
void hwapi::bna_requestParameters(void) const void hwapi::bna_requestParameters(void) const
{ {
// send command to DC in order to get static invariable device parameters like currency // send command to DC in order to get static invariable device parameters like currency
// device must be powered and polled to get these // device must be powered and polled to get these
sendFDcmd_set(0, 41, 0, 0, 0, 0, 0);
} }
bool hwapi::bna_getAllParameters(struct T_bna *bna) const bool hwapi::bna_getAllParameters(struct T_bna *bna) const
@@ -4199,38 +4262,398 @@ bool hwapi::bna_getAllParameters(struct T_bna *bna) const
// get all constant data from reader (e.g. currency) // get all constant data from reader (e.g. currency)
// and actual Host-Settings (sent with bna_sendSettings() or json) // and actual Host-Settings (sent with bna_sendSettings() or json)
// retval = true if data are valid // retval = true if data are valid
Q_UNUSED(bna); uint8_t buf[66], nn, pp;
return false;
epi_restoreBnaParams(buf);
bna->setup=buf[0];
bna->FeatureLevel=buf[1];
bna->countryCode=uchar2uint(buf[3], buf[2]);
bna->scalingFactor=uchar2uint(buf[5], buf[4]);
bna->decimalPlace=buf[6];
bna->pad1=0;
bna->stackerCap=uchar2uint(buf[8], buf[7]);
bna->billSecureLevel=uchar2uint(buf[10], buf[9]);
bna->hasEscrow=buf[11];
for (nn=0; nn<16; nn++)
bna->accBillTypes[nn] = buf[nn+12];
bna->currentStackerLevel = uchar2uint(buf[29], buf[28]);
bna->intendedAccept = uchar2uint(buf[31], buf[30]);
bna->pad2=0;
pp=32;
for (nn=0; nn<16; nn++)
{
bna->billDenomination[nn] = uchar2uint(buf[pp+1], buf[pp]);
pp+=2;
}
if (bna->setup)
return true;
else
return false;
} }
void hwapi::bna_requestCurrentNotes(void) const void hwapi::bna_requestCurrentNotes(void) const
{ {
// send command to DC in order to get transaction data // send command to DC in order to get transaction data
sendFDcmd_set(0, 116, 0, 0, 0, 0, 0);
} }
uint8_t hwapi::bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const uint8_t hwapi::bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const
{ {
// returns number of collected bank notes since start-command (current transaction) // returns number of collected bank notes since start-command (current transaction)
// latestBill: last accepted bank note, value in cent // latestBill: not used
// currentNotes an array with up to 16 (further) notes collected // currentNotes[0] = last bill value
Q_UNUSED(latestBill); // currentNotes[1] = 0/1 1 if bill in escrow 0 if bill in cash box (stacker)
Q_UNUSED(currentNotes); // currentNotes[2,3] = total sum of collected bills within this transaction
return 0;
// incoming data:
//DB1: nr of bills (this transaction)
//DB2: 1 if bill in escrow
//DB3..6: collected amount
//DB7,8: denomination of last bill
uint8_t buf[10], haveBilInEscrow, haveNrOfBills;
uint16_t lastBillVal;
uint32_t collAmountThisTrans;
epi_restoreBnaCollection(buf);
haveNrOfBills=buf[0];
haveBilInEscrow=buf[1];
collAmountThisTrans = uchar2ulong(buf[5],buf[4],buf[3],buf[2]);
lastBillVal = uchar2uint(buf[7],buf[6]);
currentNotes[0]=latestBill; // just to get rid of compiler warning
currentNotes[0]=lastBillVal;
currentNotes[1]=haveBilInEscrow;
currentNotes[2]=uint16_t(collAmountThisTrans);
collAmountThisTrans>>=16;
currentNotes[3]=uint16_t(collAmountThisTrans);
return haveNrOfBills;
} }
void hwapi::bna_requestStackerLevel(void) const void hwapi::bna_requestStackerLevel(void) const
{ {
sendFDcmd_set(0, 42, 0, 0, 0, 0, 0);
} }
uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOfBills) const
{ {
// return val: nr of bills in stacker // return val: nr of bills in stacker
// countOfBills: array of up to 16 sums, countOfBills[0]=nr of 5€-bills in stacker // countOfBills[0..7] = count of bills of bill-type 0..7 (e.g. countOfBills[0]=nr of 5€-bills in stacker)
// countOfBills[1] for 10€ and so on // countOfBills[8..15] = value of bill-type 0...7
Q_UNUSED(amountInStacker);
Q_UNUSED(countOfBills); // receive data:
return 0; //je zwei Byte pro Wert,
//1…16: Anzahl Scheine pro Typ
//33…48: Wertigkeit der Typen
uint8_t buf[66], nn, pp, qq;
uint16_t nrOfBills[16], valueOfBills[16], anzahl=0;
uint32_t totalSum=0;
epi_restoreBnaContent(buf);
pp=0; qq=32;
for (nn=0; nn<16; nn++)
{
nrOfBills[nn]=uchar2uint(buf[pp+1],buf[pp]);
pp+=2;
valueOfBills[nn]=uchar2uint(buf[qq+1],buf[qq]);
qq+=2;
}
//qDebug()<< "CAmaster hwapi::bna_getStackerLevel " << nrOfBills[0] <<" "<< nrOfBills[1]
// <<" "<<nrOfBills[2]<<" "<<nrOfBills[3];
// qDebug()<< valueOfBills[0] <<" "<< valueOfBills[1] <<" "<<valueOfBills[2]<<" "<<valueOfBills[3];
// nur 8 zurueckmelden, mehr kommen derzeit von DC auch nicht
for (nn=0; nn<8; nn++)
{
countOfBills[nn]=nrOfBills[nn];
countOfBills[nn+7]=valueOfBills[nn];
}
for (nn=0; nn<8; nn++)
{
totalSum += nrOfBills[nn] * valueOfBills[nn];
anzahl += nrOfBills[nn];
}
//qDebug()<<"sum: "<< totalSum <<" Anzahl: "<<anzahl;
*amountInStacker=totalSum;
return anzahl;
} }
// new, 14.3.24TS
bool hwapi::cash_isCollectionStarted(void) const
{
struct T_dynamicCondition myDynMachCond;
sys_getDynMachineConditions(&myDynMachCond);
if (myDynMachCond.paymentInProgress >=2)
return true;
return false;
}
QObject const *hwapi::getAPI() {
return this;
}
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
SharedMem *data = SharedMem::getData();
if (!data) {
return false;
}
char *fNameBuffer = data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY];
size_t const size = sizeof(data->m_downLoadDC.m_filename);
std::memset(fNameBuffer, 0x00, size);
std::memcpy(fNameBuffer, dcFileToDownload.toStdString().c_str(),
std::min(size, strlen(fNameBuffer)-1));
data->m_downLoadDC.m_totalBlocks = 0;
data->m_downLoadDC.m_currentblockNumber = 0;
data->m_downLoadDC.m_requested = true;
data->m_downLoadDC.m_running = false; // download thread is not running
data->m_downLoadDC.m_finished = true;
return true;
}
bool hwapi::dcDownloadRequested() const {
SharedMem const *data = SharedMem::getData();
// should be false at entry
return data ? data->m_downLoadDC.m_requested.load() : false;
}
bool hwapi::dcDownloadResetRequest() const {
SharedMem *data = SharedMem::getData();
if (data) {
data->m_downLoadDC.m_requested = false;
}
return true;
}
bool hwapi::dcDownloadRequestAck() const {
SharedMem *data = SharedMem::getData();
if (data) {
if (data->m_downLoadDC.m_requested) {
data->m_downLoadDC.m_requested = false;
data->m_downLoadDC.m_running = true;
data->m_downLoadDC.m_finished = false;
}
}
return false;
}
bool hwapi::dcDownloadRunning() const {
SharedMem const *data = SharedMem::getDataConst();
if (data) {
int cnt = 10;
while (--cnt > 0) {
bool running = data->m_downLoadDC.m_running.load();
bool finished = data->m_downLoadDC.m_finished.load();
if (!running || finished) {
if (cnt < 3) {
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
}
QThread::msleep(500);
} else break;
}
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
return (cnt > 0);
}
return false;
}
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
delete dthread;
m_downloadThread = nullptr;
}
bool hwapi::dcDownloadFinished() {
SharedMem const *data = SharedMem::getDataConst();
if (data) {
int cnt = 10;
while ((--cnt > 0) &&
((data->m_downLoadDC.m_running.load() == true) &&
(data->m_downLoadDC.m_finished.load() == false))) {
QThread::sleep(1);
}
//if (cnt > 0) {
// delete m_downloadThread;
// m_downloadThread = nullptr;
// return true;
//}
}
return false;
}
// download thread
bool hwapi::dcDownloadThreadStart() {
m_downloadThread = new DownloadThread(this);
if (m_downloadThread) {
m_downloadThread->start();
int cnt = 10;
while (--cnt > 0 && !dcDownloadThreadRunning()) {
QThread::msleep(200);
}
return (cnt > 0);
}
return false;
}
bool hwapi::dcDownloadThreadRunning() const {
return (dcDownloadGetRunning() == true)
&& (dcDownloadGetFinished() == false);
}
bool hwapi::dcDownloadThreadFinished() const {
return (dcDownloadThreadRunning() == false);
}
// report thread
bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
int cnt = 10; // if download thread is running
while (--cnt > 0 && !dcDownloadRunning()) {
QThread::msleep(500);
}
if (cnt > 0) {
m_reportingThread = new ReportingThread(this);
if (m_reportingThread) {
m_reportingThread->start();
cnt = 10;
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
QThread::msleep(200);
}
return (cnt > 0);
}
}
return false;
}
bool hwapi::dcDownloadReportThreadRunning() const {
return m_reportingThread ? m_reportingThread->isRunning() : false;
}
void hwapi::dcDownloadReportThreadFinalize() {
if (m_reportingThread) {
if (m_reportingThread->isFinished()) {
delete m_reportingThread;
m_reportingThread = nullptr;
}
}
}
void hwapi::dcDownloadReportThreadQuit() {
if (m_reportingThread) {
m_reportingThread->quit();
}
}
bool hwapi::dcDownloadReportThreadFinished() const {
return m_reportingThread ? m_reportingThread->isFinished() : false;
}
bool hwapi::dcDownloadReportStart() const {
int cnt = 10;
while (--cnt > 0 && !dcDownloadRunning()) {
QThread::msleep(200);
}
return (cnt == 0);
}
bool hwapi::dcDownloadReportRunning() const {
return dcDownloadReportThreadRunning();
}
bool hwapi::dcDownloadReportFinished() {
int cnt = 10;
while (--cnt > 0 && !dcDownloadReportThreadFinished()) {
QThread::sleep(1);
}
if (cnt == 0 && !dcDownloadReportThreadFinished()) {
return false;
}
if (dcDownloadReportThreadFinished()) {
delete m_reportingThread;
m_reportingThread = nullptr;
}
return true;
}
QString hwapi::dcDownloadFileName() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY] : "";
}
bool hwapi::dcDownloadSetRequested(bool requested) {
SharedMem *data = SharedMem::getData();
if (data) {
data->m_downLoadDC.m_requested = requested;
return true;
}
return false;
}
bool hwapi::dcDownloadSetRunning(bool running) {
SharedMem *data = SharedMem::getData();
if (data) {
data->m_downLoadDC.m_running = running;
return true;
}
return false;
}
bool hwapi::dcDownloadSetFinished(bool finished) {
SharedMem *data = SharedMem::getData();
if (data) {
data->m_downLoadDC.m_finished = finished;
return true;
}
return false;
}
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
}
void hwapi::dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = currentBlockNumber;
}
uint16_t hwapi::dcDownloadGetTotalBlockNumber() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_totalBlocks.load() : 0;
}
uint16_t hwapi::dcDownloadGetCurrentBlockNumber() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_currentblockNumber.load() : 0;
}
bool hwapi::dcDownloadGetRequested() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_requested.load() : 0;
}
bool hwapi::dcDownloadGetRunning() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_running.load() : 0;
}
bool hwapi::dcDownloadGetFinished() const {
SharedMem const *data = SharedMem::getDataConst();
return data ? data->m_downLoadDC.m_running.load() : 0;
}

View File

@@ -1,5 +1,16 @@
#ifdef WIN32
#ifndef WIN32 #include <QCoreApplication>
#include "tslib.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
#else
#undef _FORTIFY_SOURCE #undef _FORTIFY_SOURCE
@@ -7,11 +18,11 @@
#include <stdio.h> #include <stdio.h>
// Must define the interpreter to be the dynamic linker // Must define the interpreter to be the dynamic linker
#ifdef __LP64__ //#ifdef __LP64__
#error "__LP64__ not defined for PTU5" //#error "__LP64__ not defined for PTU5"
#else //#else
const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3"; //const char service_interp[] __attribute__((section(".interp"))) = "/lib/ld-linux-armhf.so.3";
#endif //#endif
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {

155
src/reporting_thread.cpp Normal file
View File

@@ -0,0 +1,155 @@
#include "reporting_thread.h"
#include "shared_mem_buffer.h"
#include "hwapi.h"
#include <QDateTime>
#include <QDebug>
ReportingThread::ReportingThread(hwapi *hw)
: m_hw(hw)
, m_fileToDownload(m_hw->dcDownloadFileName()) {
}
ReportingThread::~ReportingThread() {
}
// download thread running in ca-slave sends reports of download process to
// each component which has connects for the corresponding signals.
void ReportingThread::run() {
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
static QString report("");
int cnt = 5;
while (!m_hw->dcDownloadGetRunning()) {
if (--cnt > 0) {
report = QString("%1 waiting for download to start %2")
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
.arg(cnt);
qCritical() << __LINE__ << "STATUS" << report;
emit m_hw->hwapi_reportDCDownloadStatus(report);
QThread::sleep(1);
} else break;
}
#if 0
if (cnt == 0) {
m_hw->dcDownloadResetRequest();
status = QString("%1 reset download request")
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
qCritical() << __LINE__ << "STATUS" << status;
emit m_hw->hwapi_reportDCDownloadStatus(status);
cnt = 5;
while (!m_hw->dcDownloadRunning()) {
if (--cnt > 0) {
QThread::sleep(1);
} else break;
}
if (cnt == 0) {
status = QString("%1 download request failure")
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
qCritical() << __LINE__ << "STATUS" << status;
emit m_hw->hwapi_reportDCDownloadFailure(status);
return;
}
}
uint16_t const tnr = 1750;
uint16_t cnr = 0;
while (cnr <= tnr) {
QThread::msleep(100);
QString report("");
if (cnr > 0) {
double percent = ((double)cnr / (double)tnr) * 100.0;
report = QString(": total blocks %1, current block %2 [%3]")
.arg(tnr).arg(cnr).arg(percent, 0, 'f', 2);
} else {
report = QString(": total blocks %1, current block %2 [0]")
.arg(tnr).arg(cnr);
}
status = QDateTime::currentDateTime().toString(Qt::ISODate) + report;
qCritical() << "STATUS" << status;
emit m_hw->hwapi_reportDCDownloadStatus(status);
cnr += 1;
}
if (tnr == cnr) {
m_hw->hwapi_reportDCDownloadSuccess(
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
} else {
m_hw->hwapi_reportDCDownloadFailure(
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
.arg(m_fileToDownload).arg(tnr).arg(cnr));
}
#endif
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
if (totalBlocks) {
qint64 const start = QDateTime::currentMSecsSinceEpoch();
double durationMillis = 0;
uint16_t currentBlockNumber = 0;
while (m_hw->dcDownloadGetRunning()) {
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
.arg(totalBlocks)
.arg(currentBlockNumber)
.arg(percent, 0, 'f', 2)
.arg(estimatedSecondsLeft, 0, 'f', 2);
qCritical() << "RT report" << report;
emit m_hw->hwapi_reportDCDownloadStatus(report);
QThread::msleep(100);
}
QThread::msleep(100);
if (totalBlocks == currentBlockNumber) {
m_hw->hwapi_reportDCDownloadSuccess(
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
} else {
m_hw->hwapi_reportDCDownloadFailure(
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
.arg(m_fileToDownload).arg(totalBlocks).arg(currentBlockNumber));
}
}
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
cnt = 10;
bool running = m_hw->dcDownloadGetRunning();
bool finished = m_hw->dcDownloadGetFinished();
while (--cnt > 0 && (running && !finished)) {
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
<< QString("line=%1 REPORT THREAD: WAIT FOR END OF DOWNLOAD THREAD %2 %3 (%4)")
.arg(__LINE__).arg(running).arg(finished).arg(cnt);
QThread::sleep(1);
running = m_hw->dcDownloadGetRunning();
finished = m_hw->dcDownloadGetFinished();
}
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
<< QString("line=%1 FINISH REPORT THREAD").arg(__LINE__);
}

175
src/runProc.cpp Executable file → Normal file
View File

@@ -2,7 +2,6 @@
#include <QDebug> #include <QDebug>
#include "controlBus.h" #include "controlBus.h"
#include "dcBL.h" #include "dcBL.h"
#include "interfaces.h"
static uint32_t hwapi_lastStartAmount; static uint32_t hwapi_lastStartAmount;
static uint32_t hwapi_lastTotalAmount; static uint32_t hwapi_lastTotalAmount;
@@ -29,25 +28,41 @@ T_runProc::T_runProc()
QTimer *runProc_callProcesses = new QTimer(); QTimer *runProc_callProcesses = new QTimer();
connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess())); connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess()));
runProc_callProcesses->setSingleShot(false); runProc_callProcesses->setSingleShot(false);
runProc_callProcesses->start(100); // in ms runProc_callProcesses->start(10); // in ms
hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted
// bit0: upper door 1:middle 2:lower 3=cash-box out // bit0: upper door 1:middle 2:lower 3=cash-box out
hwapi_triggerBL = new QTimer(); // hwapi_triggerBL = new QTimer();
connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart())); // connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
hwapi_triggerBL->setSingleShot(false); // hwapi_triggerBL->setSingleShot(false);
hwapi_triggerBL->stop(); // hwapi_triggerBL->stop();
myTO = new QTimer();
myTO->setSingleShot(true);
myTO->start(200);
} }
void T_runProc::runProc_slotProcess(void) void T_runProc::runProc_slotProcess(void)
{ {
#ifndef THIS_IS_CA_MASTER
bool const coinAttached = epi_getDI_CoinAttach();
// exchange: (atomically) replaces the underlying value of m_coinAttached
// with the value of coinAttached, returns the value of m_coinAttached
// before the call
if (m_coinAttached.exchange(coinAttached) == false) {
if (coinAttached) {
// old value was false, and new value is true
emit runProc_coinAttached();
}
}
cash_paymentProcessing(); cash_paymentProcessing();
doors_supervise(); doors_supervise();
bl_performComplStart(); // neu 1.12.23
dcBL_cycle(); dcBL_cycle();
#endif
} }
bool T_runProc::cash_startPayment(uint32_t amount) bool T_runProc::cash_startPayment(uint32_t amount)
@@ -160,6 +175,7 @@ uint8_t T_runProc::cash_paymentProcessing(void)
sub_getDynMachineConditions(&myDynMachCond); sub_getDynMachineConditions(&myDynMachCond);
payInProg= myDynMachCond.paymentInProgress; payInProg= myDynMachCond.paymentInProgress;
// Version Szeged: aug2023
// 0: stopped by timeout // 0: stopped by timeout
// 1: running 2: wait4lastCoin // 1: running 2: wait4lastCoin
// 3: payment stopped manually, coins in Escrow // 3: payment stopped manually, coins in Escrow
@@ -169,9 +185,26 @@ uint8_t T_runProc::cash_paymentProcessing(void)
// 7: coins returned 2 cases: due to cancel-button or printer-error // 7: coins returned 2 cases: due to cancel-button or printer-error
// 8: CoinChecker or MDB on Error // 8: CoinChecker or MDB on Error
// since Schoenau with bill and changer, nov2023
//0 = no payment
//will be set to 1 by cash_startCollection()
//neu 1: wait for devices getting ready for payment
//2 = payment,
//3 = wait for last coin/bill
//4 = Bezahlvorgang manuell beendet
//5 = payment stopped autom, amount collected, coins in Escrow
//6 = Bezahlvorgang beendet weil ZK voll
//4,5,6: payment done, keep on polling, wait for cash or return command
//7 = encash collected money from coin escrow into cash box
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
//9 = wait for changer result
//10= print refund receipt with "amountToReturn"
// qCritical() << "emitting signal payCancelled"; // qCritical() << "emitting signal payCancelled";
// emit runProc_payCancelled(); // emit runProc_payCancelled();
/*
// gabs bei Szeged, jetzt nicht mehr:
if (payInProg==8) if (payInProg==8)
{ {
// coin checker faulty, cannot start // coin checker faulty, cannot start
@@ -182,11 +215,11 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_coinCollectionAborted(); emit runProc_coinCollectionAborted();
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment //sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
} }
return 10; // error cannot start return 10; // error cannot start
} }*/
if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // Szeged
if ( payInProg==2 ) //8.12.23
{ {
// coin acceptance is active now: // coin acceptance is active now:
if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23 if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23
@@ -219,7 +252,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
} else } else
if (payInProg==3) // user pressed "Next/Continue", keep coin //if (payInProg==3) // user pressed "Next/Continue", keep coin
if (payInProg==4) // user pressed "Next/Continue", keep coin since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=3; collActiv=3;
@@ -227,7 +261,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByPushbutton(); emit runProc_payStopByPushbutton();
} else } else
if (payInProg==4) // max achieved, keep coins //if (payInProg==4) // max achieved, keep coins
if (payInProg==5) // max achieved, keep coins since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=4; collActiv=4;
@@ -235,7 +270,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByMax(); emit runProc_payStopByMax();
} else } else
if (payInProg==5) // escrow full, keep coins //if (payInProg==5) // escrow full, keep coins
if (payInProg==6) // escrow full, keep coins since nov2023
{ {
hwapi_paymentStarted++; hwapi_paymentStarted++;
collActiv=5; collActiv=5;
@@ -243,14 +279,14 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_payStopByEscrow(); emit runProc_payStopByEscrow();
} }
/* 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler // 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler
if ( (empState<10) || (empState>12)) // error if ( (empState<10) || (empState>12)) // error
{ {
collActiv=13; //collActiv=13;
hwapi_paymentStarted=90; //hwapi_paymentStarted=90;
qCritical() << "emitting signal payStopByError" << empState; //qCritical() << "emitting signal payStopByError" << empState;
emit runProc_payStopByError(); //emit runProc_payStopByError();
} */ }
} }
@@ -258,7 +294,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
{ {
// coin collection finished, but coins kept until printing done // coin collection finished, but coins kept until printing done
collActiv=2; collActiv=2;
if (payInProg==6) // coins encashed //if (payInProg==6) // coins encashed
if (payInProg==7) // coins encashed since nov2023
{ {
collActiv=6; collActiv=6;
hwapi_paymentStarted++; hwapi_paymentStarted++;
@@ -266,7 +303,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
emit runProc_coinProcessJustStopped(); emit runProc_coinProcessJustStopped();
} else } else
if (payInProg==7) // coins returned, printing failed //if (payInProg==7) // coins returned, printing failed
if (payInProg==0) // coins returned, printing failed since nov2023
{ {
collActiv=7; collActiv=7;
hwapi_paymentStarted++; hwapi_paymentStarted++;
@@ -362,22 +400,7 @@ void T_runProc::changer_getAllParameters(struct T_changer *mw)
void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCond) void T_runProc::sub_getDynMachineConditions(struct T_dynamicCondition *dynMachCond)
{ {
epi_restoreDynMachineConditions(dynMachCond);
uint16_t LL, nn;
char *start;
uint8_t buf[70], leng;
epi_restoreDynMachineConditions(&leng, buf);
// Puffer in struct eintragen:
LL=sizeof(struct T_dynamicCondition);
start = &dynMachCond->allDoorsDebounced;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
} }
@@ -654,7 +677,7 @@ bool T_runProc::bl_isUp(void)
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176) receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
{ {
qDebug() << "got BL response to readFWversion"; qDebug() << "got BL response to readFWversion";
epi_clrRawReceivedString(); //epi_clrRawReceivedString();
return true; return true;
} }
// response to "start BL" // response to "start BL"
@@ -662,7 +685,7 @@ bool T_runProc::bl_isUp(void)
receivedData[3]==223 && receivedData[4] ==131 ) receivedData[3]==223 && receivedData[4] ==131 )
{ {
qDebug() << "hwapi_bl_isUp: got BL response to start"; qDebug() << "hwapi_bl_isUp: got BL response to start";
epi_clrRawReceivedString(); //epi_clrRawReceivedString();
return true; return true;
} }
} }
@@ -677,7 +700,8 @@ void T_runProc::bl_completeStart(void)
bool T_runProc::bl_performComplStart(void) bool T_runProc::bl_performComplStart(void)
{ {
// must be called cyclic by timer bool result;
static uint8_t retryCtr; static uint8_t retryCtr;
if ((bl_startupStep<1) || (bl_startupStep>10)) if ((bl_startupStep<1) || (bl_startupStep>10))
@@ -691,58 +715,69 @@ bool T_runProc::bl_performComplStart(void)
if (bl_startupStep==2) if (bl_startupStep==2)
{ {
qDebug()<<"rebooting";
bl_rebootDC(); bl_rebootDC();
hwapi_triggerBL->stop(); myTO->stop();
hwapi_triggerBL->start(1000); // call next step in 1s myTO->start(500);
retryCtr=0; retryCtr=0;
bl_startupStep++; bl_startupStep++;
} else } else
if (bl_startupStep==3) if (bl_startupStep==3)
{ {
//qDebug()<<"starting BL"; if (!myTO->isActive())
bl_startBL(); {
hwapi_triggerBL->stop(); qDebug()<<"starting BL";
hwapi_triggerBL->start(100); bl_startBL();
bl_startupStep++; myTO->stop();
myTO->start(500);
bl_startupStep++;
}
} else } else
if (bl_startupStep==4) if (bl_startupStep==4)
{ {
//if (!myTO->isActive()) if (!myTO->isActive())
//{ {
bl_checkBL(); qDebug()<<"checking BL";
hwapi_triggerBL->stop(); bl_checkBL();
hwapi_triggerBL->start(100); myTO->stop();
bl_startupStep++; myTO->start(200);
bl_startupStep++;
//} }
} else } else
if (bl_startupStep==5) if (bl_startupStep==5)
{ {
hwapi_triggerBL->stop(); if (!myTO->isActive())
if (bl_isUp())
{ {
bl_startupStep=99; qDebug()<<"step 5";
// BL is up and running result = bl_isUp();
} else qDebug()<<"BL result: "<< result;
{ if (result)
retryCtr++; // start again
if (retryCtr>=15)
{ {
bl_startupStep=99; bl_startupStep=99;
//qDebug()<<"BL error!!!"; qDebug()<<"BL is working now...";
// BL is up and running
return true;
} else } else
{ {
bl_startupStep=3; retryCtr++; // start again
//qDebug()<<"BL retry..."; if (retryCtr>=10)
{
bl_startupStep=99;
qDebug()<<"BL error!!!";
} else
{
bl_startupStep=3;
myTO->stop();
myTO->start(200);
qDebug()<<"BL retry...";
}
} }
} }
} }
return true; return false;
} }

View File

@@ -1,811 +0,0 @@
#include <stdint.h>
#include <QString>
#include <QDebug>
#include <QDateTime>
#include "tslib.h"
#include "sendWRcmd.h"
#include "shared_mem_buffer.h"
void indat_PrnPwr(void);
void sendWRcmd_INI(void)
{
sendWRcmd_clrCmdStack();
sendWRcmd_clrCmd4Stack();
sendFDcmd_clrStack();
}
// Command Stack for commands without parameters
//static uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
//static uint8_t nrOfCmdsInQueue;
/* convention: use simple (not rotating) FIFO Stack:
Example: nrOfCmdsInQueue=4 then
nextAsynchsendCmd0[0]=cmd1 // was stored as first
nextAsynchsendCmd0[1]=cmd2
nextAsynchsendCmd0[2]=cmd3
nextAsynchsendCmd0[3]=cmd4 // came in as last
Send: [0] first, then move buffer 1 down:
nextAsynchsendCmd0[0]=cmd2
nextAsynchsendCmd0[1]=cmd3
nextAsynchsendCmd0[2]=cmd4
nextAsynchsendCmd0[3]=0;
nrOfCmdsInQueue=3 now
*/
void sendWRcmd_clrCmdStack(void)
{
uint8_t nn;
for (nn=0; nn<CMDSTACKDEPTH; nn++)
SharedMem::write()->nextAsynchsendCmd0[nn]=0;
SharedMem::write()->nrOfCmdsInQueue=0;
}
bool sendWRcmd_setSendCommand0(uint16_t nextCmd)
{
// write Command to memory, wait for transport
uint8_t ciq=SharedMem::read()->nrOfCmdsInQueue;
if (ciq>=CMDSTACKDEPTH)
{
qDebug() << "cannot save cmd because stack is full";
return false; // not possible
}
SharedMem::write()->nextAsynchsendCmd0[ciq++]=nextCmd;
SharedMem::write()->nrOfCmdsInQueue=ciq;
//qDebug() << "PI cmd queued:"<< nextCmd << ", saved, pp=" << nrOfCmdsInQueue;
return true; // ok, will be sent
}
uint16_t sendWRcmd_getSendCommand0(void)
{
uint16_t nxtAsynchCmd, data;
uint8_t nn, ll;
uint8_t ciq=SharedMem::read()->nrOfCmdsInQueue;
if (ciq==0 || ciq>CMDSTACKDEPTH)
return 0; // error
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd0[0];
// move Puffer down by one element
if (ciq>0)
ll=ciq-1;
else
ll=0;
for (nn=0; nn<ll; nn++)
{
data=SharedMem::read()->nextAsynchsendCmd0[nn+1];
SharedMem::write()->nextAsynchsendCmd0[nn]=data;
}
SharedMem::write()->nrOfCmdsInQueue=ciq;
//qDebug() << "PI cmd queued:"<< nxtAsynchCmd << ", restored, pp now =" << nrOfCmdsInQueue;
return nxtAsynchCmd;
}
//---------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------
// Command Stack for commands with 4 parameters
/*
static uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
static uint8_t nextCmd4para1[CMD4STACKDEPTH];
static uint8_t nextCmd4para2[CMD4STACKDEPTH];
static uint8_t nextCmd4para3[CMD4STACKDEPTH];
static uint8_t nextCmd4para4[CMD4STACKDEPTH];
static uint8_t nrOfCmds4InQueue;
*/
void sendWRcmd_clrCmd4Stack(void)
{
uint8_t nn;
for (nn=0; nn<CMD4STACKDEPTH; nn++)
{
SharedMem::write()->nextAsynchsendCmd4[nn]=0;
SharedMem::write()->nextCmd4para1[nn]=0;
SharedMem::write()->nextCmd4para2[nn]=0;
SharedMem::write()->nextCmd4para3[nn]=0;
SharedMem::write()->nextCmd4para4[nn]=0;
}
SharedMem::write()->nrOfCmds4InQueue=0;
}
bool sendWRcmd_setSendCommand4(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint8_t dat3, uint8_t dat4)
{
// write Command to memory, wait for transport
uint8_t ciq;
ciq=SharedMem::read()->nrOfCmds4InQueue;
if (ciq>=CMD4STACKDEPTH)
{
qDebug() << "cannot save cmd because stack is full";
return false; // not possible
}
SharedMem::write()->nextAsynchsendCmd4[ciq]=nextCmd;
SharedMem::write()->nextCmd4para1[ciq]=dat1;
SharedMem::write()->nextCmd4para2[ciq]=dat2;
SharedMem::write()->nextCmd4para3[ciq]=dat3;
SharedMem::write()->nextCmd4para4[ciq]=dat4;
ciq++;
SharedMem::write()->nrOfCmds4InQueue=ciq;
//qDebug() << QDateTime::currentDateTime().time()
// << "sendWRcmd 4 byte saved, pp=" << nextCmd
// << " para: " << SharedMem::getDataConst()->nextCmd4para1[pp];
return true; // ok, will be sent
}
/*
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
{
uint16_t nxtAsynchCmd;
uint8_t nn, ll;
if (nrOfCmds4InQueue==0 || nrOfCmds4InQueue>CMD4STACKDEPTH)
return 0; // error
nxtAsynchCmd=nextAsynchsendCmd4[0];
*dat1=nextCmd4para1[0];
*dat2=nextCmd4para2[0];
*dat3=nextCmd4para3[0];
*dat4=nextCmd4para4[0];
//qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue;
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
// move Puffer down by one element
if (CMD4STACKDEPTH>0)
ll=CMD4STACKDEPTH-1;
else
ll=0;
for (nn=0; nn<ll; nn++)
{
nextAsynchsendCmd4[nn]=nextAsynchsendCmd4[nn+1];
nextCmd4para1[nn]=nextCmd4para1[nn+1];
nextCmd4para2[nn]=nextCmd4para2[nn+1];
nextCmd4para3[nn]=nextCmd4para3[nn+1];
nextCmd4para4[nn]=nextCmd4para4[nn+1];
}
if (nrOfCmds4InQueue>0)
nrOfCmds4InQueue--;
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
return nxtAsynchCmd;
}
*/
uint16_t sendWRcmd_getSendCommand4(uint8_t *dat1, uint8_t *dat2, uint8_t *dat3, uint8_t *dat4)
{
uint16_t nxtAsynchCmd, data;
uint8_t nn;
uint8_t ciq=SharedMem::read()->nrOfCmds4InQueue;
if (ciq==0 || ciq > CMD4STACKDEPTH)
return 0; // error
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd4[0];
*dat1=SharedMem::read()->nextCmd4para1[0];
*dat2=SharedMem::read()->nextCmd4para2[0];
*dat3=SharedMem::read()->nextCmd4para3[0];
*dat4=SharedMem::read()->nextCmd4para4[0];
//qDebug() << "cmd4 restored to send from [0]; pp=" << nrOfCmds4InQueue;
//qDebug() << " data1: " << nextCmd4para1[0] << " data2: " << nextCmd4para2[0] <<
// " data3: " << nextCmd4para3[0] << " data4: " << nextCmd4para4[0];
// move Puffer down by one element
if (ciq>0) ciq--;
for (nn=0; nn<ciq; nn++)
{
data=SharedMem::read()->nextAsynchsendCmd4[nn+1];
SharedMem::write()->nextAsynchsendCmd4[nn]=data;
data=SharedMem::read()->nextCmd4para1[nn+1];
SharedMem::write()->nextCmd4para1[nn]=data;
data=SharedMem::read()->nextCmd4para2[nn+1];
SharedMem::write()->nextCmd4para2[nn]=data;
data=SharedMem::read()->nextCmd4para3[nn+1];
SharedMem::write()->nextCmd4para3[nn]=data;
data=SharedMem::read()->nextCmd4para4[nn+1];
SharedMem::write()->nextCmd4para4[nn]=data;
}
SharedMem::write()->nrOfCmds4InQueue=ciq;
return nxtAsynchCmd;
}
void sendWRcmd_clrCmd8Stack(void)
{
uint8_t nn;
for (nn=0; nn<CMD8STACKDEPTH; nn++)
{
SharedMem::write()->nextAsynchsendCmd8[nn]=0;
SharedMem::write()->nextCmd8para1[nn]=0;
SharedMem::write()->nextCmd8para2[nn]=0;
SharedMem::write()->nextCmd8para3[nn]=0;
SharedMem::write()->nextCmd8para4[nn]=0;
}
SharedMem::write()->nrOfCmds8InQueue=0;
}
bool sendWRcmd_setSendCommand8(uint16_t nextCmd, uint8_t dat1, uint8_t dat2, uint16_t dat3, uint32_t dat4)
{
// write Command to memory, wait for transport
uint8_t ciq;
ciq=SharedMem::read()->nrOfCmds8InQueue;
if (ciq>=CMD8STACKDEPTH)
{
qDebug() << "cannot save cmd because stack is full";
return false; // not possible
}
SharedMem::write()->nextAsynchsendCmd8[ciq]=nextCmd;
SharedMem::write()->nextCmd8para1[ciq]=dat1;
SharedMem::write()->nextCmd8para2[ciq]=dat2;
SharedMem::write()->nextCmd8para3[ciq]=dat3;
SharedMem::write()->nextCmd8para4[ciq]=dat4;
ciq++;
SharedMem::write()->nrOfCmds8InQueue=ciq;
return true; // ok, will be sent
}
uint16_t sendWRcmd_getSendCommand8(uint8_t *dat1, uint8_t *dat2, uint16_t *dat3, uint32_t *dat4)
{
uint16_t nxtAsynchCmd, data;
uint8_t nn;
uint8_t ciq=SharedMem::read()->nrOfCmds8InQueue;
if (ciq==0 || ciq > CMD8STACKDEPTH)
return 0; // error
nxtAsynchCmd=SharedMem::read()->nextAsynchsendCmd8[0];
*dat1=SharedMem::read()->nextCmd8para1[0];
*dat2=SharedMem::read()->nextCmd8para2[0];
*dat3=SharedMem::read()->nextCmd8para3[0];
*dat4=SharedMem::read()->nextCmd8para4[0];
// move buffer down by one element
if (ciq>0) ciq--;
for (nn=0; nn<ciq; nn++)
{
data=SharedMem::read()->nextAsynchsendCmd8[nn+1];
SharedMem::write()->nextAsynchsendCmd8[nn]=data;
data=SharedMem::read()->nextCmd8para1[nn+1];
SharedMem::write()->nextCmd8para1[nn]=data;
data=SharedMem::read()->nextCmd8para2[nn+1];
SharedMem::write()->nextCmd8para2[nn]=data;
data=SharedMem::read()->nextCmd8para3[nn+1];
SharedMem::write()->nextCmd8para3[nn]=data;
data=SharedMem::read()->nextCmd8para4[nn+1];
SharedMem::write()->nextCmd8para4[nn]=data;
}
SharedMem::write()->nrOfCmds8InQueue=ciq;
return nxtAsynchCmd;
}
//static uint8_t sendAsynchDataBuf[160]; // no stack, only ONE buffer
//static uint8_t sendAsyDatLen;
bool sendWRcmd_setSendBlock160(uint8_t leng, uint8_t *buf)
{
if (leng>SENDASYDAT_BUFFSIZE) leng=SENDASYDAT_BUFFSIZE;
SharedMem::write()->sendAsyDatLen=leng;
tslib_strclr(SharedMem::write()->sendAsynchDataBuf, 0, SENDASYDAT_BUFFSIZE);
for (uint8_t nn=0; nn<leng; nn++)
SharedMem::write()->sendAsynchDataBuf[nn]=buf[nn];
return true; // ok, will be sent
}
uint8_t sendWRcmd_getSendBlock160(uint8_t *leng, uint8_t *buf)
{
uint8_t dl=SharedMem::read()->sendAsyDatLen;
*leng=dl;
for (uint8_t nn=0; nn<dl; nn++)
buf[nn]=SharedMem::read()->sendAsynchDataBuf[nn];
SharedMem::write()->sendAsyDatLen=0;
//tslib_strclr(SharedMem::write()->sendAsynchDataBuf, 0, SENDASYDAT_BUFFSIZE);
return *leng;
}
// ------------------------------------------------------------------------------------
// MDB Sendind Data are store here for next transport to DC (Device Controller)
// Transport to Slave runs every 100ms, answer from mdb-slave (e.g. coin changer) comes rigth
// with next slave answer
// start with: SENDDIRCMD_EXCHGMDB,
// send crude data from here to DC, DC to mdb slaves, mdb answer, return here within 50ms
//static uint8_t Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE];
//static uint8_t Sdata_mdbSendLen;
uint8_t epi_store64ByteSendData(uint8_t length, uint8_t *buf)
{
if (length>MDBSEND_BUFFSIZE) length=MDBSEND_BUFFSIZE;
// HWapi writes data to be forwarded to DC and further to mdb-device
for (uint8_t nn=0; nn<length; nn++)
SharedMem::write()->Sdata_mdbSendBuffer[nn]=buf[nn];
SharedMem::write()->Sdata_mdbSendLen=length;
return 0;
}
uint8_t gpi_restore64ByteSendData(uint8_t *length, uint8_t *buf)
{
// datif reads data to forward to dc
uint8_t dl=SharedMem::read()->Sdata_mdbSendLen;
for (uint8_t nn=0; nn<dl; nn++)
buf[nn]=SharedMem::read()->Sdata_mdbSendBuffer[nn];
*length=dl;
SharedMem::write()->Sdata_mdbSendLen=0;
return 0;
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
//---------------------------------------- Printer Text Fifo -------------------------
//static uint8_t prnDataParameters[];
//static uint8_t prnDataBufferUser;
void epi_storeUserOfSendingTextBuffer(uint8_t user, uint8_t para1, uint8_t para2, uint8_t para3, uint8_t para4 )
{
// user=1: Text-Print is using this buffer
// 2: QR-code-Printer is using this buffer
SharedMem::write()->prnDataBufferUser=user;
SharedMem::write()->prnDataParameters[0]=para1;
SharedMem::write()->prnDataParameters[1]=para2;
SharedMem::write()->prnDataParameters[2]=para3;
SharedMem::write()->prnDataParameters[3]=para4;
// qDebug() << "new user stored: " << user;
}
uint8_t gpi_getUserOfSendingTextBuffer(uint8_t *para1, uint8_t *para2, uint8_t *para3, uint8_t *para4)
{
// user=1: Text-Print is using this buffer
// 2: QR-code-Printer is using this buffer
//qDebug() << "returning user "<< prnDataBufferUser;
*para1=SharedMem::read()->prnDataParameters[0];
*para2=SharedMem::read()->prnDataParameters[1];
*para3=SharedMem::read()->prnDataParameters[2];
*para4=SharedMem::read()->prnDataParameters[3];
return SharedMem::read()->prnDataBufferUser;
}
// Sending Text Fifo
// ONE printer doc consists of 20 x 64 byte
// #define MAXNROF_PRNBYTES 64
// #define MAXNROF_PRNBLOCKS 20
//static char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
//static uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
//static uint8_t pPrnDataBuff; // points to next waiting printer text
// defined above, needed if more then one text is stored (before sent)
// every block will be sent after 100ms, if 8 blocks are stored within this 100ms
// then pointer goes up to 8. Important: FIFO!!!!!!!!
void epi_resetPrinterStack(void)
{
SharedMem::write()->pPrnDataBuff=0;
}
uint8_t epi_storePrnText(char *buf, uint8_t leng)
{
// store text from Gui in next higher free memory 0....9
uint16_t len;
uint8_t pp, nn;
pp=SharedMem::read()->pPrnDataBuff; // next free memory block with 64byte each
if (pp>=MAXNROF_PRNBLOCKS)
return 1; // not possible, no free mem
//len=tslib_strlen(buf); // kennt keine Binärzeichen!!!!!!
len=leng;
if (len>MAXNROF_PRNBYTES)
len=MAXNROF_PRNBYTES;
tslib_strclr(SharedMem::write()->Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
for (nn=0; nn<len; nn++)
SharedMem::write()->Sdata_PRN_TEXT[pp][nn]=buf[nn]; // copy new text into buffer
if (SharedMem::read()->pPrnDataBuff<MAXNROF_PRNBLOCKS)
SharedMem::write()->pPrnDataBuff++; // inc pointer if end not yet reached
return 0; // OK
}
uint8_t gpi_restorePrnText(uint8_t *retbuf)
{
// read printer text and send to slave, size of retbuf == 64
// always read from [0] because this is the oldest (Fifo)
// then move all text lines down by one and dec pointer
uint8_t nn, mm, pp=SharedMem::read()->pPrnDataBuff;
char buf[MAXNROF_PRNBYTES];
if (pp==0) // next free memory block with 64byte each
return 1; // no text in buffer
// example: pp=5: then buffers [0...4] are occupied
for (nn=0; nn<MAXNROF_PRNBYTES; nn++)
retbuf[nn] = uint8_t (SharedMem::read()->Sdata_PRN_TEXT[0][nn]); // restore oldest text
// now copy textline [1] to [0], then
// copy textline [2] to [1], then
// copy textline [3] to [2] .... upto [pp-1] to [pp-2]
// hint: copying from 9....0 would delete all strings!!!!!!
for (nn=0; nn<(pp-1); nn++)
{
for (mm=0; mm<MAXNROF_PRNBYTES; mm++)
buf[mm]=SharedMem::read()->Sdata_PRN_TEXT[nn+1][mm];
for (mm=0; mm<MAXNROF_PRNBYTES; mm++)
SharedMem::write()->Sdata_PRN_TEXT[nn][mm]=buf[mm];
}
if (pp>0) pp--;
SharedMem::write()->pPrnDataBuff=pp;
// example: pp=4: then buffers [0...3] are still occupied, pp=0: all buffers empty
// now clear highest copyed line (which became free now)
tslib_strclr(SharedMem::write()->Sdata_PRN_TEXT[pp], 0, MAXNROF_PRNBYTES);
// optionally: clear all remaining higher lines:
for (nn=(pp+1); nn<MAXNROF_PRNBLOCKS; nn++)
tslib_strclr(SharedMem::write()->Sdata_PRN_TEXT[nn], 0, MAXNROF_PRNBYTES);
return 0;
}
uint8_t gpi_chk4remainingText(void)
{
// retval: 0: no more textline left (to send) >0: nr of 64byte-blocks
return (SharedMem::read()->pPrnDataBuff);
}
// ---------------------------------------------------------------------------------
// 11.4.23 neu, Kommando direkt an "FastDevice"-protokoll senden, nicht mehr umsetzen
// ---------------------------------------------------------------------------------
/*
// header
static uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
static uint8_t nextFDrdCmd[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 nextFDpara2[FDCMD_STACKDEPTH];
static uint8_t nextFDpara3[FDCMD_STACKDEPTH];
static uint8_t nextFDpara4[FDCMD_STACKDEPTH];
// long data:
static uint8_t longFDlength[FDCMD_STACKDEPTH];
static uint8_t longFDpara[FDCMD_STACKDEPTH][64];
static uint8_t p_nextFDcmdsInQueue;
*/
/* convention: use simple (not rotating) FIFO Stack:
Example: nrOfCmdsInQueue=4 then
nextAsynchsendCmd0[0]=cmd1 // was stored as first
nextAsynchsendCmd0[1]=cmd2
nextAsynchsendCmd0[2]=cmd3
nextAsynchsendCmd0[3]=cmd4 // came in as last
Send: [0] first, then move buffer 1 down:
nextAsynchsendCmd0[0]=cmd2
nextAsynchsendCmd0[1]=cmd3
nextAsynchsendCmd0[2]=cmd4
nextAsynchsendCmd0[3]=0;
nrOfCmdsInQueue=3 now
*/
void sendFDcmd_clrStack(void)
{
uint8_t nn;
for (nn=0; nn<FDCMD_STACKDEPTH; nn++)
{
SharedMem::write()->nextFDwrCmd[nn]=0;
SharedMem::write()->nextFDrdCmd[nn]=0;
SharedMem::write()->nextFDblkNr[nn]=0;
SharedMem::write()->nextFDshort[nn]=0;
SharedMem::write()->nextFDpara1[nn]=0;
SharedMem::write()->nextFDpara2[nn]=0;
SharedMem::write()->nextFDpara3[nn]=0;
SharedMem::write()->nextFDpara4[nn]=0;
SharedMem::write()->longFDlength[nn]=0;
memset(&SharedMem::write()->longFDpara[nn][0],0,64);
}
SharedMem::write()->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)
{
// write Command to memory, wait for transport
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
if (pFDcmd >=FDCMD_STACKDEPTH)
{
qDebug() << "cannot save cmd because stack is full";
return false; // not possible
}
SharedMem::write()->nextFDwrCmd[pFDcmd]=nextWrCmd;
SharedMem::write()->nextFDrdCmd[pFDcmd]=nextRdCmd;
SharedMem::write()->nextFDblkNr[pFDcmd]=blockNum;
SharedMem::write()->nextFDpara1[pFDcmd]=dat1;
SharedMem::write()->nextFDpara2[pFDcmd]=dat2;
SharedMem::write()->nextFDpara3[pFDcmd]=dat3;
SharedMem::write()->nextFDpara4[pFDcmd]=dat4;
//qDebug() << "data with 4 data byte saved, pp=" << pFDcmd;
//qDebug() << " dat1=" << nextCmd4para1[pFDcmd] << " dat2=" << nextCmd4para2[pFDcmd]
// << " dat3=" << nextCmd4para3[pFDcmd] << " dat4=" << nextCmd4para4[pFDcmd];
SharedMem::write()->nextFDshort[pFDcmd]=1; // 1=short
pFDcmd++;
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
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;
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
if (pFDcmd>=FDCMD_STACKDEPTH)
{
qDebug() << "cannot save cmd because stack is full";
return false; // not possible
}
SharedMem::write()->nextFDwrCmd[pFDcmd]=nextWrCmd;
SharedMem::write()->nextFDrdCmd[pFDcmd]=nextRdCmd;
SharedMem::write()->nextFDblkNr[pFDcmd]=blockNum;
SharedMem::write()->longFDlength[pFDcmd]=length;
for (nn=0; nn<64; nn++)
SharedMem::write()->longFDpara[pFDcmd][nn]=data[nn];
SharedMem::write()->nextFDshort[pFDcmd]=2;
pFDcmd++;
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
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)
{
uint8_t nn, mm, data; // ll
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
if (pFDcmd==0 || pFDcmd>FDCMD_STACKDEPTH)
return false; // not possible
*nextWrCmd=SharedMem::read()->nextFDwrCmd[0];
*nextRdCmd=SharedMem::read()->nextFDrdCmd[0];
*blockNum=SharedMem::read()->nextFDblkNr[0];
*dat1=SharedMem::read()->nextFDpara1[0];
*dat2=SharedMem::read()->nextFDpara2[0];
*dat3=SharedMem::read()->nextFDpara3[0];
*dat4=SharedMem::read()->nextFDpara4[0];
//qDebug() << "sendFDcmd_get [0]; pp=" << SharedMem::read()->p_nextFDcmdsInQueue;
//qDebug() << " data1: " << SharedMem::read()->nextCmd4para1[0] << " data2: " << SharedMem::read()->nextCmd4para2[0] <<
// " data3: " << SharedMem::read()->nextCmd4para3[0] << " data4: " << SharedMem::read()->nextCmd4para4[0];
// move Puffer down by one element
//if (FDCMD_STACKDEPTH>0)
// ll=FDCMD_STACKDEPTH-1;
//else
// ll=0;
if (pFDcmd>0) pFDcmd--; else pFDcmd=0;
//for (nn=0; nn<ll; nn++)
for (nn=0; nn<pFDcmd; nn++)
{
data=SharedMem::read()->nextFDwrCmd[nn+1];
SharedMem::write()->nextFDwrCmd[nn]=data;
data=SharedMem::read()->nextFDrdCmd[nn+1];
SharedMem::write()->nextFDrdCmd[nn]=data;
data=SharedMem::read()->nextFDblkNr[nn+1];
SharedMem::write()->nextFDblkNr[nn]=data;
data=SharedMem::read()->nextFDpara1[nn+1];
SharedMem::write()->nextFDpara1[nn]=data;
data=SharedMem::read()->nextFDpara2[nn+1];
SharedMem::write()->nextFDpara2[nn]=data;
data=SharedMem::read()->nextFDpara3[nn+1];
SharedMem::write()->nextFDpara3[nn]=data;
data=SharedMem::read()->nextFDpara4[nn+1];
SharedMem::write()->nextFDpara4[nn]=data;
data=SharedMem::read()->nextFDshort[nn+1];
SharedMem::write()->nextFDshort[nn] = data;
data=SharedMem::read()->longFDlength[nn+1];
SharedMem::write()->longFDlength[nn] = data;
for (mm=0; mm<64; mm++)
{
SharedMem::write()->longFDpara[nn][mm] = SharedMem::read()->longFDpara[nn+1][mm];
}
}
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
//qDebug() << "cmd4 after push down: pp=" << nrOfCmds4InQueue;
// clear released buffer:
//for (nn=p_nextFDcmdsInQueue; nn<FDCMD_STACKDEPTH; nn++)
//{
SharedMem::write()->nextFDwrCmd[pFDcmd]=0;
SharedMem::write()->nextFDrdCmd[pFDcmd]=0;
SharedMem::write()->nextFDblkNr[pFDcmd]=0;
SharedMem::write()->nextFDpara1[pFDcmd]=0;
SharedMem::write()->nextFDpara2[pFDcmd]=0;
SharedMem::write()->nextFDpara3[pFDcmd]=0;
SharedMem::write()->nextFDpara4[pFDcmd]=0;
SharedMem::write()->nextFDshort[pFDcmd]=0;
SharedMem::write()->longFDlength[pFDcmd]=0;
for (mm=0; mm<64; mm++)
SharedMem::write()->longFDpara[pFDcmd][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
}
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 (SharedMem::read()->p_nextFDcmdsInQueue==0)
return 0;
if (SharedMem::read()->nextFDshort[0]==1)
return 1;
return 2;
}
uint8_t check4FDshortCmd(void)
{
// returns number of waiting command, max FDCMD_STACKDEPTH
return SharedMem::read()->p_nextFDcmdsInQueue;
}
uint8_t check4freeFDshortCmd(void)
{
// returns number of free places in short-command stack
return FDCMD_STACKDEPTH - SharedMem::read()->p_nextFDcmdsInQueue;
}
bool longFDcmd_get(uint8_t *nextWrCmd, uint8_t *nextRdCmd, uint8_t *blockNum, uint8_t *length, uint8_t *data)
{
uint8_t nn, mm, uctmp;
uint8_t pFDcmd=SharedMem::read()->p_nextFDcmdsInQueue;
if (pFDcmd==0 || pFDcmd>FDCMD_STACKDEPTH)
return false; // not possible
*nextWrCmd=SharedMem::read()->nextFDwrCmd[0];
*nextRdCmd=SharedMem::read()->nextFDrdCmd[0];
*blockNum=SharedMem::read()->nextFDblkNr[0];
*length = SharedMem::read()->longFDlength[0];
for (mm=0; mm<64; mm++)
data[mm] = SharedMem::read()->longFDpara[0][mm];
if (pFDcmd>0) pFDcmd--; else pFDcmd=0;
//for (nn=0; nn<ll; nn++)
for (nn=0; nn<pFDcmd; nn++)
{
uctmp=SharedMem::read()->nextFDwrCmd[nn+1];
SharedMem::write()->nextFDwrCmd[nn]=uctmp;
uctmp=SharedMem::read()->nextFDrdCmd[nn+1];
SharedMem::write()->nextFDrdCmd[nn]=uctmp;
uctmp=SharedMem::read()->nextFDblkNr[nn+1];
SharedMem::write()->nextFDblkNr[nn]=uctmp;
uctmp=SharedMem::read()->nextFDpara1[nn+1];
SharedMem::write()->nextFDpara1[nn]=uctmp;
uctmp=SharedMem::read()->nextFDpara2[nn+1];
SharedMem::write()->nextFDpara2[nn]=uctmp;
uctmp=SharedMem::read()->nextFDpara3[nn+1];
SharedMem::write()->nextFDpara3[nn]=uctmp;
uctmp=SharedMem::read()->nextFDpara4[nn+1];
SharedMem::write()->nextFDpara4[nn]=uctmp;
uctmp=SharedMem::read()->nextFDshort[nn+1];
SharedMem::write()->nextFDshort[nn]=uctmp;
uctmp=SharedMem::read()->longFDlength[nn+1];
SharedMem::write()->longFDlength[nn]=uctmp;
for (mm=0; mm<64; mm++)
{
SharedMem::write()->longFDpara[nn][mm] = SharedMem::read()->longFDpara[nn+1][mm];
}
}
SharedMem::write()->p_nextFDcmdsInQueue=pFDcmd;
// clear released buffer:
SharedMem::write()->nextFDwrCmd[pFDcmd]=0;
SharedMem::write()->nextFDrdCmd[pFDcmd]=0;
SharedMem::write()->nextFDblkNr[pFDcmd]=0;
SharedMem::write()->nextFDpara1[pFDcmd]=0;
SharedMem::write()->nextFDpara2[pFDcmd]=0;
SharedMem::write()->nextFDpara3[pFDcmd]=0;
SharedMem::write()->nextFDpara4[pFDcmd]=0;
SharedMem::write()->nextFDshort[pFDcmd]=0;
SharedMem::write()->longFDlength[pFDcmd]=0;
for (mm=0; mm<64; mm++)
SharedMem::write()->longFDpara[pFDcmd][mm] = 0;
return true; // ok, will be sent
}

File diff suppressed because it is too large Load Diff

View File

@@ -6,12 +6,15 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "datei.h" #include "datei.h"
#include "interfaces.h" // #include "dynamic-machine-conditions.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;
@@ -1772,15 +1775,25 @@ void epi_clearCurrentPayment(void)
void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue) void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
{ {
uint8_t pLC=SharedMem::read()->p_lastCoin; uint8_t pLC;
SharedMem::write()->store_insertedAmount=insertedAmount;
SharedMem::write()->store_lastCoinType[pLC]=lastCoinType; // 21.3.24 attention: if bit 15 in lastCoinType is set then we got a bill not a coin
SharedMem::write()->store_lastCoinValue[pLC]=lastCoinValue; SharedMem::write()->store_insertedAmount=insertedAmount;
pLC++; if (lastCoinType & 0x8000)
SharedMem::write()->p_lastCoin=pLC; {
SharedMem::write()->store_curPayNewCoin++; // then it's a banknote
//qCritical()<<"gpi_storeCurrentPayment got banknote, total: "<<insertedAmount;
} else
{
//qCritical()<<"gpi_storeCurrentPayment "<<insertedAmount<<" " << lastCoinType<<" " << lastCoinValue;
pLC=SharedMem::read()->p_lastCoin;
SharedMem::write()->store_lastCoinType[pLC]=lastCoinType;
SharedMem::write()->store_lastCoinValue[pLC]=lastCoinValue;
pLC++;
SharedMem::write()->p_lastCoin=pLC;
SharedMem::write()->store_curPayNewCoin++;
}
//qDebug()<<"gpi_storeCurrentPayment "<<insertedAmount<<" " << lastCoinType<<" " << lastCoinValue;
} }
uint32_t epi_CurrentPaymentGetAmount(void) uint32_t epi_CurrentPaymentGetAmount(void)
@@ -1818,6 +1831,13 @@ bool epi_CurrentPaymentGetAllCoins(uint16_t *types, uint16_t *values)
return true; return true;
} }
/*
int nn;
for (nn=0; nn<8; nn++)
{
data[nn]=SharedMem::read()->store_bnaCollect[nn];
}
*/
//uint64_t stor_wakSrc; //uint64_t stor_wakSrc;
//uint8_t stor_reason; //uint8_t stor_reason;
@@ -1914,32 +1934,17 @@ void epi_restoreDeviceConditions(uint8_t *leng, uint8_t *data)
void epi_clearDynMachineConditions(void) void epi_clearDynMachineConditions(void)
{ {
uint8_t nn; memset(&SharedMem::write()->dynMachCond, 0, sizeof(struct T_dynamicCondition));
SharedMem::write()->store_machCondLen=0;
for (nn=0; nn<64; nn++)
SharedMem::write()->store_machCond[nn] = 0;
} }
void gpi_storeDynMachineConditions(void const *data)
void gpi_storeDynMachineConditions(uint8_t leng, uint8_t *data)
{ {
uint8_t nn; SharedMem::write()->dynMachCond = *(struct T_dynamicCondition const *)(data);
if (leng>64) leng=64; }
SharedMem::write()->store_machCondLen=leng;
// tslib_strcpy(data, SharedMem::write()->store_machCond, leng);
for (nn=0; nn<leng; nn++)
SharedMem::write()->store_machCond[nn] = data[nn];
} void epi_restoreDynMachineConditions(void *data)
void epi_restoreDynMachineConditions(uint8_t *leng, uint8_t *data)
{ {
uint8_t nn, LL; *(struct T_dynamicCondition *)(data) = SharedMem::read()->dynMachCond;
LL=SharedMem::read()->store_machCondLen;
*leng=LL;
//tslib_strcpy(SharedMem::read()->store_machCond, data, SharedMem::read()->store_machCondLen);
for (nn=0; nn<LL; nn++)
data[nn] = SharedMem::read()->store_machCond[nn];
} }
@@ -2054,13 +2059,50 @@ uint16_t epi_getNrOfCoinsInCashBox(void)
void gpi_storeDcDataValid(bool isVal) void gpi_storeDcDataValid(bool isVal)
{ {
SharedMem::write()->store_DcDataAreValid = isVal; bool now=SharedMem::read()->store_DcDataAreValid;
if (isVal != now)
{
SharedMem::write()->store_DcDataAreValid = isVal;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib sets DcDataValid to "<<isVal;
#else
qDebug()<<"slave lib sets DcDataValid to "<<isVal;
#endif
}
} }
void epi_setDcDataValid(void)
{
bool now=SharedMem::read()->store_DcDataAreValid;
if (now==false)
{
SharedMem::write()->store_DcDataAreValid = true;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib SET DcDataValid";
#else
qDebug()<<"slave lib SET DcDataValid";
#endif
}
}
void epi_resetDcDataValid(void)
{
bool now=SharedMem::read()->store_DcDataAreValid;
if (now==true)
{
SharedMem::write()->store_DcDataAreValid = false;
#ifdef THIS_IS_CA_MASTER
qDebug()<<"master lib RESET DcDataValid";
#else
qDebug()<<"slave lib RESET DcDataValid";
#endif
}
}
bool epi_areDcDataValid() bool epi_areDcDataValid()
{ {
return SharedMem::read()->store_DcDataAreValid; return SharedMem::read()->store_DcDataAreValid;
} }
// .................................................................................... // ....................................................................................
@@ -2332,7 +2374,67 @@ void epi_restoreTubeLevel(uint8_t *data)
void gpi_storeBnaParams(uint8_t *data)
{
int nn;
for (nn=0; nn<64; nn++)
{
SharedMem::write()->store_bnaParameter[nn]=data[nn];
}
}
void epi_restoreBnaParams(uint8_t *data)
{
int nn;
for (nn=0; nn<64; nn++)
{
data[nn]=SharedMem::read()->store_bnaParameter[nn];
}
}
void gpi_storeBnaCollection(uint8_t *data)
{
int nn;
for (nn=0; nn<8; nn++)
{
SharedMem::write()->store_bnaCollect[nn]=data[nn];
}
}
void epi_restoreBnaCollection(uint8_t *data)
{
int nn;
for (nn=0; nn<8; nn++)
{
data[nn]=SharedMem::read()->store_bnaCollect[nn];
}
}
void gpi_storeBnaContent(uint8_t *data)
{
int nn;
for (nn=0; nn<64; nn++)
{
SharedMem::write()->store_bnaContent[nn]=data[nn];
}
}
void epi_restoreBnaContent(uint8_t *data)
{
int nn;
for (nn=0; nn<64; nn++)
{
data[nn]=SharedMem::read()->store_bnaContent[nn];
}
}