Compare commits
4 Commits
1.1.0
...
f6efb1ee9a
| Author | SHA1 | Date | |
|---|---|---|---|
| f6efb1ee9a | |||
| a1237749dc | |||
| f5613d5aad | |||
| 3564bac8d4 |
@@ -90,9 +90,7 @@ HEADERS += \
|
|||||||
$${PWD}/include/sendWRcmd.h \
|
$${PWD}/include/sendWRcmd.h \
|
||||||
$${PWD}/include/storeINdata.h \
|
$${PWD}/include/storeINdata.h \
|
||||||
$${PWD}/include/tslib.h \
|
$${PWD}/include/tslib.h \
|
||||||
$${PWD}/include/shared_mem_buffer.h \
|
$${PWD}/include/shared_mem_buffer.h
|
||||||
$${PWD}/include/reporting_thread.h \
|
|
||||||
$${PWD}/include/download_thread.h
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$${PWD}/src/datei.cpp \
|
$${PWD}/src/datei.cpp \
|
||||||
@@ -103,9 +101,7 @@ SOURCES += \
|
|||||||
$${PWD}/src/sendWRcmd.cpp \
|
$${PWD}/src/sendWRcmd.cpp \
|
||||||
$${PWD}/src/storeINdata.cpp \
|
$${PWD}/src/storeINdata.cpp \
|
||||||
$${PWD}/src/tslib.cpp \
|
$${PWD}/src/tslib.cpp \
|
||||||
$${PWD}/src/shared_mem_buffer.cpp \
|
$${PWD}/src/shared_mem_buffer.cpp
|
||||||
$${PWD}/src/reporting_thread.cpp \
|
|
||||||
$${PWD}/src/download_thread.cpp
|
|
||||||
|
|
||||||
|
|
||||||
# INTERFACE = DeviceController
|
# INTERFACE = DeviceController
|
||||||
|
|||||||
@@ -134,7 +134,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class DownloadThread;
|
||||||
|
class hwinf;
|
||||||
class T_datif : public QObject
|
class T_datif : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -165,13 +166,14 @@ class T_datif : public QObject
|
|||||||
T_prot *myDCIF;
|
T_prot *myDCIF;
|
||||||
QTimer *datif_trigger;
|
QTimer *datif_trigger;
|
||||||
uint8_t selectedSlaveAddr;
|
uint8_t selectedSlaveAddr;
|
||||||
|
hwinf *m_hw = nullptr;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
char datif_cycleSend();
|
char datif_cycleSend();
|
||||||
void StoredRecData();
|
void StoredRecData();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T_datif(QObject *parent = nullptr);
|
T_datif(hwinf *hw, QObject *parent = nullptr);
|
||||||
|
|
||||||
void resetChain(void);
|
void resetChain(void);
|
||||||
char isPortOpen(void);
|
char isPortOpen(void);
|
||||||
|
|||||||
@@ -93,14 +93,13 @@ private:
|
|||||||
void sub_storeSendingText(QByteArray *buf) const;
|
void sub_storeSendingText(QByteArray *buf) const;
|
||||||
QTimer *hwapi_TimerPayment;
|
QTimer *hwapi_TimerPayment;
|
||||||
QSharedMemory *m_sharedMem;
|
QSharedMemory *m_sharedMem;
|
||||||
ReportingThread *m_reportingThread;
|
ReportingThread *m_reportingThread = nullptr;
|
||||||
DownloadThread *m_downloadThread;
|
DownloadThread *m_downloadThread = nullptr;
|
||||||
//QTimer *hwapi_triggerBL;
|
//QTimer *hwapi_triggerBL;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit hwapi(QWidget *parent = nullptr);
|
explicit hwapi(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
|
||||||
#ifdef THIS_IS_CA_MASTER
|
#ifdef THIS_IS_CA_MASTER
|
||||||
T_datif *myDatif;
|
T_datif *myDatif;
|
||||||
#endif
|
#endif
|
||||||
@@ -1384,7 +1383,9 @@ signals:
|
|||||||
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
void hwapi_doorCBinAndAllDoorsClosed(void) const override;
|
||||||
void hwapi_doorAllDoorsClosed(void) const override;
|
void hwapi_doorAllDoorsClosed(void) const override;
|
||||||
|
|
||||||
void hwapi_coinAttached() const override;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//void hwapi_slotPrintFinished_OK(void);
|
//void hwapi_slotPrintFinished_OK(void);
|
||||||
@@ -1412,7 +1413,8 @@ signals:
|
|||||||
void sub_slotCoin15(void);
|
void sub_slotCoin15(void);
|
||||||
void sub_slotCoin16(void);
|
void sub_slotCoin16(void);
|
||||||
|
|
||||||
void coinAttached();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -2390,7 +2390,6 @@ signals:
|
|||||||
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
virtual void hwapi_doorCBinAndAllDoorsClosed(void) const=0;
|
||||||
virtual void hwapi_doorAllDoorsClosed(void) const=0;
|
virtual void hwapi_doorAllDoorsClosed(void) const=0;
|
||||||
|
|
||||||
virtual void hwapi_coinAttached() const = 0;
|
|
||||||
|
|
||||||
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
// NOTE: declaring a "pure virtual" "signal" should be an error and thus not valid.
|
||||||
/* GH Version, bringt Fehler
|
/* GH Version, bringt Fehler
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
// #include <functional>
|
||||||
|
|
||||||
class hwapi;
|
class hwapi;
|
||||||
class ReportingThread : public QThread {
|
class ReportingThread : public QThread {
|
||||||
@@ -12,6 +13,14 @@ public:
|
|||||||
ReportingThread(hwapi *hw);
|
ReportingThread(hwapi *hw);
|
||||||
~ReportingThread();
|
~ReportingThread();
|
||||||
|
|
||||||
|
//void setFunction(std::function<void(QString const&)> f) {
|
||||||
|
// m_f = f;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//std::function<void(QString const&)> function() {
|
||||||
|
// return m_f;
|
||||||
|
//}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// reporting thread does not have a running event queue, and therefore
|
// reporting thread does not have a running event queue, and therefore
|
||||||
// no slots. signals work the usual way.
|
// no slots. signals work the usual way.
|
||||||
@@ -20,6 +29,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
hwapi *m_hw;
|
hwapi *m_hw;
|
||||||
QString m_fileToDownload;
|
QString m_fileToDownload;
|
||||||
|
//std::function<void(QString const&)> m_f;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPORTING_THREAD_H_INCLUDED
|
#endif // REPORTING_THREAD_H_INCLUDED
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "datIf.h"
|
#include "datIf.h"
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <atomic>
|
|
||||||
#include "sendWRcmd.h"
|
#include "sendWRcmd.h"
|
||||||
#include "controlBus.h"
|
#include "controlBus.h"
|
||||||
#include "storeINdata.h"
|
#include "storeINdata.h"
|
||||||
@@ -36,10 +35,6 @@ class T_runProc : public QObject
|
|||||||
|
|
||||||
void restoreDeviceParameter(struct T_devices *deviceSettings);
|
void restoreDeviceParameter(struct T_devices *deviceSettings);
|
||||||
|
|
||||||
#ifndef THIS_IS_CA_MASTER
|
|
||||||
std::atomic_bool m_coinAttached{false};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void runProc_slotProcess(void);
|
void runProc_slotProcess(void);
|
||||||
bool bl_performComplStart(void);
|
bool bl_performComplStart(void);
|
||||||
@@ -85,7 +80,6 @@ signals:
|
|||||||
void runProc_doorCBinAndAllDoorsClosed(void);
|
void runProc_doorCBinAndAllDoorsClosed(void);
|
||||||
void runProc_doorAllDoorsClosed(void);
|
void runProc_doorAllDoorsClosed(void);
|
||||||
|
|
||||||
void runProc_coinAttached();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ VERSION="1.0.1"
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
../include/com.h \
|
../include/com.h \
|
||||||
../include/datIf.h \
|
../include/datIf.h \
|
||||||
../include/prot.h
|
../include/prot.h \
|
||||||
|
../include/download_thread.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
../src/com.cpp \
|
../src/com.cpp \
|
||||||
../src/datIf.cpp \
|
../src/datIf.cpp \
|
||||||
../src/prot.cpp
|
../src/prot.cpp \
|
||||||
|
../src/download_thread.cpp
|
||||||
|
|
||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ TEMPLATE = lib
|
|||||||
TARGET = CAslave
|
TARGET = CAslave
|
||||||
VERSION="1.0.1"
|
VERSION="1.0.1"
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
../include/reporting_thread.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../src/reporting_thread.cpp
|
||||||
|
|
||||||
include(../DCLibraries.pri)
|
include(../DCLibraries.pri)
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
|
|||||||
@@ -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_doorCoinBoxInserted()), this, SLOT(sub_slotCoin14())); // hwapi_doorCoinBoxInserted()));
|
||||||
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed()));
|
connect(runProcess, SIGNAL(runProc_doorCBinAndAllDoorsClosed()), this, SLOT(sub_slotCoin15())); // hwapi_doorCBinAndAllDoorsClosed()));
|
||||||
connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
|
connect(runProcess, SIGNAL(runProc_doorAllDoorsClosed()), this, SLOT(sub_slotCoin16())); // hwapi_doorAllDoorsClosed()));
|
||||||
connect(runProcess, SIGNAL(runProc_coinAttached()), this, SLOT(coinAttached()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hwapi::hwapi_slotPayProc(void)
|
void hwapi::hwapi_slotPayProc(void)
|
||||||
@@ -226,9 +227,6 @@ void hwapi::sub_slotCoin16(void)
|
|||||||
emit hwapi_doorAllDoorsClosed();
|
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
|
// attention: only applies if function "sys_sendDeviceParameter()" was used to send this settings before
|
||||||
// cannot be used to see settings programmed by JsonFile
|
// cannot be used to see settings programmed by JsonFile
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
uint8_t LL;
|
uint8_t LL, nn;
|
||||||
tslib_strclr(buf,0,64);
|
tslib_strclr(buf,0,64);
|
||||||
|
uint8_t *start;
|
||||||
|
|
||||||
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
|
//runProcess->epi_restore64BdevParameter(&LL, buf); // wozu die???
|
||||||
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
|
epi_restoreRbDeviceSettings(&LL, buf); // viel besser, stimmt immer
|
||||||
|
|
||||||
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
|
bool hwapi::sys_areDCdataValid(void) const
|
||||||
|
|||||||
@@ -4,10 +4,15 @@
|
|||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
ReportingThread::ReportingThread(hwapi *hw)
|
ReportingThread::ReportingThread(hwapi *hw)
|
||||||
: m_hw(hw)
|
: m_hw(hw)
|
||||||
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
, m_fileToDownload(m_hw->dcDownloadFileName()) {
|
||||||
|
// , m_f([](QString const&){}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReportingThread::~ReportingThread() {
|
ReportingThread::~ReportingThread() {
|
||||||
@@ -17,7 +22,9 @@ ReportingThread::~ReportingThread() {
|
|||||||
// each component which has connects for the corresponding signals.
|
// each component which has connects for the corresponding signals.
|
||||||
void ReportingThread::run() {
|
void ReportingThread::run() {
|
||||||
|
|
||||||
qCritical() << QDateTime::currentDateTime() << "START DOWNLOAD THREAD";
|
qCritical()
|
||||||
|
<< QDateTime::currentDateTime() << "START REPORT THREAD"
|
||||||
|
<< "(PART OF APPLICATION" << QCoreApplication::applicationName() << ")";
|
||||||
|
|
||||||
static QString report("");
|
static QString report("");
|
||||||
|
|
||||||
@@ -96,28 +103,37 @@ void ReportingThread::run() {
|
|||||||
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
qCritical() << QDateTime::currentDateTime() << "TOTAL BLOCKS" << totalBlocks;
|
||||||
|
|
||||||
if (totalBlocks) {
|
if (totalBlocks) {
|
||||||
qint64 const start = QDateTime::currentMSecsSinceEpoch();
|
QDateTime const start = QDateTime::currentDateTime();
|
||||||
double durationMillis = 0;
|
|
||||||
uint16_t currentBlockNumber = 0;
|
uint16_t currentBlockNumber = 0;
|
||||||
|
uint16_t prevBlockNumber = ~0;
|
||||||
|
|
||||||
while (m_hw->dcDownloadGetRunning()) {
|
while (m_hw->dcDownloadGetRunning()) {
|
||||||
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
currentBlockNumber = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||||
|
if (prevBlockNumber != currentBlockNumber) {
|
||||||
|
double durationSecs = start.secsTo(QDateTime::currentDateTime());
|
||||||
|
|
||||||
durationMillis += QDateTime::currentMSecsSinceEpoch() - start;
|
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationSecs / currentBlockNumber) : durationSecs;
|
||||||
|
long estimatedSecondsLeft = lround((timeAveragePerBlock * (totalBlocks - currentBlockNumber)));
|
||||||
double const timeAveragePerBlock = (currentBlockNumber > 0) ? (durationMillis / currentBlockNumber) : durationMillis;
|
long estimatedMinutesLeft =
|
||||||
double const estimatedSecondsLeft = (timeAveragePerBlock * (totalBlocks - currentBlockNumber)) / 1000.0;
|
((estimatedSecondsLeft % 60) == 0) ?
|
||||||
|
(estimatedSecondsLeft / 60) :
|
||||||
|
((estimatedSecondsLeft + 60) / 60);
|
||||||
|
estimatedSecondsLeft = (estimatedSecondsLeft % 60);
|
||||||
|
|
||||||
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
double percent = ((double)currentBlockNumber / (double)totalBlocks) * 100.0;
|
||||||
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4s)")
|
report = QString(": total blocks %1, current block %2 [%3] (est. time left: %4min %5s)")
|
||||||
.arg(totalBlocks)
|
.arg(totalBlocks)
|
||||||
.arg(currentBlockNumber)
|
.arg(currentBlockNumber)
|
||||||
.arg(percent, 0, 'f', 2)
|
.arg(percent, 0, 'f', 2)
|
||||||
.arg(estimatedSecondsLeft, 0, 'f', 2);
|
.arg(estimatedMinutesLeft)
|
||||||
|
.arg(estimatedSecondsLeft, 2);
|
||||||
|
|
||||||
qCritical() << "RT report" << report;
|
qCritical() << m_hw << "RT report" << report;
|
||||||
|
|
||||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||||
|
|
||||||
|
prevBlockNumber = currentBlockNumber;
|
||||||
|
}
|
||||||
QThread::msleep(100);
|
QThread::msleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,6 @@ T_runProc::T_runProc()
|
|||||||
void T_runProc::runProc_slotProcess(void)
|
void T_runProc::runProc_slotProcess(void)
|
||||||
{
|
{
|
||||||
#ifndef THIS_IS_CA_MASTER
|
#ifndef THIS_IS_CA_MASTER
|
||||||
bool const coinAttached = epi_getDI_CoinAttach();
|
|
||||||
// exchange: (atomically) replaces the underlying value of m_coinAttached
|
|
||||||
// with the value of coinAttached, returns the value of m_coinAttached
|
|
||||||
// before the call
|
|
||||||
if (m_coinAttached.exchange(coinAttached) == false) {
|
|
||||||
if (coinAttached) {
|
|
||||||
// old value was false, and new value is true
|
|
||||||
emit runProc_coinAttached();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cash_paymentProcessing();
|
cash_paymentProcessing();
|
||||||
doors_supervise();
|
doors_supervise();
|
||||||
bl_performComplStart(); // neu 1.12.23
|
bl_performComplStart(); // neu 1.12.23
|
||||||
|
|||||||
Reference in New Issue
Block a user