doUpdate(): start reorting thread to report download-progress to GUI.
This commit is contained in:
parent
8d2d7bbb15
commit
3581dd4b1d
77
update.cpp
77
update.cpp
@ -631,7 +631,6 @@ bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
||||||
if (m_sys_areDCdataValid == false) {
|
if (m_sys_areDCdataValid == false) {
|
||||||
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
qCritical() << "ERROR!!! DC DATA NOT VALID -> CA-MASTER-PLUGIN NOT CONNECTED";
|
||||||
@ -639,30 +638,74 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
bool dcDownloadPossible = true;
|
||||||
|
|
||||||
QList<QString>::const_iterator it;
|
QList<QString>::const_iterator it;
|
||||||
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
for (it = filesToWorkOn.cbegin(); it != filesToWorkOn.cend(); ++it) {
|
||||||
m_worker->startProgressLoop();
|
m_worker->startProgressLoop();
|
||||||
|
|
||||||
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
QString const &fToWorkOn = QDir::cleanPath(m_customerRepository + QDir::separator() + it->trimmed());
|
||||||
|
if (fToWorkOn.endsWith("/dc2c.bin") && dcDownloadPossible) {
|
||||||
|
qCritical() << "F-TO-WORK-ON" << fToWorkOn;
|
||||||
|
// download for dc possible only once
|
||||||
|
dcDownloadPossible = false;
|
||||||
|
|
||||||
|
if (!m_hw->dcDownloadRequest(fToWorkOn)) { // initiate download process
|
||||||
|
qCritical() << "DOWNLOAD-REQUEST-ERROR FOR" << fToWorkOn;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QThread::sleep(2);
|
||||||
|
|
||||||
|
if (!m_hw->dcDownloadRunning()) { // may take some time
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD NOT RUNNING";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD RUNNING";
|
||||||
|
|
||||||
|
if (!m_hw->dcDownloadReportThreadStart()) { // may take some time
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD NOT STARTED";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") REPORT THREAD STARTED";
|
||||||
|
|
||||||
|
QThread::sleep(2);
|
||||||
|
if (!m_hw->dcDownloadReportRunning()) { // may take some time
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT NOT RUNNING";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qCritical() << QDateTime::currentDateTime().toString(Qt::ISODate)
|
||||||
|
<< "(" << __func__ << ":" << __LINE__ << ") DOWNLOAD REPORT RUNNING";
|
||||||
|
|
||||||
|
while (m_hw->dcDownloadReportRunning()) {
|
||||||
|
QThread::msleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (fToWorkOn.contains("dc2c.bin")) {
|
|
||||||
bool updateBinaryRes = true;
|
bool updateBinaryRes = true;
|
||||||
|
|
||||||
// CONSOLE()
|
// CONSOLE()
|
||||||
|
#if 0
|
||||||
|
m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
||||||
|
QThread::sleep(1); // wait to be sure that there are no more
|
||||||
|
// commands sent to dc-hardware
|
||||||
|
|
||||||
// m_hw->dc_autoRequest(false);// default: turn auto-request setting off
|
if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) {
|
||||||
// QThread::sleep(1); // wait to be sure that there are no more
|
|
||||||
// // commands sent to dc-hardware
|
|
||||||
|
|
||||||
// if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) {
|
|
||||||
//
|
|
||||||
// qCritical() << "downloaded binary" << fToWorkOn;
|
// qCritical() << "downloaded binary" << fToWorkOn;
|
||||||
|
|
||||||
// ++displayIndex;
|
++displayIndex;
|
||||||
// emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
|
||||||
// + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||||
// Worker::UPDATE_STEP_DONE);
|
Worker::UPDATE_STEP_DONE);
|
||||||
//}
|
}
|
||||||
|
|
||||||
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
m_hw->dc_autoRequest(true); // turn auto-request setting on
|
||||||
|
|
||||||
@ -678,11 +721,10 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
res = updateBinaryRes;
|
res = updateBinaryRes;
|
||||||
|
|
||||||
} else {
|
} else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
||||||
if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
|
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
res = true;
|
res = true;
|
||||||
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
|
||||||
@ -736,7 +778,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
|
|||||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
}
|
// m_worker->stopProgressLoop();
|
||||||
|
// m_worker->setProgress(100);
|
||||||
|
|
||||||
if (res == false) {
|
if (res == false) {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user