Compare commits

..

4 Commits

11 changed files with 75 additions and 53 deletions

View File

@@ -90,9 +90,7 @@ HEADERS += \
$${PWD}/include/sendWRcmd.h \
$${PWD}/include/storeINdata.h \
$${PWD}/include/tslib.h \
$${PWD}/include/shared_mem_buffer.h \
$${PWD}/include/reporting_thread.h \
$${PWD}/include/download_thread.h
$${PWD}/include/shared_mem_buffer.h
SOURCES += \
$${PWD}/src/datei.cpp \
@@ -103,9 +101,7 @@ SOURCES += \
$${PWD}/src/sendWRcmd.cpp \
$${PWD}/src/storeINdata.cpp \
$${PWD}/src/tslib.cpp \
$${PWD}/src/shared_mem_buffer.cpp \
$${PWD}/src/reporting_thread.cpp \
$${PWD}/src/download_thread.cpp
$${PWD}/src/shared_mem_buffer.cpp
# INTERFACE = DeviceController

View File

@@ -134,7 +134,8 @@
class DownloadThread;
class hwinf;
class T_datif : public QObject
{
Q_OBJECT
@@ -165,13 +166,14 @@ class T_datif : public QObject
T_prot *myDCIF;
QTimer *datif_trigger;
uint8_t selectedSlaveAddr;
hwinf *m_hw = nullptr;
private slots:
char datif_cycleSend();
void StoredRecData();
public:
T_datif(QObject *parent = nullptr);
T_datif(hwinf *hw, QObject *parent = nullptr);
void resetChain(void);
char isPortOpen(void);

View File

@@ -93,14 +93,13 @@ private:
void sub_storeSendingText(QByteArray *buf) const;
QTimer *hwapi_TimerPayment;
QSharedMemory *m_sharedMem;
ReportingThread *m_reportingThread;
DownloadThread *m_downloadThread;
ReportingThread *m_reportingThread = nullptr;
DownloadThread *m_downloadThread = nullptr;
//QTimer *hwapi_triggerBL;
public:
explicit hwapi(QWidget *parent = nullptr);
#ifdef THIS_IS_CA_MASTER
T_datif *myDatif;
#endif
@@ -1384,7 +1383,9 @@ signals:
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
void hwapi_doorAllDoorsClosed(void) const override;
void hwapi_coinAttached() const override;
private slots:
//void hwapi_slotPrintFinished_OK(void);
@@ -1412,7 +1413,8 @@ signals:
void sub_slotCoin15(void);
void sub_slotCoin16(void);
void coinAttached();
};

View File

