#include "download_thread.h" #include "shared_mem_buffer.h" #include "hwapi.h" #include #include DownloadThread::DownloadThread(hwinf *hw) : m_hw(hw) , m_fileToDownload(m_hw->dcDownloadFileName()) { // connect(this, &QThread::finished, // dynamic_cast(m_hw), &QThread::deleteLater); } DownloadThread::~DownloadThread() { } // download thread running in ca-master sends the dc-file down to firmware void DownloadThread::run() { m_hw->dcDownloadRequestAck(); qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate) + "DOWNLOAD THREAD STARTED"; // 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); }