829 lines
33 KiB
C++
829 lines
33 KiB
C++
#ifndef WORKER_H_INCLUDED
|
|
#define WORKER_H_INCLUDED
|
|
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <QStringList>
|
|
#include <QTimer>
|
|
#include <QFile>
|
|
#include <QJsonObject>
|
|
#include <QHash>
|
|
#include <QMap>
|
|
#include <QDebug>
|
|
|
|
#include <optional>
|
|
#include <initializer_list>
|
|
|
|
#include "worker_thread.h"
|
|
#include "update.h"
|
|
#include "git/git_client.h"
|
|
#include "ismas/ismas_client.h"
|
|
#include "utils.h"
|
|
|
|
#ifdef PTU5
|
|
#define SERIAL_PORT "ttymxc2"
|
|
#else
|
|
#define SERIAL_PORT "ttyUSB0"
|
|
#endif
|
|
|
|
#define _ISMAS_DONE "U0001" // 100%
|
|
#define _ISMAS_SET_WAIT_OK "U0002" // empty WAIT-button ("")
|
|
#define _ISMAS_FAILURE "U0003" // FAIL
|
|
#define _ISMAS_CONTINUE "U0010" // %-values
|
|
#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 _APPLY_REPOSITORY_CHANGES (40)
|
|
#define _EXEC_OPKG_COMMANDS (41)
|
|
#define _EXEC_OPKG_COMMAND_1 (42)
|
|
#define _EXEC_OPKG_COMMAND_2 (43)
|
|
#define _EXEC_OPKG_COMMAND_3 (44)
|
|
#define _EXEC_OPKG_COMMAND_4 (45)
|
|
#define _EXEC_OPKG_COMMAND_5 (46)
|
|
#define _EXEC_OPKG_COMMAND_6 (47)
|
|
#define _EXEC_OPKG_COMMAND_7 (48)
|
|
#define _EXEC_OPKG_COMMAND_8 (49)
|
|
#define _EXEC_OPKG_COMMAND_9 (50)
|
|
#define _EXEC_OPKG_COMMAND_LAST (51)
|
|
#define _EXEC_OPKG_COMMAND_FAILURE (52)
|
|
#define _EXEC_OPKG_COMMAND_SUCCESS (53)
|
|
#define _DOWNLOAD_CONFIG_FILE (54)
|
|
#define _DOWNLOAD_CONFIG_FILE_SUCCESS (63)
|
|
#define _DOWNLOAD_CONFIG_FILE_FAILURE (64)
|
|
#define _DOWNLOAD_DEVICE_CONTROLLER (65)
|
|
#define _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS (86)
|
|
#define _DOWNLOAD_DEVICE_CONTROLLER_FAILURE (87)
|
|
#define _APPLY_REPOSITORY_CHANGES_FAILURE (88)
|
|
#define _APPLY_REPOSITORY_CHANGES_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 _FINISHED (100)
|
|
#define _DEBUG (1000)
|
|
#define _ERROR (1001)
|
|
|
|
#define _SEND_LAST_VERSION_CORRECTION (4)
|
|
#define _UPDATE_SUCCEEDED_CORRECTION (3)
|
|
#define _UPDATE_FAILED_CORRECTION (2)
|
|
#define _UPDATE_ACTIVATED_CORRECTION (1)
|
|
|
|
#define ISMAS_UPDATE_REQUESTS (10)
|
|
#define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..."
|
|
|
|
class MainWindow;
|
|
class hwinf;
|
|
class Worker : public QObject {
|
|
Q_OBJECT
|
|
|
|
WorkerThread m_workerThread;
|
|
int const m_customerNr;
|
|
QString const m_customerNrStr;
|
|
int const m_machineNr;
|
|
int const m_zoneNr;
|
|
QString const m_pluginName;
|
|
QString const m_workingDirectory;
|
|
QString const m_branchName;
|
|
QString const m_customerRepositoryPath;
|
|
QString const m_customerRepository;
|
|
bool const m_dryRun;
|
|
QObject *m_parent;
|
|
QString const m_serialInterface;
|
|
QString const m_baudrate;
|
|
IsmasClient m_ismasClient;
|
|
GitClient m_gc;
|
|
QString const m_osVersion;
|
|
QString const m_atbqtVersion;
|
|
QString const m_atbUpdateToolVersion;
|
|
QString const m_cpuSerial;
|
|
QString const m_pluginVersionATBDeciceController;
|
|
QString const m_pluginVersionIngenicoISelf;
|
|
QString const m_pluginVersionMobilisisCalc;
|
|
QString const m_pluginVersionMobilisisCalcConfig;
|
|
QString const m_pluginVersionPrmCalc;
|
|
QString const m_pluginVersionPrmCalcConfig;
|
|
QString const m_pluginVersionTcpZvt;
|
|
|
|
int m_ismasUpdateRequests;
|
|
QTimer m_waitForNewUpdates;
|
|
|
|
QStringList m_filesToUpdate;
|
|
QStringList m_filesToDownload;
|
|
bool m_updateProcessRunning;
|
|
int m_displayIndex;
|
|
bool m_clone = false;
|
|
bool m_initialClone = false;
|
|
bool m_repairClone = false;
|
|
bool m_ismasTriggerActive = false;
|
|
|
|
MainWindow *m_mainWindow;
|
|
bool m_withoutIsmasDirectPort;
|
|
QString m_apismVersion;
|
|
|
|
bool executeOpkgCommand(QString opkgCommand);
|
|
QString getOsVersion() const;
|
|
QString getATBQTVersion() const;
|
|
QString getATBUpdateToolVersion() const;
|
|
QString getCPUSerial() const;
|
|
QString getRaucVersion() const;
|
|
QString getOpkgVersion() const;
|
|
QString getPluginVersion(QString const &pluginFileName) const;
|
|
QStringList getDCVersion() const;
|
|
|
|
qint64 getFileSize(QString const &fileName) const;
|
|
bool isRepositoryCorrupted();
|
|
bool repairCorruptedRepository();
|
|
|
|
int sendCloneAndCheckoutSuccess();
|
|
int sendCloneAndCheckoutFailure();
|
|
int sendIsmasTriggerFailure();
|
|
int sendPullFailure();
|
|
int sendFileUpdateFailure();
|
|
int sendRsyncFailure();
|
|
int sendLastVersionFailure();
|
|
int sendSaveLogFilesFailure();
|
|
int sendCustomerEnvironmentConfigurationFailed();
|
|
int sendFoundFilesToUpdateSuccess();
|
|
int sendUpdateSucceededAndActivated();
|
|
int sendFinalResult();
|
|
|
|
struct UpdateProcessRunning {
|
|
Worker *m_worker;
|
|
|
|
explicit UpdateProcessRunning(Worker *worker) : m_worker(worker) {
|
|
m_worker->m_updateProcessRunning = true;
|
|
emit m_worker->disableExit();
|
|
m_worker->startProgressLoop();
|
|
}
|
|
|
|
virtual ~UpdateProcessRunning() {
|
|
m_worker->ISMAS() << (m_worker->GUI() << (m_worker->CONSOLE()
|
|
<< UPDATE_STEP::SEND_LAST_VERSION));
|
|
m_worker->stopProgressLoop();
|
|
|
|
m_worker->m_updateProcessRunning = false;
|
|
emit m_worker->enableExit();
|
|
emit m_worker->restartExitTimer();
|
|
}
|
|
};
|
|
|
|
friend struct UpdateProcessRunning;
|
|
|
|
public:
|
|
enum class UPDATE_STEP {
|
|
STARTED = _STARTED,
|
|
CHECK_REPOSITORY = _CHECK_REPOSITORY,
|
|
CHECK_REPOSITORY_SUCCESS = _CHECK_REPOSITORY_SUCCESS,
|
|
CHECK_REPOSITORY_FAILURE = _CHECK_REPOSITORY_FAILURE,
|
|
CHECK_SANITY = _CHECK_SANITY,
|
|
CHECK_SANITY_SUCCESS = _CHECK_SANITY_SUCCESS,
|
|
CHECK_SANITY_FAILURE = _CHECK_SANITY_FAILURE,
|
|
REPOSITORY_RECOVERED_SUCCESS = _REPOSITORY_RECOVERED_SUCCESS,
|
|
REPOSITORY_RECOVERED_FAILURE = _REPOSITORY_RECOVERED_FAILURE,
|
|
CLONE_REPOSITORY = _CLONE_REPOSITORY,
|
|
CLONE_REPOSITORY_SUCCESS = _CLONE_REPOSITORY_SUCCESS,
|
|
CLONE_REPOSITORY_FAILURE = _CLONE_REPOSITORY_FAILURE,
|
|
CHECKOUT_REPOSITORY = _CHECKOUT_REPOSITORY,
|
|
CHECKOUT_REPOSITORY_SUCCESS = _CHECKOUT_REPOSITORY_SUCCESS,
|
|
CHECKOUT_REPOSITORY_FAILURE = _CHECKOUT_REPOSITORY_FAILURE,
|
|
CHECK_ISMAS_TRIGGER = _CHECK_ISMAS_TRIGGER,
|
|
CHECK_ISMAS_TRIGGER_WRONG_VALUE = _CHECK_ISMAS_TRIGGER_WRONG_VALUE,
|
|
CHECK_ISMAS_TRIGGER_SUCCESS = _CHECK_ISMAS_TRIGGER_SUCCESS,
|
|
CHECK_ISMAS_TRIGGER_FAILURE = _CHECK_ISMAS_TRIGGER_FAILURE,
|
|
INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITHOUT_ACTIVE_ISMAS_TRIGGER,
|
|
INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER = _INITIAL_CLONE_WITH_ACTIVE_ISMAS_TRIGGER,
|
|
CHECKOUT_BRANCH = _CHECKOUT_BRANCH,
|
|
CHECKOUT_BRANCH_SUCCESS = _CHECKOUT_BRANCH_SUCCESS,
|
|
CHECKOUT_BRANCH_FAILURE = _CHECKOUT_BRANCH_FAILURE,
|
|
UPDATE_REPOSITORY = _UPDATE_REPOSITORY,
|
|
UPDATE_REPOSITORY_SUCCESS = _UPDATE_REPOSITORY_SUCCESS,
|
|
UPDATE_REPOSITORY_FAILURE = _UPDATE_REPOSITORY_FAILURE,
|
|
CHECK_FOR_REPOSITORY_CHANGES = _CHECK_FOR_REPOSITORY_CHANGES,
|
|
CHECK_FOR_REPOSITORY_CHANGES_SUCCESS = _CHECK_FOR_REPOSITORY_CHANGES_SUCCESS,
|
|
CHECK_FOR_REPOSITORY_CHANGES_FAILURE = _CHECK_FOR_REPOSITORY_CHANGES_FAILURE,
|
|
FILES_TO_UPDATE = _FILES_TO_UPDATE,
|
|
APPLY_REPOSITORY_CHANGES = _APPLY_REPOSITORY_CHANGES,
|
|
FILES_TO_DOWNLOAD = _FILES_TO_DOWNLOAD,
|
|
EXEC_OPKG_COMMANDS = _EXEC_OPKG_COMMANDS,
|
|
EXEC_OPKG_COMMAND_1 = _EXEC_OPKG_COMMAND_1,
|
|
EXEC_OPKG_COMMAND_2 = _EXEC_OPKG_COMMAND_2,
|
|
EXEC_OPKG_COMMAND_3 = _EXEC_OPKG_COMMAND_3,
|
|
EXEC_OPKG_COMMAND_4 = _EXEC_OPKG_COMMAND_4,
|
|
EXEC_OPKG_COMMAND_5 = _EXEC_OPKG_COMMAND_5,
|
|
EXEC_OPKG_COMMAND_6 = _EXEC_OPKG_COMMAND_6,
|
|
EXEC_OPKG_COMMAND_7 = _EXEC_OPKG_COMMAND_7,
|
|
EXEC_OPKG_COMMAND_8 = _EXEC_OPKG_COMMAND_8,
|
|
EXEC_OPKG_COMMAND_9 = _EXEC_OPKG_COMMAND_9,
|
|
EXEC_OPKG_COMMAND_LAST = _EXEC_OPKG_COMMAND_LAST,
|
|
EXEC_OPKG_COMMAND_SUCCESS = _EXEC_OPKG_COMMAND_SUCCESS,
|
|
EXEC_OPKG_COMMAND_FAILURE = _EXEC_OPKG_COMMAND_FAILURE,
|
|
DOWNLOAD_CONFIG_FILE = _DOWNLOAD_CONFIG_FILE,
|
|
DOWNLOAD_CONFIG_FILE_SUCCESS = _DOWNLOAD_CONFIG_FILE_SUCCESS,
|
|
DOWNLOAD_CONFIG_FILE_FAILURE = _DOWNLOAD_CONFIG_FILE_FAILURE,
|
|
DOWNLOAD_DEVICE_CONTROLLER = _DOWNLOAD_DEVICE_CONTROLLER,
|
|
DOWNLOAD_DEVICE_CONTROLLER_SUCCESS = _DOWNLOAD_DEVICE_CONTROLLER_SUCCESS,
|
|
DOWNLOAD_DEVICE_CONTROLLER_FAILURE = _DOWNLOAD_DEVICE_CONTROLLER_FAILURE,
|
|
APPLY_REPOSITORY_CHANGES_SUCCESS = _APPLY_REPOSITORY_CHANGES_SUCCESS,
|
|
APPLY_REPOSITORY_CHANGES_FAILURE = _APPLY_REPOSITORY_CHANGES_FAILURE,
|
|
SYNC_CUSTOMER_REPOSITORY = _SYNC_CUSTOMER_REPOSITORY,
|
|
SYNC_CUSTOMER_REPOSITORY_SUCCESS = _SYNC_CUSTOMER_REPOSITORY_SUCCESS,
|
|
SYNC_CUSTOMER_REPOSITORY_FAILURE = _SYNC_CUSTOMER_REPOSITORY_FAILURE,
|
|
SAVE_LOGS = _SAVE_LOGS,
|
|
SAVE_LOGS_SUCCESS = _SAVE_LOGS_SUCCESS,
|
|
SAVE_LOGS_FAILURE = _SAVE_LOGS_FAILURE,
|
|
SEND_LAST_VERSION = _SEND_LAST_VERSION,
|
|
UPDATE_SUCCEEDED = _UPDATE_SUCCEEDED,
|
|
UPDATE_ACTIVATED = _UPDATE_ACTIVATED,
|
|
UPDATE_FAILED = _UPDATE_FAILED,
|
|
FINISHED = _FINISHED,
|
|
DEBUG = _DEBUG,
|
|
ERROR = _ERROR
|
|
};
|
|
|
|
private:
|
|
QStringList m_debugMsg;
|
|
QStringList m_guiMsg;
|
|
QStringList m_ismasMsg;
|
|
UPDATE_STEP m_currentStep;
|
|
static Worker *instance;
|
|
QStringList m_opkgCommands;
|
|
|
|
public:
|
|
QDebug CONSOLE(QStringList const &lst = QStringList()) {
|
|
m_debugMsg = lst;
|
|
return qDebug();
|
|
}
|
|
|
|
IsmasClient &ISMAS(QStringList const &lst = QStringList()) {
|
|
m_ismasMsg = lst;
|
|
return m_ismasClient;
|
|
}
|
|
|
|
Worker *GUI(QStringList const &lst = QStringList()) {
|
|
m_guiMsg = lst;
|
|
return this;
|
|
}
|
|
|
|
static QMap<UPDATE_STEP, const char*> const &getSmap() {
|
|
return smap;
|
|
}
|
|
|
|
static QString getATBUpdateToolYoctoVersion();
|
|
static QString getATBUpdateToolYoctoInstallationStatus();
|
|
|
|
static const QString UPDATE_STEP_OK;
|
|
static const QString UPDATE_STEP_DONE;
|
|
static const QString UPDATE_STEP_FAIL;
|
|
static const QString UPDATE_STEP_SUCCESS;
|
|
|
|
explicit Worker(int customerNr, // 281
|
|
int machineNr,
|
|
int zoneNr,
|
|
QString branchName,
|
|
QString pluginName,
|
|
QString workingDir = ".",
|
|
bool dryRun = false,
|
|
QObject *parent = nullptr,
|
|
char const *serialInterface = SERIAL_PORT,
|
|
char const *baudrate = "115200");
|
|
~Worker();
|
|
|
|
void setMainWindow(MainWindow *mainWindow) { m_mainWindow = mainWindow; }
|
|
hwinf *getPlugin();
|
|
hwinf const *getPlugin() const;
|
|
void setProgress(int progress);
|
|
void displayProgressInMainWindow(int progress);
|
|
void startProgressLoop();
|
|
void stopProgressLoop();
|
|
|
|
IsmasClient &getIsmasClient() { return m_ismasClient; }
|
|
IsmasClient const &getIsmasClient() const { return m_ismasClient; }
|
|
|
|
bool updateProcessRunning() const { return m_updateProcessRunning; }
|
|
int returnCode() const { return m_returnCode; }
|
|
|
|
int machineNr() const { return m_machineNr; }
|
|
int customerNr() const { return m_customerNr; }
|
|
int zoneNr() const { return m_zoneNr; }
|
|
QString apismVersion() const { return m_apismVersion; }
|
|
QString atbUpdateToolVersion() const { return m_atbUpdateToolVersion; }
|
|
|
|
MainWindow *mainWindow() { return m_mainWindow; }
|
|
MainWindow const *mainWindow() const { return m_mainWindow; }
|
|
|
|
signals:
|
|
void appendText(QString, QString suffix = "");
|
|
void replaceLast(QString, QString);
|
|
void replaceLast(QStringList, QString);
|
|
void showErrorMessage(QString title, QString description);
|
|
void showStatusMessage(QString title, QString description);
|
|
void showErrorMessage(QStringList titleAndDesc);
|
|
void showStatusMessage(QStringList titleAndDesc);
|
|
void stopStartTimer();
|
|
void restartExitTimer();
|
|
void enableExit();
|
|
void disableExit();
|
|
|
|
public slots:
|
|
void update();
|
|
|
|
private slots:
|
|
bool updateTriggerSet();
|
|
bool customerEnvironment(int progress);
|
|
bool filesToUpdate(int progress);
|
|
bool updateFiles(int percent);
|
|
bool syncCustomerRepositoryAndFS(int progress);
|
|
bool sendIsmasLastVersionNotification(int progress);
|
|
bool saveLogFile(int progress);
|
|
|
|
private:
|
|
PSAInstalled getPSAInstalled();
|
|
void privateUpdate();
|
|
std::optional<QString> getApismVersion();
|
|
void printProgress(UPDATE_STEP step);
|
|
|
|
static const QMap<UPDATE_STEP, const char*> smap;
|
|
|
|
// CONSOLE()
|
|
friend UPDATE_STEP operator<<(QDebug debug, UPDATE_STEP step) {
|
|
if (!Worker::instance) {
|
|
return step;
|
|
}
|
|
|
|
Worker::instance->m_currentStep = step;
|
|
|
|
switch (step) {
|
|
case UPDATE_STEP::STARTED: {
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CURRENT TIME ...............%1").arg(QDateTime::currentDateTime().toString(Qt::ISODate))
|
|
<< QString("OS VERSION .................%1").arg(instance->m_osVersion)
|
|
<< QString("ATBQT VERSION ..............%1").arg(instance->m_atbqtVersion)
|
|
<< QString("CPU SERIAL .................%1").arg(instance->m_cpuSerial)
|
|
<< QString("CUSTOMER_NR ................%1").arg(instance->m_customerNr)
|
|
<< QString("CUSTOMER_NR_STR ............%1").arg(instance->m_customerNrStr)
|
|
<< QString("CUSTOMER_REPOSITORY_PATH ...%1").arg(instance->m_customerRepositoryPath)
|
|
<< QString("CUSTOMER_REPOSITORY ........%1").arg(instance->m_customerRepository)
|
|
<< QString("MACHINE_NR .................%1").arg(instance->m_machineNr)
|
|
<< QString("ZONE_NR ....................%1").arg(instance->m_zoneNr)
|
|
<< QString("BRANCH_NAME ................%1").arg(instance->m_branchName)
|
|
<< QString("PLUGIN_NAME ................%1").arg(instance->m_pluginName)
|
|
<< QString("WORKING_DIRECTORY ..........%1").arg(instance->m_workingDirectory)
|
|
<< QString("APISM VERSION ..............%1").arg(instance->m_apismVersion)
|
|
<< QString("ATB UPDATE TOOL VERSION ....%1").arg(instance->m_atbUpdateToolVersion));
|
|
} break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CHECK SANITY OF CUSTOMER REPOSITORY %1")
|
|
.arg(instance->m_customerRepository));
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("SANITY OF CUSTOMER REPOSITORY %1 OK")
|
|
.arg(instance->m_customerRepository));
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_FAILURE:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CORRUPTED CUSTOMER REPOSITORY %1. REPAIRING...")
|
|
.arg(instance->m_customerRepository));
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CORRUPTED CUSTOMER REPOSITORY %1. REPAIRING DONE")
|
|
.arg(instance->m_customerRepository));
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CORRUPTED CUSTOMER REPOSITORY %1. REPAIRING FAILED")
|
|
.arg(instance->m_customerRepository));
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
Utils::printUpdateStatusMsg(
|
|
debug,
|
|
QStringList(smap[step])
|
|
<< QString("CHECK ISMAS-TRIGGER-STATUS..."));
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SEND_LAST_VERSION:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_SUCCEEDED:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_FAILED:
|
|
break;
|
|
case UPDATE_STEP::FINISHED:
|
|
break;
|
|
case UPDATE_STEP::DEBUG:
|
|
Utils::printUpdateStatusMsg(
|
|
debug, QStringList(smap[step]) << instance->m_debugMsg);
|
|
break;
|
|
case UPDATE_STEP::ERROR:
|
|
//Utils::printUpdateStatusMsg(
|
|
// debug, QStringList(smap[step]) << instance->m_errorMsg);
|
|
break;
|
|
}
|
|
|
|
return step;
|
|
}
|
|
|
|
friend UPDATE_STEP operator<<(IsmasClient &ismasClient, UPDATE_STEP step) {
|
|
|
|
if (!Worker::instance) {
|
|
return step;
|
|
}
|
|
|
|
switch (step) {
|
|
case UPDATE_STEP::STARTED: {
|
|
ismasClient.setProgressInPercent(_STARTED);
|
|
} break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY:
|
|
ismasClient.setProgressInPercent(_CHECK_REPOSITORY);
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY:
|
|
ismasClient.setProgressInPercent(_CHECK_SANITY);
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
|
|
ismasClient.setProgressInPercent(_CHECK_SANITY_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_FAILURE:
|
|
ismasClient.setProgressInPercent(_CHECK_SANITY_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY:
|
|
ismasClient.setProgressInPercent(_CLONE_REPOSITORY);
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS: {
|
|
ismasClient.setProgressInPercent(_CLONE_REPOSITORY_SUCCESS);
|
|
QString const &ismasUpdateNews =
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
ismasClient.updateNewsToIsmas(
|
|
"U0010",
|
|
_CLONE_REPOSITORY_SUCCESS,
|
|
IsmasClient::RESULT_CODE::SUCCESS,
|
|
smap[step],
|
|
QString("CLONED REPOSITORY %1 AND CHECKED OUT BRANCH %2")
|
|
.arg(instance->m_customerRepository)
|
|
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
|
"");
|
|
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
ismasUpdateNews);
|
|
} break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_FAILURE: {
|
|
ismasClient.setProgressInPercent(_CLONE_REPOSITORY_FAILURE);
|
|
QString const &ismasUpdateNews =
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
ismasClient.updateNewsToIsmas(
|
|
"U0003",
|
|
_CLONE_REPOSITORY_FAILURE,
|
|
IsmasClient::RESULT_CODE::INSTALL_ERROR,
|
|
smap[step],
|
|
QString("CLONING REPOSITORY %1 OR CHECKING OUT BRANCH %2 FAILED")
|
|
.arg(instance->m_customerRepository)
|
|
.arg(instance->m_gc.branchName()).toStdString().c_str(),
|
|
"");
|
|
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
ismasUpdateNews);
|
|
} break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY:
|
|
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY);
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS:
|
|
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_SUCCESS);
|
|
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
ismasClient.cloneAndCheckoutCustomerRepository(
|
|
QString("CHECKED OUT REPOSITORY %1 AND CHECKED OUT BRANCH %2")
|
|
.arg(instance->m_customerRepository)
|
|
.arg(instance->m_gc.branchName())));
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE:
|
|
ismasClient.setProgressInPercent(_CHECKOUT_REPOSITORY_FAILURE);
|
|
break;
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER);
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
|
|
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_SUCCESS);
|
|
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
ismasClient.updateTriggerSet("ISMAS TRIGGER SET", ""));
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE:
|
|
ismasClient.setProgressInPercent(_CHECK_ISMAS_TRIGGER_FAILURE);
|
|
ismasClient.sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT,
|
|
QString("#M=APISM#C=CMD_EVENT#J=") +
|
|
ismasClient.errorUpdateTrigger(instance->m_ismasMsg.join(' '), ""));
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY:
|
|
ismasClient.setProgressInPercent(_UPDATE_REPOSITORY);
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS:
|
|
ismasClient.setProgressInPercent(_UPDATE_REPOSITORY_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_FAILURE:
|
|
ismasClient.setProgressInPercent(_UPDATE_REPOSITORY_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES:
|
|
ismasClient.setProgressInPercent(_CHECK_FOR_REPOSITORY_CHANGES);
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS:
|
|
ismasClient.setProgressInPercent(_CHECK_FOR_REPOSITORY_CHANGES_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
|
|
ismasClient.setProgressInPercent(_CHECK_FOR_REPOSITORY_CHANGES_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
|
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_CONFIG_FILE_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
|
ismasClient.setProgressInPercent(_DOWNLOAD_DEVICE_CONTROLLER_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
|
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
|
ismasClient.setProgressInPercent(_APPLY_REPOSITORY_CHANGES_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY);
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
|
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
|
ismasClient.setProgressInPercent(_SYNC_CUSTOMER_REPOSITORY_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS:
|
|
ismasClient.setProgressInPercent(_SAVE_LOGS);
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
|
ismasClient.setProgressInPercent(_SAVE_LOGS_SUCCESS);
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
|
ismasClient.setProgressInPercent(_SAVE_LOGS_FAILURE);
|
|
break;
|
|
case UPDATE_STEP::SEND_LAST_VERSION:
|
|
ismasClient.setProgressInPercent(_SEND_LAST_VERSION);
|
|
break;
|
|
case UPDATE_STEP::UPDATE_SUCCEEDED:
|
|
ismasClient.setProgressInPercent(_UPDATE_SUCCEEDED);
|
|
break;
|
|
case UPDATE_STEP::UPDATE_FAILED:
|
|
ismasClient.setProgressInPercent(_UPDATE_FAILED);
|
|
break;
|
|
case UPDATE_STEP::FINISHED:
|
|
ismasClient.setProgressInPercent(_FINISHED);
|
|
break;
|
|
case UPDATE_STEP::DEBUG:
|
|
break;
|
|
case UPDATE_STEP::ERROR:
|
|
break;
|
|
}
|
|
|
|
return step;
|
|
}
|
|
|
|
friend UPDATE_STEP operator<<(Worker *worker, UPDATE_STEP step) {
|
|
switch (step) {
|
|
case UPDATE_STEP::STARTED:
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY:
|
|
emit worker->appendText("\nInitializing customer environment ...");
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY:
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_SANITY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::REPOSITORY_RECOVERED_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY:
|
|
emit worker->appendText("\nInitializing customer environment ...");
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_SUCCESS:
|
|
emit worker->replaceLast("Initializing customer environment",
|
|
Worker::UPDATE_STEP_DONE);
|
|
break;
|
|
case UPDATE_STEP::CLONE_REPOSITORY_FAILURE:
|
|
emit worker->replaceLast("Initializing customer environment",
|
|
Worker::UPDATE_STEP_FAIL);
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECKOUT_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER:
|
|
emit worker->appendText("\n" CHECK_UPDATE_TRIGGER_SET);
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_ISMAS_TRIGGER_FAILURE:
|
|
emit worker->showErrorMessage(worker->m_guiMsg);
|
|
emit worker->replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL);
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::CHECK_FOR_REPOSITORY_CHANGES_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_CONFIG_FILE_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::DOWNLOAD_DEVICE_CONTROLLER_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::APPLY_REPOSITORY_CHANGES_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::SYNC_CUSTOMER_REPOSITORY_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_SUCCESS:
|
|
break;
|
|
case UPDATE_STEP::SAVE_LOGS_FAILURE:
|
|
break;
|
|
case UPDATE_STEP::SEND_LAST_VERSION:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_SUCCEEDED:
|
|
break;
|
|
case UPDATE_STEP::UPDATE_FAILED:
|
|
break;
|
|
case UPDATE_STEP::FINISHED:
|
|
break;
|
|
case UPDATE_STEP::DEBUG:
|
|
emit worker->showStatusMessage(worker->m_guiMsg);
|
|
break;
|
|
case UPDATE_STEP::ERROR:
|
|
emit worker->showErrorMessage(worker->m_guiMsg);
|
|
break;
|
|
}
|
|
|
|
return step;
|
|
}
|
|
};
|
|
|
|
#endif // WORKER_H_INCLUDED
|