Compare commits
29 Commits
1.99.3
...
dc-downloa
Author | SHA1 | Date | |
---|---|---|---|
23fe319497 | |||
3fc8562a2b | |||
544bab4332 | |||
35f7d56c2a | |||
a63e7018a4 | |||
b05325e5f4 | |||
5cfc346317 | |||
15151a9df4 | |||
b7449ff4a2 | |||
04055e9607 | |||
bdef3ff652 | |||
352b550190 | |||
5599c56114 | |||
0723ef335c | |||
ef31911e74 | |||
100ada06f8 | |||
fb5cf3cc6a | |||
287106d8f3 | |||
e7f45251a9 | |||
0839254f06 | |||
6005fddc66 | |||
392b849a9b | |||
6fa689f142 | |||
fc28666946 | |||
3bf3e741a0 | |||
f6efb1ee9a | |||
a1237749dc | |||
f5613d5aad | |||
3564bac8d4 |
@@ -1,6 +1,6 @@
|
|||||||
CONFIG += plugin
|
CONFIG += plugin
|
||||||
QT -= gui
|
QT -= gui
|
||||||
QT += serialport
|
QT += widgets serialport
|
||||||
|
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
@@ -33,6 +33,8 @@ QMAKE_CXXFLAGS += -C
|
|||||||
QMAKE_CXXFLAGS += -O2 -O
|
QMAKE_CXXFLAGS += -O2 -O
|
||||||
QMAKE_CXXFLAGS += -g
|
QMAKE_CXXFLAGS += -g
|
||||||
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
QMAKE_CXXFLAGS += -Wno-deprecated-copy
|
||||||
|
# QMAKE_CXXFLAGS += -fsanitize=address
|
||||||
|
# QMAKE_CXXFLAGS += -fno-omit-frame-pointer
|
||||||
|
|
||||||
QMAKE_LFLAGS += -Wl,-e,main
|
QMAKE_LFLAGS += -Wl,-e,main
|
||||||
|
|
||||||
@@ -90,9 +92,7 @@ HEADERS += \
|
|||||||
$${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/datei.cpp \
|
$${PWD}/src/datei.cpp \
|
||||||
@@ -103,9 +103,7 @@ SOURCES += \
|
|||||||
$${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
|
||||||
|
BIN
build/CArunGui
Executable file
BIN
build/CArunGui
Executable file
Binary file not shown.
1147
build/carun_out.txt
Normal file
1147
build/carun_out.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
build/dCArun
Executable file
BIN
build/dCArun
Executable file
Binary file not shown.
2492
build/interfaces.h
Executable file
2492
build/interfaces.h
Executable file
File diff suppressed because it is too large
Load Diff
BIN
build/libCAmaster.so
Executable file
BIN
build/libCAmaster.so
Executable file
Binary file not shown.
BIN
build/libCAslave.so
Executable file
BIN
build/libCAslave.so
Executable file
Binary file not shown.
170
dCArun/CArun.cpp
170
dCArun/CArun.cpp
@@ -1,170 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -1,56 +0,0 @@
|
|||||||
#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
|
|
@@ -1,5 +1,5 @@
|
|||||||
QT += core
|
QT += core gui
|
||||||
QT += serialport
|
QT +=widgets serialport
|
||||||
QT +=network
|
QT +=network
|
||||||
# for TCP-IP
|
# for TCP-IP
|
||||||
|
|
||||||
@@ -11,6 +11,8 @@ 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
|
||||||
|
|
||||||
@@ -39,15 +41,18 @@ 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
|
||||||
|
@@ -1,14 +1,15 @@
|
|||||||
#include "CArun.h"
|
#include "mainwindow.h"
|
||||||
//#include "message_handler.h"
|
//#include "message_handler.h"
|
||||||
#include <QCoreApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
int thisisglobal;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication myapp(argc, argv);
|
int ret;
|
||||||
|
QApplication myapp(argc, argv);
|
||||||
QCoreApplication::setOrganizationName("ATB");
|
QApplication::setApplicationName("CArunGui");
|
||||||
QCoreApplication::setApplicationName("CArun");
|
QApplication::setApplicationVersion(APP_VERSION);
|
||||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||||
@@ -17,9 +18,16 @@ int main(int argc, char *argv[])
|
|||||||
//setDebugLevel(QtMsgType::QtDebugMsg);
|
//setDebugLevel(QtMsgType::QtDebugMsg);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
CArun carun;
|
MainWindow myMainWin;
|
||||||
|
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();
|
||||||
|
|
||||||
return myapp.exec();
|
ret=myapp.exec();
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
439
dCArun/mainwindow.cpp
Executable file
439
dCArun/mainwindow.cpp
Executable file
@@ -0,0 +1,439 @@
|
|||||||
|
#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
|
||||||
|
pluginLoader->setFileName("/usr/lib/libCAmaster.so"); // for ptu5
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
72
dCArun/mainwindow.h
Executable file
72
dCArun/mainwindow.h
Executable file
@@ -0,0 +1,72 @@
|
|||||||
|
#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
|
210
dCArun/stepList.h
Executable file
210
dCArun/stepList.h
Executable file
@@ -0,0 +1,210 @@
|
|||||||
|
#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
|
609
dCArun/win01_com.cpp
Executable file
609
dCArun/win01_com.cpp
Executable file
@@ -0,0 +1,609 @@
|
|||||||
|
#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"
|
||||||
|
QString bs, cn;
|
||||||
|
int br, ci;
|
||||||
|
|
||||||
|
|
||||||
|
this->updateGui();
|
||||||
|
*nextScreen=0; // 0=no change
|
||||||
|
*useNavi=0;
|
||||||
|
|
||||||
|
if (myStep==0)
|
||||||
|
{
|
||||||
|
// 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
|
||||||
|
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";
|
||||||
|
|
||||||
|
bs="115200";
|
||||||
|
br=5;
|
||||||
|
//cn="COM14"; // Windows
|
||||||
|
cn="ttymxc2"; // PTU5
|
||||||
|
ci=2;
|
||||||
|
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
myTO->start(100); // restart
|
||||||
|
myStep++;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (myStep==1)
|
||||||
|
{
|
||||||
|
if (!myTO->isActive())
|
||||||
|
{
|
||||||
|
if (HWaccess->dc_isPortOpen())
|
||||||
|
{
|
||||||
|
myStep++;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: port is still closed, restarting..";
|
||||||
|
}
|
||||||
|
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=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: got no answer from DC, retry..";
|
||||||
|
}
|
||||||
|
myTO->start(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (myStep==4)
|
||||||
|
{
|
||||||
|
HWaccess->dc_autoRequest(1);
|
||||||
|
AutSendButton->setChecked(true); // taste "druecken"
|
||||||
|
myStep++;
|
||||||
|
myTO->start(2000);
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (myStep==5)
|
||||||
|
{
|
||||||
|
if (!myTO->isActive())
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
if (myStep==6)
|
||||||
|
{
|
||||||
|
// restart autoconnect cycle
|
||||||
|
myTO->start(100); // restart
|
||||||
|
myStep=0;
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (myStep==7)
|
||||||
|
{
|
||||||
|
// stay here, DC connection is up and running
|
||||||
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (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();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
107
dCArun/win01_com.h
Executable file
107
dCArun/win01_com.h
Executable file
@@ -0,0 +1,107 @@
|
|||||||
|
#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
|
@@ -3,7 +3,7 @@
|
|||||||
#ifndef SER_H
|
#ifndef SER_H
|
||||||
#define SER_H
|
#define SER_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <QObject>
|
#include <QMainWindow>
|
||||||
//#include <QString>
|
//#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QSerialPort>
|
#include <QSerialPort>
|
||||||
|
@@ -134,7 +134,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadThread;
|
||||||
|
class hwinf;
|
||||||
class T_datif : public QObject
|
class T_datif : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -165,13 +166,14 @@ class T_datif : public QObject
|
|||||||
T_prot *myDCIF;
|
T_prot *myDCIF;
|
||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
uint8_t selectedSlaveAddr;
|
uint8_t selectedSlaveAddr;
|
||||||
|
hwinf *m_hw = nullptr;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
char datif_cycleSend();
|
char datif_cycleSend();
|
||||||
void StoredRecData();
|
void StoredRecData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_datif(QObject *parent = nullptr);
|
T_datif(hwinf *hw, QObject *parent = nullptr);
|
||||||
|
|
||||||
void resetChain(void);
|
void resetChain(void);
|
||||||
char isPortOpen(void);
|
char isPortOpen(void);
|
||||||
|
@@ -27,6 +27,7 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
|||||||
#define hwapi_H
|
#define hwapi_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
//#include <QTabWidget>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -92,13 +93,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;
|
ReportingThread *m_reportingThread = nullptr;
|
||||||
DownloadThread *m_downloadThread;
|
DownloadThread *m_downloadThread = nullptr;
|
||||||
//QTimer *hwapi_triggerBL;
|
//QTimer *hwapi_triggerBL;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit hwapi(QObject *parent = nullptr);
|
explicit hwapi(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
#ifdef THIS_IS_CA_MASTER
|
#ifdef THIS_IS_CA_MASTER
|
||||||
T_datif *myDatif;
|
T_datif *myDatif;
|
||||||
@@ -1318,10 +1318,6 @@ 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
|
// download device controller
|
||||||
bool dcDownloadRequest(QString const &fileToDownload) const override;
|
bool dcDownloadRequest(QString const &fileToDownload) const override;
|
||||||
bool dcDownloadRequested() const override;
|
bool dcDownloadRequested() const override;
|
||||||
@@ -1359,9 +1355,9 @@ public:
|
|||||||
virtual QObject const *getAPI() override;
|
virtual QObject const *getAPI() override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void hwapi_reportDCDownloadStatus(QString const&) const override;
|
void hwapi_reportDCDownloadStatus(QString const&) const;
|
||||||
void hwapi_reportDCDownloadSuccess(QString const&) const override;
|
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
||||||
void hwapi_reportDCDownloadFailure(QString const&) const override;
|
void hwapi_reportDCDownloadFailure(QString const&) const;
|
||||||
|
|
||||||
void hwapi_templatePrintFinished_OK(void) const override;
|
void hwapi_templatePrintFinished_OK(void) const override;
|
||||||
void hwapi_templatePrintFinished_Err(void) const override;
|
void hwapi_templatePrintFinished_Err(void) const override;
|
||||||
@@ -1387,7 +1383,9 @@ signals:
|
|||||||
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
||||||
void hwapi_doorAllDoorsClosed(void) const override;
|
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);
|
||||||
@@ -1415,7 +1413,8 @@ signals:
|
|||||||
void sub_slotCoin15(void);
|
void sub_slotCoin15(void);
|
||||||
void sub_slotCoin16(void);
|
void sub_slotCoin16(void);
|
||||||
|
|
||||||
void coinAttached();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -170,7 +170,6 @@ 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
|
||||||
@@ -183,53 +182,44 @@ 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;
|
||||||
uint8_t padd01;
|
// 31
|
||||||
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;
|
||||||
@@ -238,11 +228,10 @@ 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 coinAttached;
|
char reserve;
|
||||||
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;
|
||||||
@@ -277,7 +266,6 @@ struct T_dynamicCondition
|
|||||||
|
|
||||||
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;
|
||||||
@@ -287,10 +275,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
|
||||||
@@ -304,15 +292,7 @@ struct T_dynamicCondition
|
|||||||
// bit5: printer not ready
|
// bit5: printer not ready
|
||||||
uint8_t startupTestIsRunning;
|
uint8_t startupTestIsRunning;
|
||||||
|
|
||||||
uint8_t padd01;
|
//54
|
||||||
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
|
||||||
@@ -349,7 +329,6 @@ 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
|
||||||
@@ -358,33 +337,27 @@ 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
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2326,9 +2299,6 @@ 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
|
// download device controller
|
||||||
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
|
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
|
||||||
@@ -2420,7 +2390,6 @@ signals:
|
|||||||
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
||||||
virtual void hwapi_doorAllDoorsClosed(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
|
/* GH Version, bringt Fehler
|
||||||
@@ -2509,12 +2478,10 @@ signals:
|
|||||||
|
|
||||||
// hier dazwischen: Umstellung ALLER Prototypen
|
// hier dazwischen: Umstellung ALLER Prototypen
|
||||||
// hier von =0 auf {} durch Gerhard
|
// hier von =0 auf {} durch Gerhard
|
||||||
//#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2"
|
|
||||||
|
#define HWINF_iid "Atb.Psa1256ptu5.software.HWapi/5.2"
|
||||||
// 7.11.2023: bna functions activated
|
// 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)
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
#ifndef SERIAL_FRAME_H
|
#ifndef SERIAL_FRAME_H
|
||||||
#define SERIAL_FRAME_H
|
#define SERIAL_FRAME_H
|
||||||
#include <QObject>
|
#include <QMainWindow>
|
||||||
#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 QObject
|
class T_prot : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
// #include <functional>
|
||||||
|
|
||||||
class hwapi;
|
class hwapi;
|
||||||
class ReportingThread : public QThread {
|
class ReportingThread : public QThread {
|
||||||
@@ -12,6 +13,14 @@ public:
|
|||||||
ReportingThread(hwapi *hw);
|
ReportingThread(hwapi *hw);
|
||||||
~ReportingThread();
|
~ReportingThread();
|
||||||
|
|
||||||
|
//void setFunction(std::function<void(QString const&)> f) {
|
||||||
|
// m_f = f;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//std::function<void(QString const&)> function() {
|
||||||
|
// return m_f;
|
||||||
|
//}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// reporting thread does not have a running event queue, and therefore
|
// reporting thread does not have a running event queue, and therefore
|
||||||
// no slots. signals work the usual way.
|
// no slots. signals work the usual way.
|
||||||
@@ -20,6 +29,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
hwapi *m_hw;
|
hwapi *m_hw;
|
||||||
QString m_fileToDownload;
|
QString m_fileToDownload;
|
||||||
|
//std::function<void(QString const&)> m_f;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPORTING_THREAD_H_INCLUDED
|
#endif // REPORTING_THREAD_H_INCLUDED
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
#define RUN_PROCESS_H
|
#define RUN_PROCESS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <QObject>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include "tslib.h"
|
#include "tslib.h"
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
#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"
|
||||||
@@ -36,10 +35,6 @@ 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);
|
||||||
@@ -85,7 +80,6 @@ signals:
|
|||||||
void runProc_doorCBinAndAllDoorsClosed(void);
|
void runProc_doorCBinAndAllDoorsClosed(void);
|
||||||
void runProc_doorAllDoorsClosed(void);
|
void runProc_doorAllDoorsClosed(void);
|
||||||
|
|
||||||
void runProc_coinAttached();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -321,6 +321,10 @@ struct SharedMem
|
|||||||
std::atomic_bool m_finished{false};
|
std::atomic_bool m_finished{false};
|
||||||
} m_downLoadDC;
|
} m_downLoadDC;
|
||||||
|
|
||||||
|
// meta-data
|
||||||
|
char os_release[64];
|
||||||
|
char date_of_creation[32];
|
||||||
|
char creator[128]; // name of application plus pid
|
||||||
|
|
||||||
static QSharedMemory *getShm(std::size_t s = 0);
|
static QSharedMemory *getShm(std::size_t s = 0);
|
||||||
|
|
||||||
|
601
include/shared_mem_buffer.h.new
Normal file
601
include/shared_mem_buffer.h.new
Normal file
@@ -0,0 +1,601 @@
|
|||||||
|
#ifndef SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
#define SHARED_MEM_BUFFER_INCLUDED_H
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
|
#include <QSharedMemory>
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
|
bool shdMem_firstUse(void);
|
||||||
|
|
||||||
|
// Vorsicht: im shared memory ist kein QString erlaubt!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
// nur standard C Typen!!!!!!
|
||||||
|
// also auch kein QByteArray o.ä.
|
||||||
|
|
||||||
|
// Vorsicht: Zugriffe auf Comport NICHT ins shared mem --> Absturz!!!!
|
||||||
|
|
||||||
|
struct SharedMem
|
||||||
|
{
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ------------------ Comport Control --------------------------------
|
||||||
|
bool rs_portIsOpen;
|
||||||
|
bool AutoEmissionOn;
|
||||||
|
bool Sdata_serialTestResult;
|
||||||
|
uint8_t Sdata_pProtResultOk;
|
||||||
|
uint16_t Sdata_receivedDataLength;
|
||||||
|
uint8_t Sdata_receivedDataBlock[64];
|
||||||
|
uint8_t ndbs, pari, nsb, br;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t Sdata_lastResult;
|
||||||
|
uint8_t Sdata_OverallResult;
|
||||||
|
bool Sdata_startSV;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ------------------ Data INPUT --------------------------------
|
||||||
|
|
||||||
|
bool indat_savePrnPwr;
|
||||||
|
bool indat_saveMifPwr;
|
||||||
|
bool indat_MdbIsOn;
|
||||||
|
//QString indat_HWversion;
|
||||||
|
//QString indat_SWversion;
|
||||||
|
//QString indat_DCstate;
|
||||||
|
|
||||||
|
#define versionBufferLen 32
|
||||||
|
char indat_HWversion[versionBufferLen];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char indat_SWversion[versionBufferLen];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_5;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char indat_DCstate[versionBufferLen];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_6;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct Sdata
|
||||||
|
{
|
||||||
|
uint64_t slaveUID;
|
||||||
|
uint8_t UIDstr[8];
|
||||||
|
} Sdata;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_7;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct T_globTime
|
||||||
|
{
|
||||||
|
// Reihenfolge nicht vertauschen!!!!!
|
||||||
|
uint8_t hour;
|
||||||
|
uint8_t minute;
|
||||||
|
uint8_t second;
|
||||||
|
uint8_t Year;
|
||||||
|
uint8_t Month;
|
||||||
|
uint8_t DayOfMonth;
|
||||||
|
uint8_t DayOfWeek; // 1=monday...7
|
||||||
|
uint8_t reserve1;
|
||||||
|
|
||||||
|
uint16_t MinutesOfToday;
|
||||||
|
uint16_t reserve2;
|
||||||
|
|
||||||
|
uint32_t SecondsOfToday;
|
||||||
|
|
||||||
|
uint8_t IsLeapyear;
|
||||||
|
uint8_t nextLeap;
|
||||||
|
uint8_t lastLeap;
|
||||||
|
uint8_t hoursOfWeek;
|
||||||
|
|
||||||
|
uint16_t minOfWeek;
|
||||||
|
uint16_t hoursOfMonth;
|
||||||
|
uint16_t minOfMonth;
|
||||||
|
uint16_t dayOfYear;
|
||||||
|
uint16_t hoursOfYear;
|
||||||
|
uint16_t reserve3;
|
||||||
|
|
||||||
|
uint32_t minOfYear;
|
||||||
|
|
||||||
|
uint8_t squareOutMode;
|
||||||
|
uint8_t free1;
|
||||||
|
uint16_t reserve4;
|
||||||
|
uint32_t minOfMillenium;
|
||||||
|
// bis hierher 44byts
|
||||||
|
uint32_t free2;
|
||||||
|
uint32_t free3;
|
||||||
|
uint32_t free4;
|
||||||
|
|
||||||
|
} getGlobalTime;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_8;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAXNROF_AI 4
|
||||||
|
uint16_t AI_val[MAXNROF_AI];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_9;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAXNROF_MEASURE 4
|
||||||
|
uint32_t Sdata_measurement[MAXNROF_MEASURE];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_10;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t di_doorSwitch;
|
||||||
|
uint8_t di_vaultSwitch;
|
||||||
|
uint8_t di_lockSwitch;
|
||||||
|
uint8_t di_opto;
|
||||||
|
uint8_t di_aux;
|
||||||
|
bool di_wakeFromPtu;
|
||||||
|
bool di_wakeFromMdb;
|
||||||
|
bool di_PrnReady;
|
||||||
|
bool di_CoinAttach;
|
||||||
|
bool di_CoinEscrowOpen;
|
||||||
|
bool di_mifCardTap;
|
||||||
|
bool di_wakeFromModem;
|
||||||
|
bool di_contactPwrOn;
|
||||||
|
bool di_mifarePwrOn;
|
||||||
|
bool di_rdbk_mdbTxd;
|
||||||
|
bool di_AuxPwrOn;
|
||||||
|
bool di_gsmPwrOn;
|
||||||
|
bool di_creditPwrOn;
|
||||||
|
bool di_printerPwrOn;
|
||||||
|
bool di_mdbPwrOn;
|
||||||
|
bool di_rejMot_home;
|
||||||
|
uint8_t di_npe_sensor;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_11;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t do_mbdRxTst;
|
||||||
|
uint8_t do_motorBits;
|
||||||
|
uint8_t do_serialSwitch;
|
||||||
|
uint8_t do_ledsAndFan;
|
||||||
|
uint8_t do_laermUndRelay;
|
||||||
|
uint8_t do_ptuWake;
|
||||||
|
uint8_t do_auxPower;
|
||||||
|
uint8_t do_coinShutter;
|
||||||
|
uint8_t do_coinEscrow;
|
||||||
|
uint8_t do_printerPower;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_12;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define NROFMIFSTATEBYTES 40
|
||||||
|
//uint8_t Sdata_MIF_STATE[NROFMIFSTATEBYTES];
|
||||||
|
uint8_t Sdata_MIF_DATA[64];
|
||||||
|
//uint8_t mif_cardType;
|
||||||
|
//uint8_t mif_cardHolder[8];
|
||||||
|
uint8_t Sdata_MIF_ATB[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_13;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define pi_prnStateArraySize 20
|
||||||
|
uint8_t Sdata_PRN_STATE[pi_prnStateArraySize];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_14;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define pi_prnFontArraySize 20
|
||||||
|
uint8_t Sdata_PRN_FONTS[pi_prnFontArraySize];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_15;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool Sdata_mdb_busRdy;
|
||||||
|
bool Sdata_mdb_V12on;
|
||||||
|
bool Sdata_mdb_V5on;
|
||||||
|
|
||||||
|
uint8_t Sdata_mdbNrOfRecData;
|
||||||
|
uint8_t Sdata_RecBuff[40];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t Sdata_empNrOfsettings;
|
||||||
|
uint8_t Sdata_emp_settingsBuff[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_17;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct T_coin
|
||||||
|
{
|
||||||
|
uint8_t valid;
|
||||||
|
uint8_t signal;
|
||||||
|
uint8_t error;
|
||||||
|
uint8_t pad;
|
||||||
|
uint16_t value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MEMDEPTH_GOTCOINS 16
|
||||||
|
struct T_coin gotCoin[MEMDEPTH_GOTCOINS];
|
||||||
|
uint8_t ctr_gotCoin;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_18;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t Sdata_NrOfDeviceSetting;
|
||||||
|
uint8_t Sdata_DeviceSettingBuff[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_19;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t SizeMachineIDBuff;
|
||||||
|
uint8_t MachineIDBuff[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_20;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t store_insertedAmount;
|
||||||
|
uint16_t store_lastCoinType[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_21;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t store_lastCoinValue[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_22;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t p_lastCoin;
|
||||||
|
char store_curPayNewCoin;
|
||||||
|
|
||||||
|
uint64_t stor_wakSrc;
|
||||||
|
uint8_t stor_reason;
|
||||||
|
|
||||||
|
uint8_t store_rbDevParamLen;
|
||||||
|
uint8_t store_rbDevParams[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_23;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_deviceCondLen;
|
||||||
|
uint8_t store_deviceCond[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_24;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_machCondLen;
|
||||||
|
uint8_t store_machCond[66];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_25;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_DcBackupNrOfAccNr;
|
||||||
|
uint16_t store_DcBackupAccNr[16]; // z.Z. nur 8
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_26;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PI_SIZOFVAULTRECORD 400
|
||||||
|
uint8_t store_gotNrBlocksOfVaultRec;
|
||||||
|
uint8_t store_vaultrecord[PI_SIZOFVAULTRECORD];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_27;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint32_t store_amount;
|
||||||
|
uint16_t store_nrOfCoins;
|
||||||
|
|
||||||
|
bool store_DcDataAreValid;
|
||||||
|
|
||||||
|
uint8_t storeDCdynPrinterData[64];
|
||||||
|
uint8_t DCdynPrinterDataActual;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_28;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint16_t store_DCNextAccountNumber;
|
||||||
|
|
||||||
|
uint16_t storeMifCardTypDataLen;
|
||||||
|
uint8_t storeMcardTypData[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_29;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// new from 6.9.23:
|
||||||
|
#define RAW_BL_DATALEN 150
|
||||||
|
uint8_t Sdata_rawData[RAW_BL_DATALEN];
|
||||||
|
uint8_t Sdata_LengthRawData;
|
||||||
|
|
||||||
|
#define numberOfJsons 36
|
||||||
|
#define versionStringLength 16
|
||||||
|
char store_jsonVersion[versionStringLength][numberOfJsons];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_30;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t Sdata_changeResult;
|
||||||
|
uint32_t Sdata_changedAmount;
|
||||||
|
uint8_t store_tubeLev[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_31;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_bnaParameter[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_32;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_bnaCollect[8];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_33;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t store_bnaContent[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_34;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// Mitteilung von Hwapi zu Datif:
|
||||||
|
bool Sdata_coinPaymentNow;
|
||||||
|
bool Sdata_bootloadingNow;
|
||||||
|
|
||||||
|
|
||||||
|
// ------------------ Data OUTPUT --------------------------------
|
||||||
|
|
||||||
|
// sendWRcmd.cpp
|
||||||
|
#define CMDSTACKDEPTH 16
|
||||||
|
uint16_t nextAsynchsendCmd0[CMDSTACKDEPTH];
|
||||||
|
uint8_t nrOfCmdsInQueue;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_35;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CMD4STACKDEPTH 8
|
||||||
|
uint16_t nextAsynchsendCmd4[CMD4STACKDEPTH];
|
||||||
|
uint8_t nextCmd4para1[CMD4STACKDEPTH];
|
||||||
|
uint8_t nextCmd4para2[CMD4STACKDEPTH];
|
||||||
|
uint8_t nextCmd4para3[CMD4STACKDEPTH];
|
||||||
|
uint8_t nextCmd4para4[CMD4STACKDEPTH];
|
||||||
|
uint8_t nrOfCmds4InQueue;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_36;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CMD8STACKDEPTH 4
|
||||||
|
uint16_t nextAsynchsendCmd8[CMD8STACKDEPTH];
|
||||||
|
uint8_t nextCmd8para1[CMD8STACKDEPTH];
|
||||||
|
uint8_t nextCmd8para2[CMD8STACKDEPTH];
|
||||||
|
uint16_t nextCmd8para3[CMD8STACKDEPTH];
|
||||||
|
uint32_t nextCmd8para4[CMD8STACKDEPTH];
|
||||||
|
uint8_t nrOfCmds8InQueue;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_37;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SENDASYDAT_BUFFSIZE 200
|
||||||
|
uint8_t sendAsynchDataBuf[SENDASYDAT_BUFFSIZE]; // no stack, only ONE buffer
|
||||||
|
uint8_t sendAsyDatLen;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_38;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MDBSEND_BUFFSIZE 64
|
||||||
|
uint8_t Sdata_mdbSendBuffer[MDBSEND_BUFFSIZE];
|
||||||
|
uint8_t Sdata_mdbSendLen;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_39;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t prnDataParameters[4];
|
||||||
|
uint8_t prnDataBufferUser;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_40;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// ONE printer doc consists of 20 x 64 byte
|
||||||
|
#define MAXNROF_PRNBYTES 64
|
||||||
|
#define MAXNROF_PRNBLOCKS 20
|
||||||
|
char Sdata_PRN_TEXT[MAXNROF_PRNBLOCKS][MAXNROF_PRNBYTES];
|
||||||
|
uint8_t pPrnDataBuff; // points to next PRINTER_BLOCK
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_41;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//#define FDCMD_STACKDEPTH 16 // up to 1024 byte
|
||||||
|
#define FDCMD_STACKDEPTH 32 // up to 2048 byte
|
||||||
|
// header
|
||||||
|
uint8_t nextFDwrCmd[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDrdCmd[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDblkNr[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDshort[FDCMD_STACKDEPTH];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_42;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// short data
|
||||||
|
uint8_t nextFDpara1[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDpara2[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDpara3[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t nextFDpara4[FDCMD_STACKDEPTH];
|
||||||
|
// long data:
|
||||||
|
uint8_t longFDlength[FDCMD_STACKDEPTH];
|
||||||
|
uint8_t longFDpara[FDCMD_STACKDEPTH][64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_43;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_44;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// meta-data
|
||||||
|
char os_release[64];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_45;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char date_of_creation[32];
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_46;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char creator[128]; // name of application plus pid
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_47;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static QSharedMemory *getShm(std::size_t s = 0);
|
||||||
|
|
||||||
|
static SharedMem *getData()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||||
|
return (SharedMem *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
static SharedMem const *getDataConst()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||||
|
return (SharedMem const *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
// static SharedMemBuffer *write()
|
||||||
|
static SharedMem *write()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||||
|
return (SharedMem *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
// static SharedMemBuffer const *read()
|
||||||
|
static SharedMem const *read()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||||
|
return (SharedMem const *)getShm()->data();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool thisIsTheFirstUse(void);
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
char mem_guard_0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void check_mem_guards() {
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
static const char memcmp_array[48] = {0,};
|
||||||
|
char mem[48];
|
||||||
|
|
||||||
|
Q_ASSERT_X(getShm()->data() != nullptr, "pointer access", "nullptr");
|
||||||
|
SharedMem const *d = (SharedMem const *)getShm()->data();
|
||||||
|
|
||||||
|
mem[0] = d->mem_guard_0;
|
||||||
|
mem[1] = d->mem_guard_1; mem[2] = d->mem_guard_2; mem[3] = d->mem_guard_3;
|
||||||
|
mem[4] = d->mem_guard_4; mem[5] = d->mem_guard_5; mem[6] = d->mem_guard_6;
|
||||||
|
mem[7] = d->mem_guard_7; mem[8] = d->mem_guard_8; mem[9] = d->mem_guard_9;
|
||||||
|
|
||||||
|
mem[10] = d->mem_guard_10;
|
||||||
|
mem[11] = d->mem_guard_11; mem[12] = d->mem_guard_12; mem[13] = d->mem_guard_13;
|
||||||
|
mem[14] = d->mem_guard_14; mem[15] = d->mem_guard_15; mem[16] = d->mem_guard_16;
|
||||||
|
mem[17] = d->mem_guard_17; mem[18] = d->mem_guard_18; mem[19] = d->mem_guard_19;
|
||||||
|
|
||||||
|
mem[20] = d->mem_guard_20;
|
||||||
|
mem[21] = d->mem_guard_21; mem[22] = d->mem_guard_22; mem[23] = d->mem_guard_23;
|
||||||
|
mem[24] = d->mem_guard_24; mem[25] = d->mem_guard_25; mem[26] = d->mem_guard_26;
|
||||||
|
mem[27] = d->mem_guard_27; mem[28] = d->mem_guard_28; mem[29] = d->mem_guard_29;
|
||||||
|
|
||||||
|
mem[30] = d->mem_guard_30;
|
||||||
|
mem[31] = d->mem_guard_31; mem[32] = d->mem_guard_32; mem[33] = d->mem_guard_33;
|
||||||
|
mem[34] = d->mem_guard_34; mem[35] = d->mem_guard_35; mem[36] = d->mem_guard_36;
|
||||||
|
mem[37] = d->mem_guard_37; mem[38] = d->mem_guard_38; mem[39] = d->mem_guard_39;
|
||||||
|
|
||||||
|
mem[40] = d->mem_guard_40;
|
||||||
|
mem[41] = d->mem_guard_41; mem[42] = d->mem_guard_42; mem[43] = d->mem_guard_43;
|
||||||
|
mem[44] = d->mem_guard_44; mem[45] = d->mem_guard_45; mem[46] = d->mem_guard_46;
|
||||||
|
mem[47] = d->mem_guard_47;
|
||||||
|
|
||||||
|
if (memcmp(mem, memcmp_array, sizeof(memcmp_array))) {
|
||||||
|
qCritical() << QByteArray(mem, sizeof(memcmp_array)).toHex(':');
|
||||||
|
for (uint i = 0; i < sizeof(memcmp_array); ++i) {
|
||||||
|
fprintf(stderr, "%02d -> %02x", i, (unsigned char)mem[i]);
|
||||||
|
} fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SHARED_MEM_BUFFER_INCLUDED_H
|
@@ -1,16 +1,18 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = CAmaster
|
TARGET = CAmaster
|
||||||
VERSION="1.0.1"
|
VERSION="1.0.2"
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../include/com.h \
|
../include/com.h \
|
||||||
../include/datIf.h \
|
../include/datIf.h \
|
||||||
../include/prot.h
|
../include/prot.h \
|
||||||
|
../include/download_thread.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
../src/com.cpp \
|
../src/com.cpp \
|
||||||
../src/datIf.cpp \
|
../src/datIf.cpp \
|
||||||
../src/prot.cpp
|
../src/prot.cpp \
|
||||||
|
../src/download_thread.cpp
|
||||||
|
|
||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = CAslave
|
TARGET = CAslave
|
||||||
VERSION="1.0.1"
|
VERSION="1.0.2"
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../include/reporting_thread.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../src/reporting_thread.cpp
|
||||||
|
|
||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
|
@@ -9,10 +9,14 @@ History:
|
|||||||
#include "sendWRcmd.h"
|
#include "sendWRcmd.h"
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
|
#include "download_thread.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <datei.h>
|
#include <datei.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QString>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -54,8 +58,10 @@ static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
|||||||
//#define DATIF_CTR_GOTRESPVAL 100
|
//#define DATIF_CTR_GOTRESPVAL 100
|
||||||
|
|
||||||
|
|
||||||
T_datif::T_datif(QObject *parent) : QObject(parent)
|
T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
|
m_hw = hw;
|
||||||
|
|
||||||
QByteArray myBA;
|
QByteArray myBA;
|
||||||
QDir myDir("../dmd");
|
QDir myDir("../dmd");
|
||||||
|
|
||||||
@@ -170,10 +176,22 @@ char T_datif::datif_cycleSend()
|
|||||||
// b) Antwort meldet Fehler -> 2x wiederholen (nach einer Luecke von 10ms )
|
// b) Antwort meldet Fehler -> 2x wiederholen (nach einer Luecke von 10ms )
|
||||||
// c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms )
|
// c) gar keine Antwort, Timeout nach 100ms -> 2x wiederholen (nach einer Luecke von 10ms )
|
||||||
// cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung
|
// cycl_running=0: nichts zu tun 1: Mitteilung: Kommando wurde soeben abgesendet, 2,3,4 = Wiederholung
|
||||||
|
if (cycl_running == 0) {
|
||||||
if (cycl_running) // 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
|
if (m_hw) {
|
||||||
|
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
|
||||||
|
qCritical() << "DOWNLOAD REQUESTED";
|
||||||
|
if (!m_hw->dcDownloadThreadStart()) {
|
||||||
|
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
|
||||||
|
} else {
|
||||||
|
qCritical() << "DOWNLOAD-THREAD RUNNING";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 21.9.23 doRepeat hier raus sonst gehts warten auch nicht mehr (BL)
|
||||||
// if (cycl_running && doRepeat)
|
// if (cycl_running && doRepeat)
|
||||||
{
|
|
||||||
// request is still running, wait for response before next sending
|
// request is still running, wait for response before next sending
|
||||||
//qDebug()<< "datif wait for response";
|
//qDebug()<< "datif wait for response";
|
||||||
datif_trigger->stop();
|
datif_trigger->stop();
|
||||||
@@ -990,24 +1008,22 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
case 112: // get inserted amount in cent in sum
|
case 112: // get inserted amount in cent in sum
|
||||||
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
|
// byte 0..3: amount just paid 4,5:last coin type 6,7: last coin value
|
||||||
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]); // last coin type
|
uitmp=uchar2uint(receivedData[5],receivedData[4]);
|
||||||
uit2=uchar2uint(receivedData[7],receivedData[6]); // last coin value
|
uit2=uchar2uint(receivedData[7],receivedData[6]);
|
||||||
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern:
|
//if (uitmp>0) // nur 1x bei neuer Münze 6.10.23 aendern: beim Wechsler hat die kleinste Muenze immer coin type 0!
|
||||||
// beim Wechsler hat die kleinste Muenze immer coin type 0!
|
if (uit2>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);
|
||||||
emit datif_gotNewCoin(); // OR BILL if (uitmp & 0x8000)>0
|
//void gpi_storeCurrentPayment(uint32_t insertedAmount, uint16_t lastCoinType, uint16_t lastCoinValue)
|
||||||
|
if (newInsertedAmount != lastInsertedAmount)
|
||||||
|
{
|
||||||
|
emit datif_gotNewCoin();
|
||||||
//qDebug()<<"emit new coin";
|
//qDebug()<<"emit new coin";
|
||||||
lastInsertedAmount=newInsertedAmount;
|
|
||||||
//qCritical()<<"datif 112 store and emit new coin "<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
lastInsertedAmount=newInsertedAmount;
|
||||||
|
}
|
||||||
|
// qDebug()<<"datif store new coin"<<newInsertedAmount<<" "<<uitmp<<" "<<uit2;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 113: // get wake source, 8byte
|
case 113: // get wake source, 8byte
|
||||||
@@ -1043,9 +1059,6 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
// 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);
|
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
||||||
|
|
||||||
gpi_storeDI_CoinAttach(receivedData[6]); // 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];
|
||||||
|
@@ -104,7 +104,25 @@ void DownloadThread::run() {
|
|||||||
|
|
||||||
m_hw->dcDownloadRequestAck();
|
m_hw->dcDownloadRequestAck();
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): DOWNLOAD THREAD STARTED:";
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName();
|
||||||
|
|
||||||
|
QDateTime const start = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
QFile fn(m_hw->dcDownloadFileName());
|
||||||
|
|
||||||
|
if (!fn.exists()) {
|
||||||
|
// output via CONSOLE() etc
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< " DownloadThread::run(): Filename:" << m_hw->dcDownloadFileName() << "DOES NOT EXIST";;
|
||||||
|
} else {
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): DC-CONTROLLER SW-VERSION BEFORE"
|
||||||
|
<< m_hw->dc_getSWversion();
|
||||||
|
|
||||||
// load binary device controller file into memory
|
// load binary device controller file into memory
|
||||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
||||||
@@ -115,25 +133,53 @@ void DownloadThread::run() {
|
|||||||
// fill last block of data to be sent with 0xFF
|
// fill last block of data to be sent with 0xFF
|
||||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
|
|
||||||
|
m_hw->request_DC2_HWversion();
|
||||||
|
m_hw->request_DC2_SWversion();
|
||||||
|
QThread::sleep(1);
|
||||||
|
|
||||||
|
// m_hw->dc_autoRequest(false); // turn auto-request setting on
|
||||||
|
|
||||||
resetDeviceController();
|
resetDeviceController();
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||||
|
|
||||||
if (startBootloader()) {
|
if (startBootloader()) {
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||||
|
|
||||||
int currentBlock = 0;
|
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||||
|
// download of binary dc
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): TOTAL NUMBER OF FIRMWARE BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
|
int currentBlock = 0; // download of binary dc
|
||||||
DownloadResult res = DownloadResult::OK;
|
DownloadResult res = DownloadResult::OK;
|
||||||
qCritical() << "64-byte block " << currentBlock;
|
|
||||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
||||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
||||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): currentBlockNumber ..." << currentBlock;
|
||||||
|
|
||||||
currentBlock += 1;
|
currentBlock += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< QString("DownloadThread::run(): last 64-byte block %1").arg(currentBlock);
|
||||||
|
|
||||||
int const rest = ba.size() % 64;
|
int const rest = ba.size() % 64;
|
||||||
int const offset = ba.size() - rest;
|
int const offset = ba.size() - rest;
|
||||||
@@ -149,27 +195,92 @@ void DownloadThread::run() {
|
|||||||
} else {
|
} else {
|
||||||
m_hw->bl_sendLastBlock();
|
m_hw->bl_sendLastBlock();
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
|
|
||||||
|
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
|
||||||
|
// QThread::msleep(250);
|
||||||
}
|
}
|
||||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
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
|
stopBootloader(); // stop bootloader several times: if it
|
||||||
// test code:
|
QThread::sleep(1); // is not stopped, then the PSA has to be
|
||||||
uint16_t const totalBlocks = 100;
|
}
|
||||||
|
// restarted manually (!!!)
|
||||||
|
stopBootloader();
|
||||||
|
QThread::sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||||
|
|
||||||
|
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||||
|
// if it was not started at all
|
||||||
|
|
||||||
|
m_hw->dc_autoRequest(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // test
|
||||||
|
// 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);
|
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
||||||
|
|
||||||
|
// fill last block of data to be sent with 0xFF
|
||||||
|
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
|
|
||||||
|
m_hw->request_DC2_HWversion();
|
||||||
|
m_hw->request_DC2_SWversion();
|
||||||
|
QThread::sleep(1);
|
||||||
|
|
||||||
|
resetDeviceController();
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): RESET DEVICE-CONTROLLER";
|
||||||
|
QThread::sleep(1);
|
||||||
|
|
||||||
|
if (startBootloader()) {
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): STARTED BOOT-LOADER";
|
||||||
|
|
||||||
|
m_hw->dc_autoRequest(false);// turn auto-request setting off for
|
||||||
|
// download of binary dc
|
||||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
||||||
QThread::msleep(100);
|
qCritical() << "DownloadThread::run(): currentBlockNumber" << currentBlock;
|
||||||
|
QThread::msleep(250);
|
||||||
|
}
|
||||||
|
m_hw->dc_autoRequest(true); // turn auto-request setting on again
|
||||||
|
}
|
||||||
|
|
||||||
|
stopBootloader(); // there is no harm in stopping the bootloader even
|
||||||
|
// if it was not started at all
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "DownloadThread::run(): STOPPED BOOT-LOADER";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_hw->dcDownloadSetRunning(false);
|
m_hw->dcDownloadSetRunning(false);
|
||||||
m_hw->dcDownloadSetFinished(true);
|
m_hw->dcDownloadSetFinished(true);
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
|
QDateTime const end = QDateTime::currentDateTime();
|
||||||
|
quint64 secs = start.secsTo(end);
|
||||||
|
QString runtime;
|
||||||
|
if (secs % 60) {
|
||||||
|
runtime = QString("%1min %2s").arg(secs / 60).arg(secs % 60);
|
||||||
|
} else {
|
||||||
|
runtime = QString("%1min").arg((secs / 60) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << end.time().toString(Qt::ISODateWithMs)
|
||||||
|
<< QString("DOWNLOAD THREAD FINISHED (RUNTIME %1)")
|
||||||
|
.arg(runtime);
|
||||||
|
|
||||||
// the object deletes itself ! This is the last line in run().
|
// the object deletes itself ! This is the last line in run().
|
||||||
// Never touch the object after this statement
|
// Never touch the object after this statement
|
||||||
@@ -193,7 +304,6 @@ DownloadThread::sendNextAddress(int bNum) const {
|
|||||||
int noAnswerCount = 0;
|
int noAnswerCount = 0;
|
||||||
int errorCount = 0;
|
int errorCount = 0;
|
||||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
||||||
// qDebug() << "addr-block" << bNum << "...";
|
|
||||||
while (noAnswerCount <= 250) {
|
while (noAnswerCount <= 250) {
|
||||||
m_hw->bl_sendAddress(bNum);
|
m_hw->bl_sendAddress(bNum);
|
||||||
QThread::msleep(100);
|
QThread::msleep(100);
|
||||||
@@ -232,9 +342,6 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
|||||||
memcpy(local, binary.constData() + bAddr, 64);
|
memcpy(local, binary.constData() + bAddr, 64);
|
||||||
local[64] = local[65] = 0x00;
|
local[64] = local[65] = 0x00;
|
||||||
|
|
||||||
// QByteArray b((const char *)(&local[0]), 64);
|
|
||||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
|
||||||
|
|
||||||
while (noAnswerCount <= 250) {
|
while (noAnswerCount <= 250) {
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
m_hw->bl_sendDataBlock(64, local);
|
||||||
QThread::msleep(10);
|
QThread::msleep(10);
|
||||||
@@ -247,9 +354,7 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// qInfo() << "data for block" << bNum << "OK";
|
// qInfo() << "data for block" << bNum << "OK";
|
||||||
|
|
||||||
// TODO: hier ins shared mem schreiben
|
// TODO: hier ins shared mem schreiben
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -261,50 +366,65 @@ DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadThread::startBootloader() const {
|
bool DownloadThread::startBootloader() const {
|
||||||
qDebug() << "starting bootloader...";
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "starting bootloader...";
|
||||||
int nTry = 5;
|
int nTry = 5;
|
||||||
while (--nTry >= 0) {
|
while (--nTry >= 0) {
|
||||||
m_hw->bl_startBL();
|
m_hw->bl_startBL();
|
||||||
QThread::msleep(5000);
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_startBL() ..." << nTry;
|
||||||
|
QThread::msleep(500);
|
||||||
m_hw->bl_checkBL();
|
m_hw->bl_checkBL();
|
||||||
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||||
|
QThread::msleep(500);
|
||||||
if (m_hw->bl_isUp()) {
|
if (m_hw->bl_isUp()) {
|
||||||
qInfo() << "starting bootloader...OK";
|
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bootloader... isUP" << nTry;
|
||||||
QThread::msleep(5000);
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
qCritical() << "bootloader not up (" << nTry << ")";
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "bootloader not up (" << nTry << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCritical() << "starting bootloader...FAILED";
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "starting bootloader FAILED";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadThread::stopBootloader() const {
|
bool DownloadThread::stopBootloader() const {
|
||||||
qDebug() << "stopping bootloader...";
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "stopping bootloader...";
|
||||||
int nTry = 5;
|
int nTry = 5;
|
||||||
while (--nTry >= 0) {
|
while (--nTry >= 0) {
|
||||||
m_hw->bl_stopBL();
|
m_hw->bl_stopBL();
|
||||||
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "bl_stopBL() ...";
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
|
m_hw->bl_checkBL();
|
||||||
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs) << "bl_checkBL() ..." << nTry;
|
||||||
if (!m_hw->bl_isUp()) {
|
if (!m_hw->bl_isUp()) {
|
||||||
qInfo() << "stopping bootloader...OK";
|
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "stopping bootloader OK";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCritical() << "stopping bootloader...FAILED";
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "stopping bootloader FAILED";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadThread::resetDeviceController() const {
|
bool DownloadThread::resetDeviceController() const {
|
||||||
qDebug() << "resetting device controller...";
|
qDebug() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "resetting device controller...";
|
||||||
m_hw->bl_rebootDC();
|
m_hw->bl_rebootDC();
|
||||||
// wait maximally 3 seconds, before starting bootloader
|
// wait maximally 3 seconds, before starting bootloader
|
||||||
QThread::sleep(1);
|
QThread::sleep(1);
|
||||||
qInfo() << "resetting device controller...OK";
|
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "resetting device controller...OK";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
||||||
qDebug() << "loading dc binary" << filename << "...";
|
qInfo() << QDateTime::currentDateTime().time().toString(Qt::ISODateWithMs)
|
||||||
|
<< "loading dc binary" << filename << "...";
|
||||||
|
|
||||||
QFile file(filename); // closed in destructor call
|
QFile file(filename); // closed in destructor call
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@@ -17,19 +17,17 @@
|
|||||||
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 "download_thread.h"
|
||||||
#include "reporting_thread.h"
|
#include "reporting_thread.h"
|
||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
static uint32_t hwapi_lastStartAmount;
|
static uint32_t hwapi_lastStartAmount;
|
||||||
static uint32_t hwapi_lastTotalAmount;
|
static uint32_t hwapi_lastTotalAmount;
|
||||||
@@ -40,7 +38,7 @@ static uint8_t bl_startupStep;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
hwapi::hwapi(QObject *parent) : QObject(parent)
|
hwapi::hwapi(QWidget *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
// constructor
|
// constructor
|
||||||
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;
|
qCritical() << " hwapi::hwapi() APP_VERSION:" << APP_VERSION;
|
||||||
@@ -61,6 +59,11 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
|||||||
qCritical() << "Creating/attaching shared memory failed";
|
qCritical() << "Creating/attaching shared memory failed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_ASSERT_X(sizeof(SharedMem) == m_sharedMem->size(), "check shm-sizes",
|
||||||
|
QString("sizes different %1 != %2")
|
||||||
|
.arg(sizeof(SharedMem))
|
||||||
|
.arg(m_sharedMem->size()).toStdString().c_str());
|
||||||
|
|
||||||
//if (shdMem_firstUse()) // für Master raus
|
//if (shdMem_firstUse()) // für Master raus
|
||||||
// {
|
// {
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ hwapi::hwapi(QObject *parent) : QObject(parent)
|
|||||||
#error "SLAVE LIB COMPILED INTO MASTER"
|
#error "SLAVE LIB COMPILED INTO MASTER"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
|
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -131,7 +134,8 @@ hwapi::hwapi(QObject *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)
|
||||||
@@ -229,9 +233,6 @@ void hwapi::sub_slotCoin16(void)
|
|||||||
emit hwapi_doorAllDoorsClosed();
|
emit hwapi_doorAllDoorsClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwapi::coinAttached() {
|
|
||||||
emit hwapi_coinAttached();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2639,12 +2640,23 @@ void hwapi::bl_openBinary(void) const
|
|||||||
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
|
void hwapi::bl_sendDataBlock(uint8_t length, uint8_t *buffer) const
|
||||||
{
|
{
|
||||||
// send 64 byte from bin file
|
// send 64 byte from bin file
|
||||||
uint8_t LL=length, sendBuf[80], sendLen;
|
// gh, 09/02/2024: extend sendBuf. Buffer sometimes too small, sendLen=81
|
||||||
|
uint8_t LL=length, sendBuf[80+32], sendLen;
|
||||||
if (LL>64) LL=64;
|
if (LL>64) LL=64;
|
||||||
|
|
||||||
tslib_strclr(sendBuf,0,80);
|
memset(sendBuf, 0, sizeof(sendBuf));
|
||||||
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
|
sendLen=dcBL_prepareDC_BLcmd(0x22, LL, buffer, sendBuf); // pack into protocol frame
|
||||||
|
|
||||||
|
// qCritical() << "(" __func__ << ":" << __LINE__ << ") sendLen=" << sendLen
|
||||||
|
// << ":" << QByteArray((const char *)sendBuf, sendLen);
|
||||||
|
|
||||||
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
sendWRcmd_setSendBlock160(sendLen, sendBuf); // send 140 bytes
|
||||||
|
|
||||||
|
// if (sendLen > 80) {
|
||||||
|
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
|
||||||
|
// << QByteArray((const char *)&sendBuf[80], 32).toHex(':');
|
||||||
|
// }
|
||||||
|
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4405,22 +4417,12 @@ uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOf
|
|||||||
return anzahl;
|
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() {
|
QObject const *hwapi::getAPI() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
||||||
|
// called by worker-thread (see atbupdatetool)
|
||||||
SharedMem *data = SharedMem::getData();
|
SharedMem *data = SharedMem::getData();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return false;
|
return false;
|
||||||
@@ -4444,9 +4446,15 @@ bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequested() const {
|
bool hwapi::dcDownloadRequested() const {
|
||||||
SharedMem const *data = SharedMem::getData();
|
SharedMem *data = SharedMem::getData();
|
||||||
// should be false at entry
|
Q_ASSERT_X(data != nullptr, "check", "pointer invalid");
|
||||||
return data ? data->m_downLoadDC.m_requested.load() : false;
|
Q_ASSERT_X((void *)data == m_sharedMem->data(), "compare pointers", "pointers different");
|
||||||
|
Q_ASSERT_X(sizeof(*data) == m_sharedMem->size(), "compare sizes", "sizes different");
|
||||||
|
|
||||||
|
// called by download-thread
|
||||||
|
// 1: true at entry: reset atomically to false
|
||||||
|
// 2: false at entry: no change
|
||||||
|
return data ? data->m_downLoadDC.m_requested.exchange(false) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadResetRequest() const {
|
bool hwapi::dcDownloadResetRequest() const {
|
||||||
@@ -4458,14 +4466,12 @@ bool hwapi::dcDownloadResetRequest() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequestAck() const {
|
bool hwapi::dcDownloadRequestAck() const {
|
||||||
|
// called by download-thread
|
||||||
SharedMem *data = SharedMem::getData();
|
SharedMem *data = SharedMem::getData();
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data->m_downLoadDC.m_requested) {
|
|
||||||
data->m_downLoadDC.m_requested = false;
|
|
||||||
data->m_downLoadDC.m_running = true;
|
data->m_downLoadDC.m_running = true;
|
||||||
data->m_downLoadDC.m_finished = false;
|
data->m_downLoadDC.m_finished = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4474,14 +4480,16 @@ bool hwapi::dcDownloadRunning() const {
|
|||||||
if (data) {
|
if (data) {
|
||||||
int cnt = 10;
|
int cnt = 10;
|
||||||
while (--cnt > 0) {
|
while (--cnt > 0) {
|
||||||
bool running = data->m_downLoadDC.m_running.load();
|
bool running = data->m_downLoadDC.m_running;
|
||||||
bool finished = data->m_downLoadDC.m_finished.load();
|
bool finished = data->m_downLoadDC.m_finished;
|
||||||
if (!running || finished) {
|
if ((running == true) && (finished == false)) {
|
||||||
|
// see dcDownloadRequestAck()
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (cnt < 3) {
|
if (cnt < 3) {
|
||||||
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
|
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
|
||||||
}
|
}
|
||||||
QThread::msleep(500);
|
QThread::msleep(500);
|
||||||
} else break;
|
|
||||||
}
|
}
|
||||||
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
|
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
|
||||||
return (cnt > 0);
|
return (cnt > 0);
|
||||||
@@ -4490,18 +4498,16 @@ bool hwapi::dcDownloadRunning() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
||||||
delete dthread;
|
Q_UNUSED(dthread);
|
||||||
|
// delete dthread;
|
||||||
m_downloadThread = nullptr;
|
m_downloadThread = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadFinished() {
|
bool hwapi::dcDownloadFinished() {
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
if (data) {
|
|
||||||
int cnt = 10;
|
int cnt = 10;
|
||||||
while ((--cnt > 0) &&
|
while (dcDownloadRunning()) {
|
||||||
((data->m_downLoadDC.m_running.load() == true) &&
|
if (--cnt == 0) {
|
||||||
(data->m_downLoadDC.m_finished.load() == false))) {
|
return false;
|
||||||
QThread::sleep(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (cnt > 0) {
|
//if (cnt > 0) {
|
||||||
@@ -4510,12 +4516,13 @@ bool hwapi::dcDownloadFinished() {
|
|||||||
// return true;
|
// return true;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// download thread
|
// download thread
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadStart() {
|
bool hwapi::dcDownloadThreadStart() {
|
||||||
|
// called by timer in datIf.cpp: T_datif::datif_cycleSend()
|
||||||
m_downloadThread = new DownloadThread(this);
|
m_downloadThread = new DownloadThread(this);
|
||||||
if (m_downloadThread) {
|
if (m_downloadThread) {
|
||||||
m_downloadThread->start();
|
m_downloadThread->start();
|
||||||
@@ -4547,6 +4554,7 @@ bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
|
|||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
m_reportingThread = new ReportingThread(this);
|
m_reportingThread = new ReportingThread(this);
|
||||||
if (m_reportingThread) {
|
if (m_reportingThread) {
|
||||||
|
m_reportingThread->moveToThread(QApplication::instance()->thread());
|
||||||
m_reportingThread->start();
|
m_reportingThread->start();
|
||||||
cnt = 10;
|
cnt = 10;
|
||||||
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
|
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
|
||||||
@@ -4578,7 +4586,9 @@ void hwapi::dcDownloadReportThreadQuit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportThreadFinished() const {
|
bool hwapi::dcDownloadReportThreadFinished() const {
|
||||||
return m_reportingThread ? m_reportingThread->isFinished() : false;
|
// if the pointer to the underlying c++-object is not valid, the thread
|
||||||
|
// counts as finished
|
||||||
|
return m_reportingThread ? m_reportingThread->isFinished() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportStart() const {
|
bool hwapi::dcDownloadReportStart() const {
|
||||||
@@ -4604,9 +4614,11 @@ bool hwapi::dcDownloadReportFinished() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dcDownloadReportThreadFinished()) {
|
if (dcDownloadReportThreadFinished()) {
|
||||||
|
if (m_reportingThread) {
|
||||||
delete m_reportingThread;
|
delete m_reportingThread;
|
||||||
m_reportingThread = nullptr;
|
m_reportingThread = nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -4,10 +4,16 @@
|
|||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
ReportingThread::ReportingThread(hwapi *hw)
|
ReportingThread::ReportingThread(hwapi *hw)
|
||||||
: m_hw(hw)
|
: m_hw(hw)
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
||||||
|
// , m_f([](QString const&){}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportingThread::~ReportingThread() {
|
ReportingThread::~ReportingThread() {
|
||||||
@@ -17,7 +23,10 @@ ReportingThread::~ReportingThread() {
|
|||||||
// each component which has connects for the corresponding signals.
|
// each component which has connects for the corresponding signals.
|
||||||
void ReportingThread::run() {
|
void ReportingThread::run() {
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
qCritical()
|
||||||
|
<< QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||||
|
<< "START REPORT THREAD"
|
||||||
|
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
|
||||||
|
|
||||||
static QString report("");
|
static QString report("");
|
||||||
|
|
||||||
@@ -25,9 +34,9 @@ void ReportingThread::run() {
|
|||||||
while (!m_hw->dcDownloadGetRunning()) {
|
while (!m_hw->dcDownloadGetRunning()) {
|
||||||
if (--cnt > 0) {
|
if (--cnt > 0) {
|
||||||
report = QString("%1 waiting for download to start %2")
|
report = QString("%1 waiting for download to start %2")
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
|
.arg(QDateTime::currentDateTime().time().toString(Qt::ISODate))
|
||||||
.arg(cnt);
|
.arg(cnt);
|
||||||
qCritical() << __LINE__ << "STATUS" << report;
|
qCritical() << "(" << __func__ << ":" << __LINE__ << ") STATUS" << report;
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||||
QThread::sleep(1);
|
QThread::sleep(1);
|
||||||
} else break;
|
} else break;
|
||||||
@@ -91,33 +100,79 @@ void ReportingThread::run() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
uint16_t totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||||
|
cnt = 10;
|
||||||
|
while(--cnt > 0 && totalBlocks == 0) {
|
||||||
|
totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
||||||
|
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
||||||
|
<< QString("line=%1 TOTAL BLOCKS=%2 (%3)")
|
||||||
|
.arg(__LINE__).arg(totalBlocks).arg(cnt);
|
||||||
|
QThread::sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
|
||||||
|
<< QString("line=%1 TOTAL BLOCKS=%2").arg(__LINE__).arg(totalBlocks);
|
||||||
|
|
||||||
if (totalBlocks) {
|
if (totalBlocks) {
|
||||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
QDateTime const start = QDateTime::currentDateTime();
|
||||||
double durationMillis = 0;
|
|
||||||
uint16_t currentBlockNumber = 0;
|
uint16_t currentBlockNumber = 0;
|
||||||
|
uint16_t prevBlockNumber = ~0;
|
||||||
|
uint64_t estimatedMinutesLeftMax = ~0ULL;
|
||||||
|
uint64_t estimatedSecondsLeftMax = ~0ULL;
|
||||||
|
uint64_t estimatedMinutesLeftPrev = 0;
|
||||||
|
uint64_t estimatedSecondsLeftPrev = 0;
|
||||||
|
|
||||||
while (m_hw->dcDownloadGetRunning()) {
|
while (m_hw->dcDownloadGetRunning()) {
|
||||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||||
|
if (prevBlockNumber != currentBlockNumber) {
|
||||||
|
double durationSecs = start.secsTo(QDateTime::currentDateTime());
|
||||||
|
|
||||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
|
||||||
|
uint64_t estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
|
||||||
|
uint64_t estimatedMinutesLeft =
|
||||||
|
((estimatedSecondsLeft % 60) == 0) ?
|
||||||
|
(estimatedSecondsLeft / 60) :
|
||||||
|
((estimatedSecondsLeft + 60) / 60);
|
||||||
|
|
||||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
estimatedSecondsLeft = (estimatedSecondsLeft % 60);
|
||||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
|
||||||
|
if ((estimatedMinutesLeft <= estimatedMinutesLeftMax)
|
||||||
|
|| (estimatedSecondsLeft <= estimatedSecondsLeftMax)) {
|
||||||
|
estimatedMinutesLeftMax = estimatedMinutesLeft;
|
||||||
|
estimatedSecondsLeftMax = estimatedSecondsLeft;
|
||||||
|
estimatedMinutesLeftPrev = estimatedMinutesLeft;
|
||||||
|
estimatedSecondsLeftPrev = estimatedSecondsLeft;
|
||||||
|
|
||||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
|
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||||
.arg(totalBlocks)
|
.arg(totalBlocks)
|
||||||
.arg(currentBlockNumber)
|
.arg(currentBlockNumber)
|
||||||
.arg(percent, 0, 'f', 2)
|
.arg(percent, 0, 'f', 2)
|
||||||
.arg(estimatedSecondsLeft, 0, 'f', 2);
|
.arg(estimatedMinutesLeft)
|
||||||
|
.arg(estimatedSecondsLeft, 2);
|
||||||
|
|
||||||
qCritical() << "RT report" << report;
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||||
|
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||||
|
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||||
|
.arg(totalBlocks)
|
||||||
|
.arg(currentBlockNumber)
|
||||||
|
.arg(percent, 0, 'f', 2)
|
||||||
|
.arg(estimatedMinutesLeftPrev)
|
||||||
|
.arg(estimatedSecondsLeftPrev, 2);
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate)
|
||||||
|
<< QString("line=%1: RT report").arg(__LINE__) << report;
|
||||||
|
|
||||||
|
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevBlockNumber = currentBlockNumber;
|
||||||
|
}
|
||||||
QThread::msleep(100);
|
QThread::msleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +188,7 @@ void ReportingThread::run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
qCritical() << QDateTime::currentDateTime().time().toString(Qt::ISODate) << __PRETTY_FUNCTION__
|
||||||
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
||||||
|
|
||||||
cnt = 10;
|
cnt = 10;
|
||||||
|
@@ -48,16 +48,6 @@ T_runProc::T_runProc()
|
|||||||
void T_runProc::runProc_slotProcess(void)
|
void T_runProc::runProc_slotProcess(void)
|
||||||
{
|
{
|
||||||
#ifndef THIS_IS_CA_MASTER
|
#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
|
bl_performComplStart(); // neu 1.12.23
|
||||||
@@ -651,8 +641,11 @@ void T_runProc::bl_rebootDC(void)
|
|||||||
// BL is working for 5s after power-on-reset.
|
// BL is working for 5s after power-on-reset.
|
||||||
|
|
||||||
uint8_t len, buf[20];
|
uint8_t len, buf[20];
|
||||||
|
memset(buf, 0x00, sizeof(buf));
|
||||||
|
|
||||||
len=dcBL_restartDC(buf);
|
len=dcBL_restartDC(buf);
|
||||||
|
|
||||||
|
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||||
sendWRcmd_setSendBlock160(len, buf);
|
sendWRcmd_setSendBlock160(len, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,8 +655,13 @@ void T_runProc::bl_startBL(void)
|
|||||||
// otherwise the BL jumps to normal DC application
|
// otherwise the BL jumps to normal DC application
|
||||||
uint8_t len, buf[20];
|
uint8_t len, buf[20];
|
||||||
|
|
||||||
|
memset(buf, 0x00, sizeof(buf));
|
||||||
|
|
||||||
len=dcBL_activatBootloader(buf);
|
len=dcBL_activatBootloader(buf);
|
||||||
|
|
||||||
|
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||||
sendWRcmd_setSendBlock160(len, buf);
|
sendWRcmd_setSendBlock160(len, buf);
|
||||||
|
|
||||||
epi_setNowIsBootload(true);
|
epi_setNowIsBootload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,8 +669,11 @@ void T_runProc::bl_checkBL(void)
|
|||||||
{
|
{
|
||||||
// call this function in order to get information, afterwards use "bl_isUp()"
|
// call this function in order to get information, afterwards use "bl_isUp()"
|
||||||
uint8_t len, buf[20];
|
uint8_t len, buf[20];
|
||||||
|
memset(buf, 0x00, sizeof(buf));
|
||||||
|
|
||||||
len=dcBL_readFWversion(buf);
|
len=dcBL_readFWversion(buf);
|
||||||
|
|
||||||
|
qCritical() << __func__ << QByteArray((const char *)buf, len).toHex(':');
|
||||||
sendWRcmd_setSendBlock160(len, buf);
|
sendWRcmd_setSendBlock160(len, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,6 +684,7 @@ bool T_runProc::bl_isUp(void)
|
|||||||
|
|
||||||
for (nn=0; nn<160; nn++) receivedData[nn]=0;
|
for (nn=0; nn<160; nn++) receivedData[nn]=0;
|
||||||
LL=epi_getRawRecLength();
|
LL=epi_getRawRecLength();
|
||||||
|
|
||||||
if (LL>0)
|
if (LL>0)
|
||||||
{
|
{
|
||||||
epi_getRawReceivedData(receivedData);
|
epi_getRawReceivedData(receivedData);
|
||||||
@@ -695,15 +697,26 @@ bool T_runProc::bl_isUp(void)
|
|||||||
//epi_clrRawReceivedString();
|
//epi_clrRawReceivedString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// response to "start BL"
|
|
||||||
if (receivedData[0]==2 && receivedData[1]==101 && receivedData[2]==48 &&
|
// response to "start BL" { 2, 101, 48, 223, 131, 3}
|
||||||
receivedData[3]==223 && receivedData[4] ==131 )
|
static uint8_t const cmp[6] = {0x02, 0x65, 0x30, 0xdf, 0x83, 0x03};
|
||||||
{
|
|
||||||
qDebug() << "hwapi_bl_isUp: got BL response to start";
|
if (LL >= 6 && LL <= 13) {
|
||||||
//epi_clrRawReceivedString();
|
// (1) "02:63:34:35:62:33:03:02:65:30:df:83:03"
|
||||||
|
// (2) "02:65:30:df:83:03"
|
||||||
|
|
||||||
|
// qCritical() << "(" << __func__ << ":" << __LINE__
|
||||||
|
// << ") CHECK" << QByteArray((char const*)receivedData, LL).toHex(':');
|
||||||
|
|
||||||
|
for (int i=0; i <= LL-6; ++i) {
|
||||||
|
if (memcmp(cmp, &receivedData[i], 6) == 0) {
|
||||||
|
qCritical() << "(" << __func__ << ":" << __LINE__
|
||||||
|
<< ") BL RESPONSE to bl_start(): BOOTLOADER IS UP";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,13 @@
|
|||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#ifdef QT_POSIX_IPC
|
#ifdef QT_POSIX_IPC
|
||||||
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||||
@@ -9,33 +15,124 @@
|
|||||||
// macro will be defined. -> we use SystemV shared memory
|
// macro will be defined. -> we use SystemV shared memory
|
||||||
#error "QT_POSIX_IPC defined"
|
#error "QT_POSIX_IPC defined"
|
||||||
#else
|
#else
|
||||||
#ifdef __linux__
|
#ifdef linux
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <sys/ipc.h> // ftok
|
#include <sys/ipc.h> // ftok
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//static bool shdMemFirstUse;
|
//static bool shdMemFirstUse;
|
||||||
|
|
||||||
|
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
|
||||||
|
QFile f(fileName);
|
||||||
|
if (f.exists()) {
|
||||||
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QTextStream in(&f);
|
||||||
|
in.setCodec("UTF-8");
|
||||||
|
while(!in.atEnd()) {
|
||||||
|
return in.readLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||||
static QSharedMemory shMem;
|
static QSharedMemory shMem;
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
#ifdef __linux__
|
#ifdef linux
|
||||||
//static const long nativeKey = ftok("/etc/os-release", 'H');
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
//static const QString fkey = std::to_string(nativeKey).c_str();
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
static const QString fkey = "0123456?000=7";
|
//static const QString fkey = "0123456?000=7";
|
||||||
#else
|
#else
|
||||||
static const QString fkey = "0123456?000=9";
|
static const QString fkey = "0123456?000=9";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
|
||||||
|
|
||||||
shMem.setKey(fkey);
|
shMem.setKey(fkey);
|
||||||
if (!shMem.isAttached()) {
|
if (!shMem.isAttached()) {
|
||||||
if (shMem.create(size)) {
|
if (shMem.create(size)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "size=" << size
|
||||||
|
<< "shMem.size=" << shMem.size()
|
||||||
|
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||||
|
<< "ABOUT TO REBOOT SYSTEM...";
|
||||||
|
if (system("reboot")) {
|
||||||
|
// reboot system -> shared memory re-created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SharedMem *sh = (SharedMem *)(shMem.data());
|
||||||
|
|
||||||
|
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
|
||||||
|
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
|
||||||
|
|
||||||
|
memset(sh->os_release, 0x00, sizeof(sh->os_release));
|
||||||
|
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
|
||||||
|
memset(sh->creator, 0x00, sizeof(sh->creator));
|
||||||
|
|
||||||
|
QString const &os_release = read1stLineOfFile("/etc/os-release");
|
||||||
|
strncpy(sh->os_release, os_release.toStdString().c_str(),
|
||||||
|
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
|
||||||
|
|
||||||
|
QString const ¤tDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||||
|
char const *current = currentDateTime.toUtf8().constData();
|
||||||
|
strncpy(sh->date_of_creation, current,
|
||||||
|
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
|
||||||
|
|
||||||
|
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||||
|
.arg(QCoreApplication::applicationPid());
|
||||||
|
|
||||||
|
strncpy(sh->creator, appPid.toStdString().c_str(),
|
||||||
|
std::min((int)strlen(appPid.toStdString().c_str()),
|
||||||
|
(int)sizeof(sh->creator)-1));
|
||||||
|
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
|
|
||||||
|
#else
|
||||||
|
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
#endif
|
||||||
return &shMem;
|
return &shMem;
|
||||||
} else {
|
} else {
|
||||||
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||||
if (shMem.attach()) {
|
if (shMem.attach()) {
|
||||||
|
#ifdef linux
|
||||||
|
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "size=" << size
|
||||||
|
<< "shMem.size=" << shMem.size()
|
||||||
|
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||||
|
<< "ABOUT TO REBOOT SYSTEM...";
|
||||||
|
if (system("reboot")) {
|
||||||
|
// reboot system -> shared memory re-created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||||
|
.arg(QCoreApplication::applicationPid());
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
|
||||||
|
|
||||||
|
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
|
|
||||||
return &shMem;
|
return &shMem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,6 +140,13 @@ QSharedMemory *SharedMem::getShm(std::size_t size) {
|
|||||||
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||||
<< shMem.error() << shMem.errorString();
|
<< shMem.error() << shMem.errorString();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
|
||||||
|
|
||||||
|
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &shMem;
|
return &shMem;
|
||||||
|
232
src/shared_mem_buffer.cpp.new
Normal file
232
src/shared_mem_buffer.cpp.new
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
#include "shared_mem_buffer.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QString>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <atomic>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#ifdef QT_POSIX_IPC
|
||||||
|
// The POSIX backend can be explicitly selected using the -feature-ipc_posix
|
||||||
|
// option to the Qt configure script. If it is enabled, the QT_POSIX_IPC
|
||||||
|
// macro will be defined. -> we use SystemV shared memory
|
||||||
|
#error "QT_POSIX_IPC defined"
|
||||||
|
#else
|
||||||
|
#ifdef linux
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/ipc.h> // ftok
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//static bool shdMemFirstUse;
|
||||||
|
|
||||||
|
static QString read1stLineOfFile(QString fileName) { // read for instance /etc/os-release
|
||||||
|
QFile f(fileName);
|
||||||
|
if (f.exists()) {
|
||||||
|
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QTextStream in(&f);
|
||||||
|
in.setCodec("UTF-8");
|
||||||
|
while(!in.atEnd()) {
|
||||||
|
return in.readLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
|
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||||
|
static QSharedMemory shMem;
|
||||||
|
if (size > 0) {
|
||||||
|
#ifdef linux
|
||||||
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
|
//static const QString fkey = "0123456?000=7";
|
||||||
|
#else
|
||||||
|
static const QString fkey = "0123456?000=9";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": size" << size;
|
||||||
|
|
||||||
|
shMem.setKey(fkey);
|
||||||
|
if (!shMem.isAttached()) {
|
||||||
|
if (shMem.create(size)) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << ": created shared memory";
|
||||||
|
|
||||||
|
#ifdef linux
|
||||||
|
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "size=" << size
|
||||||
|
<< "shMem.size=" << shMem.size()
|
||||||
|
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||||
|
<< "ABOUT TO REBOOT SYSTEM...";
|
||||||
|
if (system("reboot")) {
|
||||||
|
// reboot system -> shared memory re-created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SharedMem *sh = (SharedMem *)(shMem.data());
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG
|
||||||
|
sh->mem_guard_0 = 0;
|
||||||
|
sh->mem_guard_1 = 0; sh->mem_guard_2 = 0; sh->mem_guard_3 = 0;
|
||||||
|
sh->mem_guard_4 = 0; sh->mem_guard_5 = 0; sh->mem_guard_6 = 0;
|
||||||
|
sh->mem_guard_7 = 0; sh->mem_guard_8 = 0; sh->mem_guard_9 = 0;
|
||||||
|
|
||||||
|
sh->mem_guard_10 = 0;
|
||||||
|
sh->mem_guard_11 = 0; sh->mem_guard_12 = 0; sh->mem_guard_13 = 0;
|
||||||
|
sh->mem_guard_14 = 0; sh->mem_guard_15 = 0; sh->mem_guard_16 = 0;
|
||||||
|
sh->mem_guard_17 = 0; sh->mem_guard_18 = 0; sh->mem_guard_19 = 0;
|
||||||
|
|
||||||
|
sh->mem_guard_20 = 0;
|
||||||
|
sh->mem_guard_21 = 0; sh->mem_guard_22 = 0; sh->mem_guard_23 = 0;
|
||||||
|
sh->mem_guard_24 = 0; sh->mem_guard_25 = 0; sh->mem_guard_26 = 0;
|
||||||
|
sh->mem_guard_27 = 0; sh->mem_guard_28 = 0; sh->mem_guard_29 = 0;
|
||||||
|
|
||||||
|
sh->mem_guard_30 = 0;
|
||||||
|
sh->mem_guard_31 = 0; sh->mem_guard_32 = 0; sh->mem_guard_33 = 0;
|
||||||
|
sh->mem_guard_34 = 0; sh->mem_guard_35 = 0; sh->mem_guard_36 = 0;
|
||||||
|
sh->mem_guard_37 = 0; sh->mem_guard_38 = 0; sh->mem_guard_39 = 0;
|
||||||
|
|
||||||
|
sh->mem_guard_40 = 0;
|
||||||
|
sh->mem_guard_41 = 0; sh->mem_guard_42 = 0; sh->mem_guard_43 = 0;
|
||||||
|
sh->mem_guard_44 = 0; sh->mem_guard_45 = 0; sh->mem_guard_46 = 0;
|
||||||
|
sh->mem_guard_47 = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memset(sh->indat_HWversion, 0x00, sizeof(sh->indat_HWversion));
|
||||||
|
memset(sh->indat_SWversion, 0x00, sizeof(sh->indat_SWversion));
|
||||||
|
|
||||||
|
memset(sh->os_release, 0x00, sizeof(sh->os_release));
|
||||||
|
memset(sh->date_of_creation, 0x00, sizeof(sh->date_of_creation));
|
||||||
|
memset(sh->creator, 0x00, sizeof(sh->creator));
|
||||||
|
|
||||||
|
QString const &os_release = read1stLineOfFile("/etc/os-release");
|
||||||
|
strncpy(sh->os_release, os_release.toStdString().c_str(),
|
||||||
|
std::min((int)os_release.size(), (int)sizeof(sh->os_release)-1));
|
||||||
|
|
||||||
|
QString const ¤tDateTime = QDateTime::currentDateTime().toString(Qt::ISODate);
|
||||||
|
char const *current = currentDateTime.toUtf8().constData();
|
||||||
|
strncpy(sh->date_of_creation, current,
|
||||||
|
std::min((int)strlen(current), (int)sizeof(sh->date_of_creation)-1));
|
||||||
|
|
||||||
|
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||||
|
.arg(QCoreApplication::applicationPid());
|
||||||
|
|
||||||
|
strncpy(sh->creator, appPid.toStdString().c_str(),
|
||||||
|
std::min((int)strlen(appPid.toStdString().c_str()),
|
||||||
|
(int)sizeof(sh->creator)-1));
|
||||||
|
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
|
|
||||||
|
#else
|
||||||
|
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
#endif
|
||||||
|
return &shMem;
|
||||||
|
} else {
|
||||||
|
if (shMem.error() == QSharedMemory::AlreadyExists) {
|
||||||
|
if (shMem.attach()) {
|
||||||
|
#ifdef linux
|
||||||
|
if ((size != (std::size_t)shMem.size()) || (sizeof(SharedMem) != shMem.size())) {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__
|
||||||
|
<< "size=" << size
|
||||||
|
<< "shMem.size=" << shMem.size()
|
||||||
|
<< "sizeof(SharedMem)=" << sizeof(SharedMem)
|
||||||
|
<< "ABOUT TO REBOOT SYSTEM...";
|
||||||
|
if (system("reboot")) {
|
||||||
|
// reboot system -> shared memory re-created
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Q_ASSERT_X(size != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
Q_ASSERT_X(sizeof(SharedMem) != shMem.size(), "compare sizes", "sizes different");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QString const &appPid = QString("%1 (%2)").arg(QCoreApplication::applicationName())
|
||||||
|
.arg(QCoreApplication::applicationPid());
|
||||||
|
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << appPid << "attached shared memory";
|
||||||
|
|
||||||
|
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
|
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||||
|
<< shMem.error() << shMem.errorString();
|
||||||
|
return nullptr;
|
||||||
|
} else {
|
||||||
|
qCritical() << __func__ << ":" << __LINE__ << "shared memory already attached";
|
||||||
|
|
||||||
|
struct SharedMem const *sh = (SharedMem const *)(shMem.data());
|
||||||
|
qCritical() << "os-release:" << sh->os_release;
|
||||||
|
qCritical() << " creator:" << sh->creator;
|
||||||
|
qCritical() << " date:" << sh->date_of_creation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// std::atomic_bool SharedMemBuffer::__sharedMemLocked{false};
|
||||||
|
/*
|
||||||
|
//QSharedMemory *SharedMemBuffer::getShm(std::size_t size) {
|
||||||
|
QSharedMemory *SharedMem::getShm(std::size_t size) {
|
||||||
|
|
||||||
|
static QSharedMemory shMem;
|
||||||
|
if (size > 0) {
|
||||||
|
#ifdef __linux__
|
||||||
|
static const long nativeKey = ftok("/etc/os-release", 'H');
|
||||||
|
static const QString fkey = std::to_string(nativeKey).c_str();
|
||||||
|
#else
|
||||||
|
static const QString fkey = "0123456?000=9";
|
||||||
|
#endif
|
||||||
|
shdMemFirstUse=false;
|
||||||
|
shMem.setKey(fkey);
|
||||||
|
if (!shMem.isAttached())
|
||||||
|
{
|
||||||
|
if (shMem.create(size))
|
||||||
|
{
|
||||||
|
// sm was created successful, did not exist before
|
||||||
|
shdMemFirstUse=true;
|
||||||
|
return &shMem;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// create was false because mem already existed
|
||||||
|
if (shMem.error() == QSharedMemory::AlreadyExists)
|
||||||
|
{
|
||||||
|
if (shMem.attach())
|
||||||
|
{
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
qCritical() << shMem.nativeKey() << shMem.key() << shMem.data()
|
||||||
|
<< shMem.error() << shMem.errorString();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &shMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool shdMem_firstUse(void)
|
||||||
|
{
|
||||||
|
return shdMemFirstUse;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@@ -6,6 +6,8 @@
|
|||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
#include "datei.h"
|
#include "datei.h"
|
||||||
|
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
// 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)
|
||||||
|
|
||||||
@@ -64,66 +66,64 @@ bool indat_isMdbOn()
|
|||||||
|
|
||||||
void gpi_storeHWver(QString text)
|
void gpi_storeHWver(QString text)
|
||||||
{
|
{
|
||||||
// change Qstring to array of chars, because shared mem allowes no QString!
|
QString prev(QByteArray(SharedMem::read()->indat_HWversion, versionBufferLen-1));
|
||||||
int nn, LL = text.length();
|
prev = prev.trimmed();
|
||||||
if (LL >= versionBufferLen)
|
|
||||||
LL=versionBufferLen-1; // leave place for termination
|
|
||||||
|
|
||||||
for (nn=0; nn<LL; nn++)
|
QString const textTruncated = text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||||
{
|
|
||||||
SharedMem::write()->indat_HWversion[nn] = text.at(nn).toLatin1();
|
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||||
|
&& textTruncated != prev) {
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||||
|
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||||
|
if (!string.isEmpty()) {
|
||||||
|
memset(SharedMem::write()->indat_HWversion, 0, versionBufferLen);
|
||||||
|
char *p = (char *)SharedMem::write()->indat_HWversion;
|
||||||
|
char *q = (char *)string.constData();
|
||||||
|
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||||
|
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||||
|
if (q[j]) {
|
||||||
|
*p++ = q[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (nn=LL; nn<versionBufferLen; nn++)
|
|
||||||
SharedMem::write()->indat_HWversion[nn] =0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString epi_loadHWver(void)
|
QString epi_loadHWver(void)
|
||||||
{
|
{
|
||||||
// load array of chars from SM and change to QString
|
QString text(SharedMem::read()->indat_HWversion);
|
||||||
int nn, LL = versionBufferLen;
|
return text.mid(0, qMin(versionBufferLen-1, text.size())).trimmed();
|
||||||
char cc;
|
|
||||||
QString myStr;
|
|
||||||
|
|
||||||
myStr.clear();
|
|
||||||
|
|
||||||
for (nn=0; nn<LL; nn++)
|
|
||||||
{
|
|
||||||
cc = SharedMem::read()->indat_HWversion[nn];
|
|
||||||
myStr.append(cc);
|
|
||||||
}
|
|
||||||
return myStr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeSWver(QString text)
|
void gpi_storeSWver(QString text)
|
||||||
{
|
{
|
||||||
int nn, LL = text.length();
|
QString prev(QByteArray(SharedMem::read()->indat_SWversion, 12));
|
||||||
if (LL >= versionBufferLen)
|
prev = prev.trimmed();
|
||||||
LL=versionBufferLen-1; // leave place for termination
|
|
||||||
|
|
||||||
for (nn=0; nn<LL; nn++)
|
QString const textTruncated = text.mid(0, qMin(12, text.size())).trimmed();
|
||||||
{
|
|
||||||
SharedMem::write()->indat_SWversion[nn] = text.at(nn).toLatin1();
|
if (textTruncated.startsWith("DC2C", Qt::CaseInsensitive)
|
||||||
|
&& textTruncated != prev) {
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("Windows-1252");
|
||||||
|
QString string = codec->toUnicode(textTruncated.toUtf8());
|
||||||
|
if (!string.isEmpty()) {
|
||||||
|
memset(SharedMem::write()->indat_SWversion, 0, versionBufferLen);
|
||||||
|
char *p = (char *)SharedMem::write()->indat_SWversion;
|
||||||
|
char *q = (char *)string.constData();
|
||||||
|
for (int i=0; i < qMin(versionBufferLen, string.size()); ++i) {
|
||||||
|
int const j = (sizeof(QChar) == 2) ? i*2 : i;
|
||||||
|
if (q[j]) {
|
||||||
|
*p++ = q[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (nn=LL; nn<versionBufferLen; nn++)
|
|
||||||
SharedMem::write()->indat_SWversion[nn] =0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString epi_loadSWver(void)
|
QString epi_loadSWver(void)
|
||||||
{
|
{
|
||||||
int nn, LL = versionBufferLen;
|
QString text(SharedMem::read()->indat_SWversion);
|
||||||
char cc;
|
return text.mid(0, qMin(12, text.size())).trimmed();
|
||||||
QString myStr;
|
|
||||||
|
|
||||||
myStr.clear();
|
|
||||||
|
|
||||||
for (nn=0; nn<LL; nn++)
|
|
||||||
{
|
|
||||||
cc = SharedMem::read()->indat_SWversion[nn];
|
|
||||||
myStr.append(cc);
|
|
||||||
}
|
|
||||||
return myStr;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gpi_storeDCstate(QString text)
|
void gpi_storeDCstate(QString text)
|
||||||
@@ -1773,25 +1773,15 @@ 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;
|
uint8_t pLC=SharedMem::read()->p_lastCoin;
|
||||||
|
|
||||||
// 21.3.24 attention: if bit 15 in lastCoinType is set then we got a bill not a coin
|
|
||||||
SharedMem::write()->store_insertedAmount=insertedAmount;
|
SharedMem::write()->store_insertedAmount=insertedAmount;
|
||||||
if (lastCoinType & 0x8000)
|
|
||||||
{
|
|
||||||
// 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_lastCoinType[pLC]=lastCoinType;
|
||||||
SharedMem::write()->store_lastCoinValue[pLC]=lastCoinValue;
|
SharedMem::write()->store_lastCoinValue[pLC]=lastCoinValue;
|
||||||
pLC++;
|
pLC++;
|
||||||
SharedMem::write()->p_lastCoin=pLC;
|
SharedMem::write()->p_lastCoin=pLC;
|
||||||
SharedMem::write()->store_curPayNewCoin++;
|
SharedMem::write()->store_curPayNewCoin++;
|
||||||
}
|
|
||||||
|
|
||||||
|
//qDebug()<<"gpi_storeCurrentPayment "<<insertedAmount<<" " << lastCoinType<<" " << lastCoinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t epi_CurrentPaymentGetAmount(void)
|
uint32_t epi_CurrentPaymentGetAmount(void)
|
||||||
@@ -1829,13 +1819,6 @@ 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;
|
||||||
@@ -2220,8 +2203,8 @@ void gpi_storeRawReceivedData(uint8_t RdDlen, uint8_t *receivedData)
|
|||||||
SharedMem::write()->Sdata_LengthRawData=lrd;
|
SharedMem::write()->Sdata_LengthRawData=lrd;
|
||||||
for (nn=0; nn<lrd; nn++)
|
for (nn=0; nn<lrd; nn++)
|
||||||
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
SharedMem::write()->Sdata_rawData[nn]=receivedData[nn];
|
||||||
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
|
||||||
|
|
||||||
|
//qDebug()<<"dcBL got data"<< Sdata_LengthRawData << "bytes :)";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
uint8_t epi_getRawReceivedData(uint8_t *receivedData)
|
||||||
|
Reference in New Issue
Block a user