From e6f6d43bf23ba8d428afa1189f2d28a86b9d1d35 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:17:16 +0100 Subject: [PATCH 01/40] Adden helpers: QString getLocation(QString fileName); QString getTariffVersion(QString fileName); QString getTariffInfo(QString fileName); --- utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils.h b/utils.h index 1e77a17..8fdd648 100644 --- a/utils.h +++ b/utils.h @@ -12,6 +12,9 @@ namespace Utils { int read1stLineOfFile(QString fileName); + QString getLocation(QString fileName); + QString getTariffVersion(QString fileName); + QString getTariffInfo(QString fileName); QString zoneName(quint8 i); void printCriticalErrorMsg(QString const &errorMsg, bool upper=false, bool lower=false); void printCriticalErrorMsg(QStringList const &errorMsg); From bc9ebb7d686fb3fa0388989c78269e837053186e Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:18:03 +0100 Subject: [PATCH 02/40] Implemented helpers: QString getLocation(QString fileName); QString getTariffVersion(QString fileName); QString getTariffInfo(QString fileName); Read project location, tariff location and tariff-info from tariff[].json file. --- utils.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/utils.cpp b/utils.cpp index 870af4e..cab60d3 100644 --- a/utils.cpp +++ b/utils.cpp @@ -30,6 +30,82 @@ int Utils::read1stLineOfFile(QString fileName) { return -1; } +QString Utils::getLocation(QString fileName) { + QString location("N/A"); + QFile f(fileName); + if (f.exists()) { + if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&f); + in.setCodec("UTF-8"); + while(!in.atEnd()) { + QString const &line = in.readLine(); + if (line.indexOf("Project", Qt::CaseInsensitive) != -1) { + int const c = line.indexOf(":"); + if (c != -1) { + location = line.mid(c+1); + if (!location.isEmpty()) { + return location.replace(QChar('"'), QString("")).trimmed(); + } + } + } + } + } + } + + return location; +} + +QString Utils::getTariffVersion(QString fileName) { + QString version("N/A"); + QFile f(fileName); + if (f.exists()) { + if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&f); + in.setCodec("UTF-8"); + while(!in.atEnd()) { + QString const &line = in.readLine(); + if (line.indexOf("Version", Qt::CaseInsensitive) != -1) { + int const c = line.indexOf(":"); + if (c != -1) { + version = line.mid(c+1); + if (!version.isEmpty()) { + return version.replace(QChar('"'), QString("")).trimmed(); + } + } + } + } + } + } + + return version; +} + +QString Utils::getTariffInfo(QString fileName) { + QString info("N/A"); + QFile f(fileName); + if (f.exists()) { + if (f.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&f); + in.setCodec("UTF-8"); + while(!in.atEnd()) { + QString const &line = in.readLine(); + if (line.indexOf("Info", Qt::CaseInsensitive) != -1) { + int const c = line.indexOf(":"); + if (c != -1) { + info = line.mid(c+1); + if (!info.isEmpty()) { + return info.replace(QChar('"'), QString("")).trimmed(); + } + } + } + } + } + } + + return info; + +} + QString Utils::zoneName(quint8 i) { static constexpr char const *zName[] = { "", From 30d8cc36849151dcff26b6385a497c681737eff0 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:25:35 +0100 Subject: [PATCH 03/40] Add m_version_info as memeber. --- worker.h | 1 + 1 file changed, 1 insertion(+) diff --git a/worker.h b/worker.h index 6ea9bb7..1f00784 100644 --- a/worker.h +++ b/worker.h @@ -132,6 +132,7 @@ class Worker : public QThread{ QString const m_baudrate; IsmasClient m_ismasClient; GitClient m_gc; + QStringList m_versionInfo; QString const m_osVersion; QString const m_atbqtVersion; QString const m_atbUpdateToolVersion; From 6a67d8e9b0b27a1375e6b95e7ccb42f2a125a545 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:26:14 +0100 Subject: [PATCH 04/40] Minor: update percent numbers in some cases. --- worker.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/worker.h b/worker.h index 1f00784..5702c8b 100644 --- a/worker.h +++ b/worker.h @@ -653,8 +653,10 @@ private: ismasClient.setProgressInPercent(_CHECK_REPOSITORY); break; case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS: + ismasClient.setProgressInPercent(_CHECK_REPOSITORY_SUCCESS); break; case UPDATE_STEP::CHECK_REPOSITORY_FAILURE: + ismasClient.setProgressInPercent(_CHECK_REPOSITORY_FAILURE); break; case UPDATE_STEP::CHECK_SANITY: ismasClient.setProgressInPercent(_CHECK_SANITY); @@ -666,8 +668,10 @@ private: ismasClient.setProgressInPercent(_CHECK_SANITY_FAILURE); break; case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS: + ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_SUCCESS); break; case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE: + ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_FAILURE); break; case UPDATE_STEP::CLONE_REPOSITORY: ismasClient.setProgressInPercent(_CLONE_REPOSITORY); From 73d02d214a4a78a3f3435192b7933edd1ae91bca Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:26:53 +0100 Subject: [PATCH 05/40] Send contant of m_versionInfo(0) (git commit of repository) to ISMAS. --- worker.h | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/worker.h b/worker.h index 5702c8b..ba13ece 100644 --- a/worker.h +++ b/worker.h @@ -688,7 +688,7 @@ private: QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2") .arg(instance->m_customerRepository) .arg(instance->m_gc.branchName()).toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -704,7 +704,7 @@ private: QString("CLONING REPOSITORY %1 OR CHECKING OUT BRANCH %2 FAILED") .arg(instance->m_customerRepository) .arg(instance->m_gc.branchName()).toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -718,7 +718,8 @@ private: ismasClient.cloneAndCheckoutCustomerRepository( QString("CHECKED OUT REPOSITORY %1 AND CHECKED OUT BRANCH %2") .arg(instance->m_customerRepository) - .arg(instance->m_gc.branchName()))); + .arg(instance->m_gc.branchName()), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A")); break; case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE: ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_FAILURE); @@ -730,7 +731,8 @@ private: ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_SUCCESS); ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + - ismasClient.updateTriggerSet("ISMAS TRIGGER SET", "")); + ismasClient.updateTriggerSet("ISMAS TRIGGER SET", + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A")); break; case UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE: ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_WRONG_VALUE); @@ -745,7 +747,7 @@ private: IsmasClient::RESULT_CODE::INSTALL_ERROR, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -768,7 +770,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -782,7 +784,7 @@ private: IsmasClient::RESULT_CODE::INSTALL_ERROR, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -916,7 +918,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -933,7 +935,7 @@ private: IsmasClient::RESULT_CODE::INSTALL_ERROR, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -959,7 +961,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -976,7 +978,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -996,7 +998,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -1016,7 +1018,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -1039,7 +1041,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -1053,7 +1055,7 @@ private: IsmasClient::RESULT_CODE::SUCCESS, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; @@ -1067,7 +1069,7 @@ private: IsmasClient::RESULT_CODE::INSTALL_ERROR, smap[step], instance->m_ismasMsg.join(' ').toStdString().c_str(), - ""); + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; From cf77d0ff7642f36385103fd5ca918dcd979c8fc0 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:28:49 +0100 Subject: [PATCH 06/40] Initialize m_versionInfo and send its contents to ISMAS in the update-process. --- worker.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/worker.cpp b/worker.cpp index 239b562..d3e7c3c 100644 --- a/worker.cpp +++ b/worker.cpp @@ -140,6 +140,7 @@ Worker::Worker(int customerNr, , m_serialInterface(serialInterface) , m_baudrate(baudrate) , m_gc(m_customerNrStr, m_customerRepository, m_workingDirectory, m_branchName, this) + , m_versionInfo(QStringList()) , m_osVersion(getOsVersion()) , m_atbqtVersion(getATBQTVersion()) , m_atbUpdateToolVersion(getATBUpdateToolVersion()) @@ -301,6 +302,9 @@ void Worker::privateUpdate() { setProgress(i); // and switch to branch if (m_gc.gitCloneAndCheckoutBranch()) { if (!isRepositoryCorrupted()) { + if (m_versionInfo.size() == 0) { + m_versionInfo = m_gc.gitShowReason(m_branchName); + } GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY_SUCCESS)); continueUpdate = true; m_clone = true; @@ -330,6 +334,11 @@ void Worker::privateUpdate() { } } } + + if (m_versionInfo.size() == 0) { + m_versionInfo = m_gc.gitShowReason(m_branchName); + } + CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_SUCCESS; setProgress(_CHECKOUT_REPOSITORY_SUCCESS); From d90954c6eb3d5a3c621e34a68e6703a757f5bb12 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:30:34 +0100 Subject: [PATCH 07/40] Add location, version and info to send-last-version object. --- worker.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/worker.cpp b/worker.cpp index d3e7c3c..6e21e4a 100644 --- a/worker.cpp +++ b/worker.cpp @@ -1127,15 +1127,14 @@ PSAInstalled Worker::getPSAInstalled() { QString absPathName; QString absPathNameRepository; - psaInstalled.versionInfo.lastCommit = ""; - psaInstalled.versionInfo.reason = ""; - psaInstalled.versionInfo.created = ""; + psaInstalled.versionInfo.lastCommit = "N/A"; + psaInstalled.versionInfo.reason = "N/A"; + psaInstalled.versionInfo.created = "N/A"; - QStringList versionInfo = m_gc.gitShowReason(m_branchName); - if (versionInfo.size() == 3) { - psaInstalled.versionInfo.lastCommit = versionInfo.at(0); - psaInstalled.versionInfo.reason = versionInfo.at(1); - psaInstalled.versionInfo.created = versionInfo.at(2); + if (m_versionInfo.size() == 3) { + psaInstalled.versionInfo.lastCommit = m_versionInfo.at(0); + psaInstalled.versionInfo.reason = m_versionInfo.at(1); + psaInstalled.versionInfo.created = m_versionInfo.at(2); } if (m_zoneNr != 0) { @@ -1148,10 +1147,10 @@ PSAInstalled Worker::getPSAInstalled() { psaInstalled.tariff.size = getFileSize(absPathName); psaInstalled.tariff.zone = m_zoneNr; psaInstalled.tariff.loadTime = Utils::getTariffLoadTime(absPathName); + psaInstalled.tariff.project = Utils::getLocation(absPathName); + psaInstalled.tariff.version = Utils::getTariffVersion(absPathName); + psaInstalled.tariff.info = Utils::getTariffInfo(absPathName); } - psaInstalled.tariff.project = "Szeged"; - psaInstalled.tariff.info = "N/A"; - psaInstalled.tariff.version = "N/A"; psaInstalled.hw.linuxVersion = getOsVersion(); psaInstalled.hw.cpuSerial = m_cpuSerial; From 1e1820724d99b2a192535838c7ecaddb5787f8ae Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:32:26 +0100 Subject: [PATCH 08/40] Set version to v1.4.0. Set compile-option -O (FORTIFY_SOURCE). --- OnDemandUpdatePTU.pro | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index 9c38f4f..c487531 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -81,9 +81,19 @@ DEFINES += QT_DEPRECATED_WARNINGS # Fix the path-names of the json-files and the device-controller. # Set automatic download of json-file in ATBUpdateTool.ini file for # a fresh clone of the repository. -# 1.3.23 Added a 'break' to prevent a possible endless loop when checking if +# 1.3.23: Added a 'break' to prevent a possible endless loop when checking if # the device is alive. -VERSION="1.3.24" +# +# NOTE: The versioning info has to be shifted up by one version, i.e. what +# happened for 1.3.23 was actually done in 1.3.24. +# 1.3.24 +# +# 1.3._24_: Special version for szeged using a old dc-controller (4.42): +# Changes: +# (1) the ini-File now uses the libCAmaster.so. +# 1.3._25_: Again special version for szeged, using interface.h, version 4.4. +# 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged) +VERSION="1.4.0" # PLANNED TODOS: # 1: Das Repository wird repariert bwz. neu geklont. Unabhaengig vom WAIT. @@ -170,7 +180,7 @@ DEFINES+=APP_EXTENDED_VERSION=\\\"$$EXTENDED_VERSION\\\" # keep comments, as /* fall through */ QMAKE_CXXFLAGS += -C QMAKE_CXXFLAGS += -g -QMAKE_CXXFLAGS += -Wno-deprecated-copy +QMAKE_CXXFLAGS += -Wno-deprecated-copy -O contains( CONFIG, PTU5 ) { greaterThan(QT_MAJOR_VERSION, 4): QT += serialport From 979afa37d3ad1513d90a9e154e8b635bec316e57 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 17 Jan 2024 15:38:05 +0100 Subject: [PATCH 09/40] Minor: add comment --- OnDemandUpdatePTU.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index c487531..0e8cf18 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -93,6 +93,8 @@ DEFINES += QT_DEPRECATED_WARNINGS # (1) the ini-File now uses the libCAmaster.so. # 1.3._25_: Again special version for szeged, using interface.h, version 4.4. # 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged) +# Set hash-value in EVENT-objects. Set location (project), version +# and info in send-last-version. VERSION="1.4.0" # PLANNED TODOS: From 9a687e6628bbeb269bd937087e1d391105f40e86 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:16:26 +0100 Subject: [PATCH 10/40] Minor: add some debug output --- commandline_parser.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/commandline_parser.cpp b/commandline_parser.cpp index 7fbeae8..c178fb5 100644 --- a/commandline_parser.cpp +++ b/commandline_parser.cpp @@ -128,12 +128,20 @@ void CommandLineParser::readSettings() { QString const iniFileDir = m_parser.value(m_iniFileDirectoryOption); QString const iniFileName = m_parser.value(m_iniFileNameOption); m_iniFileName = QDir::cleanPath(iniFileDir + QDir::separator() + iniFileName); + + qCritical() << __PRETTY_FUNCTION__ << " iniFileDir" << iniFileDir; + qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName; + if (!m_iniFileName.isEmpty()) { if (QFile(m_iniFileName).exists()) { QSettings settings(m_iniFileName, QSettings::IniFormat); QStringList keys = settings.allKeys(); for (QString const &key: keys) { QVariant v = settings.value(key); + + qCritical() << __PRETTY_FUNCTION__ + << key << " -> " << v.toString(); + if (key.contains("repository-url")) { m_repositoryUrl = v.toString(); } else @@ -166,8 +174,14 @@ void CommandLineParser::readSettings() { } else if (key.contains("plugin-name")) { m_plugInName = v.toString(); + } else { + qCritical() << __PRETTY_FUNCTION__ + << key << " -> (UNKNOWN) " << v.toString(); } } + } else { + qCritical() << __PRETTY_FUNCTION__ << "iniFileName" << m_iniFileName + << "DOES NOT EXIST"; } } } @@ -238,7 +252,9 @@ bool CommandLineParser::extendedVersion() { bool CommandLineParser::alwaysDownloadConfig() { if (m_parser.isSet(m_alwaysDownloadConfigOption)) { m_alwaysDownloadConfig = m_parser.value(m_alwaysDownloadConfigOption); + qCritical() << "m_alwaysDownloadConfigOption IS SET" << m_alwaysDownloadConfig; } + qCritical() << "m_alwaysDownloadConfig" << m_alwaysDownloadConfig; return m_alwaysDownloadConfig == "false" ? false : true; } From 1ecb844b647dab2fc8b3a845e005547051993f56 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:20:21 +0100 Subject: [PATCH 11/40] Added for future use when updating device-controller-frimware: hwinf *m_hw = nullptr; UPDATE_STEP m_lastFailedUpdateStep = UPDATE_STEP::NONE; --- worker.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/worker.h b/worker.h index ba13ece..71ef5c5 100644 --- a/worker.h +++ b/worker.h @@ -290,6 +290,8 @@ private: static Worker *instance; QStringList m_opkgCommands; Update *m_update = nullptr; + hwinf *m_hw = nullptr; + UPDATE_STEP m_lastFailedUpdateStep = UPDATE_STEP::NONE; protected: virtual void run(); @@ -347,6 +349,8 @@ public: void displayProgressInMainWindow(int progress); void startProgressLoop(); void stopProgressLoop(); + void setHW(hwinf *hw) { m_hw = hw; } + hwinf *getHW() { return m_hw; } IsmasClient &getIsmasClient() { return m_ismasClient; } IsmasClient const &getIsmasClient() const { return m_ismasClient; } From 0aa8d9ba5aa9b971604567bc98ea8df3635a0f6f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:22:03 +0100 Subject: [PATCH 12/40] Check if update-process was really necessary, i.e. NOT activated by an automatic nightly update. --- worker.h | 69 ++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/worker.h b/worker.h index 71ef5c5..1ad311d 100644 --- a/worker.h +++ b/worker.h @@ -82,28 +82,31 @@ #define _DOWNLOAD_CONFIG_FILE_SUCCESS (56) #define _DOWNLOAD_CONFIG_FILE_FAILURE (57) #define _DOWNLOAD_DEVICE_CONTROLLER (65) -#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86) -#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (87) -#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (88) -#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (89) -#define _SYNC_CUSTOMER_REPOSITORY (90) -#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (91) -#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (92) -#define _SAVE_LOGS (93) -#define _SAVE_LOGS_FAILURE (94) -#define _SAVE_LOGS_SUCCESS (95) -#define _SEND_LAST_VERSION (96) -#define _UPDATE_SUCCEEDED (97) -#define _UPDATE_FAILED (98) -#define _UPDATE_ACTIVATED (99) +#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (85) +#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (86) +#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (87) +#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (88) +#define _SYNC_CUSTOMER_REPOSITORY (89) +#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (90) +#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (91) +#define _SAVE_LOGS (92) +#define _SAVE_LOGS_FAILURE (93) +#define _SAVE_LOGS_SUCCESS (94) +#define _SEND_LAST_VERSION (95) +#define _UPDATE_SUCCEEDED (96) +#define _UPDATE_FAILED (97) +#define _UPDATE_ACTIVATED (98) +#define _UPDATE_NOT_NECESSARY (99) #define _FINISHED (100) #define _DEBUG (1000) #define _ERROR (1001) +#define _NONE (1002) -#define _SEND_LAST_VERSION_CORRECTION (4) -#define _UPDATE_SUCCEEDED_CORRECTION (3) -#define _UPDATE_FAILED_CORRECTION (2) -#define _UPDATE_ACTIVATED_CORRECTION (1) +#define _SEND_LAST_VERSION_CORRECTION (5) +#define _UPDATE_SUCCEEDED_CORRECTION (4) +#define _UPDATE_FAILED_CORRECTION (3) +#define _UPDATE_ACTIVATED_CORRECTION (2) +#define _UPDATE_NOT_NECESSARY_CORRECTION (1) #define ISMAS_UPDATE_REQUESTS (10) #define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..." @@ -276,10 +279,12 @@ public: SEND_LAST_VERSION = _SEND_LAST_VERSION, UPDATE_SUCCEEDED = _UPDATE_SUCCEEDED, UPDATE_ACTIVATED = _UPDATE_ACTIVATED, + UPDATE_NOT_NECESSARY = _UPDATE_NOT_NECESSARY, UPDATE_FAILED = _UPDATE_FAILED, FINISHED = _FINISHED, DEBUG = _DEBUG, - ERROR = _ERROR + ERROR = _ERROR, + NONE = _NONE }; private: @@ -410,6 +415,8 @@ private: QStringList lst = QStringList(smap[step]); switch (step) { + case UPDATE_STEP::NONE: { + } break; case UPDATE_STEP::STARTED: { Utils::printUpdateStatusMsg( debug, @@ -617,6 +624,10 @@ private: lst << instance->m_debugMsg; Utils::printUpdateStatusMsg(debug, lst); break; + case UPDATE_STEP::UPDATE_NOT_NECESSARY: + lst << instance->m_debugMsg; + Utils::printUpdateStatusMsg(debug, lst); + break; case UPDATE_STEP::UPDATE_FAILED: break; case UPDATE_STEP::FINISHED: @@ -650,6 +661,8 @@ private: QStringList lst = QStringList(smap[step]); switch (step) { + case UPDATE_STEP::NONE: { + } break; case UPDATE_STEP::STARTED: { ismasClient.setProgressInPercent(_STARTED); } break; @@ -1063,6 +1076,20 @@ private: ismasClient.sendRequestReceiveResponse( IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; + case UPDATE_STEP::UPDATE_NOT_NECESSARY: { + ismasClient.setProgressInPercent(_UPDATE_NOT_NECESSARY + _UPDATE_NOT_NECESSARY_CORRECTION); + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0002", // reset WAIT-button to "" (empty string) + ismasClient.getProgressInPercent(), + IsmasClient::RESULT_CODE::SUCCESS, + smap[step], + instance->m_ismasMsg.join(' ').toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; case UPDATE_STEP::UPDATE_FAILED: { ismasClient.setProgressInPercent(_UPDATE_FAILED); QString const &ismasUpdateNews = @@ -1100,6 +1127,8 @@ private: Worker::instance->m_currentStep = step; switch (step) { + case UPDATE_STEP::NONE: { + } break; case UPDATE_STEP::STARTED: break; case UPDATE_STEP::CHECK_REPOSITORY: @@ -1274,6 +1303,8 @@ private: break; case UPDATE_STEP::UPDATE_ACTIVATED: break; + case UPDATE_STEP::UPDATE_NOT_NECESSARY: + break; case UPDATE_STEP::UPDATE_FAILED: emit worker->appendText(QString("UPDATE "), UPDATE_STEP_FAIL); break; From 1c0786e28c8a25bd00f7e532df9d80bcba22142d Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:24:54 +0100 Subject: [PATCH 13/40] Minor: Add NONE constant (for UPDATE_NECESSARY). --- worker.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/worker.cpp b/worker.cpp index 6e21e4a..585ef65 100644 --- a/worker.cpp +++ b/worker.cpp @@ -101,7 +101,8 @@ const QMap Worker::smap ( INSERT_ELEMENT(UPDATE_STEP::UPDATE_ACTIVATED), INSERT_ELEMENT(UPDATE_STEP::FINISHED), INSERT_ELEMENT(UPDATE_STEP::DEBUG), - INSERT_ELEMENT(UPDATE_STEP::ERROR) + INSERT_ELEMENT(UPDATE_STEP::ERROR), + INSERT_ELEMENT(UPDATE_STEP::NONE) #undef INSERT_ELEMENT }); From 005e4d249f6022796729c97bdaeb766c16e2bdf5 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:27:07 +0100 Subject: [PATCH 14/40] Set m_lastFailedUpdateStep (future use for downloading the firmware-device-controller). --- worker.cpp | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/worker.cpp b/worker.cpp index 585ef65..a0f1397 100644 --- a/worker.cpp +++ b/worker.cpp @@ -164,6 +164,8 @@ Worker::Worker(int customerNr, // TODO: turn object into singleton instance = this; + m_lastFailedUpdateStep = UPDATE_STEP::NONE; + this->setObjectName("worker-object"); QDir::setCurrent(m_workingDirectory); @@ -283,12 +285,12 @@ void Worker::privateUpdate() { if (isRepositoryCorrupted()) { // a not-existing repository is not meant // to be corrupted - CONSOLE() << UPDATE_STEP::CHECK_SANITY_FAILURE; + CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_SANITY_FAILURE); if ((continueUpdate = repairCorruptedRepository()) == true) { m_repairClone = true; CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS; } else { - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE)); + ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE))); return; } } @@ -316,7 +318,7 @@ void Worker::privateUpdate() { } if (continueUpdate == false) { - GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY_FAILURE)); + GUI() << (ISMAS() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CLONE_REPOSITORY_FAILURE))); return; } @@ -330,7 +332,7 @@ void Worker::privateUpdate() { CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY; if (isRepositoryCorrupted()) { - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_FAILURE)); + ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_REPOSITORY_FAILURE))); return; } } @@ -521,12 +523,12 @@ bool Worker::updateTriggerSet() { .arg(parseError.error) .arg(parseError.errorString()) .arg(parseError.offset)); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } if (!document.isObject()) { QStringList lst(QString("not a json-object %1").arg(result.value())); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } @@ -535,7 +537,7 @@ bool Worker::updateTriggerSet() { // always look for an 'error' first if (obj.contains("error")) { QStringList lst(obj.value("error").toString()); - CONSOLE(QStringList(lst)) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE; + CONSOLE(QStringList(lst)) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); QThread::sleep(6); continue; } @@ -552,28 +554,28 @@ bool Worker::updateTriggerSet() { if (customerNr != m_customerNr) { QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)") .arg(customerNr).arg(m_customerNr)); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } if (machineNr != m_machineNr) { QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)") .arg(machineNr).arg(m_machineNr)); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID"); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst("Dev_ID KEY NOT A JSON-OBJECT"); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst("Dev_ID KEY NOT AVAILABLE"); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } @@ -593,7 +595,7 @@ bool Worker::updateTriggerSet() { // if the customer repository has just been cloned break; // it is OK the ISMAS trigger might not be 'WAIT' } else { - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); } QThread::sleep(6); continue; @@ -603,28 +605,28 @@ bool Worker::updateTriggerSet() { GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE); } else { QStringList lst(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); } break; } } else { QStringList lst("TRG key not available"); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst("Fileupload not a json-object"); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst(QString("Fileupload not available")); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); break; } } else { QStringList lst = QStringList(QString("no ISMAS response")); - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); QThread::sleep(6); } } @@ -632,7 +634,7 @@ bool Worker::updateTriggerSet() { if (m_initialClone == false) { if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) { QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")"); - ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); } } @@ -650,11 +652,11 @@ bool Worker::customerEnvironment() { return true; } else { QStringList lst(QString("CHECKOUT OF " + m_customerRepository + "FAILED")); - ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECKOUT_BRANCH_FAILURE))); } } else {// cannot happen QStringList lst(QString(m_customerRepository + " DOES NOT EXIST")); - ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECKOUT_BRANCH_FAILURE))); } return false; @@ -709,7 +711,7 @@ bool Worker::filesToUpdate() { GUI(m_filesToUpdate) << (CONSOLE(m_filesToUpdate) << UPDATE_STEP::FILES_TO_UPDATE); setProgress(_FILES_TO_UPDATE); } else { - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_FAILURE)); + ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::UPDATE_REPOSITORY_FAILURE))); return false; } @@ -817,7 +819,7 @@ bool Worker::execOpkgCommands() { } } else { m_displayIndex = 1; - ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE)); + ISMAS(opkgErrorLst) << (GUI(opkgErrorLst) << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE))); GUI() << UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE; setProgress(_EXEC_OPKG_COMMAND_FAILURE); return false; @@ -859,7 +861,7 @@ bool Worker::downloadFilesToPSAHardware() { } return false; } else { - CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE; + CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << (m_lastFailedUpdateStep = UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE); setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE); } } @@ -947,7 +949,7 @@ bool Worker::syncCustomerRepositoryAndFS() { } } } - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE)); + ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE))); setProgress(_SYNC_CUSTOMER_REPOSITORY_FAILURE); return false; } From 530ea33460de98ef1258478d1ce4128a941b78eb Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 08:29:03 +0100 Subject: [PATCH 15/40] Minor: debug output. --- update.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/update.cpp b/update.cpp index be7cabe..764fb15 100644 --- a/update.cpp +++ b/update.cpp @@ -54,6 +54,10 @@ hwinf *Update::loadDCPlugin(QDir const &plugInDir, QString const &fname) { qCritical() << pluginLoader.errorString(); exit(-1); } + + qCritical() << "loadDCPlugin() plugin directory:" << plugInDir.absolutePath(); + qCritical() << "loadDCPlugin() plugin file name:" << pluginLoader.fileName(); + if (!pluginLoader.isLoaded()) { qCritical() << pluginLoader.errorString(); exit(-2); @@ -129,7 +133,7 @@ Update::Update(Worker *worker, QThread::msleep(500); } - qCritical() << "UPDATE: m_sys_areDCDataValid ..." << m_sys_areDCdataValid; + qCritical() << __PRETTY_FUNCTION__ << "m_sys_areDCDataValid ..." << m_sys_areDCdataValid; //qInfo() << "UPDATE: m_serialInterface ..." << m_serialInterface; //qInfo() << "UPDATE: m_baudrate ..." << m_baudrate; From db24853062f6cc87d6c58f7191440d5b46a69959 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:01:46 +0100 Subject: [PATCH 16/40] Initialize new member m_ismasTriggerStatusMessage. --- worker.cpp | 116 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 46 deletions(-) diff --git a/worker.cpp b/worker.cpp index a0f1397..c58b862 100644 --- a/worker.cpp +++ b/worker.cpp @@ -97,6 +97,7 @@ const QMap Worker::smap ( INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE), INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION), INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED), + INSERT_ELEMENT(UPDATE_STEP::UPDATE_NOT_NECESSARY), INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED), INSERT_ELEMENT(UPDATE_STEP::UPDATE_ACTIVATED), INSERT_ELEMENT(UPDATE_STEP::FINISHED), @@ -478,11 +479,13 @@ bool Worker::updateTriggerSet() { // (WAIT-button) is activated even in case of initial checkout static const QString func = "UPDATE-TRIGGER-SET"; - if (m_withoutIsmasDirectPort) { // useful for testing - return true; - } + // if (m_withoutIsmasDirectPort) { // useful for testing + // return true; + //} - GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER)); + m_ismasTriggerStatusMessage.clear(); + + GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER); QString triggerValue("NOT CHECKED YET"); static constexpr int const repeats = 15; @@ -492,10 +495,10 @@ bool Worker::updateTriggerSet() { int const startMs = QTime::currentTime().msecsSinceStartOfDay(); int const durationMs = QTime::currentTime().msecsSinceStartOfDay() - startMs; QString const &s = QString("elapsed: %1.%2s").arg(durationMs / 1000).arg(durationMs % 1000); - CONSOLE(QStringList(func) << s) << UPDATE_STEP::DEBUG; + QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << s)); + CONSOLE(lst) << UPDATE_STEP::DEBUG; } else { - QStringList lst = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat)); - // GUI(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER; + QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << QString("-> REPEAT=%1 (%2)").arg(repeat).arg(repeats-repeat))); CONSOLE(lst) << UPDATE_STEP::DEBUG; } @@ -504,7 +507,8 @@ bool Worker::updateTriggerSet() { Command c("systemctl restart apism"); if (c.execute("/tmp")) { QThread::sleep(20); // give APISM some time to reconnect - CONSOLE(QStringList(func) << "RESTART APISM DONE") << UPDATE_STEP::DEBUG; + QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << "RESTART APISM DONE")); + CONSOLE(lst) << UPDATE_STEP::DEBUG; } } @@ -513,30 +517,34 @@ bool Worker::updateTriggerSet() { IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) { QString const &msg = QString("APISM RESPONSE(%1)=(").arg(repeat) + result.value() + ")"; - CONSOLE(QStringList(func) << msg) << UPDATE_STEP::DEBUG; + QStringList lst = (m_ismasTriggerStatusMessage = (QStringList(func) << msg)); + CONSOLE(lst) << UPDATE_STEP::DEBUG; QJsonParseError parseError; QJsonDocument document(QJsonDocument::fromJson(result.value().toUtf8(), &parseError)); if (parseError.error != QJsonParseError::NoError) { - QStringList lst(QString("INVALID JSON MSG: PARSING FAILED (json=%1 error=[%2] str=[%3] offset=[%4])") - .arg(msg) - .arg(parseError.error) - .arg(parseError.errorString()) - .arg(parseError.offset)); + m_ismasTriggerStatusMessage = QStringList(QString("INVALID JSON MSG: PARSING FAILED (json=%1 error=[%2] str=[%3] offset=[%4])") + .arg(msg) + .arg(parseError.error) + .arg(parseError.errorString()) + .arg(parseError.offset)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } if (!document.isObject()) { - QStringList lst(QString("not a json-object %1").arg(result.value())); + m_ismasTriggerStatusMessage = QStringList(QString("not a json-object %1").arg(result.value())); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } QJsonObject obj = document.object(); // always look for an 'error' first if (obj.contains("error")) { - QStringList lst(obj.value("error").toString()); + m_ismasTriggerStatusMessage = QStringList(obj.value("error").toString()); + QStringList lst = m_ismasTriggerStatusMessage; CONSOLE(QStringList(lst)) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); QThread::sleep(6); continue; @@ -552,31 +560,35 @@ bool Worker::updateTriggerSet() { int const customerNr = obj.value("Custom_ID").toInt(-1); int const machineNr = obj.value("Device_ID").toInt(-1); if (customerNr != m_customerNr) { - QStringList lst(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)") - .arg(customerNr).arg(m_customerNr)); + m_ismasTriggerStatusMessage = QStringList(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)") + .arg(customerNr).arg(m_customerNr)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } if (machineNr != m_machineNr) { - QStringList lst(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)") - .arg(machineNr).arg(m_machineNr)); + m_ismasTriggerStatusMessage = QStringList(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)") + .arg(machineNr).arg(m_machineNr)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID"); + QStringList lst(QString("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID (LINE=%1)").arg(__LINE__)); GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst("Dev_ID KEY NOT A JSON-OBJECT"); + m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT A JSON-OBJECT (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst("Dev_ID KEY NOT AVAILABLE"); + m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT AVAILABLE (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } if (obj.contains("Fileupload")) { @@ -585,56 +597,68 @@ bool Worker::updateTriggerSet() { obj = v.toObject(); if (obj.contains("TRG")) { if ((triggerValue = obj.value("TRG").toString()) == "WAIT") { + m_ismasTriggerStatusMessage = QStringList("ISMAS_UPDATE-TRIGGER SET TO WAIT"); m_ismasTriggerActive = true; return m_ismasTriggerActive; } else if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace - QStringList lst(QString("%1 empty update trigger (%2)").arg(repeat).arg(repeats-repeat)); + m_ismasTriggerStatusMessage = QStringList(QString("%1 EMPTY UPDATE TRIGGER (%2)").arg(repeat).arg(repeats-repeat)); + QStringList lst = m_ismasTriggerStatusMessage; if (m_clone) { - GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE); + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)); // if the customer repository has just been cloned - break; // it is OK the ISMAS trigger might not be 'WAIT' + return false; // it is OK the ISMAS trigger might not be 'WAIT' } else { GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); } QThread::sleep(6); continue; } else { - // if the download-button once has the wrong value, it will never recover + // if the download-button once has a wrong value, it will never recover if (m_clone) { - GUI() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE); + m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); + QStringList lst = m_ismasTriggerStatusMessage; + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)); } else { - QStringList lst(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); + m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); } - break; + return false; } } else { - QStringList lst("TRG key not available"); + m_ismasTriggerStatusMessage = QStringList(QString("TRG key not available (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst("Fileupload not a json-object"); + m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not a json-object (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst(QString("Fileupload not available")); + m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not available (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); - break; + return false; } } else { - QStringList lst = QStringList(QString("no ISMAS response")); + m_ismasTriggerStatusMessage = QStringList(QString("no ISMAS response (LINE=%1)").arg(__LINE__)); + QStringList lst = m_ismasTriggerStatusMessage; GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); QThread::sleep(6); + continue; } } if (m_initialClone == false) { if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) { - QStringList lst(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")"); - ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); + m_ismasTriggerStatusMessage = QStringList(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")"); + QStringList lst = m_ismasTriggerStatusMessage; + GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + return false; } } From 0dff2ece7591aea3aaa8a1bd48c9ac422a8b9c95 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:02:59 +0100 Subject: [PATCH 17/40] Check ISMAS update trigger as very first thing. Save the result in m_ismasTriggerActive for later use. --- worker.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/worker.cpp b/worker.cpp index c58b862..5c18467 100644 --- a/worker.cpp +++ b/worker.cpp @@ -260,6 +260,34 @@ void Worker::privateUpdate() { QScopedPointer upr(new UpdateProcessRunning(this)); + //////////////////////////////////////////////////////////////////////////// + // + // CHECK UPDATE TRIGGER + // + //////////////////////////////////////////////////////////////////////////// + // NOTE: make sure that nothing is sent to ISMAS during updateTriggerSet + ISMAS() << UPDATE_STEP::CHECK_ISMAS_TRIGGER; + m_ismasTriggerActive = false; + m_updateNotNecessary = false; + + m_ismasTriggerActive = updateTriggerSet(); + if (m_ismasTriggerActive == false) { + if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository + m_versionInfo = m_gc.gitShowReason(m_branchName); + QDateTime const ¤t = QDateTime::currentDateTime(); + if (current.time().hour() < 4) { // update has been triggered within [00:00:00, 00:03:59] + m_updateNotNecessary = true; + m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + m_lastFailedUpdateStep = UPDATE_STEP::NONE; + } + // the customer-repository does exist, but the ISMAS-trigger is + // *NOT* "WAIT", so STOP the update procedure + return; + } + // in case the customer-repository does not exist, so PROCEED with the + // update procedure, even if ISMAS-trigger is not correctly set ("WAIT") + } + QDir customerRepository(m_customerRepository); QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")); @@ -347,14 +375,8 @@ void Worker::privateUpdate() { setProgress(_CHECKOUT_REPOSITORY_SUCCESS); - //////////////////////////////////////////////////////////////////////////// - // - // CHECK UPDATE TRIGGER - // - //////////////////////////////////////////////////////////////////////////// - m_ismasTriggerActive = false; if (m_clone == false) { - if ((continueUpdate = updateTriggerSet()) == false) { + if (m_ismasTriggerActive == false) { return; } else { GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS)); From d2300b87c6ad2cb2a8f696bedb49db42bcc5cb57 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:04:12 +0100 Subject: [PATCH 18/40] Move final processing to subclass UpdateProcessRunning. --- worker.cpp | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/worker.cpp b/worker.cpp index 5c18467..23f2b2e 100644 --- a/worker.cpp +++ b/worker.cpp @@ -472,28 +472,7 @@ void Worker::privateUpdate() { // ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SAVE_LOGS_SUCCESS)); setProgress(_SAVE_LOGS_SUCCESS); - - //////////////////////////////////////////////////////////////////////////// - // - // FINAL MESSAGES (PART 1) - // - //////////////////////////////////////////////////////////////////////////// - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_SUCCEEDED)); - setProgress(_UPDATE_SUCCEEDED); - - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_ACTIVATED)); - setProgress(_UPDATE_ACTIVATED); - - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::FINISHED)); - setProgress(_FINISHED); - - - //////////////////////////////////////////////////////////////////////////// - // - // FINAL MESSAGES (PART 2): SEND-LAST-VERSION - // (destructor of struct UpdateProcessRunning) - // - //////////////////////////////////////////////////////////////////////////// + // final messages: see destructor of UpdateProcessRunning subclass } bool Worker::updateTriggerSet() { From e040e784fc55dd7fc4e171a3b0d4edd720600a27 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:05:46 +0100 Subject: [PATCH 19/40] Add members bool m_updateNotNecessary = false; QStringList m_ismasTriggerStatusMessage; --- worker.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/worker.h b/worker.h index 1ad311d..cd80f62 100644 --- a/worker.h +++ b/worker.h @@ -159,6 +159,8 @@ class Worker : public QThread{ bool m_initialClone = false; bool m_repairClone = false; bool m_ismasTriggerActive = false; + bool m_updateNotNecessary = false; + QStringList m_ismasTriggerStatusMessage; MainWindow *m_mainWindow; bool m_withoutIsmasDirectPort; From ec0e687c2177ca0c18d9abc21712bc258515d39c Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:06:11 +0100 Subject: [PATCH 20/40] Adapt step order: check of ISMAS trigger is done with percent value 2. --- worker.h | 62 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/worker.h b/worker.h index cd80f62..5eddade 100644 --- a/worker.h +++ b/worker.h @@ -33,37 +33,37 @@ #define _ISMAS_RESET_WAIT "ISMAS" // reset WAIT-button to "WAIT" #define _STARTED (1) -#define _CHECK_SANITY (2) -#define _CHECK_SANITY_FAILURE (3) -#define _CHECK_SANITY_SUCCESS (4) -#define _REPOSITORY_RECOVERED_FAILURE (5) -#define _REPOSITORY_RECOVERED_SUCCESS (6) -#define _CHECK_REPOSITORY (7) -#define _CHECK_REPOSITORY_FAILURE (8) -#define _CHECK_REPOSITORY_SUCCESS (9) -#define _CLONE_REPOSITORY (10) -#define _CLONE_REPOSITORY_FAILURE (11) -#define _CLONE_REPOSITORY_SUCCESS (12) -#define _CHECKOUT_REPOSITORY (13) -#define _CHECKOUT_REPOSITORY_FAILURE (14) -#define _CHECKOUT_REPOSITORY_SUCCESS (15) -#define _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER (16) -#define _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER (17) -#define _CHECK_ISMAS_TRIGGER (19) -#define _CHECK_ISMAS_TRIGGER_WRONG_VALUE (20) -#define _CHECK_ISMAS_TRIGGER_SUCCESS (21) -#define _CHECK_ISMAS_TRIGGER_FAILURE (22) -#define _CHECKOUT_BRANCH (23) -#define _CHECKOUT_BRANCH_FAILURE (24) -#define _CHECKOUT_BRANCH_SUCCESS (25) -#define _UPDATE_REPOSITORY (26) -#define _UPDATE_REPOSITORY_FAILURE (28) -#define _UPDATE_REPOSITORY_SUCCESS (29) -#define _CHECK_FOR_REPOSITORY_CHANGES (30) -#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (36) -#define _FILES_TO_UPDATE (37) -#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (38) -#define _FILES_TO_DOWNLOAD (39) +#define _CHECK_ISMAS_TRIGGER (2) +#define _CHECK_SANITY (3) +#define _CHECK_SANITY_FAILURE (4) +#define _CHECK_SANITY_SUCCESS (5) +#define _REPOSITORY_RECOVERED_FAILURE (6) +#define _REPOSITORY_RECOVERED_SUCCESS (7) +#define _CHECK_REPOSITORY (8) +#define _CHECK_REPOSITORY_FAILURE (9) +#define _CHECK_REPOSITORY_SUCCESS (10) +#define _CLONE_REPOSITORY (11) +#define _CLONE_REPOSITORY_FAILURE (12) +#define _CLONE_REPOSITORY_SUCCESS (13) +#define _CHECKOUT_REPOSITORY (14) +#define _CHECKOUT_REPOSITORY_FAILURE (15) +#define _CHECKOUT_REPOSITORY_SUCCESS (16) +#define _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER (17) +#define _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER (18) +#define _CHECK_ISMAS_TRIGGER_WRONG_VALUE (19) +#define _CHECK_ISMAS_TRIGGER_SUCCESS (20) +#define _CHECK_ISMAS_TRIGGER_FAILURE (21) +#define _CHECKOUT_BRANCH (22) +#define _CHECKOUT_BRANCH_FAILURE (23) +#define _CHECKOUT_BRANCH_SUCCESS (24) +#define _UPDATE_REPOSITORY (25) +#define _UPDATE_REPOSITORY_FAILURE (26) +#define _UPDATE_REPOSITORY_SUCCESS (27) +#define _CHECK_FOR_REPOSITORY_CHANGES (28) +#define _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS (29) +#define _FILES_TO_UPDATE (30) +#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (31) +#define _FILES_TO_DOWNLOAD (32) #define _EXEC_OPKG_COMMANDS (41) #define _EXEC_OPKG_COMMAND_1 (42) #define _EXEC_OPKG_COMMAND_2 (43) From 1c9bb11f0bc4bb7ce47212eb78948bfa65477289 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:06:58 +0100 Subject: [PATCH 21/40] Moved final processing into destructor of subclsee UpdateProcessRunning. --- worker.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/worker.h b/worker.h index 5eddade..fbe3e61 100644 --- a/worker.h +++ b/worker.h @@ -204,6 +204,31 @@ class Worker : public QThread{ } virtual ~UpdateProcessRunning() { + + if (m_worker->m_lastFailedUpdateStep == UPDATE_STEP::NONE) { + if (m_worker->m_updateNotNecessary) { + // m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + QStringList lst = m_worker->m_ismasTriggerStatusMessage; + m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_NOT_NECESSARY)); + } else { + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::UPDATE_SUCCEEDED)); + m_worker->setProgress(_UPDATE_SUCCEEDED); + + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::UPDATE_ACTIVATED)); + m_worker->setProgress(_UPDATE_ACTIVATED); + + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::FINISHED)); + m_worker->setProgress(_FINISHED); + } + } else { + QStringList lst = m_worker->m_ismasTriggerStatusMessage; + UPDATE_STEP last = m_worker->m_lastFailedUpdateStep; + if (m_worker->smap.contains(last)) { + lst << QString(" (last failed: %1)").arg(m_worker->smap[last]); + } + m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_FAILED)); + } + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::SEND_LAST_VERSION)); m_worker->stopProgressLoop(); From 41392a98e35b27c5986bc7a5ca33e532f519f4d6 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:11:12 +0100 Subject: [PATCH 22/40] Minor: added comment. --- OnDemandUpdatePTU.pro | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index 0e8cf18..b87e632 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -95,6 +95,10 @@ DEFINES += QT_DEPRECATED_WARNINGS # 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged) # Set hash-value in EVENT-objects. Set location (project), version # and info in send-last-version. +# Check the ISMAS update-trigger as very first step. +# If the current time is between 0.00 - 4.00 o'clock, then a wrong +# trigger-value wil result in an UPDATE_STEP_NOT_NECESSARY. +# Move final processing to subclass UpdateProcessRunning. VERSION="1.4.0" # PLANNED TODOS: From 6b3ebde2b5e957a9f6198ba6d73fef8be07f3b36 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:40:24 +0100 Subject: [PATCH 23/40] Check for automatic update and add a hint in SEND-LAST-MESSAGE. --- worker.cpp | 6 ++++-- worker.h | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/worker.cpp b/worker.cpp index 23f2b2e..ae97b12 100644 --- a/worker.cpp +++ b/worker.cpp @@ -270,12 +270,14 @@ void Worker::privateUpdate() { m_ismasTriggerActive = false; m_updateNotNecessary = false; + QDateTime const ¤t = QDateTime::currentDateTime(); + m_automaticUpdate = (current.time().hour() < 4); + m_ismasTriggerActive = updateTriggerSet(); if (m_ismasTriggerActive == false) { if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository m_versionInfo = m_gc.gitShowReason(m_branchName); - QDateTime const ¤t = QDateTime::currentDateTime(); - if (current.time().hour() < 4) { // update has been triggered within [00:00:00, 00:03:59] + if (m_automaticUpdate) { // update has been triggered within [00:00:00, 00:03:59] m_updateNotNecessary = true; m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); m_lastFailedUpdateStep = UPDATE_STEP::NONE; diff --git a/worker.h b/worker.h index fbe3e61..0a2ae30 100644 --- a/worker.h +++ b/worker.h @@ -160,6 +160,7 @@ class Worker : public QThread{ bool m_repairClone = false; bool m_ismasTriggerActive = false; bool m_updateNotNecessary = false; + bool m_automaticUpdate = false; QStringList m_ismasTriggerStatusMessage; MainWindow *m_mainWindow; @@ -207,7 +208,6 @@ class Worker : public QThread{ if (m_worker->m_lastFailedUpdateStep == UPDATE_STEP::NONE) { if (m_worker->m_updateNotNecessary) { - // m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); QStringList lst = m_worker->m_ismasTriggerStatusMessage; m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_NOT_NECESSARY)); } else { @@ -229,8 +229,17 @@ class Worker : public QThread{ m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_FAILED)); } - m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() - << UPDATE_STEP::SEND_LAST_VERSION)); + if (m_worker->m_automaticUpdate) { + QStringList lst = (QStringList() << "AUTOMATIC UPDATE"); + if (m_worker->m_updateNotNecessary) { + lst << "UPDATE NOT NECESSARY"; + } + m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) + << UPDATE_STEP::SEND_LAST_VERSION)); + } else { + m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() + << UPDATE_STEP::SEND_LAST_VERSION)); + } m_worker->stopProgressLoop(); m_worker->m_updateProcessRunning = false; From 8da6443833e5038f1508799fb7c1a93137cf4cb0 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 19 Jan 2024 13:58:08 +0100 Subject: [PATCH 24/40] Send additional messages to ISMAS about recovering the customer-repository --- worker.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/worker.cpp b/worker.cpp index ae97b12..5ffdbb6 100644 --- a/worker.cpp +++ b/worker.cpp @@ -286,14 +286,14 @@ void Worker::privateUpdate() { // *NOT* "WAIT", so STOP the update procedure return; } - // in case the customer-repository does not exist, so PROCEED with the + // the customer-repository does not exist, so PROCEED with the // update procedure, even if ISMAS-trigger is not correctly set ("WAIT") } QDir customerRepository(m_customerRepository); QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")); - CONSOLE() << UPDATE_STEP::CHECK_SANITY; + CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY); m_clone = false; m_repairClone = false; @@ -316,22 +316,22 @@ void Worker::privateUpdate() { if (isRepositoryCorrupted()) { // a not-existing repository is not meant // to be corrupted - CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_SANITY_FAILURE); + CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY_FAILURE); if ((continueUpdate = repairCorruptedRepository()) == true) { m_repairClone = true; - CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS; + CONSOLE() << (ISMAS() << UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS); } else { - ISMAS() << (GUI() << (CONSOLE() << (m_lastFailedUpdateStep = UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE))); + ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE)); return; } } - CONSOLE() << UPDATE_STEP::CHECK_SANITY_SUCCESS; + CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY_SUCCESS); if (continueUpdate) { if ((continueUpdate = customerRepository.exists()) == false) { m_initialClone = (m_repairClone == false); - GUI() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY); + ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::CLONE_REPOSITORY)); for (int i = 0; i < 5; ++i) { // try to checkout git repository setProgress(i); // and switch to branch if (m_gc.gitCloneAndCheckoutBranch()) { From 23ff4977d9b4e2ffc74b793f2125484a14293761 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 12:02:18 +0100 Subject: [PATCH 25/40] Disable exit button after checking update trigger button. --- worker.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/worker.cpp b/worker.cpp index 5ffdbb6..537d650 100644 --- a/worker.cpp +++ b/worker.cpp @@ -290,6 +290,8 @@ void Worker::privateUpdate() { // update procedure, even if ISMAS-trigger is not correctly set ("WAIT") } + emit this->disableExit(); + QDir customerRepository(m_customerRepository); QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")); From 100bfd63ab070ca4cc5d5a869a70c482ce20d795 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 12:03:46 +0100 Subject: [PATCH 26/40] Do not write to GUO when running in loop to check ISMAS trigger button --- worker.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/worker.cpp b/worker.cpp index 537d650..cb21b99 100644 --- a/worker.cpp +++ b/worker.cpp @@ -378,7 +378,6 @@ void Worker::privateUpdate() { CONSOLE() << UPDATE_STEP::CHECK_REPOSITORY_SUCCESS; setProgress(_CHECKOUT_REPOSITORY_SUCCESS); - if (m_clone == false) { if (m_ismasTriggerActive == false) { return; @@ -614,7 +613,7 @@ bool Worker::updateTriggerSet() { // if the customer repository has just been cloned return false; // it is OK the ISMAS trigger might not be 'WAIT' } else { - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); } QThread::sleep(6); continue; @@ -652,7 +651,7 @@ bool Worker::updateTriggerSet() { } else { m_ismasTriggerStatusMessage = QStringList(QString("no ISMAS response (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE); QThread::sleep(6); continue; } From 8c02ebcf15e742c7cb6f379509e39a306c70e9c6 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 12:07:42 +0100 Subject: [PATCH 27/40] Minor: debug output to GUI. --- worker.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worker.h b/worker.h index 0a2ae30..80ff5c1 100644 --- a/worker.h +++ b/worker.h @@ -224,7 +224,9 @@ class Worker : public QThread{ QStringList lst = m_worker->m_ismasTriggerStatusMessage; UPDATE_STEP last = m_worker->m_lastFailedUpdateStep; if (m_worker->smap.contains(last)) { - lst << QString(" (last failed: %1)").arg(m_worker->smap[last]); + lst << QString(" (last failed step: %1)").arg(m_worker->smap[last]); + } else { + lst << QString(" (last failed step unknown: %1)").arg(last); } m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_FAILED)); } From c2c6bc3f8a24a4e7f1a4e6895628ec17d123d236 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 12:18:10 +0100 Subject: [PATCH 28/40] Minor: removed typo. --- worker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker.h b/worker.h index 80ff5c1..d1f2d9c 100644 --- a/worker.h +++ b/worker.h @@ -226,7 +226,7 @@ class Worker : public QThread{ if (m_worker->smap.contains(last)) { lst << QString(" (last failed step: %1)").arg(m_worker->smap[last]); } else { - lst << QString(" (last failed step unknown: %1)").arg(last); + lst << QString(" (last failed step unknown: %1)").arg((int)(last)); } m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_FAILED)); } From f9ce6a6c1b1240a74af546236f7d766cada71fd2 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 12:22:48 +0100 Subject: [PATCH 29/40] Minor: remove obsolete line. --- worker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/worker.cpp b/worker.cpp index cb21b99..88bb1f1 100644 --- a/worker.cpp +++ b/worker.cpp @@ -293,7 +293,6 @@ void Worker::privateUpdate() { emit this->disableExit(); QDir customerRepository(m_customerRepository); - QDir customerRepositoryEtc(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/")); CONSOLE() << (ISMAS() << UPDATE_STEP::CHECK_SANITY); From 4dba36a420fb185bce88a04186d4791fd7b8acd7 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 15:29:19 +0100 Subject: [PATCH 30/40] Add and use UPDATE_STEP::UPDATE_FINALIZE in debug output. --- worker.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/worker.h b/worker.h index d1f2d9c..18b9d3c 100644 --- a/worker.h +++ b/worker.h @@ -93,6 +93,7 @@ #define _SAVE_LOGS_FAILURE (93) #define _SAVE_LOGS_SUCCESS (94) #define _SEND_LAST_VERSION (95) +#define _UPDATE_FINALIZE (95) #define _UPDATE_SUCCEEDED (96) #define _UPDATE_FAILED (97) #define _UPDATE_ACTIVATED (98) @@ -315,6 +316,7 @@ public: SAVE_LOGS_SUCCESS = _SAVE_LOGS_SUCCESS, SAVE_LOGS_FAILURE = _SAVE_LOGS_FAILURE, SEND_LAST_VERSION = _SEND_LAST_VERSION, + UPDATE_FINALIZE = _UPDATE_FINALIZE, UPDATE_SUCCEEDED = _UPDATE_SUCCEEDED, UPDATE_ACTIVATED = _UPDATE_ACTIVATED, UPDATE_NOT_NECESSARY = _UPDATE_NOT_NECESSARY, @@ -1091,10 +1093,10 @@ private: QString const &ismasUpdateNews = QString("#M=APISM#C=CMD_EVENT#J=") + ismasClient.updateNewsToIsmas( - "U0001", // WAIT-button set to 100% + _ISMAS_DONE, // WAIT-button set to 100% ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::UPDATE_FINALIZE], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -1105,10 +1107,10 @@ private: QString const &ismasUpdateNews = QString("#M=APISM#C=CMD_EVENT#J=") + ismasClient.updateNewsToIsmas( - "U0002", // reset WAIT-button to "" (empty string) + _ISMAS_SET_WAIT_OK, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::UPDATE_FINALIZE], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -1119,10 +1121,10 @@ private: QString const &ismasUpdateNews = QString("#M=APISM#C=CMD_EVENT#J=") + ismasClient.updateNewsToIsmas( - "U0002", // reset WAIT-button to "" (empty string) + _ISMAS_SET_WAIT_OK, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::UPDATE_FINALIZE], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -1133,10 +1135,10 @@ private: QString const &ismasUpdateNews = QString("#M=APISM#C=CMD_EVENT#J=") + ismasClient.updateNewsToIsmas( - "U0003", + _ISMAS_FAILURE, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::INSTALL_ERROR, - smap[step], + smap[UPDATE_STEP::UPDATE_FINALIZE], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( From 0a43654f9b5b7ca28e00e6f47eaa8074818e8cd0 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 15:30:31 +0100 Subject: [PATCH 31/40] Improve output, esecially to ISMAS --- worker.h | 59 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/worker.h b/worker.h index 18b9d3c..582cc3a 100644 --- a/worker.h +++ b/worker.h @@ -212,13 +212,16 @@ class Worker : public QThread{ QStringList lst = m_worker->m_ismasTriggerStatusMessage; m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << (m_worker->ISMAS(lst) << UPDATE_STEP::UPDATE_NOT_NECESSARY)); } else { - m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::UPDATE_SUCCEEDED)); + QStringList lst(QString(m_worker->smap[UPDATE_STEP::UPDATE_SUCCEEDED])); + m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << UPDATE_STEP::UPDATE_SUCCEEDED)); m_worker->setProgress(_UPDATE_SUCCEEDED); - m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::UPDATE_ACTIVATED)); + lst = QStringList(QString(m_worker->smap[UPDATE_STEP::UPDATE_ACTIVATED])); + m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << UPDATE_STEP::UPDATE_ACTIVATED)); m_worker->setProgress(_UPDATE_ACTIVATED); - m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() << UPDATE_STEP::FINISHED)); + lst = QStringList(QString(m_worker->smap[UPDATE_STEP::FINISHED])); + m_worker->CONSOLE(lst) << UPDATE_STEP::FINISHED; m_worker->setProgress(_FINISHED); } } else { @@ -233,15 +236,17 @@ class Worker : public QThread{ } if (m_worker->m_automaticUpdate) { - QStringList lst = (QStringList() << "AUTOMATIC UPDATE"); + QStringList lst(QString(m_worker->smap[UPDATE_STEP::SEND_LAST_VERSION])); + lst << "AUTOMATIC UPDATE"; if (m_worker->m_updateNotNecessary) { lst << "UPDATE NOT NECESSARY"; } m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) << UPDATE_STEP::SEND_LAST_VERSION)); } else { - m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE() - << UPDATE_STEP::SEND_LAST_VERSION)); + QStringList lst(QString(m_worker->smap[UPDATE_STEP::SEND_LAST_VERSION])); + m_worker->ISMAS(lst) << (m_worker->GUI(lst) << (m_worker->CONSOLE(lst) + << UPDATE_STEP::SEND_LAST_VERSION)); } m_worker->stopProgressLoop(); @@ -741,7 +746,7 @@ private: "U0010", _CLONE_REPOSITORY_SUCCESS, IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::CLONE_REPOSITORY], QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2") .arg(instance->m_customerRepository) .arg(instance->m_gc.branchName()).toStdString().c_str(), @@ -757,7 +762,7 @@ private: "U0003", _CLONE_REPOSITORY_FAILURE, IsmasClient::RESULT_CODE::INSTALL_ERROR, - smap[step], + smap[UPDATE_STEP::CHECKOUT_REPOSITORY], QString("CLONING REPOSITORY %1 OR CHECKING OUT BRANCH %2 FAILED") .arg(instance->m_customerRepository) .arg(instance->m_gc.branchName()).toStdString().c_str(), @@ -802,7 +807,7 @@ private: "U0003", _CHECK_ISMAS_TRIGGER_FAILURE, IsmasClient::RESULT_CODE::INSTALL_ERROR, - smap[step], + smap[UPDATE_STEP::CHECK_ISMAS_TRIGGER], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -814,9 +819,20 @@ private: case UPDATE_STEP::INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER: ismasClient.setProgressInPercent(_INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER); break; - case UPDATE_STEP::CHECKOUT_BRANCH: + case UPDATE_STEP::CHECKOUT_BRANCH: { ismasClient.setProgressInPercent(_CHECKOUT_BRANCH); - break; + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0010", + _CHECKOUT_BRANCH_SUCCESS, + IsmasClient::RESULT_CODE::SUCCESS, + smap[UPDATE_STEP::CHECKOUT_BRANCH], + instance->m_ismasMsg.join(' ').toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; case UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS: { ismasClient.setProgressInPercent(_CHECKOUT_BRANCH_SUCCESS); QString const &ismasUpdateNews = @@ -825,7 +841,7 @@ private: "U0010", _CHECKOUT_BRANCH_SUCCESS, IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::CHECKOUT_BRANCH], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -839,7 +855,7 @@ private: "U0003", _CHECKOUT_BRANCH_FAILURE, IsmasClient::RESULT_CODE::INSTALL_ERROR, - smap[step], + smap[UPDATE_STEP::CHECKOUT_BRANCH], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -981,6 +997,17 @@ private: } break; case UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS: { ismasClient.setProgressInPercent(_EXEC_OPKG_COMMAND_SUCCESS); + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + _ISMAS_CONTINUE, + ismasClient.getProgressInPercent(), + IsmasClient::RESULT_CODE::SUCCESS, + smap[UPDATE_STEP::EXEC_OPKG_COMMANDS], + instance->m_ismasMsg.join(' ').toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); } break; case UPDATE_STEP::EXEC_OPKG_COMMAND_FAILURE: { ismasClient.setProgressInPercent(_EXEC_OPKG_COMMAND_FAILURE); @@ -1016,7 +1043,7 @@ private: _ISMAS_CONTINUE, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -1033,7 +1060,7 @@ private: _ISMAS_CONTINUE, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( @@ -1053,7 +1080,7 @@ private: _ISMAS_CONTINUE, ismasClient.getProgressInPercent(), IsmasClient::RESULT_CODE::SUCCESS, - smap[step], + smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY], instance->m_ismasMsg.join(' ').toStdString().c_str(), instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); ismasClient.sendRequestReceiveResponse( From 9a9480035bf4fc74ee4225cd9d96fd2af7781ef1 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 15:31:12 +0100 Subject: [PATCH 32/40] Improve output, esecially to ISMAS --- worker.cpp | 62 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/worker.cpp b/worker.cpp index 88bb1f1..7c20940 100644 --- a/worker.cpp +++ b/worker.cpp @@ -96,6 +96,7 @@ const QMap Worker::smap ( INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_SUCCESS), INSERT_ELEMENT(UPDATE_STEP::SAVE_LOGS_FAILURE), INSERT_ELEMENT(UPDATE_STEP::SEND_LAST_VERSION), + INSERT_ELEMENT(UPDATE_STEP::UPDATE_FINALIZE), INSERT_ELEMENT(UPDATE_STEP::UPDATE_SUCCEEDED), INSERT_ELEMENT(UPDATE_STEP::UPDATE_NOT_NECESSARY), INSERT_ELEMENT(UPDATE_STEP::UPDATE_FAILED), @@ -259,6 +260,7 @@ void Worker::privateUpdate() { GUI() << (ISMAS() << (CONSOLE() << UPDATE_STEP::STARTED)); QScopedPointer upr(new UpdateProcessRunning(this)); + QStringList lst; //////////////////////////////////////////////////////////////////////////// // @@ -411,7 +413,8 @@ void Worker::privateUpdate() { if ((continueUpdate = customerEnvironment()) == false) { return; } - CONSOLE() << UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS; + lst = QStringList(QString(smap[UPDATE_STEP::CHECKOUT_BRANCH_SUCCESS])); + ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::CHECKOUT_BRANCH); setProgress(_CHECKOUT_BRANCH_SUCCESS); @@ -423,7 +426,8 @@ void Worker::privateUpdate() { if ((continueUpdate = filesToUpdate()) == false) { return; } - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS)); + lst = QStringList(QString(smap[UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS])); + ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::UPDATE_REPOSITORY)); setProgress(_UPDATE_REPOSITORY_SUCCESS); @@ -435,7 +439,8 @@ void Worker::privateUpdate() { if ((continueUpdate = execOpkgCommands()) == false) { return; } - GUI() << (CONSOLE() << UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS); + lst = QStringList(QString(smap[UPDATE_STEP::EXEC_OPKG_COMMAND_SUCCESS])); + GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::EXEC_OPKG_COMMANDS); setProgress(_EXEC_OPKG_COMMAND_SUCCESS); @@ -447,7 +452,8 @@ void Worker::privateUpdate() { if ((continueUpdate = downloadFilesToPSAHardware()) == false) { return; } - GUI() << (CONSOLE() << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS); + lst = QStringList(QString(smap[UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS])); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE)); setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS); @@ -459,10 +465,10 @@ void Worker::privateUpdate() { if ((continueUpdate = syncCustomerRepositoryAndFS()) == false) { return; } - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS)); + lst = QStringList(QString(smap[UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS])); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS)); setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS); - //////////////////////////////////////////////////////////////////////////// // // FUTURE: SAVE LOG FILES @@ -532,13 +538,13 @@ bool Worker::updateTriggerSet() { .arg(parseError.errorString()) .arg(parseError.offset)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } if (!document.isObject()) { m_ismasTriggerStatusMessage = QStringList(QString("not a json-object %1").arg(result.value())); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } @@ -566,31 +572,31 @@ bool Worker::updateTriggerSet() { m_ismasTriggerStatusMessage = QStringList(QString("CUSTOMER-NR (%1) != LOCAL CUSTOMER-NR (%2)") .arg(customerNr).arg(m_customerNr)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } if (machineNr != m_machineNr) { m_ismasTriggerStatusMessage = QStringList(QString("MACHINE-NR (%1) != LOCAL MACHINE-NR (%2)") .arg(machineNr).arg(m_machineNr)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { QStringList lst(QString("Dev_ID DOES NOT CONTAIN Custom_ID AND/OR Device_ID (LINE=%1)").arg(__LINE__)); - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT A JSON-OBJECT (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { m_ismasTriggerStatusMessage = QStringList(QString("Dev_ID KEY NOT AVAILABLE (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } @@ -608,7 +614,7 @@ bool Worker::updateTriggerSet() { m_ismasTriggerStatusMessage = QStringList(QString("%1 EMPTY UPDATE TRIGGER (%2)").arg(repeat).arg(repeats-repeat)); QStringList lst = m_ismasTriggerStatusMessage; if (m_clone) { - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE))); // if the customer repository has just been cloned return false; // it is OK the ISMAS trigger might not be 'WAIT' } else { @@ -619,32 +625,32 @@ bool Worker::updateTriggerSet() { } else { // if the download-button once has a wrong value, it will never recover if (m_clone) { - m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); + m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE='%1' != 'WAIT'").arg(triggerValue)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_WRONG_VALUE))); } else { - m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE=<%1> NOT 'WAIT'").arg(triggerValue)); + m_ismasTriggerStatusMessage = QStringList(QString("TRIGGER-VALUE='%1' != 'WAIT'").arg(triggerValue)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); } return false; } } else { m_ismasTriggerStatusMessage = QStringList(QString("TRG key not available (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not a json-object (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { m_ismasTriggerStatusMessage = QStringList(QString("Fileupload not available (LINE=%1)").arg(__LINE__)); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } else { @@ -660,7 +666,7 @@ bool Worker::updateTriggerSet() { if (!triggerValue.contains("WAIT", Qt::CaseInsensitive)) { m_ismasTriggerStatusMessage = QStringList(QString("ISMAS_UPDATE-TRIGGER-NOT-SET-OR-WRONG: VALUE=(") + triggerValue + ")"); QStringList lst = m_ismasTriggerStatusMessage; - GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE)); + ISMAS(lst) << (GUI(lst) << (CONSOLE(lst) << (m_lastFailedUpdateStep = UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE))); return false; } } @@ -866,8 +872,9 @@ bool Worker::downloadFilesToPSAHardware() { setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE); if (m_noUpdatePsaHardware == false) { - if (computeFilesToDownload()) { - CONSOLE(m_filesToDownload) << UPDATE_STEP::FILES_TO_DOWNLOAD; + if (computeFilesToDownload() > 0) { + QStringList lst = m_filesToDownload; + ISMAS(lst) << (CONSOLE(lst) << UPDATE_STEP::FILES_TO_DOWNLOAD); Update update(this, QDir::cleanPath(m_workingDirectory + QDir::separator() + m_customerNrStr), @@ -886,10 +893,11 @@ bool Worker::downloadFilesToPSAHardware() { return true; } - return false; - } else { + CONSOLE(QStringList("NO FILES TO DOWNLOAD TO PSA-HW")) << (m_lastFailedUpdateStep = UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE); setProgress(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE); + + return false; } } @@ -969,7 +977,7 @@ bool Worker::syncCustomerRepositoryAndFS() { QDir dir1(QDir::cleanPath(m_customerRepository + QDir::separator() + "etc/psa_tariff")); QDir dir2("/etc/psa_tariff"); if (Utils::sameFilesInDirs(dir1, dir2)) { - ISMAS() << (GUI() << (CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS)); + CONSOLE() << UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS; setProgress(_SYNC_CUSTOMER_REPOSITORY_SUCCESS); return true; } From aaa485e2fc619e39e78411db857c7e02ae7dd001 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 23 Jan 2024 16:09:15 +0100 Subject: [PATCH 33/40] Send messages to ISMAS for checking/repairing the customer repository --- worker.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/worker.h b/worker.h index 582cc3a..f86c94c 100644 --- a/worker.h +++ b/worker.h @@ -714,21 +714,73 @@ private: case UPDATE_STEP::CHECK_REPOSITORY: ismasClient.setProgressInPercent(_CHECK_REPOSITORY); break; - case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS: + case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS: { ismasClient.setProgressInPercent(_CHECK_REPOSITORY_SUCCESS); - break; - case UPDATE_STEP::CHECK_REPOSITORY_FAILURE: + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0010", + _CHECKOUT_REPOSITORY_SUCCESS, + IsmasClient::RESULT_CODE::SUCCESS, + smap[UPDATE_STEP::CHECK_REPOSITORY], + QString("REPOSITORY %1 AND BRANCH %2 OK") + .arg(instance->m_customerRepository) + .arg(instance->m_gc.branchName()).toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; + case UPDATE_STEP::CHECK_REPOSITORY_FAILURE: { ismasClient.setProgressInPercent(_CHECK_REPOSITORY_FAILURE); - break; - case UPDATE_STEP::CHECK_SANITY: + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0010", + _CHECKOUT_REPOSITORY_FAILURE, + IsmasClient::RESULT_CODE::INSTALL_ERROR, + smap[UPDATE_STEP::CHECKOUT_REPOSITORY], + QString("REPOSITORY %1 and BRANCH %2 ***NOT OK***") + .arg(instance->m_customerRepository) + .arg(instance->m_gc.branchName()).toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; + case UPDATE_STEP::CHECK_SANITY: { ismasClient.setProgressInPercent(_CHECK_SANITY); - break; - case UPDATE_STEP::CHECK_SANITY_SUCCESS: + } break; + case UPDATE_STEP::CHECK_SANITY_SUCCESS: { ismasClient.setProgressInPercent(_CHECK_SANITY_SUCCESS); - break; - case UPDATE_STEP::CHECK_SANITY_FAILURE: + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0010", + _CHECK_SANITY_SUCCESS, + IsmasClient::RESULT_CODE::SUCCESS, + smap[UPDATE_STEP::CHECK_SANITY], + QString("SANITY OF %1 (BRANCH %2) OK") + .arg(instance->m_customerRepository) + .arg(instance->m_gc.branchName()).toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; + case UPDATE_STEP::CHECK_SANITY_FAILURE: { ismasClient.setProgressInPercent(_CHECK_SANITY_FAILURE); - break; + QString const &ismasUpdateNews = + QString("#M=APISM#C=CMD_EVENT#J=") + + ismasClient.updateNewsToIsmas( + "U0010", + _CHECK_SANITY_FAILURE, + IsmasClient::RESULT_CODE::INSTALL_ERROR, + smap[UPDATE_STEP::CHECK_SANITY], + QString("SANITY OF %1 and BRANCH %2 ***NOT*** OK") + .arg(instance->m_customerRepository) + .arg(instance->m_gc.branchName()).toStdString().c_str(), + instance->m_versionInfo.size() >= 1 ? instance->m_versionInfo.at(0).toUtf8().constData() : "N/A"); + ismasClient.sendRequestReceiveResponse( + IsmasClient::APISM::DB_PORT, ismasUpdateNews); + } break; case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS: ismasClient.setProgressInPercent(_REPOSITORY_RECOVERED_SUCCESS); break; From 728185ddb968738bdfdb584f3d7257082347edba Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 24 Jan 2024 08:31:22 +0100 Subject: [PATCH 34/40] Set m_lastFailedUpdateStep = UPDATE_STEP::NONE as last step in case of a successful update. --- worker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/worker.cpp b/worker.cpp index 7c20940..25813c4 100644 --- a/worker.cpp +++ b/worker.cpp @@ -481,6 +481,7 @@ void Worker::privateUpdate() { setProgress(_SAVE_LOGS_SUCCESS); // final messages: see destructor of UpdateProcessRunning subclass + m_lastFailedUpdateStep = UPDATE_STEP::NONE; } bool Worker::updateTriggerSet() { From e04636e3f73cf90471175a0c2c1b69895d99579f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Wed, 24 Jan 2024 13:07:39 +0100 Subject: [PATCH 35/40] Minor: add debug output --- worker.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/worker.cpp b/worker.cpp index 25813c4..29b8cf0 100644 --- a/worker.cpp +++ b/worker.cpp @@ -279,11 +279,22 @@ void Worker::privateUpdate() { if (m_ismasTriggerActive == false) { if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository m_versionInfo = m_gc.gitShowReason(m_branchName); + + qCritical() << "***"; + qCritical() << "privateUpdate ............. m_versionInfo:" << m_versionInfo; + qCritical() << "privateUpdate ......... m_automaticUpdate:" << m_automaticUpdate; + if (m_automaticUpdate) { // update has been triggered within [00:00:00, 00:03:59] m_updateNotNecessary = true; m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + + qCritical() << "privateUpdate m_ismasTriggerStatusMessage:" = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + m_lastFailedUpdateStep = UPDATE_STEP::NONE; } + + qCritical() << "***"; + // the customer-repository does exist, but the ISMAS-trigger is // *NOT* "WAIT", so STOP the update procedure return; From cbe8bb7aeb75aa64ad2f195028e289392448a674 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 Jan 2024 09:01:04 +0100 Subject: [PATCH 36/40] Minor: add comment --- OnDemandUpdatePTU.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index b87e632..1b86b82 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -99,6 +99,8 @@ DEFINES += QT_DEPRECATED_WARNINGS # If the current time is between 0.00 - 4.00 o'clock, then a wrong # trigger-value wil result in an UPDATE_STEP_NOT_NECESSARY. # Move final processing to subclass UpdateProcessRunning. +# Disable EXIT-button for the whole update-process, except for the +# checking of the ISMAS-trigger-button (aka WAIT-button). VERSION="1.4.0" # PLANNED TODOS: From 630cd36f131e5bd3cf687cc2f025d944ec6daa86 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 Jan 2024 11:54:13 +0100 Subject: [PATCH 37/40] Minor: removed typo --- worker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker.cpp b/worker.cpp index 29b8cf0..58b1952 100644 --- a/worker.cpp +++ b/worker.cpp @@ -288,7 +288,7 @@ void Worker::privateUpdate() { m_updateNotNecessary = true; m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); - qCritical() << "privateUpdate m_ismasTriggerStatusMessage:" = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + qCritical() << "privateUpdate m_ismasTriggerStatusMessage:" << QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); m_lastFailedUpdateStep = UPDATE_STEP::NONE; } From 76ec41c291f766a2d2c02b6b2b35a2fc6177dadc Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 Jan 2024 15:13:56 +0100 Subject: [PATCH 38/40] Minor: add some comment. --- OnDemandUpdatePTU.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OnDemandUpdatePTU.pro b/OnDemandUpdatePTU.pro index 1b86b82..267db82 100644 --- a/OnDemandUpdatePTU.pro +++ b/OnDemandUpdatePTU.pro @@ -95,9 +95,11 @@ DEFINES += QT_DEPRECATED_WARNINGS # 1.4.0 : Start with version at 1.4.0 (mainly to see a difference with Szeged) # Set hash-value in EVENT-objects. Set location (project), version # and info in send-last-version. -# Check the ISMAS update-trigger as very first step. +# If the customer repository does not exist, then do not check the +# ISMAS trigger, but proceed with the update procedure. Otherwise, +# check the ISMAS update-trigger as first step. # If the current time is between 0.00 - 4.00 o'clock, then a wrong -# trigger-value wil result in an UPDATE_STEP_NOT_NECESSARY. +# trigger-value will result in an UPDATE_STEP_NOT_NECESSARY. # Move final processing to subclass UpdateProcessRunning. # Disable EXIT-button for the whole update-process, except for the # checking of the ISMAS-trigger-button (aka WAIT-button). From 0b1ed62df1d75a8123c41f539cc5f90fd1bc8e4d Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 Jan 2024 15:14:42 +0100 Subject: [PATCH 39/40] Optimization: if customer repository does not exist, do noy check the ISMAS trigger, but proceed with the update procedure. --- worker.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/worker.cpp b/worker.cpp index 58b1952..ed3a178 100644 --- a/worker.cpp +++ b/worker.cpp @@ -272,12 +272,11 @@ void Worker::privateUpdate() { m_ismasTriggerActive = false; m_updateNotNecessary = false; - QDateTime const ¤t = QDateTime::currentDateTime(); - m_automaticUpdate = (current.time().hour() < 4); - - m_ismasTriggerActive = updateTriggerSet(); - if (m_ismasTriggerActive == false) { - if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository + if (QDir(m_customerRepository).exists()) { // ignore a possibly corrupted repository + m_ismasTriggerActive = updateTriggerSet(); + if (m_ismasTriggerActive == false) { + QDateTime const ¤t = QDateTime::currentDateTime(); + m_automaticUpdate = (current.time().hour() < 4); m_versionInfo = m_gc.gitShowReason(m_branchName); qCritical() << "***"; @@ -289,8 +288,14 @@ void Worker::privateUpdate() { m_ismasTriggerStatusMessage = QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); qCritical() << "privateUpdate m_ismasTriggerStatusMessage:" << QStringList(QString("NO UPDATE NECESSARY (%1)").arg(current.toString(Qt::ISODate))); + qCritical() << "***"; + + // the customer-repository does exist, but the ISMAS-trigger is + // *NOT* "WAIT", but from 00:00:00 - 00:03:59 this counts as an + // automatic update m_lastFailedUpdateStep = UPDATE_STEP::NONE; + return; } qCritical() << "***"; @@ -299,6 +304,9 @@ void Worker::privateUpdate() { // *NOT* "WAIT", so STOP the update procedure return; } + // the customer-repository does exist, and the ISMAS-trigger is "WAIT", + // so continue the update procedure + } else { // the customer-repository does not exist, so PROCEED with the // update procedure, even if ISMAS-trigger is not correctly set ("WAIT") } From 7578746d2f7585f5e5d2ab60689466f00d684e3f Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 25 Jan 2024 15:46:46 +0100 Subject: [PATCH 40/40] make it explicit that no device-controller is loaded down with this version --- update.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/update.cpp b/update.cpp index 764fb15..c6dd626 100644 --- a/update.cpp +++ b/update.cpp @@ -605,19 +605,19 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) { // CONSOLE() - 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 - - if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) { + // 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 + // if ((updateBinaryRes = updateBinary(fToWorkOn)) == true) { + // // qCritical() << "downloaded binary" << fToWorkOn; - ++displayIndex; - emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") - + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), - Worker::UPDATE_STEP_DONE); - } + // ++displayIndex; + // emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")") + // + QString(" Update ") + QFileInfo(fToWorkOn).fileName(), + // Worker::UPDATE_STEP_DONE); + //} m_hw->dc_autoRequest(true); // turn auto-request setting on