Test implementation of download thread without an actual download of dc.

This commit is contained in:
Gerhard Hoffmann 2023-12-08 13:01:47 +01:00
parent 4efbbcbb5a
commit 5f88c8f856

View File

@ -2,9 +2,15 @@
#include "shared_mem_buffer.h" #include "shared_mem_buffer.h"
#include "hwapi.h" #include "hwapi.h"
#include <QDebug>
#include <QDateTime>
DownloadThread::DownloadThread(hwinf *hw) DownloadThread::DownloadThread(hwinf *hw)
: m_hw(hw) : m_hw(hw)
, m_fileToDownload(m_hw->dcDownloadFileName()) { , m_fileToDownload(m_hw->dcDownloadFileName()) {
// connect(this, &QThread::finished,
// dynamic_cast<QObject const *>(m_hw), &QThread::deleteLater);
} }
DownloadThread::~DownloadThread() { DownloadThread::~DownloadThread() {
@ -12,10 +18,26 @@ DownloadThread::~DownloadThread() {
// download thread running in ca-master sends the dc-file down to firmware // download thread running in ca-master sends the dc-file down to firmware
void DownloadThread::run() { void DownloadThread::run() {
// m_hw->dcDownloadInit(m_fileToDownload);
// hier dann den eigentlichen download-process eintragen m_hw->dcDownloadRequestAck();
// m_hw->dcDownloadGetCurrentBlockNumber(currentBlockNumber); qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD STARTED";
// m_hw->dcDownloadGetTotalBlockNumber(totalBlockNumber);
// 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);
}
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);
} }