doUpdate(): start reorting thread to report download-progress to GUI.
This commit is contained in:
parent
8d2d7bbb15
commit
3581dd4b1d
175
update.cpp
175
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,65 +721,65 @@ 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);
|
||||||
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
|
||||||
if ((templateIdx < 1) || (templateIdx > 32)) {
|
if ((templateIdx < 1) || (templateIdx > 32)) {
|
||||||
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
qCritical() << "WRONG TEMPLATE INDEX" << templateIdx;
|
||||||
res = false;
|
|
||||||
} else {
|
|
||||||
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
|
||||||
Utils::printInfoMsg(
|
|
||||||
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
|
||||||
.arg(fToWorkOn)
|
|
||||||
.arg(templateIdx));
|
|
||||||
++displayIndex;
|
|
||||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
|
||||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
|
||||||
Worker::UPDATE_STEP_DONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
|
||||||
res = true;
|
|
||||||
if ((res = updateCashConf(fToWorkOn))) {
|
|
||||||
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
|
||||||
++displayIndex;
|
|
||||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
|
||||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
|
||||||
Worker::UPDATE_STEP_DONE);
|
|
||||||
}
|
|
||||||
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
|
||||||
res = true;
|
|
||||||
if ((res= updateConfig(fToWorkOn))) {
|
|
||||||
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
|
||||||
++displayIndex;
|
|
||||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
|
||||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
|
||||||
Worker::UPDATE_STEP_DONE);
|
|
||||||
}
|
|
||||||
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
|
||||||
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
|
||||||
res = true;
|
|
||||||
if ((res = updateDeviceConf(fToWorkOn))) {
|
|
||||||
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
|
||||||
++displayIndex;
|
|
||||||
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
|
||||||
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
|
||||||
Worker::UPDATE_STEP_DONE);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
|
||||||
res = false;
|
res = false;
|
||||||
|
} else {
|
||||||
|
if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
|
||||||
|
Utils::printInfoMsg(
|
||||||
|
QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
|
||||||
|
.arg(fToWorkOn)
|
||||||
|
.arg(templateIdx));
|
||||||
|
++displayIndex;
|
||||||
|
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||||
|
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||||
|
Worker::UPDATE_STEP_DONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
|
||||||
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
|
res = true;
|
||||||
|
if ((res = updateCashConf(fToWorkOn))) {
|
||||||
|
Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
|
||||||
|
++displayIndex;
|
||||||
|
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||||
|
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||||
|
Worker::UPDATE_STEP_DONE);
|
||||||
|
}
|
||||||
|
} else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
|
||||||
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
|
res = true;
|
||||||
|
if ((res= updateConfig(fToWorkOn))) {
|
||||||
|
Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
|
||||||
|
++displayIndex;
|
||||||
|
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||||
|
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||||
|
Worker::UPDATE_STEP_DONE);
|
||||||
|
}
|
||||||
|
} else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
|
||||||
|
&& fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
|
||||||
|
res = true;
|
||||||
|
if ((res = updateDeviceConf(fToWorkOn))) {
|
||||||
|
Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
|
||||||
|
++displayIndex;
|
||||||
|
emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
|
||||||
|
+ QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
|
||||||
|
Worker::UPDATE_STEP_DONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
|
||||||
|
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