@@ -2390,7 +2390,6 @@ signals:
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
virtual void hwapi_doorAllDoorsClosed(void) const=0;
virtual void hwapi_coinAttached() const = 0;
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
/* GH Version, bringt Fehler

View File

@@ -3,6 +3,7 @@
#include <QThread>
#include <QString>
// #include <functional>
class hwapi;
class ReportingThread : public QThread {
@@ -12,6 +13,14 @@ public:
ReportingThread(hwapi *hw);
~ReportingThread();
//void setFunction(std::function<void(QString const&)> f) {
// m_f = f;
//}
//std::function<void(QString const&)> function() {
// return m_f;
//}
protected:
// reporting thread does not have a running event queue, and therefore
// no slots. signals work the usual way.
@@ -20,6 +29,7 @@ protected:
private:
hwapi *m_hw;
QString m_fileToDownload;
//std::function<void(QString const&)> m_f;
};
#endif // REPORTING_THREAD_H_INCLUDED

View File

@@ -15,7 +15,6 @@
#include <QDebug>
#include "datIf.h"
#include <QSharedMemory>
#include <atomic>
#include "sendWRcmd.h"
#include "controlBus.h"
#include "storeINdata.h"
@@ -36,10 +35,6 @@ class T_runProc : public QObject
void restoreDeviceParameter(struct T_devices *deviceSettings);
#ifndef THIS_IS_CA_MASTER
std::atomic_bool m_coinAttached{false};
#endif
private slots:
void runProc_slotProcess(void);
bool bl_performComplStart(void);
@@ -85,7 +80,6 @@ signals:
void runProc_doorCBinAndAllDoorsClosed(void);
void runProc_doorAllDoorsClosed(void);
void runProc_coinAttached();
};

View File

@@ -5,12 +5,14 @@ VERSION="1.0.1"
HEADERS += \
../include/com.h \
../include/datIf.h \
../include/prot.h
../include/prot.h \
../include/download_thread.h
SOURCES += \
../src/com.cpp \
../src/datIf.cpp \
../src/prot.cpp
../src/prot.cpp \
../src/download_thread.cpp
include(../DCLibraries.pri)

View File

@@ -2,6 +2,12 @@ TEMPLATE = lib
TARGET = CAslave
VERSION="1.0.1"
HEADERS += \
../include/reporting_thread.h
SOURCES += \
../src/reporting_thread.cpp
include(../DCLibraries.pri)
win32 {

View File

@@ -128,7 +128,8 @@ hwapi::hwapi(QWidget *parent) : QObject(parent)
connect(runProcess, SIGNAL(runProc_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted()));
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed()));
connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
}
void hwapi::hwapi_slotPayProc(void)
@@ -226,9 +227,6 @@ void hwapi::sub_slotCoin16(void)
emit hwapi_doorAllDoorsClosed();
}
void hwapi::coinAttached() {
emit hwapi_coinAttached();
}
/*
@@ -3334,15 +3332,22 @@ void hwapi::sys_restoreDeviceParameter(struct T_devices *deviceSettings) const
// attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before
// cannot be used to see settings programmed by JsonFile
uint8_t buf[64];
uint8_t LL;
uint8_t LL, nn;
tslib_strclr(buf,0,64);
uint8_t *start;
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf));
// Puffer in struct eintragen:
start = &deviceSettings->kindOfPrinter;
nn=0;
do
{
*start = buf[nn];
start++;
} while(++nn<LL);
memcpy(deviceSettings, buf, sizeof(*deviceSettings));
}
bool hwapi::sys_areDCdataValid(void) const

View File

@@ -4,10 +4,15 @@
#include <QDateTime>
#include <QDebug>
#include <QApplication>
#include <QCoreApplication>
#include <cmath>
ReportingThread::ReportingThread(hwapi *hw)
: m_hw(hw)
, m_fileToDownload(m_hw->dcDownloadFileName()) {
// , m_f([](QString const&){}) {
}
ReportingThread::~ReportingThread() {
@@ -17,7 +22,9 @@ ReportingThread::~ReportingThread() {
// each component which has connects for the corresponding signals.
void ReportingThread::run() {
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
qCritical()
<< QDateTime::currentDateTime() << "START REPORT THREAD"
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
static QString report("");
@@ -96,28 +103,37 @@ void ReportingThread::run() {
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
if (totalBlocks) {
qint64 const start = QDateTime::currentMSecsSinceEpoch();
double durationMillis = 0;
QDateTime const start = QDateTime::currentDateTime();
uint16_t currentBlockNumber = 0;
uint16_t prevBlockNumber = ~0;
while (m_hw->dcDownloadGetRunning()) {
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
if (prevBlockNumber != currentBlockNumber) {
double durationSecs = start.secsTo(QDateTime::currentDateTime());
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
long estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
long estimatedMinutesLeft =
((estimatedSecondsLeft % 60) == 0) ?
(estimatedSecondsLeft / 60) :
((estimatedSecondsLeft + 60) / 60);
estimatedSecondsLeft = (estimatedSecondsLeft % 60);
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: %4min %5s)")
.arg(totalBlocks)
.arg(currentBlockNumber)
.arg(percent, 0, 'f', 2)
.arg(estimatedMinutesLeft)
.arg(estimatedSecondsLeft, 2);
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() << m_hw << "RT report" << report;
qCritical() << "RT report" << report;
emit m_hw->hwapi_reportDCDownloadStatus(report);
emit m_hw->hwapi_reportDCDownloadStatus(report);
prevBlockNumber = currentBlockNumber;
}
QThread::msleep(100);
}

View File

@@ -48,16 +48,6 @@ T_runProc::T_runProc()
void T_runProc::runProc_slotProcess(void)
{
#ifndef THIS_IS_CA_MASTER
bool const coinAttached = epi_getDI_CoinAttach();
// exchange: (atomically) replaces the underlying value of m_coinAttached
// with the value of coinAttached, returns the value of m_coinAttached
// before the call
if (m_coinAttached.exchange(coinAttached) == false) {
if (coinAttached) {
// old value was false, and new value is true
emit runProc_coinAttached();
}
}
cash_paymentProcessing();
doors_supervise();
bl_performComplStart(); // neu 1.12.23