devl continue

This commit is contained in:
Gerhard Hoffmann 2023-12-06 16:35:17 +01:00
parent 2025a75d56
commit b7ff6dcdbe

View File

@ -3,6 +3,7 @@
#include "hwapi.h"
#include <QDateTime>
#include <QDebug>
ReportingThread::ReportingThread(hwapi *hw)
: m_hw(hw)
@ -15,8 +16,12 @@ ReportingThread::~ReportingThread() {
// download thread running in ca-slave sends reports of download process to
// each component which has connects for the corresponding signals.
void ReportingThread::run() {
qCritical() << "START DOWNLOAD THREAD";
static QString status;
#if 0
int cnt = 5;
while (!m_hw->dcDownloadRunning()) {
if (--cnt > 0) {
@ -51,6 +56,39 @@ void ReportingThread::run() {
return;
}
}
#endif
uint16_t const tnr = 1750;
uint16_t cnr = 0;
while (cnr <= tnr) {
QThread::msleep(100);
QString report("");
if (cnr > 0) {
double percent = (double)cnr / (double)tnr;
report = QString("total blocks %1, current block %2 [%3%]")
.arg(tnr).arg(cnr).arg(percent, 0, 'f', 2);
} else {
report = QString("total blocks %1, current block %2 [0]")
.arg(tnr).arg(cnr);
}
status = QDateTime::currentDateTime().toString(Qt::ISODate) + report;
qCritical() << "STATUS" << status;
emit m_hw->hwapi_reportDCDownloadStatus(status);
cnr += 1;
}
if (tnr == cnr) {
m_hw->hwapi_reportDCDownloadSuccess(
QString("SUCCESS DOWNLOADING") + m_fileToDownload);
} else {
m_hw->hwapi_reportDCDownloadFailure(
QString("ERROR DOWNLOADING %1 (total blocks=%2, sent blocks=%3)")
.arg(m_fileToDownload).arg(tnr).arg(cnr));
}
#if 0
@ -84,4 +122,6 @@ void ReportingThread::run() {
.arg(m_fileToDownload).arg(tnr).arg(cnr));
}
#endif
qCritical() << "FINISH DOWNLOAD THREAD";
}