Compare commits
31 Commits
gerhard-en
...
1.0.3-1
Author | SHA1 | Date | |
---|---|---|---|
2c67638c34 | |||
e7538ae5df | |||
cb403b5dbb | |||
f226179e24 | |||
3eff32b45c | |||
075a9d9316 | |||
8c261af1a7 | |||
e0346e0a9b | |||
16b6ea8087 | |||
9bdc08f6fc | |||
a3bc3d53cd | |||
9971b7ac2e | |||
15ada1ad26 | |||
1811842082 | |||
13ff32b108 | |||
cea817cbcb | |||
e50871cf9f | |||
f6f90fe770 | |||
7b1ea963e2 | |||
8163be5022 | |||
1fdbf3b9ca | |||
d380bcafe8 | |||
27c0aa56ee | |||
6377c6c18f | |||
e906213441 | |||
57b4ade2e5 | |||
f817d07e8c | |||
fc2bc6bafc | |||
7f672db841 | |||
d8232e0163 | |||
fc2132184e |
@@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
// bit0,1: enable/disable button "next"
|
// bit0,1: enable/disable button "next"
|
||||||
// bit2,3: enable/disable button "home"
|
// bit2,3: enable/disable button "home"
|
||||||
// bit4,5: enable/disable button "back"
|
// bit4,5: enable/disable button "back"
|
||||||
|
QString bs, cn;
|
||||||
|
int br, ci;
|
||||||
|
|
||||||
|
|
||||||
this->updateGui();
|
this->updateGui();
|
||||||
*nextScreen=0; // 0=no change
|
*nextScreen=0; // 0=no change
|
||||||
@@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
// load and use last settings: --------------------
|
// load and use last settings: --------------------
|
||||||
QByteArray myBA;
|
QByteArray myBA;
|
||||||
myBA=datei_readFromFile(FILENAME_COMPORT);
|
myBA=datei_readFromFile(FILENAME_COMPORT);
|
||||||
|
if (myBA.length()>0)
|
||||||
|
{
|
||||||
|
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
||||||
|
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
||||||
|
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
||||||
|
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
||||||
|
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
||||||
|
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||||
|
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
|
||||||
|
connectButton->setChecked(true); // connect Taste "druecken"
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// open with default settings
|
||||||
|
qDebug()<<"CArunGui: open serial with default values";
|
||||||
|
|
||||||
//uint32_t len= datei_nrOfEntriesInFile(myBA);
|
bs="115200";
|
||||||
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0);
|
br=5;
|
||||||
//qDebug()<<"win_startup load long numer: "<<ulltmp;
|
//cn="COM14"; // Windows
|
||||||
|
cn="ttymxc2"; // PTU5
|
||||||
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
ci=2;
|
||||||
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||||
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
|
||||||
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
|
||||||
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
|
||||||
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
|
|
||||||
HWaccess->dc_openSerial(br,bs,cn,1);
|
|
||||||
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
|
|
||||||
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
|
|
||||||
connectButton->setChecked(true); // connect Taste "druecken"
|
|
||||||
|
|
||||||
|
}
|
||||||
myTO->start(100); // restart
|
myTO->start(100); // restart
|
||||||
myStep++;
|
myStep++;
|
||||||
} else
|
} else
|
||||||
@@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
if (!myTO->isActive())
|
if (!myTO->isActive())
|
||||||
{
|
{
|
||||||
if (HWaccess->dc_isPortOpen())
|
if (HWaccess->dc_isPortOpen())
|
||||||
|
{
|
||||||
myStep++;
|
myStep++;
|
||||||
else
|
} else
|
||||||
myStep=99; // stop automatic connection and wait for manual start
|
{
|
||||||
|
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: port is still closed, restarting..";
|
||||||
|
}
|
||||||
myTO->start(100);
|
myTO->start(100);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
if (HWaccess->dc_readAnswTestResponse())
|
if (HWaccess->dc_readAnswTestResponse())
|
||||||
myStep++; // response was correct
|
myStep++; // response was correct
|
||||||
else
|
else
|
||||||
myStep=99; // stop automatic connection and wait for manual start
|
{
|
||||||
|
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: got no answer from DC, retry..";
|
||||||
|
}
|
||||||
myTO->start(100);
|
myTO->start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
HWaccess->dc_autoRequest(1);
|
HWaccess->dc_autoRequest(1);
|
||||||
AutSendButton->setChecked(true); // taste "druecken"
|
AutSendButton->setChecked(true); // taste "druecken"
|
||||||
myStep++;
|
myStep++;
|
||||||
|
myTO->start(2000);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==5)
|
if (myStep==5)
|
||||||
{
|
{
|
||||||
// got next screen:
|
if (!myTO->isActive())
|
||||||
//myNextStep=2; // nicht bei CArun
|
{
|
||||||
myStep++;
|
if (HWaccess->sys_areDCdataValid())
|
||||||
|
{
|
||||||
|
qDebug()<<"CArunGui: DC is connected";
|
||||||
|
myStep=7; // OK, connection is up and running
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
qDebug()<<"CArunGui: auto request is not running, retry...";
|
||||||
|
myStep++;
|
||||||
|
myTO->start(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==6)
|
if (myStep==6)
|
||||||
{
|
{
|
||||||
// stop here, everything done
|
// restart autoconnect cycle
|
||||||
|
myTO->start(100); // restart
|
||||||
|
myStep=0;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==7)
|
if (myStep==7)
|
||||||
{
|
{
|
||||||
|
// stay here, DC connection is up and running
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
|
|
||||||
if (myNextStep)
|
if (myNextStep)
|
||||||
{
|
{
|
||||||
//qDebug()<<"fenster1 working: "<< myNextStep;
|
|
||||||
*nextScreen=myNextStep;
|
*nextScreen=myNextStep;
|
||||||
myNextStep=0;
|
myNextStep=0;
|
||||||
}
|
}
|
||||||
|
@@ -81,37 +81,27 @@ contains( CONFIG, PTU5_YOCTO ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$${PWD}/include/com.h \
|
|
||||||
$${PWD}/include/datei.h \
|
$${PWD}/include/datei.h \
|
||||||
$${PWD}/include/runProc.h \
|
$${PWD}/include/runProc.h \
|
||||||
$${PWD}/include/controlBus.h \
|
$${PWD}/include/controlBus.h \
|
||||||
$${PWD}/include/datIf.h \
|
|
||||||
$${PWD}/include/dcBL.h \
|
$${PWD}/include/dcBL.h \
|
||||||
$${PWD}/include/hwapi.h \
|
$${PWD}/include/hwapi.h \
|
||||||
$${PWD}/include/interfaces.h \
|
$${PWD}/include/interfaces.h \
|
||||||
$${PWD}/include/prot.h \
|
|
||||||
$${PWD}/include/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/download_thread.h \
|
|
||||||
$${PWD}/include/reporting_thread.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$${PWD}/src/com.cpp \
|
|
||||||
$${PWD}/src/datei.cpp \
|
$${PWD}/src/datei.cpp \
|
||||||
$${PWD}/src/runProc.cpp \
|
$${PWD}/src/runProc.cpp \
|
||||||
$${PWD}/src/controlBus.cpp \
|
$${PWD}/src/controlBus.cpp \
|
||||||
$${PWD}/src/datIf.cpp \
|
|
||||||
$${PWD}/src/dcBL.cpp \
|
$${PWD}/src/dcBL.cpp \
|
||||||
$${PWD}/src/hwapi.cpp \
|
$${PWD}/src/hwapi.cpp \
|
||||||
$${PWD}/src/prot.cpp \
|
|
||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp \
|
$${PWD}/src/tslib.cpp \
|
||||||
$${PWD}/src/shared_mem_buffer.cpp \
|
$${PWD}/src/shared_mem_buffer.cpp
|
||||||
$${PWD}/src/download_thread.cpp \
|
|
||||||
$${PWD}/src/reporting_thread.cpp
|
|
||||||
|
|
||||||
|
|
||||||
# INTERFACE = DeviceController
|
# INTERFACE = DeviceController
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
CONFIG += ordered
|
CONFIG += ordered
|
||||||
SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun
|
SUBDIRS = lib_ca_master lib_ca_slave CArunGUI dCArun
|
||||||
|
|
||||||
|
@@ -375,6 +375,9 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
// bit0,1: enable/disable button "next"
|
// bit0,1: enable/disable button "next"
|
||||||
// bit2,3: enable/disable button "home"
|
// bit2,3: enable/disable button "home"
|
||||||
// bit4,5: enable/disable button "back"
|
// bit4,5: enable/disable button "back"
|
||||||
|
QString bs, cn;
|
||||||
|
int br, ci;
|
||||||
|
|
||||||
|
|
||||||
this->updateGui();
|
this->updateGui();
|
||||||
*nextScreen=0; // 0=no change
|
*nextScreen=0; // 0=no change
|
||||||
@@ -385,22 +388,29 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
// load and use last settings: --------------------
|
// load and use last settings: --------------------
|
||||||
QByteArray myBA;
|
QByteArray myBA;
|
||||||
myBA=datei_readFromFile(FILENAME_COMPORT);
|
myBA=datei_readFromFile(FILENAME_COMPORT);
|
||||||
|
if (myBA.length()>0)
|
||||||
|
{
|
||||||
|
bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
||||||
|
br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
||||||
|
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
||||||
|
cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
||||||
|
ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
||||||
|
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||||
|
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
|
||||||
|
connectButton->setChecked(true); // connect Taste "druecken"
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
// open with default settings
|
||||||
|
qDebug()<<"CArunGui: open serial with default values";
|
||||||
|
|
||||||
//uint32_t len= datei_nrOfEntriesInFile(myBA);
|
bs="115200";
|
||||||
//uint64_t ulltmp=csv_getEntryAs2Ulong(myBA,0);
|
br=5;
|
||||||
//qDebug()<<"win_startup load long numer: "<<ulltmp;
|
//cn="COM14"; // Windows
|
||||||
|
cn="ttymxc2"; // PTU5
|
||||||
QString bs=csv_getEntryAsString(myBA,0); // read the 's' war 2!??
|
ci=2;
|
||||||
int br=csv_getEntryAsInt(myBA,1); // z.B. 5 (5.Eintrag in der Baud-Liste)
|
HWaccess->dc_openSerial(br,bs,cn,1);
|
||||||
bs=csv_getEntryAsString(myBA,2); // z.B 115200
|
|
||||||
QString cn=csv_getEntryAsString(myBA,3); // z.B. COM9
|
|
||||||
int ci=csv_getEntryAsInt(myBA,4); // Eintragsnummer in COM-Fenster
|
|
||||||
//qDebug()<<"win_startup loaded com settings: "<<br<<" "<<bs<<" "<<cn;
|
|
||||||
HWaccess->dc_openSerial(br,bs,cn,1);
|
|
||||||
//CB_baudSel->setCurrentIndex(br); // im BR auswahlfenster diese Baud vorgeben
|
|
||||||
CB_portSel->setCurrentIndex(ci); // den Port aus der Datei hier vorgeben
|
|
||||||
connectButton->setChecked(true); // connect Taste "druecken"
|
|
||||||
|
|
||||||
|
}
|
||||||
myTO->start(100); // restart
|
myTO->start(100); // restart
|
||||||
myStep++;
|
myStep++;
|
||||||
} else
|
} else
|
||||||
@@ -410,9 +420,13 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
if (!myTO->isActive())
|
if (!myTO->isActive())
|
||||||
{
|
{
|
||||||
if (HWaccess->dc_isPortOpen())
|
if (HWaccess->dc_isPortOpen())
|
||||||
|
{
|
||||||
myStep++;
|
myStep++;
|
||||||
else
|
} else
|
||||||
myStep=99; // stop automatic connection and wait for manual start
|
{
|
||||||
|
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: port is still closed, restarting..";
|
||||||
|
}
|
||||||
myTO->start(100);
|
myTO->start(100);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -434,7 +448,10 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
if (HWaccess->dc_readAnswTestResponse())
|
if (HWaccess->dc_readAnswTestResponse())
|
||||||
myStep++; // response was correct
|
myStep++; // response was correct
|
||||||
else
|
else
|
||||||
myStep=99; // stop automatic connection and wait for manual start
|
{
|
||||||
|
myStep=6; // 13.12.23: start Autoconnect cycle
|
||||||
|
qDebug()<<"CArunGui: got no answer from DC, retry..";
|
||||||
|
}
|
||||||
myTO->start(100);
|
myTO->start(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,23 +462,38 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
HWaccess->dc_autoRequest(1);
|
HWaccess->dc_autoRequest(1);
|
||||||
AutSendButton->setChecked(true); // taste "druecken"
|
AutSendButton->setChecked(true); // taste "druecken"
|
||||||
myStep++;
|
myStep++;
|
||||||
|
myTO->start(2000);
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==5)
|
if (myStep==5)
|
||||||
{
|
{
|
||||||
// got next screen:
|
if (!myTO->isActive())
|
||||||
//myNextStep=2; // nicht bei CArun
|
{
|
||||||
myStep++;
|
if (HWaccess->sys_areDCdataValid())
|
||||||
|
{
|
||||||
|
qDebug()<<"CArunGui: DC is connected";
|
||||||
|
myStep=7; // OK, connection is up and running
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
qDebug()<<"CArunGui: auto request is not running, retry...";
|
||||||
|
myStep++;
|
||||||
|
myTO->start(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==6)
|
if (myStep==6)
|
||||||
{
|
{
|
||||||
// stop here, everything done
|
// restart autoconnect cycle
|
||||||
|
myTO->start(100); // restart
|
||||||
|
myStep=0;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (myStep==7)
|
if (myStep==7)
|
||||||
{
|
{
|
||||||
|
// stay here, DC connection is up and running
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -470,7 +502,6 @@ bool T_winComPort::working(uint16_t *nextScreen, uint8_t *useNavi)
|
|||||||
|
|
||||||
if (myNextStep)
|
if (myNextStep)
|
||||||
{
|
{
|
||||||
//qDebug()<<"fenster1 working: "<< myNextStep;
|
|
||||||
*nextScreen=myNextStep;
|
*nextScreen=myNextStep;
|
||||||
myNextStep=0;
|
myNextStep=0;
|
||||||
}
|
}
|
||||||
|
@@ -133,8 +133,8 @@
|
|||||||
#define SENDCOMBINED 0
|
#define SENDCOMBINED 0
|
||||||
|
|
||||||
|
|
||||||
class hwinf;
|
|
||||||
class DownloadThread;
|
|
||||||
class T_datif : public QObject
|
class T_datif : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -165,15 +165,13 @@ class T_datif : public QObject
|
|||||||
T_prot *myDCIF;
|
T_prot *myDCIF;
|
||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
uint8_t selectedSlaveAddr;
|
uint8_t selectedSlaveAddr;
|
||||||
DownloadThread *m_downloadThread;
|
|
||||||
hwinf *m_hw;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
char datif_cycleSend();
|
char datif_cycleSend();
|
||||||
void StoredRecData();
|
void StoredRecData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_datif(hwinf *hw, QObject *parent = nullptr);
|
T_datif(QObject *parent = nullptr);
|
||||||
|
|
||||||
void resetChain(void);
|
void resetChain(void);
|
||||||
char isPortOpen(void);
|
char isPortOpen(void);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#ifndef DATEI_H
|
#ifndef DATEI_H
|
||||||
#define DATEI_H
|
#define DATEI_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@@ -1,37 +0,0 @@
|
|||||||
#ifndef DOWNLOAD_THREAD_H_INCLUDED
|
|
||||||
#define DOWNLOAD_THREAD_H_INCLUDED
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QString>
|
|
||||||
#include <QByteArray>
|
|
||||||
|
|
||||||
class hwinf;
|
|
||||||
class DownloadThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
|
||||||
|
|
||||||
DownloadThread(hwinf *hw);
|
|
||||||
~DownloadThread();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// download thread does not have a running event queue, and therefore
|
|
||||||
// no slots. signals work the usual way.
|
|
||||||
void run() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DownloadResult sendStatus(int ret) const;
|
|
||||||
DownloadResult sendNextAddress(int bNum) const;
|
|
||||||
DownloadResult sendNextDataBlock(QByteArray const &binary, int bNum) const;
|
|
||||||
bool startBootloader() const;
|
|
||||||
bool stopBootloader() const;
|
|
||||||
QByteArray loadBinaryDCFile(QString dcFileName) const;
|
|
||||||
bool resetDeviceController() const;
|
|
||||||
DownloadResult dcDownloadBinary(QByteArray const &b) const;
|
|
||||||
|
|
||||||
hwinf *m_hw;
|
|
||||||
QString m_fileToDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DOWNLOAD_THREAD_H_INCLUDED
|
|
113
include/hwapi.h
113
include/hwapi.h
@@ -26,6 +26,8 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
|||||||
#ifndef hwapi_H
|
#ifndef hwapi_H
|
||||||
#define hwapi_H
|
#define hwapi_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
//#include <QTabWidget>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -37,11 +39,11 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
|||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include "dcBL.h"
|
#include "dcBL.h"
|
||||||
#include "interfaces.h"
|
//#include <../plugins/interfaces.h>
|
||||||
#include "shared_mem_buffer.h"
|
#include "shared_mem_buffer.h"
|
||||||
#include "runProc.h"
|
#include "runProc.h"
|
||||||
#include "download_thread.h"
|
#include "interfaces.h"
|
||||||
#include "reporting_thread.h"
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* select Plugin Type here
|
* select Plugin Type here
|
||||||
@@ -70,13 +72,15 @@ V4.0 6.9.2023: activating DC-Bootloader in slve-lib (SM)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//for CAslave:
|
//for CAslave:
|
||||||
//#undef THIS_IS_CA_MASTER
|
//#undef THIS_IS_CA_MASTER
|
||||||
|
|
||||||
|
//for CAmaster:
|
||||||
|
//#define THIS_IS_CA_MASTER
|
||||||
|
|
||||||
|
|
||||||
//for CAmaster:
|
|
||||||
|
|
||||||
class QSharedMemory;
|
class QSharedMemory;
|
||||||
class ReportingThread;
|
|
||||||
class DownloadThread;
|
|
||||||
class hwapi : public QObject,
|
class hwapi : public QObject,
|
||||||
public hwinf
|
public hwinf
|
||||||
{
|
{
|
||||||
@@ -88,8 +92,7 @@ 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;
|
//QTimer *hwapi_triggerBL;
|
||||||
DownloadThread *m_downloadThread;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit hwapi(QWidget *parent = nullptr);
|
explicit hwapi(QWidget *parent = nullptr);
|
||||||
@@ -1296,8 +1299,15 @@ public:
|
|||||||
|
|
||||||
uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override;
|
uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const override;
|
||||||
// returns number of collected bank notes since start-command (current transaction)
|
// returns number of collected bank notes since start-command (current transaction)
|
||||||
// latestBill: last accepted bank note, value in cent
|
// return value: numbers of bills or 99 in case of error
|
||||||
// currentNotes an array with up to 16 (further) notes collected
|
// latestBill: not used
|
||||||
|
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
|
||||||
|
// in normal case:
|
||||||
|
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
|
||||||
|
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
|
||||||
|
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
|
||||||
|
// currentNotes[2]: total sum of bills in cent, low word (16bit)
|
||||||
|
// currentNotes[3]: total sum of bills in cent, high word (16bit)
|
||||||
|
|
||||||
void bna_requestStackerLevel(void) const override;
|
void bna_requestStackerLevel(void) const override;
|
||||||
|
|
||||||
@@ -1307,71 +1317,36 @@ public:
|
|||||||
// countOfBills[1] for 10€ and so on
|
// countOfBills[1] for 10€ and so on
|
||||||
|
|
||||||
|
|
||||||
// download device controller
|
|
||||||
bool dcDownloadRequest(QString const &fileToDownload) const override;
|
|
||||||
bool dcDownloadRequested() const override;
|
|
||||||
bool dcDownloadResetRequest() const override;
|
|
||||||
bool dcDownloadRequestAck() const override;
|
|
||||||
bool dcDownloadRunning() const override;
|
|
||||||
bool dcDownloadFinished() override;
|
|
||||||
|
|
||||||
bool dcDownloadReportStart() const override;
|
|
||||||
bool dcDownloadReportRunning() const override;
|
|
||||||
bool dcDownloadReportFinished() override;
|
|
||||||
|
|
||||||
|
|
||||||
bool dcDownloadThreadStart() override;
|
signals:
|
||||||
bool dcDownloadThreadRunning() const override;
|
void hwapi_templatePrintFinished_OK(void) const override;
|
||||||
void dcDownloadThreadFinalize(DownloadThread *) override;
|
void hwapi_templatePrintFinished_Err(void) const override;
|
||||||
bool dcDownloadThreadFinished() const override;
|
|
||||||
bool dcDownloadReportThreadStart() override;
|
|
||||||
bool dcDownloadReportThreadRunning() const override;
|
|
||||||
void dcDownloadReportThreadFinalize() override;
|
|
||||||
void dcDownloadReportThreadQuit() override;
|
|
||||||
bool dcDownloadReportThreadFinished() const override;
|
|
||||||
|
|
||||||
QString dcDownloadFileName() const override;
|
void hwapi_coinCollectionJustStarted(void) const override;
|
||||||
bool dcDownloadSetRequested(bool) override;
|
void hwapi_coinCollectionAborted(void) const override;
|
||||||
bool dcDownloadSetRunning(bool) override;
|
|
||||||
bool dcDownloadSetFinished(bool) override;
|
|
||||||
void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) override;
|
|
||||||
void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) override;
|
|
||||||
bool dcDownloadGetRequested() const override;
|
|
||||||
bool dcDownloadGetRunning() const override;
|
|
||||||
bool dcDownloadGetFinished() const override;
|
|
||||||
uint16_t dcDownloadGetTotalBlockNumber() const override;
|
|
||||||
uint16_t dcDownloadGetCurrentBlockNumber() const override;
|
|
||||||
|
|
||||||
virtual QObject const *getAPI() override;
|
void hwapi_gotNewCoin(void) const override;
|
||||||
|
void hwapi_payStopByMax(void) const override;
|
||||||
|
void hwapi_payStopByPushbutton(void) const override;
|
||||||
|
|
||||||
signals: // for download
|
void hwapi_payStopByEscrow(void) const override;
|
||||||
void hwapi_reportDCDownloadStatus(QString const&) const;
|
void hwapi_payStopByError(void) const override;
|
||||||
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
void hwapi_payStopByTimeout(void) const override;
|
||||||
void hwapi_reportDCDownloadFailure(QString const&) const;
|
void hwapi_payCancelled(void) const override;
|
||||||
// already declared in interfaces.h
|
void hwapi_coinProcessJustStopped(void) const override;
|
||||||
void hwapi_templatePrintFinished_OK(void) const;
|
|
||||||
void hwapi_templatePrintFinished_Err(void) const;
|
|
||||||
|
|
||||||
void hwapi_coinCollectionJustStarted(void) const;
|
|
||||||
void hwapi_coinCollectionAborted(void) const;
|
|
||||||
|
|
||||||
void hwapi_gotNewCoin(void) const;
|
|
||||||
void hwapi_payStopByMax(void) const;
|
|
||||||
void hwapi_payStopByPushbutton(void) const;
|
|
||||||
|
|
||||||
void hwapi_payStopByEscrow(void) const;
|
|
||||||
void hwapi_payStopByError(void) const;
|
|
||||||
void hwapi_payStopByTimeout(void) const;
|
|
||||||
void hwapi_payCancelled(void) const;
|
|
||||||
void hwapi_coinProcessJustStopped(void) const;
|
|
||||||
|
|
||||||
// new from 2023.06.12
|
// new from 2023.06.12
|
||||||
void hwapi_doorServiceDoorOpened(void) const;
|
void hwapi_doorServiceDoorOpened(void) const override;
|
||||||
void hwapi_doorVaultDoorOpened(void) const;
|
void hwapi_doorVaultDoorOpened(void) const override;
|
||||||
void hwapi_doorCoinBoxRemoved(void) const;
|
void hwapi_doorCoinBoxRemoved(void) const override;
|
||||||
void hwapi_doorCoinBoxInserted(void) const;
|
void hwapi_doorCoinBoxInserted(void) const override;
|
||||||
void hwapi_doorCBinAndAllDoorsClosed(void) const;
|
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
||||||
void hwapi_doorAllDoorsClosed(void) const;
|
void hwapi_doorAllDoorsClosed(void) const override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//void hwapi_slotPrintFinished_OK(void);
|
//void hwapi_slotPrintFinished_OK(void);
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
#define INTERFACE_H
|
#define INTERFACE_H
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +24,8 @@ struct T_emp
|
|||||||
|
|
||||||
// dynamic:
|
// dynamic:
|
||||||
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
uint8_t state; // step counter of EMP (electronic coin checker) FSM (finite state machine):
|
||||||
// 0=start command
|
/*
|
||||||
|
// 0=start command
|
||||||
// 1=powered, do emp ini, send reset
|
// 1=powered, do emp ini, send reset
|
||||||
// 2=delay
|
// 2=delay
|
||||||
// 3=wait for response, requesting status after response
|
// 3=wait for response, requesting status after response
|
||||||
@@ -40,7 +40,7 @@ struct T_emp
|
|||||||
// 90: stop all, 1s delay
|
// 90: stop all, 1s delay
|
||||||
// 99: off, all stopped
|
// 99: off, all stopped
|
||||||
|
|
||||||
|
*/
|
||||||
uint8_t pollingRunning;
|
uint8_t pollingRunning;
|
||||||
uint8_t paymentRunning;
|
uint8_t paymentRunning;
|
||||||
|
|
||||||
@@ -239,6 +239,7 @@ struct T_dynamicCondition
|
|||||||
uint8_t lastVDoorState;
|
uint8_t lastVDoorState;
|
||||||
uint8_t lastCBstate;
|
uint8_t lastCBstate;
|
||||||
char paymentInProgress;
|
char paymentInProgress;
|
||||||
|
// Version Szeged: aug2023
|
||||||
// 0: stopped by timeout
|
// 0: stopped by timeout
|
||||||
// 1: running 2: wait4lastCoin
|
// 1: running 2: wait4lastCoin
|
||||||
// 3: payment stopped manually, coins in Escrow
|
// 3: payment stopped manually, coins in Escrow
|
||||||
@@ -247,6 +248,21 @@ struct T_dynamicCondition
|
|||||||
// 6: coins encashed 7:coins returned
|
// 6: coins encashed 7:coins returned
|
||||||
// 8: CoinChecker or MDB on Error
|
// 8: CoinChecker or MDB on Error
|
||||||
|
|
||||||
|
// since Schoenau with bill and changer, nov2023
|
||||||
|
//0 = no payment
|
||||||
|
//will be set to 1 by cash_startCollection()
|
||||||
|
//neu 1: wait for devices getting ready for payment
|
||||||
|
//2 = payment,
|
||||||
|
//3 = wait for last coin/bill
|
||||||
|
//4 = Bezahlvorgang manuell beendet
|
||||||
|
//5 = payment stopped autom, amount collected, coins in Escrow
|
||||||
|
//6 = Bezahlvorgang beendet weil ZK voll
|
||||||
|
//4,5,6: payment done, keep on polling, wait for cash or return command
|
||||||
|
//7 = encash collected money from coin escrow into cash box
|
||||||
|
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
|
||||||
|
//9 = wait for changer result
|
||||||
|
//10= print refund receipt with "amountToReturn"
|
||||||
|
|
||||||
|
|
||||||
char res1;
|
char res1;
|
||||||
uint16_t U_Batt;
|
uint16_t U_Batt;
|
||||||
@@ -398,8 +414,6 @@ struct T_bna
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class hwapi;
|
|
||||||
class DownloadThread;
|
|
||||||
class hwinf
|
class hwinf
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -2255,14 +2269,23 @@ public:
|
|||||||
virtual void bna_requestCurrentNotes() const {}
|
virtual void bna_requestCurrentNotes() const {}
|
||||||
// send command to DC in order to get transaction data
|
// send command to DC in order to get transaction data
|
||||||
|
|
||||||
virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const {
|
virtual uint8_t bna_getCurrentNotes(uint16_t latestBill, uint16_t *currentNotes) const
|
||||||
|
{
|
||||||
Q_UNUSED(latestBill);
|
Q_UNUSED(latestBill);
|
||||||
Q_UNUSED(currentNotes);
|
Q_UNUSED(currentNotes);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// returns number of collected bank notes since start-command (current transaction)
|
// returns number of collected bank notes since start-command (current transaction)
|
||||||
// latestBill: last accepted bank note, value in cent
|
// return value: numbers of bills or 99 in case of error
|
||||||
// currentNotes an array with up to 16 (further) notes collected
|
// latestBill: not used
|
||||||
|
// in case of error: currentNotes[0,1,2,3] = 1..4 error number(s)
|
||||||
|
// in normal case:
|
||||||
|
// currentNotes[0]: last bill in cent (e.g. 1000 = 10€)
|
||||||
|
// currentNotes[1]: bin 1 = bill is still in escrow else bill is stacked
|
||||||
|
// note: by now (dec2023) escrow is not used, bills always go to stacker (box)
|
||||||
|
// currentNotes[2]: total sum of bills in cent, low word (16bit)
|
||||||
|
// currentNotes[3]: total sum of bills in cent, high word (16bit)
|
||||||
|
|
||||||
|
|
||||||
virtual void bna_requestStackerLevel() const {}
|
virtual void bna_requestStackerLevel() const {}
|
||||||
|
|
||||||
@@ -2276,62 +2299,35 @@ public:
|
|||||||
// countOfBills[1] for 10€ and so on
|
// countOfBills[1] for 10€ and so on
|
||||||
|
|
||||||
|
|
||||||
// download device controller
|
|
||||||
virtual bool dcDownloadRequest(QString const &fileToDownload) const {
|
|
||||||
Q_UNUSED(fileToDownload);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool dcDownloadRequested() const { return false; }
|
|
||||||
virtual bool dcDownloadResetRequest() const { return false; }
|
|
||||||
virtual bool dcDownloadRequestAck() const { return false; }
|
|
||||||
virtual bool dcDownloadRunning() const { return false; }
|
|
||||||
virtual bool dcDownloadFinished() { return false; }
|
|
||||||
|
|
||||||
virtual bool dcDownloadReportStart() const { return false; }
|
|
||||||
virtual bool dcDownloadReportRunning() const { return true; }
|
|
||||||
virtual bool dcDownloadReportFinished() { return true; }
|
|
||||||
|
|
||||||
virtual bool dcDownloadThreadStart() { return false; }
|
|
||||||
virtual bool dcDownloadThreadRunning() const { return true; }
|
|
||||||
virtual void dcDownloadThreadFinalize(DownloadThread *) {}
|
|
||||||
virtual bool dcDownloadThreadFinished() const { return true; }
|
|
||||||
virtual bool dcDownloadReportThreadStart() { return false; }
|
|
||||||
virtual bool dcDownloadReportThreadRunning() const { return true; }
|
|
||||||
virtual void dcDownloadReportThreadFinalize() {}
|
|
||||||
virtual void dcDownloadReportThreadQuit() {}
|
|
||||||
virtual bool dcDownloadReportThreadFinished() const { return true; }
|
|
||||||
|
|
||||||
|
|
||||||
virtual QString dcDownloadFileName() const { return ""; }
|
signals:
|
||||||
virtual bool dcDownloadSetRequested(bool requested) {
|
virtual void hwapi_templatePrintFinished_OK(void) const=0;
|
||||||
Q_UNUSED(requested); return false;
|
virtual void hwapi_templatePrintFinished_Err(void) const=0;
|
||||||
}
|
|
||||||
virtual bool dcDownloadSetRunning(bool running) {
|
|
||||||
Q_UNUSED(running); return false;
|
|
||||||
}
|
|
||||||
virtual bool dcDownloadSetFinished(bool finished) {
|
|
||||||
Q_UNUSED(finished); return false;
|
|
||||||
}
|
|
||||||
virtual void dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
|
||||||
Q_UNUSED(totalBlockNumber);
|
|
||||||
}
|
|
||||||
virtual void dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
|
||||||
Q_UNUSED(currentBlockNumber);
|
|
||||||
}
|
|
||||||
virtual bool dcDownloadGetRequested() const { return false; }
|
|
||||||
virtual bool dcDownloadGetRunning() const { return false; }
|
|
||||||
virtual bool dcDownloadGetFinished() const { return false; }
|
|
||||||
virtual uint16_t dcDownloadGetTotalBlockNumber() const { return 0; }
|
|
||||||
virtual uint16_t dcDownloadGetCurrentBlockNumber() const { return 0; }
|
|
||||||
|
|
||||||
virtual QObject const *getAPI() { return nullptr; }
|
virtual void hwapi_coinCollectionJustStarted(void) const=0;
|
||||||
|
virtual void hwapi_coinCollectionAborted(void) const=0;
|
||||||
|
|
||||||
|
virtual void hwapi_gotNewCoin(void) const=0;
|
||||||
|
virtual void hwapi_payStopByMax(void) const=0;
|
||||||
|
virtual void hwapi_payStopByPushbutton(void) const=0;
|
||||||
|
|
||||||
|
virtual void hwapi_payStopByEscrow(void) const=0;
|
||||||
|
virtual void hwapi_payStopByError(void) const=0;
|
||||||
|
virtual void hwapi_payStopByTimeout(void) const=0;
|
||||||
|
virtual void hwapi_payCancelled(void) const=0;
|
||||||
|
virtual void hwapi_coinProcessJustStopped(void) const=0;
|
||||||
|
|
||||||
|
virtual void hwapi_doorServiceDoorOpened(void) const=0;
|
||||||
|
virtual void hwapi_doorVaultDoorOpened(void) const=0;
|
||||||
|
virtual void hwapi_doorCoinBoxRemoved(void) const=0;
|
||||||
|
virtual void hwapi_doorCoinBoxInserted(void) const=0;
|
||||||
|
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
||||||
|
virtual void hwapi_doorAllDoorsClosed(void) const=0;
|
||||||
|
|
||||||
signals: // for download
|
|
||||||
void hwapi_reportDCDownloadStatus(QString const&) const;
|
|
||||||
void hwapi_reportDCDownloadSuccess(QString const&) const;
|
|
||||||
void hwapi_reportDCDownloadFailure(QString const&) const;
|
|
||||||
|
|
||||||
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
||||||
|
/* GH Version, bringt Fehler
|
||||||
void hwapi_templatePrintFinished_OK() const;
|
void hwapi_templatePrintFinished_OK() const;
|
||||||
void hwapi_templatePrintFinished_Err() const;
|
void hwapi_templatePrintFinished_Err() const;
|
||||||
|
|
||||||
@@ -2354,6 +2350,7 @@ signals: // for download
|
|||||||
void hwapi_doorCoinBoxInserted() const;
|
void hwapi_doorCoinBoxInserted() const;
|
||||||
void hwapi_doorCBinAndAllDoorsClosed() const;
|
void hwapi_doorCBinAndAllDoorsClosed() const;
|
||||||
void hwapi_doorAllDoorsClosed() const;
|
void hwapi_doorAllDoorsClosed() const;
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
#ifndef REPORTING_THREAD_H_INCLUDED
|
|
||||||
#define REPORTING_THREAD_H_INCLUDED
|
|
||||||
|
|
||||||
#include <QThread>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
class hwapi;
|
|
||||||
class ReportingThread : public QThread {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ReportingThread(hwapi *hw);
|
|
||||||
~ReportingThread();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// reporting thread does not have a running event queue, and therefore
|
|
||||||
// no slots. signals work the usual way.
|
|
||||||
void run() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
hwapi *m_hw;
|
|
||||||
QString m_fileToDownload;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // REPORTING_THREAD_H_INCLUDED
|
|
@@ -2,6 +2,7 @@
|
|||||||
#ifndef RUN_PROCESS_H
|
#ifndef RUN_PROCESS_H
|
||||||
#define RUN_PROCESS_H
|
#define RUN_PROCESS_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -25,7 +26,7 @@
|
|||||||
class T_runProc : public QObject
|
class T_runProc : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QTimer *hwapi_TimerPayment, *hwapi_triggerBL;
|
QTimer *hwapi_TimerPayment, *hwapi_triggerBL, *myTO;
|
||||||
|
|
||||||
void sub_emp_getAllParameters(struct T_emp *emp);
|
void sub_emp_getAllParameters(struct T_emp *emp);
|
||||||
void changer_getAllParameters(struct T_changer *mw);
|
void changer_getAllParameters(struct T_changer *mw);
|
||||||
|
@@ -301,26 +301,9 @@ struct SharedMem
|
|||||||
uint8_t p_nextFDcmdsInQueue;
|
uint8_t p_nextFDcmdsInQueue;
|
||||||
|
|
||||||
|
|
||||||
// download of device controller and json files
|
|
||||||
struct DCDownload {
|
|
||||||
enum class FILE_INDEX {
|
|
||||||
DC_BINARY = 0, DC2C_CASH = 1, DC2C_CONF = 2, DC2C_SERIAL=3,
|
|
||||||
DC2C_PRINT_01, DC2C_PRINT_02, DC2C_PRINT_03, DC2C_PRINT_04,
|
|
||||||
DC2C_PRINT_05, DC2C_PRINT_06, DC2C_PRINT_07, DC2C_PRINT_08,
|
|
||||||
DC2C_PRINT_09, DC2C_PRINT_10, DC2C_PRINT_11, DC2C_PRINT_12,
|
|
||||||
DC2C_PRINT_13, DC2C_PRINT_14, DC2C_PRINT_15, DC2C_PRINT_16,
|
|
||||||
DC2C_PRINT_17, DC2C_PRINT_18, DC2C_PRINT_19, DC2C_PRINT_20,
|
|
||||||
DC2C_PRINT_21, DC2C_PRINT_22, DC2C_PRINT_23, DC2C_PRINT_24,
|
|
||||||
DC2C_PRINT_25, DC2C_PRINT_26, DC2C_PRINT_27, DC2C_PRINT_28,
|
|
||||||
DC2C_PRINT_29, DC2C_PRINT_30, DC2C_PRINT_31, DC2C_PRINT_32
|
|
||||||
};
|
|
||||||
char m_filename[(int)FILE_INDEX::DC2C_PRINT_32][512];
|
|
||||||
std::atomic_ushort m_totalBlocks;
|
|
||||||
std::atomic_ushort m_currentblockNumber;
|
|
||||||
std::atomic_bool m_requested{false};
|
|
||||||
std::atomic_bool m_running{false};
|
|
||||||
std::atomic_bool m_finished{false};
|
|
||||||
} m_downLoadDC;
|
|
||||||
|
|
||||||
static QSharedMemory *getShm(std::size_t s = 0);
|
static QSharedMemory *getShm(std::size_t s = 0);
|
||||||
|
|
||||||
|
@@ -527,6 +527,9 @@ void gpi_storeDcDataValid(bool isVal);
|
|||||||
|
|
||||||
bool epi_areDcDataValid();
|
bool epi_areDcDataValid();
|
||||||
|
|
||||||
|
void epi_setDcDataValid(void);
|
||||||
|
|
||||||
|
void epi_resetDcDataValid(void);
|
||||||
|
|
||||||
|
|
||||||
void epi_clearDynData(void);
|
void epi_clearDynData(void);
|
||||||
|
@@ -2,10 +2,20 @@ TEMPLATE = lib
|
|||||||
TARGET = CAmaster
|
TARGET = CAmaster
|
||||||
VERSION="1.0.0"
|
VERSION="1.0.0"
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../include/com.h \
|
||||||
|
../include/datIf.h \
|
||||||
|
../include/prot.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../src/com.cpp \
|
||||||
|
../src/datIf.cpp \
|
||||||
|
../src/prot.cpp
|
||||||
|
|
||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
|
|
||||||
DEFINES+=THIS_IS_CA_MASTER
|
DEFINES+=THIS_IS_CA_MASTER
|
||||||
DEFINES-=THIS_IS_CA_SLAVE
|
|
||||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
|
@@ -5,8 +5,6 @@ VERSION="1.0.0"
|
|||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
DEFINES+=THIS_IS_CA_SLAVE
|
DEFINES+=THIS_IS_CA_SLAVE
|
||||||
DEFINES-=THIS_IS_CA_MASTER
|
|
||||||
|
|
||||||
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
DESTDIR=$${_PRO_FILE_PWD_}/../build
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
|
117
src/datIf.cpp
117
src/datIf.cpp
@@ -1,10 +1,14 @@
|
|||||||
|
/*
|
||||||
|
History:
|
||||||
|
06.12.2023: weitere IN-requests in Autorequest übernommen
|
||||||
|
Umschaltung mit/ohne Verkauf, während VK nur 12 wichtige, sonst alle 36
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
#include "datIf.h"
|
#include "datIf.h"
|
||||||
#include "sendWRcmd.h"
|
#include "sendWRcmd.h"
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
#include "download_thread.h"
|
|
||||||
#include "hwapi.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <datei.h>
|
#include <datei.h>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -50,10 +54,8 @@ static uint8_t datif_pNextCmd, datif_sendSlowCmd;
|
|||||||
//#define DATIF_CTR_GOTRESPVAL 100
|
//#define DATIF_CTR_GOTRESPVAL 100
|
||||||
|
|
||||||
|
|
||||||
T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
|
T_datif::T_datif(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
m_hw = hw;
|
|
||||||
|
|
||||||
QByteArray myBA;
|
QByteArray myBA;
|
||||||
QDir myDir("../dmd");
|
QDir myDir("../dmd");
|
||||||
|
|
||||||
@@ -86,7 +88,8 @@ T_datif::T_datif(hwinf *hw, QObject *parent) : QObject(parent)
|
|||||||
dif_scanStep=0;
|
dif_scanStep=0;
|
||||||
selectedSlaveAddr=FIX_SLAVE_ADDR;
|
selectedSlaveAddr=FIX_SLAVE_ADDR;
|
||||||
cycl_running=0;
|
cycl_running=0;
|
||||||
gpi_storeDcDataValid(0); // data are not yet valid, no response from DC by now
|
epi_resetDcDataValid(); // data are not yet valid, no response from DC by now
|
||||||
|
|
||||||
datif_noResponseCtr=0;
|
datif_noResponseCtr=0;
|
||||||
|
|
||||||
datif_repeatCtr=0;
|
datif_repeatCtr=0;
|
||||||
@@ -142,14 +145,14 @@ char T_datif::datif_cycleSend()
|
|||||||
if ( !myDCIF->isPortOpen())
|
if ( !myDCIF->isPortOpen())
|
||||||
{
|
{
|
||||||
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
|
//qDebug() << "com port not available"; // wird ununterbrochen ausgegeben
|
||||||
gpi_storeDcDataValid(0); // DC data not valid
|
epi_resetDcDataValid(); // DC data not valid
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// supervise if DC data are valid
|
// supervise if DC data are valid
|
||||||
datif_noResponseCtr++; // inc every 20ms
|
datif_noResponseCtr++; // inc every 20ms
|
||||||
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s
|
if (datif_noResponseCtr>250) // no life sign from device controller (DC) for about 3s
|
||||||
gpi_storeDcDataValid(0); // DC data has not updated for >=5s -> no longer valid!
|
epi_resetDcDataValid(); // DC data has not updated for >=5s -> no longer valid!
|
||||||
|
|
||||||
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
|
// Ueberwachung ob ein oder mehrere Commands am Stueck erfolgreich waren
|
||||||
if (gpi_wantToResetSupervision())
|
if (gpi_wantToResetSupervision())
|
||||||
@@ -203,21 +206,8 @@ char T_datif::datif_cycleSend()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_hw->dcDownloadRequested()) { // only happens in ca-master
|
|
||||||
m_hw->dcDownloadResetRequest();
|
|
||||||
|
|
||||||
// start download-thread.
|
|
||||||
m_downloadThread = new DownloadThread(m_hw);
|
|
||||||
m_downloadThread->start();
|
|
||||||
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0 && !m_downloadThread->isRunning()) {
|
|
||||||
QThread::msleep(100);
|
|
||||||
}
|
|
||||||
if (cnt <= 0) {
|
|
||||||
qCritical() << "DOWNLOAD-THREAD NOT RUNNING WITHIN 1000ms";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 17.7.2023: repeat commands if result was !=OK -------------------------------------------------------------------
|
// 17.7.2023: repeat commands if result was !=OK -------------------------------------------------------------------
|
||||||
if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht
|
if (datif_cmdWasPerformed==2 && doRepeat) // Cmd was not or false performed und Wiederholen erwuenscht
|
||||||
@@ -355,7 +345,7 @@ char T_datif::datif_cycleSend()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dif_scanStep=0; // always start from beginning
|
dif_scanStep=0; // always start from beginning
|
||||||
gpi_storeDcDataValid(0);
|
epi_resetDcDataValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
datif_cmdWasPerformed=0; // 0: no response by now
|
datif_cmdWasPerformed=0; // 0: no response by now
|
||||||
@@ -368,9 +358,20 @@ char T_datif::datif_cycleSend()
|
|||||||
char T_datif::sendINrequestsAutomatic(void)
|
char T_datif::sendINrequestsAutomatic(void)
|
||||||
{
|
{
|
||||||
//qDebug() << "send IN request " << dif_scanStep;
|
//qDebug() << "send IN request " << dif_scanStep;
|
||||||
// uint8_t datif_autoRequCommandList[50]={11, 12, 18, 104, 106, 103, 14, 27, 109, 17, 19, 23, 30, 31, 32, 33, 114, 35};
|
//uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30,
|
||||||
uint8_t datif_autoRequCommandList[30]={11, 12, 14, 17, 18, 19, 22, 23, 27, 30, 31, 32, 33, 35, 102, 103, 104, 106, 107, 109, 114,0,0,0,0,0,0,0,0,0};
|
// 31, 32, 33, 35, 102, 103, 104, 106, 107, 109,
|
||||||
uint8_t datif_maxNrCommands=21, datif_sendNow;
|
// 114,0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
|
// extension 6.12.23, complete list:
|
||||||
|
uint8_t datif_autoRequCommandList[40]={11, 12, 13, 14, 17, 18, 19, 21, 22, 23,
|
||||||
|
24, 25, 27, 30, 31, 32, 33, 35, 39, 40,
|
||||||
|
41, 42, 102,103,104,106,107,108,109,110,
|
||||||
|
112,113,114,115,116,0, 0, 0, 0, 0};
|
||||||
|
uint8_t datif_maxNrCommands=35, datif_sendNow;
|
||||||
|
|
||||||
|
// send quicker while transaction is ongoing:
|
||||||
|
uint8_t datif_vendRequCommandList[15]={102,107,108,110,112,115,116,31,32,40,41,42,23,0,0};
|
||||||
|
uint8_t datif_maxVendingCmds=13;
|
||||||
|
|
||||||
// special commands:
|
// special commands:
|
||||||
// 102: get IOs run constantly!!!
|
// 102: get IOs run constantly!!!
|
||||||
@@ -380,40 +381,44 @@ char T_datif::sendINrequestsAutomatic(void)
|
|||||||
// 107, 22: MDB: poll if needed
|
// 107, 22: MDB: poll if needed
|
||||||
|
|
||||||
doRepeat=true; // 20.9.23 15uhr (after release)
|
doRepeat=true; // 20.9.23 15uhr (after release)
|
||||||
if (datif_sendSlowCmd>0)
|
|
||||||
{
|
|
||||||
// send special command, slowly
|
|
||||||
datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
|
|
||||||
if (datif_pNextCmd >= datif_maxNrCommands)
|
|
||||||
datif_pNextCmd=0;
|
|
||||||
if (datif_sendNow>0) // never send Command 0
|
|
||||||
datif_sendIOrequest(0, datif_sendNow, 0);
|
|
||||||
else
|
|
||||||
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
|
|
||||||
|
|
||||||
//qDebug()<< "datif send request " << datif_sendNow;
|
if (gpi_getNowCoinPay())
|
||||||
|
{
|
||||||
|
// send only important commands while transaction in progress
|
||||||
|
if (datif_pNextCmd>=datif_maxVendingCmds ) datif_pNextCmd=0;
|
||||||
|
datif_sendNow=datif_vendRequCommandList[datif_pNextCmd++];
|
||||||
|
if (datif_sendNow>0) // never send Command 0
|
||||||
|
{
|
||||||
|
datif_sendIOrequest(0, datif_sendNow, 0);
|
||||||
|
//qDebug() << "datif, VEND-request: " << datif_sendNow;
|
||||||
|
} else
|
||||||
|
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
|
||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
if (gpi_getNowCoinPay())
|
// no transaction, request all but request DI's more frequently
|
||||||
|
if (datif_sendSlowCmd>0) // send slow and fast commands alternating
|
||||||
{
|
{
|
||||||
// request coin input, high priority
|
// send special command, slowly
|
||||||
datif_sendIOrequest(0, 112, 0);
|
if (datif_pNextCmd>=datif_maxNrCommands ) datif_pNextCmd=0;
|
||||||
//qDebug()<< "datif send request 112 get coins";
|
datif_sendNow=datif_autoRequCommandList[datif_pNextCmd++];
|
||||||
|
if (datif_sendNow>0) // never send Command 0
|
||||||
|
{
|
||||||
|
datif_sendIOrequest(0, datif_sendNow, 0);
|
||||||
|
// qDebug() << "datif, auto-requ: " << datif_sendNow;
|
||||||
|
} else
|
||||||
|
datif_pNextCmd=0; // falls in der Liste 0 vorkommt dann von vorne beginnen
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// request inputs, high priority
|
// request inputs, high priority
|
||||||
datif_sendIOrequest(0, 31, 0); // 102
|
datif_sendIOrequest(0, 31, 0); // 102
|
||||||
// while coin collection DIs are polled slowly with datif_autoRequCommandList[]
|
// while coin collection DIs are polled slower
|
||||||
|
//qDebug()<< "datif send requ.31 get DIs";
|
||||||
//qDebug()<< "datif send request 102 get DIs";
|
|
||||||
}
|
}
|
||||||
|
if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0....
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++datif_sendSlowCmd>1) datif_sendSlowCmd=0; // 0,1,0,1,0,1,0....
|
|
||||||
|
|
||||||
return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!!
|
return 0; // 25.9.2023, wichtig sonst bleibt die komplette PTU stehen!!!!
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -457,7 +462,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
uint32_t ultmp;
|
uint32_t ultmp;
|
||||||
//int portNr;
|
//int portNr;
|
||||||
bool ret;
|
bool ret;
|
||||||
uint8_t uctmp; //, res; // maxai
|
uint8_t uctmp; //, nn; //, res; // maxai
|
||||||
char ctmp;
|
char ctmp;
|
||||||
//static uint8_t lastResult;
|
//static uint8_t lastResult;
|
||||||
//uint8_t prnResult;
|
//uint8_t prnResult;
|
||||||
@@ -1032,7 +1037,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
case 31: // Get dynamic machine conditions (doors, voltage, alarm….)
|
case 31: // Get dynamic machine conditions (doors, voltage, alarm….)
|
||||||
if (RdDleng>50)
|
if (RdDleng>50)
|
||||||
{
|
{
|
||||||
gpi_storeDcDataValid(1); // DC-Data are valid as DC responded.
|
epi_setDcDataValid(); // DC-Data are valid as DC responded.
|
||||||
// Could be set to every response but this (31)
|
// Could be set to every response but this (31)
|
||||||
// is a very common and very important request
|
// is a very common and very important request
|
||||||
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
gpi_storeDynMachineConditions(RdDleng, receivedData);
|
||||||
@@ -1079,11 +1084,11 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
/*
|
/*
|
||||||
qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress;
|
qDebug()<<"datif cmd38 got vault data. blockNr: "<<readAddress;
|
||||||
if (readAddress==0)
|
if (readAddress==0)
|
||||||
for (nn=0; nn<64; nn+=8)
|
for (nn=0; nn<64; nn+=8)
|
||||||
{
|
{
|
||||||
qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" "
|
qDebug()<<receivedData[nn]<<" "<<receivedData[nn+1]<<" "<<receivedData[nn+2]<<" "<<receivedData[nn+3]<<" "
|
||||||
<<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7];
|
<<receivedData[nn+4]<<" "<<receivedData[nn+5]<<" "<<receivedData[nn+6]<<" "<<receivedData[nn+7];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//}
|
//}
|
||||||
break;
|
break;
|
||||||
@@ -1123,9 +1128,7 @@ char T_datif::loadRecDataFromFrame()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 42: // get BNA box content and value of types
|
case 42: // get BNA box content and value of types
|
||||||
// qDebug()<< "CAmaster datif_got 42 ";
|
//qDebug()<< "CAslave datif_got 42";
|
||||||
// for (uctmp=0; uctmp<64; uctmp++)
|
|
||||||
// qDebug()<<receivedData[uctmp]<<" ";
|
|
||||||
|
|
||||||
if (RdDleng>60)
|
if (RdDleng>60)
|
||||||
{
|
{
|
||||||
|
@@ -1,320 +0,0 @@
|
|||||||
#include "download_thread.h"
|
|
||||||
#include "shared_mem_buffer.h"
|
|
||||||
#include "hwapi.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDateTime>
|
|
||||||
|
|
||||||
|
|
||||||
DownloadThread::DownloadThread(hwinf *hw)
|
|
||||||
: m_hw(hw)
|
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
|
||||||
// connect(this, &QThread::finished,
|
|
||||||
// dynamic_cast<QObject const *>(m_hw), &QThread::deleteLater);
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::~DownloadThread() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// USING THE DC BOOTLOADER
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
1 : bl_reboot() // send to application, want DC2 to reset (in order to
|
|
||||||
// start the bootloader)
|
|
||||||
//
|
|
||||||
// NOTE: this function is NOT reliable !!! Sometimes it
|
|
||||||
// simply does not work, in which case bl_startBL,
|
|
||||||
// bl_checkBL and bl_isUp do not work as well.
|
|
||||||
// Alas, there is no feedback if bl_reboot worked!
|
|
||||||
//
|
|
||||||
// NOTE: this function can be called only once per
|
|
||||||
// minute, because once called again, the controller
|
|
||||||
// performs some self-checks consuming some time.
|
|
||||||
//
|
|
||||||
// NOTE: after a successful bl_reboot(), the device is
|
|
||||||
// waiting about 4 seconds in the bootloader. To stay in
|
|
||||||
// the bootloader, we have to send the command
|
|
||||||
// bl_startBL(), which is kind of a misnomer, as it
|
|
||||||
// should be bl_doNotLeaveBL().
|
|
||||||
//
|
|
||||||
2 : bl_startBL(): // send within 4s after DC power-on, otherwise
|
|
||||||
// bootloader is left.
|
|
||||||
//
|
|
||||||
// NOTE: a running bootloader is a MUST for the download
|
|
||||||
// process of a device controller firmware as it does
|
|
||||||
// the actual writing of the memory (the bl_reboot()
|
|
||||||
// from above erases the available memory).
|
|
||||||
//
|
|
||||||
3 : bl_check(): // send command to verify if bl is up
|
|
||||||
//
|
|
||||||
// NOTE: this command is kind of a request that we want
|
|
||||||
// to check if the bootloader is up. The device
|
|
||||||
// (actually the bootloader) responds with its version.
|
|
||||||
//
|
|
||||||
4 : bl_isUp(): // returns true if bl is up and running
|
|
||||||
//
|
|
||||||
// NOTE: we know what the bootloader version actually is
|
|
||||||
// as the bootloader does not change. By comparing the
|
|
||||||
// string received in the previous step with this known
|
|
||||||
// version string we know if the bootloader is up.
|
|
||||||
//
|
|
||||||
// NOTE FOR ALL PREVIOUS STEPS: execute them in their
|
|
||||||
// own slots each to be sure to receive any possible
|
|
||||||
// responds from the device.
|
|
||||||
//
|
|
||||||
5 : bl_sendAddress(blockNumber)
|
|
||||||
// send start address, nr of 64-byte block, start with 0
|
|
||||||
// will be sent only for following block-numbers:
|
|
||||||
// 0, 1024, 2048, 3072 and 4096, so basically every
|
|
||||||
// 64kByte.
|
|
||||||
// for other addresses nothing happens
|
|
||||||
|
|
||||||
6 : bl_wasSendingAddOK()
|
|
||||||
// return val: 0: no response by now
|
|
||||||
// 1: error
|
|
||||||
// 10: OK
|
|
||||||
|
|
||||||
7 : bl_sendDataBlock()
|
|
||||||
// send 64 byte from bin file
|
|
||||||
|
|
||||||
8 : bl_sendLastBlock()
|
|
||||||
// send this command after all data are transferred
|
|
||||||
|
|
||||||
9 : bl_wasSendingDataOK()
|
|
||||||
// return val: 0: no response by now
|
|
||||||
// 1: error
|
|
||||||
// 10: OK
|
|
||||||
|
|
||||||
10 : bl_stopBL() // leave bl and start (the new) application
|
|
||||||
//
|
|
||||||
// NOTE: this function MUST work under all conditions.
|
|
||||||
// Alas, there is no direct result for this command, so
|
|
||||||
// the only way of knowing it was successful is to ask
|
|
||||||
// the device if the bootloader is still running.
|
|
||||||
// There is no problem to repeat this command until the
|
|
||||||
// bootloader is really not running anymore.
|
|
||||||
*/
|
|
||||||
void DownloadThread::run() {
|
|
||||||
// download thread running in ca-master sends the dc-file down to firmware
|
|
||||||
// TODO: send the json files as well
|
|
||||||
|
|
||||||
m_hw->dcDownloadRequestAck();
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): DOWNLOAD THREAD STARTED";
|
|
||||||
|
|
||||||
// load binary device controller file into memory
|
|
||||||
QByteArray ba = loadBinaryDCFile(m_hw->dcDownloadFileName());
|
|
||||||
if (ba.size() > 0) {
|
|
||||||
uint16_t const totalBlocks = (((ba.size())%64)==0) ? (ba.size()/64) : (ba.size()/64)+1;
|
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
|
||||||
|
|
||||||
// fill last block of data to be sent with 0xFF
|
|
||||||
ba = ba.leftJustified(totalBlocks*64, (char)(0xFF));
|
|
||||||
|
|
||||||
resetDeviceController();
|
|
||||||
if (startBootloader()) {
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BYTES TO SEND TO DC" << ba.size();
|
|
||||||
qCritical() << "DownloadThread::run(): TOTAL NUMBER OF BLOCKS" << totalBlocks;
|
|
||||||
|
|
||||||
int currentBlock = 0;
|
|
||||||
DownloadResult res = DownloadResult::OK;
|
|
||||||
qCritical() << "64-byte block " << currentBlock;
|
|
||||||
while (res != DownloadResult::ERROR && currentBlock < totalBlocks) {
|
|
||||||
if ((res = sendNextAddress(currentBlock)) != DownloadResult::ERROR) {
|
|
||||||
if ((res = sendNextDataBlock(ba, currentBlock)) != DownloadResult::ERROR) {
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
currentBlock += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << "DownloadThread::run(): last 64-byte block %04d" << currentBlock;
|
|
||||||
|
|
||||||
int const rest = ba.size() % 64;
|
|
||||||
int const offset = ba.size() - rest;
|
|
||||||
char const *startAddress = ba.constData() + offset;
|
|
||||||
|
|
||||||
if (rest > 0) {
|
|
||||||
// SHOULD NEVER HAPPEN !!!
|
|
||||||
uint8_t local[66];
|
|
||||||
memset(local, 0xFF, sizeof(local));
|
|
||||||
memcpy(local, startAddress, rest);
|
|
||||||
qCritical() << "DownloadThread::run(): ERROR SEND REMAINING" << rest << "BYTES";
|
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
|
||||||
} else {
|
|
||||||
m_hw->bl_sendLastBlock();
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
}
|
|
||||||
qCritical() << "DownloadThread::run(): last result" << (int)sendStatus(m_hw->bl_wasSendingDataOK());
|
|
||||||
}
|
|
||||||
stopBootloader(); // there is no harm in stopping the bootloader even
|
|
||||||
} // if it was not started at all
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// test code:
|
|
||||||
uint16_t const totalBlocks = 100;
|
|
||||||
m_hw->dcDownloadSetTotalBlockNumber(totalBlocks);
|
|
||||||
|
|
||||||
for (uint16_t currentBlock = 0; currentBlock <= totalBlocks; ++currentBlock) {
|
|
||||||
m_hw->dcDownloadSetCurrentBlockNumber(currentBlock);
|
|
||||||
QThread::msleep(100);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_hw->dcDownloadSetRunning(false);
|
|
||||||
m_hw->dcDownloadSetFinished(true);
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD FINISHED";
|
|
||||||
|
|
||||||
// the object deletes itself ! This is the last line in run().
|
|
||||||
// Never touch the object after this statement
|
|
||||||
// m_hw->dcDownloadThreadFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult DownloadThread::sendStatus(int ret) const {
|
|
||||||
switch (ret) { // return values of dc are:
|
|
||||||
case 0: // 0: no answer by now
|
|
||||||
return DownloadResult::NOP; // 1: error
|
|
||||||
case 10: // 10: success
|
|
||||||
return DownloadResult::OK;
|
|
||||||
default:;
|
|
||||||
}
|
|
||||||
return DownloadResult::ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult
|
|
||||||
DownloadThread::sendNextAddress(int bNum) const {
|
|
||||||
// sends address only if blockNumber is one of 0, 1024, 2048, 3072, 4096
|
|
||||||
int noAnswerCount = 0;
|
|
||||||
int errorCount = 0;
|
|
||||||
if ( bNum==0 || bNum==1024 || bNum==2048 || bNum==3072 || bNum==4096 ) {
|
|
||||||
// qDebug() << "addr-block" << bNum << "...";
|
|
||||||
while (noAnswerCount <= 250) {
|
|
||||||
m_hw->bl_sendAddress(bNum);
|
|
||||||
QThread::msleep(100);
|
|
||||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingAddOK());
|
|
||||||
if (res != DownloadResult::NOP) {
|
|
||||||
if (res == DownloadResult::ERROR) {
|
|
||||||
if (++errorCount >= 10) {
|
|
||||||
qCritical() << "addr-block" << bNum << "...FAILED";
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else { // res == DownloadResult::OK
|
|
||||||
// qInfo() << "addr-block" << bNum << "...OK";
|
|
||||||
|
|
||||||
// TODO: hier ins shared-mem schreiben
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
noAnswerCount += 1; // no answer by now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// wait max. about 3 seconds
|
|
||||||
return DownloadResult::TIMEOUT;
|
|
||||||
}
|
|
||||||
// blockNumber is not one of 0, 1024, 2048, 3072, 4096 -> do nothing
|
|
||||||
return DownloadResult::NOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadThread::DownloadResult
|
|
||||||
DownloadThread::sendNextDataBlock(QByteArray const &binary, int bNum) const {
|
|
||||||
uint8_t local[66];
|
|
||||||
int const bAddr = bNum * 64;
|
|
||||||
int noAnswerCount = 0;
|
|
||||||
int errorCount = 0;
|
|
||||||
|
|
||||||
memcpy(local, binary.constData() + bAddr, 64);
|
|
||||||
local[64] = local[65] = 0x00;
|
|
||||||
|
|
||||||
// QByteArray b((const char *)(&local[0]), 64);
|
|
||||||
// qCritical() << "SNDB" << bNum << b.size() << b.toHex();
|
|
||||||
|
|
||||||
while (noAnswerCount <= 250) {
|
|
||||||
m_hw->bl_sendDataBlock(64, local);
|
|
||||||
QThread::msleep(10);
|
|
||||||
DownloadResult const res = sendStatus(m_hw->bl_wasSendingDataOK());
|
|
||||||
if (res != DownloadResult::NOP) {
|
|
||||||
if (res == DownloadResult::ERROR) {
|
|
||||||
if (++errorCount >= 10) {
|
|
||||||
qCritical() << "data for block" << bNum << "...FAILED";
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// qInfo() << "data for block" << bNum << "OK";
|
|
||||||
|
|
||||||
// TODO: hier ins shared mem schreiben
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
noAnswerCount += 1; // no answer by now
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// wait max. about 3 seconds
|
|
||||||
return DownloadResult::TIMEOUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::startBootloader() const {
|
|
||||||
qDebug() << "starting bootloader...";
|
|
||||||
int nTry = 5;
|
|
||||||
while (--nTry >= 0) {
|
|
||||||
m_hw->bl_startBL();
|
|
||||||
QThread::msleep(5000);
|
|
||||||
m_hw->bl_checkBL();
|
|
||||||
if (m_hw->bl_isUp()) {
|
|
||||||
qInfo() << "starting bootloader...OK";
|
|
||||||
QThread::msleep(5000);
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
qCritical() << "bootloader not up (" << nTry << ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qCritical() << "starting bootloader...FAILED";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::stopBootloader() const {
|
|
||||||
qDebug() << "stopping bootloader...";
|
|
||||||
int nTry = 5;
|
|
||||||
while (--nTry >= 0) {
|
|
||||||
m_hw->bl_stopBL();
|
|
||||||
QThread::msleep(500);
|
|
||||||
if (!m_hw->bl_isUp()) {
|
|
||||||
qInfo() << "stopping bootloader...OK";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qCritical() << "stopping bootloader...FAILED";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DownloadThread::resetDeviceController() const {
|
|
||||||
qDebug() << "resetting device controller...";
|
|
||||||
m_hw->bl_rebootDC();
|
|
||||||
// wait maximally 3 seconds, before starting bootloader
|
|
||||||
QThread::sleep(1);
|
|
||||||
qInfo() << "resetting device controller...OK";
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray DownloadThread::loadBinaryDCFile(QString filename) const {
|
|
||||||
qDebug() << "loading dc binary" << filename << "...";
|
|
||||||
|
|
||||||
QFile file(filename); // closed in destructor call
|
|
||||||
if (!file.exists()) {
|
|
||||||
qCritical() << file.fileName() << "does not exist";
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
|
||||||
qCritical() << "cannot open file" << file.fileName();
|
|
||||||
return QByteArray();
|
|
||||||
}
|
|
||||||
qInfo() << "loading dc binary" << filename << "...OK";
|
|
||||||
return file.readAll();
|
|
||||||
}
|
|
306
src/hwapi.cpp
306
src/hwapi.cpp
@@ -20,12 +20,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hwapi.h"
|
#include "hwapi.h"
|
||||||
#include "reporting_thread.h"
|
|
||||||
#include "download_thread.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
#include <atomic>
|
|
||||||
|
|
||||||
static uint32_t hwapi_lastStartAmount;
|
static uint32_t hwapi_lastStartAmount;
|
||||||
static uint32_t hwapi_lastTotalAmount;
|
static uint32_t hwapi_lastTotalAmount;
|
||||||
@@ -55,9 +49,21 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
|||||||
// {
|
// {
|
||||||
|
|
||||||
#ifdef THIS_IS_CA_MASTER
|
#ifdef THIS_IS_CA_MASTER
|
||||||
myDatif = new T_datif(this); // für die CAslave-Lib auskommentieren!
|
|
||||||
#else
|
#ifdef THIS_IS_CA_SLAVE
|
||||||
qCritical()<<"hwapi: error CAslave cannot include T_datif";
|
#error "SLAVE LIB COMPILED INTO MASTER"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
myDatif = new T_datif(); // für die CAslave-Lib auskommentieren!
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef THIS_IS_CA_SLAVE
|
||||||
|
|
||||||
|
#ifdef THIS_IS_CA_MASTER
|
||||||
|
#error "MASTER LIB COMPILED INTO MASTER"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// }
|
// }
|
||||||
@@ -115,10 +121,6 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
|
|||||||
|
|
||||||
void hwapi::hwapi_slotPayProc(void)
|
void hwapi::hwapi_slotPayProc(void)
|
||||||
{
|
{
|
||||||
//cash_paymentProcessing();
|
|
||||||
//doors_supervise();
|
|
||||||
//dcBL_cycle();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1792,6 +1794,8 @@ void hwapi::prn_sendText(QByteArray *buf) const
|
|||||||
uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak;
|
uint16_t nn, pp, mm, leng_byt, leng_blk, llb, freeStak;
|
||||||
uint8_t tmp66[66];
|
uint8_t tmp66[66];
|
||||||
|
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
gpi_storeDcDataValid(0);
|
gpi_storeDcDataValid(0);
|
||||||
|
|
||||||
@@ -2896,6 +2900,8 @@ bool hwapi::prn_printTemplate(uint8_t nrOftemplate) const
|
|||||||
{
|
{
|
||||||
// return true if sending, false if cmd-stack is full
|
// return true if sending, false if cmd-stack is full
|
||||||
|
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
gpi_storeDcDataValid(0);
|
gpi_storeDcDataValid(0);
|
||||||
|
|
||||||
@@ -3000,6 +3006,8 @@ bool hwapi::log_getVaultRecord(struct T_vaultRecord *retVR) const
|
|||||||
|
|
||||||
bool hwapi::prn_printAccountReceipt(void) const
|
bool hwapi::prn_printAccountReceipt(void) const
|
||||||
{
|
{
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
gpi_storeDcDataValid(0);
|
gpi_storeDcDataValid(0);
|
||||||
return sendFDcmd_set(154, 0,0, 0,0,0,0);
|
return sendFDcmd_set(154, 0,0, 0,0,0,0);
|
||||||
@@ -3007,6 +3015,8 @@ bool hwapi::prn_printAccountReceipt(void) const
|
|||||||
|
|
||||||
bool hwapi::prn_printTestTicket(void) const
|
bool hwapi::prn_printTestTicket(void) const
|
||||||
{
|
{
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
// return true if sending to DC OK, false if cmd-stack is full
|
// return true if sending to DC OK, false if cmd-stack is full
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
gpi_storeDcDataValid(0);
|
gpi_storeDcDataValid(0);
|
||||||
@@ -3062,7 +3072,9 @@ bool hwapi::cash_cancelPayment(void) const
|
|||||||
{
|
{
|
||||||
// DB1: 1=encash 2=cancel & return coins
|
// DB1: 1=encash 2=cancel & return coins
|
||||||
// 3=stop and keep coins in escrow
|
// 3=stop and keep coins in escrow
|
||||||
epi_setNowCoinPay(false); // new since 20.9.23
|
//epi_setNowCoinPay(false); // new since 20.9.23
|
||||||
|
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
|
||||||
|
|
||||||
//qCritical() << "cash cancel payment and return coins";
|
//qCritical() << "cash cancel payment and return coins";
|
||||||
return sendFDcmd_set(156, 0,0, 2,0,0,0);
|
return sendFDcmd_set(156, 0,0, 2,0,0,0);
|
||||||
}
|
}
|
||||||
@@ -3072,7 +3084,8 @@ bool hwapi::cash_stopPayment(void) const
|
|||||||
{
|
{
|
||||||
// DB1: 1=encash 2=cancel & return coins
|
// DB1: 1=encash 2=cancel & return coins
|
||||||
// 3=stop and keep coins in escrow
|
// 3=stop and keep coins in escrow
|
||||||
epi_setNowCoinPay(false); // new since 20.9.23
|
//epi_setNowCoinPay(false); // new since 20.9.23
|
||||||
|
// am 6.12.23 wieder raus, waehrend Druck und wechseln auch schnell abfragen
|
||||||
//qCritical() << "cash stop payment and keep coins in escrow";
|
//qCritical() << "cash stop payment and keep coins in escrow";
|
||||||
// qCritical() << "emitting signal StopByPushbutton 2";
|
// qCritical() << "emitting signal StopByPushbutton 2";
|
||||||
emit hwapi_payStopByPushbutton();
|
emit hwapi_payStopByPushbutton();
|
||||||
@@ -3433,6 +3446,8 @@ bool hwapi::prn_printKombiticket(uint8_t nrOfKombi) const
|
|||||||
if ((nrOfKombi<1) || (nrOfKombi>8))
|
if ((nrOfKombi<1) || (nrOfKombi>8))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
gpi_storeDcDataValid(0);
|
gpi_storeDcDataValid(0);
|
||||||
|
|
||||||
@@ -3563,6 +3578,8 @@ bool hwapi::log_getVaultData(uint8_t *data) const
|
|||||||
// new from 1.8.23
|
// new from 1.8.23
|
||||||
bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const
|
bool hwapi::prn_printOneAccountReceipt(uint16_t accountNr) const
|
||||||
{
|
{
|
||||||
|
qCritical() << __PRETTY_FUNCTION__ << "RESET DC DATA VALID";
|
||||||
|
|
||||||
// print one out of eight stored last accounting receipts
|
// print one out of eight stored last accounting receipts
|
||||||
// function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts
|
// function log_getHoldAccountNumbers() gives a list of acc-Nr. of the stored receipts
|
||||||
epi_clearDynMachineConditions(); // 24.6.23
|
epi_clearDynMachineConditions(); // 24.6.23
|
||||||
@@ -4377,263 +4394,4 @@ uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOf
|
|||||||
return anzahl;
|
return anzahl;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject const *hwapi::getAPI() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequest(QString const &dcFileToDownload) const {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (!data) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *fNameBuffer = data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY];
|
|
||||||
size_t const size = sizeof(data->m_downLoadDC.m_filename);
|
|
||||||
|
|
||||||
std::memset(fNameBuffer, 0x00, size);
|
|
||||||
std::memcpy(fNameBuffer, dcFileToDownload.toStdString().c_str(),
|
|
||||||
std::min(size, strlen(fNameBuffer)-1));
|
|
||||||
|
|
||||||
data->m_downLoadDC.m_totalBlocks = 0;
|
|
||||||
data->m_downLoadDC.m_currentblockNumber = 0;
|
|
||||||
|
|
||||||
data->m_downLoadDC.m_requested = true;
|
|
||||||
data->m_downLoadDC.m_running = false; // download thread is not running
|
|
||||||
data->m_downLoadDC.m_finished = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequested() const {
|
|
||||||
SharedMem const *data = SharedMem::getData();
|
|
||||||
// should be false at entry
|
|
||||||
return data ? data->m_downLoadDC.m_requested.load() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadResetRequest() const {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (data) {
|
|
||||||
data->m_downLoadDC.m_requested = false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadRequestAck() const {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (data) {
|
|
||||||
if (data->m_downLoadDC.m_requested) {
|
|
||||||
data->m_downLoadDC.m_requested = false;
|
|
||||||
data->m_downLoadDC.m_running = true;
|
|
||||||
data->m_downLoadDC.m_finished = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadRunning() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
if (data) {
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0) {
|
|
||||||
bool running = data->m_downLoadDC.m_running.load();
|
|
||||||
bool finished = data->m_downLoadDC.m_finished.load();
|
|
||||||
if (!running || finished) {
|
|
||||||
if (cnt < 3) {
|
|
||||||
qCritical() << "DOWNLOAD THREAD NOT RUNNING" << running << finished;
|
|
||||||
}
|
|
||||||
QThread::msleep(500);
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
// qCritical() << "DOWNLOAD RUNNING" << cnt << (cnt > 0);
|
|
||||||
return (cnt > 0);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadThreadFinalize(DownloadThread *dthread) {
|
|
||||||
delete dthread;
|
|
||||||
m_downloadThread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadFinished() {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
if (data) {
|
|
||||||
int cnt = 10;
|
|
||||||
while ((--cnt > 0) &&
|
|
||||||
((data->m_downLoadDC.m_running.load() == true) &&
|
|
||||||
(data->m_downLoadDC.m_finished.load() == false))) {
|
|
||||||
QThread::sleep(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (cnt > 0) {
|
|
||||||
// delete m_downloadThread;
|
|
||||||
// m_downloadThread = nullptr;
|
|
||||||
// return true;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// download thread
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadStart() {
|
|
||||||
m_downloadThread = new DownloadThread(this);
|
|
||||||
if (m_downloadThread) {
|
|
||||||
m_downloadThread->start();
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadThreadRunning()) {
|
|
||||||
QThread::msleep(200);
|
|
||||||
}
|
|
||||||
return (cnt > 0);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadRunning() const {
|
|
||||||
return (dcDownloadGetRunning() == true)
|
|
||||||
&& (dcDownloadGetFinished() == false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadThreadFinished() const {
|
|
||||||
return (dcDownloadThreadRunning() == false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// report thread
|
|
||||||
bool hwapi::dcDownloadReportThreadStart() { // only start reporting thread
|
|
||||||
int cnt = 10; // if download thread is running
|
|
||||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
|
||||||
QThread::msleep(500);
|
|
||||||
}
|
|
||||||
if (cnt > 0) {
|
|
||||||
m_reportingThread = new ReportingThread(this);
|
|
||||||
if (m_reportingThread) {
|
|
||||||
m_reportingThread->start();
|
|
||||||
cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadReportThreadRunning()) {
|
|
||||||
QThread::msleep(200);
|
|
||||||
}
|
|
||||||
return (cnt > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportThreadRunning() const {
|
|
||||||
return m_reportingThread ? m_reportingThread->isRunning() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadReportThreadFinalize() {
|
|
||||||
if (m_reportingThread) {
|
|
||||||
if (m_reportingThread->isFinished()) {
|
|
||||||
delete m_reportingThread;
|
|
||||||
m_reportingThread = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadReportThreadQuit() {
|
|
||||||
if (m_reportingThread) {
|
|
||||||
m_reportingThread->quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportThreadFinished() const {
|
|
||||||
return m_reportingThread ? m_reportingThread->isFinished() : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportStart() const {
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadRunning()) {
|
|
||||||
QThread::msleep(200);
|
|
||||||
}
|
|
||||||
return (cnt == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportRunning() const {
|
|
||||||
return dcDownloadReportThreadRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadReportFinished() {
|
|
||||||
int cnt = 10;
|
|
||||||
while (--cnt > 0 && !dcDownloadReportThreadFinished()) {
|
|
||||||
QThread::sleep(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt == 0 && !dcDownloadReportThreadFinished()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dcDownloadReportThreadFinished()) {
|
|
||||||
delete m_reportingThread;
|
|
||||||
m_reportingThread = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString hwapi::dcDownloadFileName() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_filename[(int)SharedMem::DCDownload::FILE_INDEX::DC_BINARY] : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadSetRequested(bool requested) {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (data) {
|
|
||||||
data->m_downLoadDC.m_requested = requested;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadSetRunning(bool running) {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (data) {
|
|
||||||
data->m_downLoadDC.m_running = running;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadSetFinished(bool finished) {
|
|
||||||
SharedMem *data = SharedMem::getData();
|
|
||||||
if (data) {
|
|
||||||
data->m_downLoadDC.m_finished = finished;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
|
||||||
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hwapi::dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
|
||||||
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = currentBlockNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t hwapi::dcDownloadGetTotalBlockNumber() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_totalBlocks.load() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t hwapi::dcDownloadGetCurrentBlockNumber() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_currentblockNumber.load() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadGetRequested() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_requested.load() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadGetRunning() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hwapi::dcDownloadGetFinished() const {
|
|
||||||
SharedMem const *data = SharedMem::getDataConst();
|
|
||||||
return data ? data->m_downLoadDC.m_running.load() : 0;
|
|
||||||
}
|
|
||||||
|
13
src/main.cpp
13
src/main.cpp
@@ -1,5 +1,16 @@
|
|||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
#ifndef WIN32
|
#include <QCoreApplication>
|
||||||
|
#include "tslib.h"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#undef _FORTIFY_SOURCE
|
#undef _FORTIFY_SOURCE
|
||||||
|
|
||||||
|
@@ -1,155 +0,0 @@
|
|||||||
#include "reporting_thread.h"
|
|
||||||
#include "shared_mem_buffer.h"
|
|
||||||
#include "hwapi.h"
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
ReportingThread::ReportingThread(hwapi *hw)
|
|
||||||
: m_hw(hw)
|
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ReportingThread::~ReportingThread() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// download thread running in ca-slave sends reports of download process to
|
|
||||||
// each component which has connects for the corresponding signals.
|
|
||||||
void ReportingThread::run() {
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
|
||||||
|
|
||||||
static QString report("");
|
|
||||||
|
|
||||||
int cnt = 5;
|
|
||||||
while (!m_hw->dcDownloadGetRunning()) {
|
|
||||||
if (--cnt > 0) {
|
|
||||||
report = QString("%1 waiting for download to start %2")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate))
|
|
||||||
.arg(cnt);
|
|
||||||
qCritical() << __LINE__ << "STATUS" << report;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
|
||||||
QThread::sleep(1);
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (cnt == 0) {
|
|
||||||
m_hw->dcDownloadResetRequest();
|
|
||||||
status = QString("%1 reset download request")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
|
||||||
qCritical() << __LINE__ << "STATUS" << status;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
|
||||||
|
|
||||||
cnt = 5;
|
|
||||||
while (!m_hw->dcDownloadRunning()) {
|
|
||||||
if (--cnt > 0) {
|
|
||||||
QThread::sleep(1);
|
|
||||||
} else break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cnt == 0) {
|
|
||||||
status = QString("%1 download request failure")
|
|
||||||
.arg(QDateTime::currentDateTime().toString(Qt::ISODate));
|
|
||||||
qCritical() << __LINE__ << "STATUS" << status;
|
|
||||||
emit m_hw->hwapi_reportDCDownloadFailure(status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t const tnr = 1750;
|
|
||||||
uint16_t cnr = 0;
|
|
||||||
|
|
||||||
while (cnr <= tnr) {
|
|
||||||
QThread::msleep(100);
|
|
||||||
QString report("");
|
|
||||||
|
|
||||||
if (cnr > 0) {
|
|
||||||
double percent = ((double)cnr / (double)tnr) * 100.0;
|
|
||||||
report = QString(": total blocks %1, current block %2 [%3]")
|
|
||||||
.arg(tnr).arg(cnr).arg(percent, 0, 'f', 2);
|
|
||||||
} else {
|
|
||||||
report = QString(": total blocks %1, current block %2 [0]")
|
|
||||||
.arg(tnr).arg(cnr);
|
|
||||||
}
|
|
||||||
status = QDateTime::currentDateTime().toString(Qt::ISODate) + report;
|
|
||||||
|
|
||||||
qCritical() << "STATUS" << status;
|
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(status);
|
|
||||||
cnr += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tnr == cnr) {
|
|
||||||
m_hw->hwapi_reportDCDownloadSuccess(
|
|
||||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
|
||||||
} else {
|
|
||||||
m_hw->hwapi_reportDCDownloadFailure(
|
|
||||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
|
||||||
.arg(m_fileToDownload).arg(tnr).arg(cnr));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint16_t const totalBlocks = m_hw->dcDownloadGetTotalBlockNumber();
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
|
||||||
|
|
||||||
if (totalBlocks) {
|
|
||||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
|
||||||
double durationMillis = 0;
|
|
||||||
uint16_t currentBlockNumber = 0;
|
|
||||||
|
|
||||||
while (m_hw->dcDownloadGetRunning()) {
|
|
||||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
|
||||||
|
|
||||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
|
||||||
|
|
||||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
|
||||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
|
||||||
|
|
||||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
|
||||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
|
|
||||||
.arg(totalBlocks)
|
|
||||||
.arg(currentBlockNumber)
|
|
||||||
.arg(percent, 0, 'f', 2)
|
|
||||||
.arg(estimatedSecondsLeft, 0, 'f', 2);
|
|
||||||
|
|
||||||
qCritical() << "RT report" << report;
|
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
|
||||||
QThread::msleep(100);
|
|
||||||
}
|
|
||||||
|
|
||||||
QThread::msleep(100);
|
|
||||||
|
|
||||||
if (totalBlocks == currentBlockNumber) {
|
|
||||||
m_hw->hwapi_reportDCDownloadSuccess(
|
|
||||||
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
|
|
||||||
} else {
|
|
||||||
m_hw->hwapi_reportDCDownloadFailure(
|
|
||||||
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
|
|
||||||
.arg(m_fileToDownload).arg(totalBlocks).arg(currentBlockNumber));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 REPORT THREAD ABOUT TO FINISH").arg(__LINE__);
|
|
||||||
|
|
||||||
cnt = 10;
|
|
||||||
|
|
||||||
bool running = m_hw->dcDownloadGetRunning();
|
|
||||||
bool finished = m_hw->dcDownloadGetFinished();
|
|
||||||
|
|
||||||
while (--cnt > 0 && (running && !finished)) {
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 REPORT THREAD: WAIT FOR END OF DOWNLOAD THREAD %2 %3 (%4)")
|
|
||||||
.arg(__LINE__).arg(running).arg(finished).arg(cnt);
|
|
||||||
QThread::sleep(1);
|
|
||||||
running = m_hw->dcDownloadGetRunning();
|
|
||||||
finished = m_hw->dcDownloadGetFinished();
|
|
||||||
}
|
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << __PRETTY_FUNCTION__
|
|
||||||
<< QString("line=%1 FINISH REPORT THREAD").arg(__LINE__);
|
|
||||||
}
|
|
148
src/runProc.cpp
148
src/runProc.cpp
@@ -2,7 +2,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "dcBL.h"
|
#include "dcBL.h"
|
||||||
#include "interfaces.h"
|
|
||||||
|
|
||||||
static uint32_t hwapi_lastStartAmount;
|
static uint32_t hwapi_lastStartAmount;
|
||||||
static uint32_t hwapi_lastTotalAmount;
|
static uint32_t hwapi_lastTotalAmount;
|
||||||
@@ -29,25 +28,31 @@ T_runProc::T_runProc()
|
|||||||
QTimer *runProc_callProcesses = new QTimer();
|
QTimer *runProc_callProcesses = new QTimer();
|
||||||
connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess()));
|
connect(runProc_callProcesses, SIGNAL(timeout()), this, SLOT(runProc_slotProcess()));
|
||||||
runProc_callProcesses->setSingleShot(false);
|
runProc_callProcesses->setSingleShot(false);
|
||||||
runProc_callProcesses->start(100); // in ms
|
runProc_callProcesses->start(10); // in ms
|
||||||
|
|
||||||
hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted
|
hwapi_lastDoorState=0; // default: all doors (should be) closed, coin box inserted
|
||||||
// bit0: upper door 1:middle 2:lower 3=cash-box out
|
// bit0: upper door 1:middle 2:lower 3=cash-box out
|
||||||
|
|
||||||
hwapi_triggerBL = new QTimer();
|
// hwapi_triggerBL = new QTimer();
|
||||||
connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
|
// connect(hwapi_triggerBL, SIGNAL(timeout()), this, SLOT(bl_performComplStart()));
|
||||||
hwapi_triggerBL->setSingleShot(false);
|
// hwapi_triggerBL->setSingleShot(false);
|
||||||
hwapi_triggerBL->stop();
|
// hwapi_triggerBL->stop();
|
||||||
|
|
||||||
|
myTO = new QTimer();
|
||||||
|
myTO->setSingleShot(true);
|
||||||
|
myTO->start(200);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void T_runProc::runProc_slotProcess(void)
|
void T_runProc::runProc_slotProcess(void)
|
||||||
{
|
{
|
||||||
|
#ifndef THIS_IS_CA_MASTER
|
||||||
cash_paymentProcessing();
|
cash_paymentProcessing();
|
||||||
doors_supervise();
|
doors_supervise();
|
||||||
|
bl_performComplStart(); // neu 1.12.23
|
||||||
dcBL_cycle();
|
dcBL_cycle();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool T_runProc::cash_startPayment(uint32_t amount)
|
bool T_runProc::cash_startPayment(uint32_t amount)
|
||||||
@@ -160,6 +165,7 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
|
|
||||||
sub_getDynMachineConditions(&myDynMachCond);
|
sub_getDynMachineConditions(&myDynMachCond);
|
||||||
payInProg= myDynMachCond.paymentInProgress;
|
payInProg= myDynMachCond.paymentInProgress;
|
||||||
|
// Version Szeged: aug2023
|
||||||
// 0: stopped by timeout
|
// 0: stopped by timeout
|
||||||
// 1: running 2: wait4lastCoin
|
// 1: running 2: wait4lastCoin
|
||||||
// 3: payment stopped manually, coins in Escrow
|
// 3: payment stopped manually, coins in Escrow
|
||||||
@@ -169,9 +175,26 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
// 7: coins returned 2 cases: due to cancel-button or printer-error
|
// 7: coins returned 2 cases: due to cancel-button or printer-error
|
||||||
// 8: CoinChecker or MDB on Error
|
// 8: CoinChecker or MDB on Error
|
||||||
|
|
||||||
|
// since Schoenau with bill and changer, nov2023
|
||||||
|
//0 = no payment
|
||||||
|
//will be set to 1 by cash_startCollection()
|
||||||
|
//neu 1: wait for devices getting ready for payment
|
||||||
|
//2 = payment,
|
||||||
|
//3 = wait for last coin/bill
|
||||||
|
//4 = Bezahlvorgang manuell beendet
|
||||||
|
//5 = payment stopped autom, amount collected, coins in Escrow
|
||||||
|
//6 = Bezahlvorgang beendet weil ZK voll
|
||||||
|
//4,5,6: payment done, keep on polling, wait for cash or return command
|
||||||
|
//7 = encash collected money from coin escrow into cash box
|
||||||
|
//8 = return "amountToReturn", can be complete inserted amount or only overpayment
|
||||||
|
//9 = wait for changer result
|
||||||
|
//10= print refund receipt with "amountToReturn"
|
||||||
|
|
||||||
|
|
||||||
// qCritical() << "emitting signal payCancelled";
|
// qCritical() << "emitting signal payCancelled";
|
||||||
// emit runProc_payCancelled();
|
// emit runProc_payCancelled();
|
||||||
|
/*
|
||||||
|
// gabs bei Szeged, jetzt nicht mehr:
|
||||||
if (payInProg==8)
|
if (payInProg==8)
|
||||||
{
|
{
|
||||||
// coin checker faulty, cannot start
|
// coin checker faulty, cannot start
|
||||||
@@ -182,11 +205,11 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
emit runProc_coinCollectionAborted();
|
emit runProc_coinCollectionAborted();
|
||||||
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
|
//sendFDcmd_set(156, 0,0, 2,0,0,0); // cancel payment
|
||||||
}
|
}
|
||||||
|
|
||||||
return 10; // error cannot start
|
return 10; // error cannot start
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) )
|
// if (empState>=10 && empState<=12 && (payInProg==1 || payInProg==2) ) // Szeged
|
||||||
|
if ( payInProg==2 ) //8.12.23
|
||||||
{
|
{
|
||||||
// coin acceptance is active now:
|
// coin acceptance is active now:
|
||||||
if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23
|
if (hwapi_paymentStarted==1) // && (( payInProg==0) || ( payInProg>5))) //16.6.23
|
||||||
@@ -219,7 +242,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (payInProg==3) // user pressed "Next/Continue", keep coin
|
//if (payInProg==3) // user pressed "Next/Continue", keep coin
|
||||||
|
if (payInProg==4) // user pressed "Next/Continue", keep coin since nov2023
|
||||||
{
|
{
|
||||||
hwapi_paymentStarted++;
|
hwapi_paymentStarted++;
|
||||||
collActiv=3;
|
collActiv=3;
|
||||||
@@ -227,7 +251,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
emit runProc_payStopByPushbutton();
|
emit runProc_payStopByPushbutton();
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (payInProg==4) // max achieved, keep coins
|
//if (payInProg==4) // max achieved, keep coins
|
||||||
|
if (payInProg==5) // max achieved, keep coins since nov2023
|
||||||
{
|
{
|
||||||
hwapi_paymentStarted++;
|
hwapi_paymentStarted++;
|
||||||
collActiv=4;
|
collActiv=4;
|
||||||
@@ -235,7 +260,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
emit runProc_payStopByMax();
|
emit runProc_payStopByMax();
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (payInProg==5) // escrow full, keep coins
|
//if (payInProg==5) // escrow full, keep coins
|
||||||
|
if (payInProg==6) // escrow full, keep coins since nov2023
|
||||||
{
|
{
|
||||||
hwapi_paymentStarted++;
|
hwapi_paymentStarted++;
|
||||||
collActiv=5;
|
collActiv=5;
|
||||||
@@ -243,14 +269,14 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
emit runProc_payStopByEscrow();
|
emit runProc_payStopByEscrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler
|
// 5.10.23 raus, geht auf 99 wenn Betrag erreicht, ist aber kein fehler
|
||||||
if ( (empState<10) || (empState>12)) // error
|
if ( (empState<10) || (empState>12)) // error
|
||||||
{
|
{
|
||||||
collActiv=13;
|
//collActiv=13;
|
||||||
hwapi_paymentStarted=90;
|
//hwapi_paymentStarted=90;
|
||||||
qCritical() << "emitting signal payStopByError" << empState;
|
//qCritical() << "emitting signal payStopByError" << empState;
|
||||||
emit runProc_payStopByError();
|
//emit runProc_payStopByError();
|
||||||
} */
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +284,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
{
|
{
|
||||||
// coin collection finished, but coins kept until printing done
|
// coin collection finished, but coins kept until printing done
|
||||||
collActiv=2;
|
collActiv=2;
|
||||||
if (payInProg==6) // coins encashed
|
//if (payInProg==6) // coins encashed
|
||||||
|
if (payInProg==7) // coins encashed since nov2023
|
||||||
{
|
{
|
||||||
collActiv=6;
|
collActiv=6;
|
||||||
hwapi_paymentStarted++;
|
hwapi_paymentStarted++;
|
||||||
@@ -266,7 +293,8 @@ uint8_t T_runProc::cash_paymentProcessing(void)
|
|||||||
emit runProc_coinProcessJustStopped();
|
emit runProc_coinProcessJustStopped();
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (payInProg==7) // coins returned, printing failed
|
//if (payInProg==7) // coins returned, printing failed
|
||||||
|
if (payInProg==0) // coins returned, printing failed since nov2023
|
||||||
{
|
{
|
||||||
collActiv=7;
|
collActiv=7;
|
||||||
hwapi_paymentStarted++;
|
hwapi_paymentStarted++;
|
||||||
@@ -654,7 +682,7 @@ bool T_runProc::bl_isUp(void)
|
|||||||
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
|
receivedData[3]==45 && receivedData[4] ==95 && receivedData[5]==176)
|
||||||
{
|
{
|
||||||
qDebug() << "got BL response to readFWversion";
|
qDebug() << "got BL response to readFWversion";
|
||||||
epi_clrRawReceivedString();
|
//epi_clrRawReceivedString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// response to "start BL"
|
// response to "start BL"
|
||||||
@@ -662,7 +690,7 @@ bool T_runProc::bl_isUp(void)
|
|||||||
receivedData[3]==223 && receivedData[4] ==131 )
|
receivedData[3]==223 && receivedData[4] ==131 )
|
||||||
{
|
{
|
||||||
qDebug() << "hwapi_bl_isUp: got BL response to start";
|
qDebug() << "hwapi_bl_isUp: got BL response to start";
|
||||||
epi_clrRawReceivedString();
|
//epi_clrRawReceivedString();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -677,7 +705,8 @@ void T_runProc::bl_completeStart(void)
|
|||||||
|
|
||||||
bool T_runProc::bl_performComplStart(void)
|
bool T_runProc::bl_performComplStart(void)
|
||||||
{
|
{
|
||||||
// must be called cyclic by timer
|
bool result;
|
||||||
|
|
||||||
static uint8_t retryCtr;
|
static uint8_t retryCtr;
|
||||||
|
|
||||||
if ((bl_startupStep<1) || (bl_startupStep>10))
|
if ((bl_startupStep<1) || (bl_startupStep>10))
|
||||||
@@ -691,58 +720,69 @@ bool T_runProc::bl_performComplStart(void)
|
|||||||
|
|
||||||
if (bl_startupStep==2)
|
if (bl_startupStep==2)
|
||||||
{
|
{
|
||||||
|
qDebug()<<"rebooting";
|
||||||
bl_rebootDC();
|
bl_rebootDC();
|
||||||
hwapi_triggerBL->stop();
|
myTO->stop();
|
||||||
hwapi_triggerBL->start(1000); // call next step in 1s
|
myTO->start(500);
|
||||||
retryCtr=0;
|
retryCtr=0;
|
||||||
bl_startupStep++;
|
bl_startupStep++;
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (bl_startupStep==3)
|
if (bl_startupStep==3)
|
||||||
{
|
{
|
||||||
//qDebug()<<"starting BL";
|
if (!myTO->isActive())
|
||||||
bl_startBL();
|
{
|
||||||
hwapi_triggerBL->stop();
|
qDebug()<<"starting BL";
|
||||||
hwapi_triggerBL->start(100);
|
bl_startBL();
|
||||||
bl_startupStep++;
|
myTO->stop();
|
||||||
|
myTO->start(500);
|
||||||
|
bl_startupStep++;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (bl_startupStep==4)
|
if (bl_startupStep==4)
|
||||||
{
|
{
|
||||||
//if (!myTO->isActive())
|
if (!myTO->isActive())
|
||||||
//{
|
{
|
||||||
bl_checkBL();
|
qDebug()<<"checking BL";
|
||||||
hwapi_triggerBL->stop();
|
bl_checkBL();
|
||||||
hwapi_triggerBL->start(100);
|
myTO->stop();
|
||||||
bl_startupStep++;
|
myTO->start(200);
|
||||||
|
bl_startupStep++;
|
||||||
//}
|
}
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|
||||||
if (bl_startupStep==5)
|
if (bl_startupStep==5)
|
||||||
{
|
{
|
||||||
hwapi_triggerBL->stop();
|
if (!myTO->isActive())
|
||||||
if (bl_isUp())
|
|
||||||
{
|
{
|
||||||
bl_startupStep=99;
|
qDebug()<<"step 5";
|
||||||
// BL is up and running
|
result = bl_isUp();
|
||||||
} else
|
qDebug()<<"BL result: "<< result;
|
||||||
{
|
if (result)
|
||||||
retryCtr++; // start again
|
|
||||||
if (retryCtr>=15)
|
|
||||||
{
|
{
|
||||||
bl_startupStep=99;
|
bl_startupStep=99;
|
||||||
//qDebug()<<"BL error!!!";
|
qDebug()<<"BL is working now...";
|
||||||
|
// BL is up and running
|
||||||
|
return true;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
bl_startupStep=3;
|
retryCtr++; // start again
|
||||||
//qDebug()<<"BL retry...";
|
if (retryCtr>=10)
|
||||||
|
{
|
||||||
|
bl_startupStep=99;
|
||||||
|
qDebug()<<"BL error!!!";
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
bl_startupStep=3;
|
||||||
|
myTO->stop();
|
||||||
|
myTO->start(200);
|
||||||
|
qDebug()<<"BL retry...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1984,7 +1984,7 @@ void epi_iniVRstorage(void)
|
|||||||
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
|
void gpi_storeVaultRecord(uint8_t blkNr, uint8_t *data )
|
||||||
{
|
{
|
||||||
uint16_t start=blkNr, ii;
|
uint16_t start=blkNr, ii;
|
||||||
//qDebug()<<"storing vault data "<<blkNr;
|
qDebug()<<"storing vault data "<<blkNr;
|
||||||
SharedMem::write()->store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...5
|
SharedMem::write()->store_gotNrBlocksOfVaultRec |= (1<<start); // setze pro Block ein bit, wir brauchen block 0...5
|
||||||
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
|
// also muss store_gotNrBlocksOfVaultRec auf 0x1F stehen
|
||||||
start<<=6; // *64
|
start<<=6; // *64
|
||||||
@@ -2054,13 +2054,50 @@ uint16_t epi_getNrOfCoinsInCashBox(void)
|
|||||||
|
|
||||||
void gpi_storeDcDataValid(bool isVal)
|
void gpi_storeDcDataValid(bool isVal)
|
||||||
{
|
{
|
||||||
SharedMem::write()->store_DcDataAreValid = isVal;
|
bool now=SharedMem::read()->store_DcDataAreValid;
|
||||||
|
if (isVal != now)
|
||||||
|
{
|
||||||
|
SharedMem::write()->store_DcDataAreValid = isVal;
|
||||||
|
#ifdef THIS_IS_CA_MASTER
|
||||||
|
qDebug()<<"master lib sets DcDataValid to "<<isVal;
|
||||||
|
#else
|
||||||
|
qDebug()<<"slave lib sets DcDataValid to "<<isVal;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void epi_setDcDataValid(void)
|
||||||
|
{
|
||||||
|
bool now=SharedMem::read()->store_DcDataAreValid;
|
||||||
|
if (now==false)
|
||||||
|
{
|
||||||
|
SharedMem::write()->store_DcDataAreValid = true;
|
||||||
|
#ifdef THIS_IS_CA_MASTER
|
||||||
|
qDebug()<<"master lib SET DcDataValid";
|
||||||
|
#else
|
||||||
|
qDebug()<<"slave lib SET DcDataValid";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void epi_resetDcDataValid(void)
|
||||||
|
{
|
||||||
|
bool now=SharedMem::read()->store_DcDataAreValid;
|
||||||
|
if (now==true)
|
||||||
|
{
|
||||||
|
SharedMem::write()->store_DcDataAreValid = false;
|
||||||
|
#ifdef THIS_IS_CA_MASTER
|
||||||
|
qDebug()<<"master lib RESET DcDataValid";
|
||||||
|
#else
|
||||||
|
qDebug()<<"slave lib RESET DcDataValid";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool epi_areDcDataValid()
|
bool epi_areDcDataValid()
|
||||||
{
|
{
|
||||||
return SharedMem::read()->store_DcDataAreValid;
|
return SharedMem::read()->store_DcDataAreValid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ....................................................................................
|
// ....................................................................................
|
||||||
|
Reference in New Issue
Block a user