From fba007aa3563ea708580cbea5edf3b462c8cc770 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 6 Oct 2023 12:56:03 +0200 Subject: [PATCH] Activate download of json-configuration files. --- update.cpp | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/update.cpp b/update.cpp index 8de63c5..2e9e8d2 100644 --- a/update.cpp +++ b/update.cpp @@ -29,11 +29,7 @@ #include #define UPDATE_OPKG (1) -#define UPDATE_DC (1) -#define UPDATE_PRINTER_TEMPLATES (1) -#define UPDATE_CASH_TEMPLATE (1) -#define UPDATE_CONF_TEMPLATE (1) -#define UPDATE_DEVICE_TEMPLATE (1) +#define UPDATE_DC (0) static const QMap baudrateMap = { {"1200" , 0}, {"9600" , 1}, {"19200" , 2}, {"38400" , 3}, @@ -852,13 +848,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1]; } } -#endif res = updateBinaryRes; } - } else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive) - && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { +#endif + if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive) + && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { res = true; -#if UPDATE_PRINTER_TEMPLATES == 1 int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive); int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt(); if ((templateIdx < 1) || (templateIdx > 32)) { @@ -866,50 +861,46 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { res = false; } else { if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) { - qInfo() << "downloaded printer template"<< 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(2, ' ') + QString(")") + emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")") + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), Worker::UPDATE_STEP_DONE); } } -#endif } else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive) && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { res = true; -#if UPDATE_CASH_TEMPLATE == 1 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(2, ' ') + QString(")") + emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")") + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), Worker::UPDATE_STEP_DONE); } -#endif } else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive) && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { res = true; -#if UPDATE_CONF_TEMPLATE == 1 if ((res= updateConfig(fToWorkOn))) { - qInfo() << "downloaded config template"<< fToWorkOn; + Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn)); ++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(3, ' ') + QString(")") + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), Worker::UPDATE_STEP_DONE); } -#endif } else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive) && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) { res = true; -#if UPDATE_DEVICE_TEMPLATE == 1 if ((res = updateDeviceConf(fToWorkOn))) { - qInfo() << "downloaded device template"<< fToWorkOn; + Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn)); ++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(3, ' ') + QString(")") + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), Worker::UPDATE_STEP_DONE); } -#endif } else { qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn; res = false; @@ -922,12 +913,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { } } // for (it = openLines.cbegin(); it != openLines.end(); ++it) { - //m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON - //qDebug() << "SET AUTO-REQUEST=TRUE"; - - if (serialOpened) { - m_hw->dc_closeSerial(); - } + m_hw->dc_autoRequest(true); // ALWAYS turn autoRequest ON + qDebug() << "SET AUTO-REQUEST=TRUE"; return res; }