Turned worker-object into a thread
This commit is contained in:
parent
904fa0374b
commit
e65387aa60
67
worker.h
67
worker.h
@ -10,11 +10,11 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
||||||
#include "worker_thread.h"
|
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "git/git_client.h"
|
#include "git/git_client.h"
|
||||||
#include "ismas/ismas_client.h"
|
#include "ismas/ismas_client.h"
|
||||||
@ -64,7 +64,6 @@
|
|||||||
#define _FILES_TO_UPDATE (37)
|
#define _FILES_TO_UPDATE (37)
|
||||||
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (38)
|
#define _CHECK_FOR_REPOSITORY_CHANGES_FAILURE (38)
|
||||||
#define _FILES_TO_DOWNLOAD (39)
|
#define _FILES_TO_DOWNLOAD (39)
|
||||||
#define _APPLY_REPOSITORY_CHANGES (40)
|
|
||||||
#define _EXEC_OPKG_COMMANDS (41)
|
#define _EXEC_OPKG_COMMANDS (41)
|
||||||
#define _EXEC_OPKG_COMMAND_1 (42)
|
#define _EXEC_OPKG_COMMAND_1 (42)
|
||||||
#define _EXEC_OPKG_COMMAND_2 (43)
|
#define _EXEC_OPKG_COMMAND_2 (43)
|
||||||
@ -78,14 +77,15 @@
|
|||||||
#define _EXEC_OPKG_COMMAND_LAST (51)
|
#define _EXEC_OPKG_COMMAND_LAST (51)
|
||||||
#define _EXEC_OPKG_COMMAND_FAILURE (52)
|
#define _EXEC_OPKG_COMMAND_FAILURE (52)
|
||||||
#define _EXEC_OPKG_COMMAND_SUCCESS (53)
|
#define _EXEC_OPKG_COMMAND_SUCCESS (53)
|
||||||
#define _DOWNLOAD_CONFIG_FILE (54)
|
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE (54)
|
||||||
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (63)
|
#define _DOWNLOAD_CONFIG_FILE (55)
|
||||||
#define _DOWNLOAD_CONFIG_FILE_FAILURE (64)
|
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (56)
|
||||||
|
#define _DOWNLOAD_CONFIG_FILE_FAILURE (57)
|
||||||
#define _DOWNLOAD_DEVICE_CONTROLLER (65)
|
#define _DOWNLOAD_DEVICE_CONTROLLER (65)
|
||||||
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86)
|
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86)
|
||||||
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (87)
|
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (87)
|
||||||
#define _APPLY_REPOSITORY_CHANGES_FAILURE (88)
|
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE (88)
|
||||||
#define _APPLY_REPOSITORY_CHANGES_SUCCESS (89)
|
#define _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS (89)
|
||||||
#define _SYNC_CUSTOMER_REPOSITORY (90)
|
#define _SYNC_CUSTOMER_REPOSITORY (90)
|
||||||
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (91)
|
#define _SYNC_CUSTOMER_REPOSITORY_FAILURE (91)
|
||||||
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (92)
|
#define _SYNC_CUSTOMER_REPOSITORY_SUCCESS (92)
|
||||||
@ -110,19 +110,20 @@
|
|||||||
|
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
class hwinf;
|
class hwinf;
|
||||||
class Worker : public QObject {
|
class Worker : public QThread{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
WorkerThread m_workerThread;
|
|
||||||
int const m_customerNr;
|
int const m_customerNr;
|
||||||
QString const m_customerNrStr;
|
QString const m_customerNrStr;
|
||||||
int const m_machineNr;
|
int const m_machineNr;
|
||||||
int const m_zoneNr;
|
int const m_zoneNr;
|
||||||
|
QString const m_pluginDir;
|
||||||
QString const m_pluginName;
|
QString const m_pluginName;
|
||||||
QString const m_workingDirectory;
|
QString const m_workingDirectory;
|
||||||
QString const m_branchName;
|
QString const m_branchName;
|
||||||
QString const m_customerRepositoryPath;
|
QString const m_customerRepositoryPath;
|
||||||
QString const m_customerRepository;
|
QString const m_customerRepository;
|
||||||
|
bool const m_noUpdatePsaHardware;
|
||||||
bool const m_dryRun;
|
bool const m_dryRun;
|
||||||
QObject *m_parent;
|
QObject *m_parent;
|
||||||
QString const m_serialInterface;
|
QString const m_serialInterface;
|
||||||
@ -240,7 +241,7 @@ public:
|
|||||||
CHECK_FOR_REPOSITORY_CHANGES_SUCCESS = _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS,
|
CHECK_FOR_REPOSITORY_CHANGES_SUCCESS = _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS,
|
||||||
CHECK_FOR_REPOSITORY_CHANGES_FAILURE = _CHECK_FOR_REPOSITORY_CHANGES_FAILURE,
|
CHECK_FOR_REPOSITORY_CHANGES_FAILURE = _CHECK_FOR_REPOSITORY_CHANGES_FAILURE,
|
||||||
FILES_TO_UPDATE = _FILES_TO_UPDATE,
|
FILES_TO_UPDATE = _FILES_TO_UPDATE,
|
||||||
APPLY_REPOSITORY_CHANGES = _APPLY_REPOSITORY_CHANGES,
|
DOWNLOAD_FILES_TO_PSA_HARDWARE = _DOWNLOAD_FILES_TO_PSA_HARDWARE,
|
||||||
FILES_TO_DOWNLOAD = _FILES_TO_DOWNLOAD,
|
FILES_TO_DOWNLOAD = _FILES_TO_DOWNLOAD,
|
||||||
EXEC_OPKG_COMMANDS = _EXEC_OPKG_COMMANDS,
|
EXEC_OPKG_COMMANDS = _EXEC_OPKG_COMMANDS,
|
||||||
EXEC_OPKG_COMMAND_1 = _EXEC_OPKG_COMMAND_1,
|
EXEC_OPKG_COMMAND_1 = _EXEC_OPKG_COMMAND_1,
|
||||||
@ -261,8 +262,8 @@ public:
|
|||||||
DOWNLOAD_DEVICE_CONTROLLER = _DOWNLOAD_DEVICE_CONTROLLER,
|
DOWNLOAD_DEVICE_CONTROLLER = _DOWNLOAD_DEVICE_CONTROLLER,
|
||||||
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS,
|
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS,
|
||||||
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = _DOWNLOAD_DEVICE_CONTROLLER_FAILURE,
|
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = _DOWNLOAD_DEVICE_CONTROLLER_FAILURE,
|
||||||
APPLY_REPOSITORY_CHANGES_SUCCESS = _APPLY_REPOSITORY_CHANGES_SUCCESS,
|
DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS = _DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS,
|
||||||
APPLY_REPOSITORY_CHANGES_FAILURE = _APPLY_REPOSITORY_CHANGES_FAILURE,
|
DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE = _DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE,
|
||||||
SYNC_CUSTOMER_REPOSITORY = _SYNC_CUSTOMER_REPOSITORY,
|
SYNC_CUSTOMER_REPOSITORY = _SYNC_CUSTOMER_REPOSITORY,
|
||||||
SYNC_CUSTOMER_REPOSITORY_SUCCESS = _SYNC_CUSTOMER_REPOSITORY_SUCCESS,
|
SYNC_CUSTOMER_REPOSITORY_SUCCESS = _SYNC_CUSTOMER_REPOSITORY_SUCCESS,
|
||||||
SYNC_CUSTOMER_REPOSITORY_FAILURE = _SYNC_CUSTOMER_REPOSITORY_FAILURE,
|
SYNC_CUSTOMER_REPOSITORY_FAILURE = _SYNC_CUSTOMER_REPOSITORY_FAILURE,
|
||||||
@ -285,6 +286,10 @@ private:
|
|||||||
UPDATE_STEP m_currentStep;
|
UPDATE_STEP m_currentStep;
|
||||||
static Worker *instance;
|
static Worker *instance;
|
||||||
QStringList m_opkgCommands;
|
QStringList m_opkgCommands;
|
||||||
|
Update *m_update = nullptr;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void run();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QDebug CONSOLE(QStringList const &lst = QStringList()) {
|
QDebug CONSOLE(QStringList const &lst = QStringList()) {
|
||||||
@ -321,8 +326,10 @@ public:
|
|||||||
int machineNr,
|
int machineNr,
|
||||||
int zoneNr,
|
int zoneNr,
|
||||||
QString branchName,
|
QString branchName,
|
||||||
|
QString pluginDir,
|
||||||
QString pluginName,
|
QString pluginName,
|
||||||
QString workingDir = ".",
|
QString workingDir = ".",
|
||||||
|
bool noUpdatePsaHardware = false,
|
||||||
bool dryRun = false,
|
bool dryRun = false,
|
||||||
QObject *parent = nullptr,
|
QObject *parent = nullptr,
|
||||||
char const *serialInterface = SERIAL_PORT,
|
char const *serialInterface = SERIAL_PORT,
|
||||||
@ -330,8 +337,6 @@ public:
|
|||||||
~Worker();
|
~Worker();
|
||||||
|
|
||||||
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
||||||
hwinf *getPlugin();
|
|
||||||
hwinf const *getPlugin() const;
|
|
||||||
void setProgress(int progress);
|
void setProgress(int progress);
|
||||||
void displayProgressInMainWindow(int progress);
|
void displayProgressInMainWindow(int progress);
|
||||||
void startProgressLoop();
|
void startProgressLoop();
|
||||||
@ -352,6 +357,9 @@ public:
|
|||||||
MainWindow *mainWindow() { return m_mainWindow; }
|
MainWindow *mainWindow() { return m_mainWindow; }
|
||||||
MainWindow const *mainWindow() const { return m_mainWindow; }
|
MainWindow const *mainWindow() const { return m_mainWindow; }
|
||||||
|
|
||||||
|
Update *update() { return m_update; }
|
||||||
|
Update const *update() const { return m_update; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void appendText(QString, QString suffix = "");
|
void appendText(QString, QString suffix = "");
|
||||||
void replaceLast(QString, QString);
|
void replaceLast(QString, QString);
|
||||||
@ -365,14 +373,11 @@ signals:
|
|||||||
void enableExit();
|
void enableExit();
|
||||||
void disableExit();
|
void disableExit();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void update();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
bool updateTriggerSet();
|
bool updateTriggerSet();
|
||||||
bool customerEnvironment();
|
bool customerEnvironment();
|
||||||
bool filesToUpdate();
|
bool filesToUpdate();
|
||||||
bool updateFiles();
|
bool downloadFilesToPSAHardware();
|
||||||
bool syncCustomerRepositoryAndFS();
|
bool syncCustomerRepositoryAndFS();
|
||||||
// bool sendIsmasLastVersionNotification(int progress);
|
// bool sendIsmasLastVersionNotification(int progress);
|
||||||
bool saveLogFile();
|
bool saveLogFile();
|
||||||
@ -380,6 +385,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
PSAInstalled getPSAInstalled();
|
PSAInstalled getPSAInstalled();
|
||||||
void privateUpdate();
|
void privateUpdate();
|
||||||
|
bool computeFilesToDownload();
|
||||||
|
bool execOpkgCommands();
|
||||||
|
|
||||||
static const QMap<UPDATE_STEP, const char*> smap;
|
static const QMap<UPDATE_STEP, const char*> smap;
|
||||||
|
|
||||||
@ -510,7 +517,7 @@ private:
|
|||||||
break;
|
break;
|
||||||
case UPDATE_STEP::FILES_TO_UPDATE:
|
case UPDATE_STEP::FILES_TO_UPDATE:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES: {
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE: {
|
||||||
lst << instance->m_debugMsg;
|
lst << instance->m_debugMsg;
|
||||||
Utils::printUpdateStatusMsg(debug, lst);
|
Utils::printUpdateStatusMsg(debug, lst);
|
||||||
} break;
|
} break;
|
||||||
@ -563,9 +570,9 @@ private:
|
|||||||
lst << instance->m_debugMsg;
|
lst << instance->m_debugMsg;
|
||||||
Utils::printUpdateStatusMsg(debug, lst);
|
Utils::printUpdateStatusMsg(debug, lst);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||||
break;
|
break;
|
||||||
@ -774,8 +781,8 @@ private:
|
|||||||
case UPDATE_STEP::FILES_TO_UPDATE:
|
case UPDATE_STEP::FILES_TO_UPDATE:
|
||||||
ismasClient.setProgressInPercent(_FILES_TO_UPDATE);
|
ismasClient.setProgressInPercent(_FILES_TO_UPDATE);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE:
|
||||||
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES);
|
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::FILES_TO_DOWNLOAD:
|
case UPDATE_STEP::FILES_TO_DOWNLOAD:
|
||||||
ismasClient.setProgressInPercent(_FILES_TO_DOWNLOAD);
|
ismasClient.setProgressInPercent(_FILES_TO_DOWNLOAD);
|
||||||
@ -922,11 +929,11 @@ private:
|
|||||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
||||||
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_FAILURE);
|
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_FAILURE);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS:
|
||||||
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES_SUCCESS);
|
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||||
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES_FAILURE);
|
ismasClient.setProgressInPercent(_DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE);
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||||
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY);
|
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY);
|
||||||
@ -1110,7 +1117,7 @@ private:
|
|||||||
emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(0));
|
emit worker->appendText(QString("\n ") + worker->m_filesToUpdate.at(0));
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::FILES_TO_DOWNLOAD:
|
case UPDATE_STEP::FILES_TO_DOWNLOAD:
|
||||||
break;
|
break;
|
||||||
@ -1160,9 +1167,9 @@ private:
|
|||||||
break;
|
break;
|
||||||
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_SUCCESS:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
case UPDATE_STEP::DOWNLOAD_FILES_TO_PSA_HARDWARE_FAILURE:
|
||||||
break;
|
break;
|
||||||
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
||||||
emit worker->appendText("\nSync customer environment with filesystem ...");
|
emit worker->appendText("\nSync customer environment with filesystem ...");
|
||||||
|
Loading…
Reference in New Issue
Block a user