Save development files.
This commit is contained in:
21
src/download_thread.cpp
Normal file
21
src/download_thread.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include "download_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
DownloadThread::DownloadThread(hwinf *hw, QString const &fileToDownload)
|
||||
: m_hw(hw)
|
||||
, m_fileToDownload(fileToDownload) {
|
||||
}
|
||||
|
||||
DownloadThread::~DownloadThread() {
|
||||
}
|
||||
|
||||
// download thread running in ca-master sends the dc-file down to firmware
|
||||
void DownloadThread::run() {
|
||||
m_hw->dcDownloadInit(m_fileToDownload);
|
||||
|
||||
// hier dann den eigentlichen download-process eintragen
|
||||
|
||||
// m_hw->dcDownloadGetCurrentBlockNumber(currentBlockNumber);
|
||||
// m_hw->dcDownloadGetTotalBlockNumber(totalBlockNumber);
|
||||
}
|
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
|
||||
#include "hwapi.h"
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
static uint32_t hwapi_lastStartAmount;
|
||||
static uint32_t hwapi_lastTotalAmount;
|
||||
@@ -4371,4 +4373,53 @@ uint16_t hwapi::bna_getStackerLevel(uint32_t *amountInStacker, uint16_t *countOf
|
||||
return anzahl;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadInit(QString const &dcFileToDownload) {
|
||||
char *fNameBuffer = SharedMem::getData()->m_downLoadDC.m_filename;
|
||||
size_t const size = sizeof(SharedMem::getData()->m_downLoadDC.m_filename);
|
||||
|
||||
std::memset(fNameBuffer, 0x00, size);
|
||||
std::memcpy(fNameBuffer, dcFileToDownload.toStdString().c_str(),
|
||||
std::min(size, strlen(fNameBuffer)-1));
|
||||
|
||||
SharedMem::getData()->m_downLoadDC.m_totalBlocks = 0;
|
||||
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = 0;
|
||||
SharedMem::getData()->m_downLoadDC.m_started = false;
|
||||
SharedMem::getData()->m_downLoadDC.m_running = false;
|
||||
SharedMem::getData()->m_downLoadDC.m_finished = false;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadStart() {
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadReportStart() {
|
||||
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetTotalBlockNumber(uint16_t totalBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_totalBlocks = totalBlockNumber;
|
||||
}
|
||||
|
||||
void hwapi::dcDownloadSetCurrentBlockNumber(uint16_t currentBlockNumber) {
|
||||
SharedMem::getData()->m_downLoadDC.m_currentblockNumber = currentBlockNumber;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetTotalBlockNumber() const {
|
||||
return SharedMem::getDataConst()->m_downLoadDC.m_totalBlocks;
|
||||
}
|
||||
|
||||
uint16_t hwapi::dcDownloadGetCurrentBlockNumber() const {
|
||||
return SharedMem::getDataConst()->m_downLoadDC.m_currentblockNumber;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadStarted() const {
|
||||
return SharedMem::getDataConst()->m_downLoadDC.m_started;
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadRunning() const {
|
||||
return SharedMem::getDataConst()->m_downLoadDC.m_running;
|
||||
|
||||
}
|
||||
|
||||
bool hwapi::dcDownloadFinished() const {
|
||||
return SharedMem::getDataConst()->m_downLoadDC.m_finished;
|
||||
}
|
||||
|
55
src/reporting_thread.cpp
Normal file
55
src/reporting_thread.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "reporting_thread.h"
|
||||
#include "shared_mem_buffer.h"
|
||||
#include "hwapi.h"
|
||||
|
||||
ReportingThread::ReportingThread(hwinf *hw, QString const &fileToDownload)
|
||||
: m_hw(hw)
|
||||
, m_fileToDownload(fileToDownload) {
|
||||
}
|
||||
|
||||
ReportingThread::~ReportingThread() {
|
||||
}
|
||||
|
||||
// download thread running in ca-slave sends reports download process to
|
||||
// update tool
|
||||
void ReportingThread::run() {
|
||||
|
||||
int cnt = 10;
|
||||
while (!m_hw->dcDownloadRunning()) {
|
||||
if (--cnt > 0) {
|
||||
QThread::sleep(1);
|
||||
}
|
||||
}
|
||||
if (cnt == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (m_hw->dcDownloadRunning()) {
|
||||
uint16_t const cnr = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||
uint16_t const tnr = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
|
||||
QString report("");
|
||||
|
||||
if (cnr > 0) {
|
||||
report = QString("total blocks %1, current block %2 [%3]")
|
||||
.arg(tnr).arg(cnr).arg((double)(tnr)/(double(cnr)));
|
||||
} else {
|
||||
report = QString("total blocks %1, current block %2 [0]")
|
||||
.arg(tnr).arg(cnr);
|
||||
}
|
||||
|
||||
emit m_hw->hwapi_reportDCDownloadStatus(report);
|
||||
}
|
||||
|
||||
uint16_t const cnr = m_hw->dcDownloadGetCurrentBlockNumber();
|
||||
uint16_t const tnr = m_hw->dcDownloadGetTotalBlockNumber();
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user