Compare commits
7 Commits
f6efb1ee9a
...
coin-attac
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cac6a6461 | |||
| aa10d3b275 | |||
| 790c2fd031 | |||
| 7130d052e7 | |||
| ad84464bf4 | |||
|
69d0420e7d
|
|||
|
9b2433c2cd
|
@@ -134,8 +134,7 @@
|
||||
|
||||
|
||||
|
||||
class DownloadThread;
|
||||
class hwinf;
|
||||
|
||||
class T_datif : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -166,14 +165,13 @@ 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(hwinf *hw, QObject *parent = nullptr);
|
||||
T_datif(QObject *parent = nullptr);
|
||||
|
||||
void resetChain(void);
|
||||
char isPortOpen(void);
|
||||
|
||||
@@ -93,13 +93,14 @@ private:
|
||||
void sub_storeSendingText(QByteArray *buf) const;
|
||||
QTimer *hwapi_TimerPayment;
|
||||
QSharedMemory *m_sharedMem;
|
||||
ReportingThread *m_reportingThread = nullptr;
|
||||
DownloadThread *m_downloadThread = nullptr;
|
||||
ReportingThread *m_reportingThread;
|
||||
DownloadThread *m_downloadThread;
|
||||
//QTimer *hwapi_triggerBL;
|
||||
|
||||
public:
|
||||
explicit hwapi(QWidget *parent = nullptr);
|
||||
|
||||
|
||||
#ifdef THIS_IS_CA_MASTER
|
||||
T_datif *myDatif;
|
||||
#endif
|
||||
@@ -1383,9 +1384,7 @@ 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);
|
||||
@@ -1413,8 +1412,7 @@ signals:
|
||||
void sub_slotCoin15(void);
|
||||
void sub_slotCoin16(void);
|
||||
|
||||
|
||||
|
||||
void coinAttached();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -2390,6 +2390,7 @@ 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
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <QThread>
|
||||
#include <QString>
|
||||
// #include <functional>
|
||||
|
||||
class hwapi;
|
||||
class ReportingThread : public QThread {
|
||||
@@ -13,14 +12,6 @@ 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.
|
||||
@@ -29,7 +20,6 @@ protected:
|
||||
private:
|
||||
hwapi *m_hw;
|
||||
QString m_fileToDownload;
|
||||
//std::function<void(QString const&)> m_f;
|
||||
};
|
||||
|
||||
#endif // REPORTING_THREAD_H_INCLUDED
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <QDebug>
|
||||
#include "datIf.h"
|
||||
#include <QSharedMemory>
|
||||
#include <atomic>
|
||||
#include "sendWRcmd.h"
|
||||
#include "controlBus.h"
|
||||
#include "storeINdata.h"
|
||||
@@ -35,6 +36,10 @@ 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);
|
||||
@@ -80,6 +85,7 @@ signals:
|
||||
void runProc_doorCBinAndAllDoorsClosed(void);
|
||||
void runProc_doorAllDoorsClosed(void);
|
||||
|
||||
void runProc_coinAttached();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -128,8 +128,7 @@ 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)
|
||||
@@ -227,6 +226,9 @@ void hwapi::sub_slotCoin16(void)
|
||||
emit hwapi_doorAllDoorsClosed();
|
||||
}
|
||||
|
||||
void hwapi::coinAttached() {
|
||||
emit hwapi_coinAttached();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -3332,22 +3334,15 @@ 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, nn;
|
||||
uint8_t LL;
|
||||
tslib_strclr(buf,0,64);
|
||||
uint8_t *start;
|
||||
|
||||
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
|
||||
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
|
||||
|
||||
// Puffer in struct eintragen:
|
||||
start = &deviceSettings->kindOfPrinter;
|
||||
nn=0;
|
||||
do
|
||||
{
|
||||
*start = buf[nn];
|
||||
start++;
|
||||
} while(++nn<LL);
|
||||
Q_STATIC_ASSERT(sizeof(*deviceSettings) <= sizeof(buf));
|
||||
|
||||
memcpy(deviceSettings, buf, sizeof(*deviceSettings));
|
||||
}
|
||||
|
||||
bool hwapi::sys_areDCdataValid(void) const
|
||||
|
||||
@@ -4,15 +4,10 @@
|
||||
|
||||
#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() {
|
||||
@@ -22,9 +17,7 @@ ReportingThread::~ReportingThread() {
|
||||
// each component which has connects for the corresponding signals.
|
||||
void ReportingThread::run() {
|
||||
|
||||
qCritical()
|
||||
<< QDateTime::currentDateTime() << "START REPORT THREAD"
|
||||
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
|
||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
||||
|
||||
static QString report("");
|
||||
|
||||
@@ -103,37 +96,28 @@ void ReportingThread::run() {
|
||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
||||
|
||||
if (totalBlocks) {
|
||||
QDateTime const start = QDateTime::currentDateTime();
|
||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
||||
double durationMillis = 0;
|
||||
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());
|
||||
|
||||
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);
|
||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
||||
|
||||
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 const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
||||
|
||||
qCritical() << m_hw << "RT report" << report;
|
||||
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);
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
qCritical() << "RT report" << report;
|
||||
|
||||
prevBlockNumber = currentBlockNumber;
|
||||
}
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
QThread::msleep(100);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,16 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user