From d6446f90fe51fe797ada0bfd2772739101ed8e18 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Fri, 14 Jul 2023 13:29:52 +0200 Subject: [PATCH] Removed C++-thread-handling, replaced it with Qt-versions. Using explicit Worker instance instead. --- main.cpp | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/main.cpp b/main.cpp index 6bb03ce..8371607 100644 --- a/main.cpp +++ b/main.cpp @@ -12,7 +12,6 @@ #include "plugins/interfaces.h" #include -#include #include #include #include @@ -23,10 +22,13 @@ #include #include "update.h" +#include "git/git_client.h" +#include "ismas/ismas_client.h" +#include "apism/apism_client.h" #include "worker_thread.h" #include "worker.h" -#include +#include #ifdef PTU5 #define SERIAL_PORT "ttymxc2" @@ -34,23 +36,13 @@ #define SERIAL_PORT "ttyUSB0" #endif -class hwinf; -static void doWork(hwinf *hw, QString update_ctrl_file, - QString workingDir, bool maintenanceMode, bool testMode) { - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - Update update(hw, update_ctrl_file, workingDir, maintenanceMode, testMode); - update.doUpdate(); - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - QCoreApplication::quit(); -} - // argv[1]: file to send to dc int main(int argc, char *argv[]) { - - QByteArray const value = qgetenv("XDG_RUNTIME_DIR"); - if (value.size() == 0) { - qputenv("XDG_RUNTIME_DIR", "/run/user/0"); + QByteArray const value = qgetenv("LC_ALL"); + if (value != "C") { + qputenv("LC_ALL", "C"); } + // qputenv("XDG_RUNTIME_DIR", "/run/user/0"); QApplication a(argc, argv); QApplication::setApplicationName("ATBUpdateTool"); @@ -58,7 +50,7 @@ int main(int argc, char *argv[]) { if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling atbInstallMessageHandler(atbDebugOutput); - setDebugLevel(QtMsgType::QtDebugMsg); + setDebugLevel(QtMsgType::QtInfoMsg); //setDebugLevel(QtMsgType::QtDebugMsg); } @@ -154,10 +146,15 @@ int main(int argc, char *argv[]) { // hw->dc_autoRequest(false); QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv"; - std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode, testMode); + Worker worker(hw, update_ctrl_file, + "https://git.mimbach49.de/GerhardHoffmann/customer_999.git", + "customer_999", + "zg1/zone1", + workingDir, + maintenanceMode, + testMode, + executeScriptOnly, + dryRun); - int ret = a.exec(); - t.join(); - - return ret; + return a.exec(); }