Removed C++-thread-handling, replaced it with Qt-versions. Using explicit Worker
instance instead.
This commit is contained in:
		
							
								
								
									
										41
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								main.cpp
									
									
									
									
									
								
							@@ -12,7 +12,6 @@
 | 
				
			|||||||
#include "plugins/interfaces.h"
 | 
					#include "plugins/interfaces.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <thread>
 | 
					 | 
				
			||||||
#include <memory>
 | 
					#include <memory>
 | 
				
			||||||
#include <QSharedMemory>
 | 
					#include <QSharedMemory>
 | 
				
			||||||
#include <QRunnable>
 | 
					#include <QRunnable>
 | 
				
			||||||
@@ -23,10 +22,13 @@
 | 
				
			|||||||
#include <QStandardPaths>
 | 
					#include <QStandardPaths>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "update.h"
 | 
					#include "update.h"
 | 
				
			||||||
 | 
					#include "git/git_client.h"
 | 
				
			||||||
 | 
					#include "ismas/ismas_client.h"
 | 
				
			||||||
 | 
					#include "apism/apism_client.h"
 | 
				
			||||||
#include "worker_thread.h"
 | 
					#include "worker_thread.h"
 | 
				
			||||||
#include "worker.h"
 | 
					#include "worker.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <thread>
 | 
					#include <QThread>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef PTU5
 | 
					#ifdef PTU5
 | 
				
			||||||
#define SERIAL_PORT "ttymxc2"
 | 
					#define SERIAL_PORT "ttymxc2"
 | 
				
			||||||
@@ -34,23 +36,13 @@
 | 
				
			|||||||
#define SERIAL_PORT "ttyUSB0"
 | 
					#define SERIAL_PORT "ttyUSB0"
 | 
				
			||||||
#endif
 | 
					#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
 | 
					// argv[1]: file to send to dc
 | 
				
			||||||
int main(int argc, char *argv[]) {
 | 
					int main(int argc, char *argv[]) {
 | 
				
			||||||
 | 
					    QByteArray const value = qgetenv("LC_ALL");
 | 
				
			||||||
    QByteArray const value = qgetenv("XDG_RUNTIME_DIR");
 | 
					    if (value != "C") {
 | 
				
			||||||
    if (value.size() == 0) {
 | 
					        qputenv("LC_ALL", "C");
 | 
				
			||||||
        qputenv("XDG_RUNTIME_DIR", "/run/user/0");
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    // qputenv("XDG_RUNTIME_DIR", "/run/user/0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QApplication a(argc, argv);
 | 
					    QApplication a(argc, argv);
 | 
				
			||||||
    QApplication::setApplicationName("ATBUpdateTool");
 | 
					    QApplication::setApplicationName("ATBUpdateTool");
 | 
				
			||||||
@@ -58,7 +50,7 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
 | 
					    if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
 | 
				
			||||||
        atbInstallMessageHandler(atbDebugOutput);
 | 
					        atbInstallMessageHandler(atbDebugOutput);
 | 
				
			||||||
        setDebugLevel(QtMsgType::QtDebugMsg);
 | 
					        setDebugLevel(QtMsgType::QtInfoMsg);
 | 
				
			||||||
        //setDebugLevel(QtMsgType::QtDebugMsg);
 | 
					        //setDebugLevel(QtMsgType::QtDebugMsg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -154,10 +146,15 @@ int main(int argc, char *argv[]) {
 | 
				
			|||||||
    // hw->dc_autoRequest(false);
 | 
					    // hw->dc_autoRequest(false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
 | 
					    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();
 | 
					    return a.exec();
 | 
				
			||||||
    t.join();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return ret;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user