From c3947e49abadf6c60656457ff5a69069d9890498 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 7 Mar 2025 12:10:54 +0100 Subject: [PATCH] cleaning up source code. move summary-handling to main-window. --- UpdatePTUDevCtrl/worker.cpp | 103 +++++------------------------------- UpdatePTUDevCtrl/worker.h | 8 ++- 2 files changed, 20 insertions(+), 91 deletions(-) diff --git a/UpdatePTUDevCtrl/worker.cpp b/UpdatePTUDevCtrl/worker.cpp index 189023f..322b3b0 100644 --- a/UpdatePTUDevCtrl/worker.cpp +++ b/UpdatePTUDevCtrl/worker.cpp @@ -185,7 +185,7 @@ Worker::Worker(int customerNr, , m_pluginVersionPrmCalcConfig(getPluginVersion("/opt/app/ATBAPP/plugins/libPRM_CalculatePricePlugin_ConfigUi.so")) , m_pluginVersionTcpZvt(getPluginVersion("/opt/app/ATBAPP/plugins/libTCP_ZVT_CCPlugin.so")) , m_ismasUpdateRequests(ISMAS_UPDATE_REQUESTS) - , m_waitForNewUpdates(this) + , m_summaryTimer(this) , m_filesToUpdate() , m_updateProcessRunning(true) , m_mainWindow(nullptr) /* contains plugin */ @@ -202,8 +202,8 @@ Worker::Worker(int customerNr, int next = 1; m_workList.push_back( std::make_unique( - //QString("echo CheckIsmasConnectivityCommand") - QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected") + QString("echo ATBUpdateCheck --ismas-connected") + //QString("/opt/app/tools/atbupdate/ATBUpdateCheck --ismas-connected") , this, ++next)); // *** check if update activated in ISMAS *** @@ -211,8 +211,8 @@ Worker::Worker(int customerNr, // if the update has been activated via ISMAS. m_workList.push_back( std::make_unique( - //QString("echo CheckUpdateActivationCommand") - QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested") + QString("echo ATBUpdateCheck --update-requested") + //QString("/opt/app/tools/atbupdate/ATBUpdateCheck --update-requested") , this, ++next)); // *** check and fetch git-customer repository *** @@ -221,24 +221,24 @@ Worker::Worker(int customerNr, // the corresponding branch, and check the integrity of the repository. m_workList.push_back( std::make_unique( - // QString("echo CheckAndFetchCustomerRepositoryCommand") - QString("/opt/app/tools/atbupdate/ATBUpdateGit") + QString("echo ATBUpdateGit") + // QString("/opt/app/tools/atbupdate/ATBUpdateGit") , this, ++next)); // *** exec opkg-commands (noaction) *** // NOTE: first run the opkg commands with no action -> dry-run m_workList.push_back( std::make_unique( - // QString("echo ExecOpkgCommand noaction") - QString("/opt/app/tools/atbupdate/ATBUpdateOpkg --noaction") + QString("echo ATBUpdateOpkg --noaction") + // QString("/opt/app/tools/atbupdate/ATBUpdateOpkg --noaction") , this, ++next, true)); // *** exec opkg-commands *** // NOTE: first run the opkg commands with action -> no dry-run m_workList.push_back( std::make_unique( - //QString("echo ExecOpkgCommand run") - QString("/opt/app/tools/atbupdate/ATBUpdateOpkg") + QString("echo ExecOpkgCommand run") + // QString("/opt/app/tools/atbupdate/ATBUpdateOpkg") , this, ++next, false)); // *** send json files down to device controller *** @@ -257,14 +257,14 @@ Worker::Worker(int customerNr, // send device-controller firmware down to device-controller-hardware m_workList.push_back( std::make_unique( - QString("echo ATBDownloadDCFirmware") - // QString("/opt/app/tools/atbupdate/ATBDownloadDCFirmware --read-dc-version true") + // QString("echo ATBUpdateDC") + QString("/opt/app/tools/atbupdate/ATBUpdateDC") , this, ++next)); // show/send software-status m_workList.push_back( std::make_unique( - QString("echo ATBUpdateShowPSAInstalled") + QString("echo ATBUpdateShow") , this, -1)); // reboot machine @@ -1615,78 +1615,3 @@ bool Worker::jsUpdate() { bool Worker::dcUpdate() { return m_dcDownloadFirmware->start("/opt/app/tools/atbupdate"); } - -void Worker::summary() { - - QString summary, first, second, line, tmp; - QVector> vec = Utils::installedPackages(); - - vec.append(Utils::installedTariffFiles(this, m_customerRepository)); - vec.append(Utils::installedJsonFiles(this, m_customerRepository)); - - int max_first = 0, max_second = 0; - for (int i = 0; i < vec.size(); ++i) { - max_first = std::max(max_first, vec[i].first.length()); - max_second = std::max(max_second, vec[i].second.length()); - } - - max_first += 5; - - summary = "UPDATE SUMMARY\n\n"; - - first = QString("%1").arg("start", max_first, QChar(' ')); - tmp = QString("%1").arg(start().toString(Qt::ISODate)); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - first = QString("%1").arg("update tool version", max_first, QChar(' ')); - tmp = QString("%1 - %2 %3").arg(APP_VERSION).arg(APP_BUILD_DATE).arg(APP_BUILD_TIME); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - first = QString("%1").arg("machine number", max_first, QChar(' ')); - tmp = QString("%1").arg(machineNr()); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - first = QString("%1").arg("customer number", max_first, QChar(' ')); - tmp = QString("%1").arg(customerNr()); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - first = QString("%1").arg("zone number", max_first, QChar(' ')); - tmp = QString("%1").arg(zoneNr()); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - if (m_mainWindow) { - tmp = m_mainWindow->targetDcVersion(); - if (!tmp.isEmpty()) { - first = QString("%1").arg("target device controller", max_first, QChar(' ')); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - } - } - - first = QString("%1").arg("apism", max_first, QChar(' ')); - tmp = QString("%1").arg(apismVersion()); - second = QString("%1").arg(tmp, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - - for (int i = 0; i < vec.size(); ++i) { - first = QString("%1").arg(vec[i].first, max_first, QChar(' ')); - second = QString("%1").arg(vec[i].second, -max_second, QChar(' ')); - line = first + ": " + second; - summary += line + "\n"; - } - - emit showSummary(summary); - emit enableExit(); -} diff --git a/UpdatePTUDevCtrl/worker.h b/UpdatePTUDevCtrl/worker.h index e296726..6522990 100644 --- a/UpdatePTUDevCtrl/worker.h +++ b/UpdatePTUDevCtrl/worker.h @@ -178,7 +178,7 @@ class Worker : public QThread{ QString const m_pluginVersionTcpZvt; int m_ismasUpdateRequests; - QTimer m_waitForNewUpdates; + QTimer m_summaryTimer; QStringList m_filesToUpdate; QStringList m_filesToDownload; @@ -453,6 +453,8 @@ public: void setHW(hwinf *hw) { m_hw = hw; } hwinf *getHW() { return m_hw; } + QString customerRepository() { return m_customerRepository; } + IsmasClient &getIsmasClient() { return m_ismasClient; } IsmasClient const &getIsmasClient() const { return m_ismasClient; } @@ -473,7 +475,6 @@ public: bool jsUpdate(); bool dcUpdate(); - void summary(); QDateTime start() { return m_start; } QByteArray standardOutput() const { return m_standardOutput; } @@ -481,6 +482,8 @@ public: WorkList const &workList() const { return m_workList; } WorkList &workList() { return m_workList; } + QTimer *summaryTimer() { return &m_summaryTimer; } + signals: void appendText(QString, QString suffix = ""); void insertText(QString); @@ -507,6 +510,7 @@ signals: void showDownloadDCJsonFilesStatus(QString); void showSyncCustRepoStatus(QString); void showUpdateDCFirmware(QString); + void summary(); void showSummary(QString); void setDcDownloadProgress(int);