2023-06-16 16:47:13 +02:00
|
|
|
#ifndef WORKER_H_INCLUDED
|
|
|
|
#define WORKER_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
2023-07-14 13:32:00 +02:00
|
|
|
#include <QStringList>
|
2023-06-16 16:47:13 +02:00
|
|
|
#include <QTimer>
|
2023-07-11 16:58:49 +02:00
|
|
|
#include <QFile>
|
|
|
|
#include <QJsonObject>
|
2023-07-14 13:32:00 +02:00
|
|
|
#include <QHash>
|
2023-06-16 16:47:13 +02:00
|
|
|
|
|
|
|
#include "worker_thread.h"
|
2023-07-11 16:58:49 +02:00
|
|
|
#include "update.h"
|
|
|
|
#include "git/git_client.h"
|
|
|
|
#include "ismas/ismas_client.h"
|
|
|
|
#include "apism/apism_client.h"
|
2023-06-16 16:47:13 +02:00
|
|
|
|
2023-07-11 16:58:49 +02:00
|
|
|
#ifdef PTU5
|
|
|
|
#define SERIAL_PORT "ttymxc2"
|
|
|
|
#else
|
|
|
|
#define SERIAL_PORT "ttyUSB0"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
class hwinf;
|
2023-06-16 16:47:13 +02:00
|
|
|
class Worker : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
WorkerThread m_workerThread;
|
2023-07-14 13:32:00 +02:00
|
|
|
QTimer m_startUpdateProcess;
|
2023-07-11 16:58:49 +02:00
|
|
|
Update *m_update;
|
|
|
|
ApismClient m_apismClient;
|
|
|
|
GitClient m_gc;
|
2023-07-14 13:32:00 +02:00
|
|
|
QString const m_customerId;
|
|
|
|
QString const m_workingDirectory;
|
|
|
|
QString const m_branchName;
|
|
|
|
QString const m_customerRepository;
|
|
|
|
bool m_maintenanceMode;
|
|
|
|
int m_ismasUpdateRequests;
|
|
|
|
QTimer m_waitForNewUpdates;
|
|
|
|
IsmasClient m_ismasClient;
|
|
|
|
|
|
|
|
int m_machineNr; // setzen
|
|
|
|
int m_customerNr;
|
|
|
|
|
|
|
|
|
|
|
|
enum { ISMAS_UPDATE_REQUESTS = 6 };
|
|
|
|
|
|
|
|
enum class UPDATE_STATUS : quint8 {
|
|
|
|
STARTED,
|
|
|
|
STOPPED,
|
|
|
|
ERROR_BACKEND
|
|
|
|
} m_updateStatus;
|
2023-07-11 16:58:49 +02:00
|
|
|
|
2023-06-16 16:47:13 +02:00
|
|
|
public:
|
2023-07-11 16:58:49 +02:00
|
|
|
explicit Worker(hwinf *hw,
|
|
|
|
QString update_ctrl_file,
|
2023-07-14 13:32:00 +02:00
|
|
|
QString repositoryPath,
|
|
|
|
QString customerId,
|
|
|
|
QString branchName,
|
2023-07-11 16:58:49 +02:00
|
|
|
QString workingDir = ".",
|
|
|
|
bool maintenanceMode = false,
|
|
|
|
bool testMode = false,
|
|
|
|
bool executeScriptOnly = false,
|
|
|
|
bool dryRun = false,
|
|
|
|
QObject *parent = nullptr,
|
|
|
|
char const *serialInterface = SERIAL_PORT,
|
|
|
|
char const *baudrate = "115200");
|
2023-06-16 16:47:13 +02:00
|
|
|
~Worker();
|
|
|
|
void quit() { return m_workerThread.quit(); }
|
|
|
|
|
|
|
|
signals:
|
2023-07-14 13:32:00 +02:00
|
|
|
void executeOpkgCommands(QStringList);
|
|
|
|
void executeOpkgCommand(QString);
|
|
|
|
void handleChangedFiles(QStringList);
|
|
|
|
void summarizeUpload(QStringList);
|
|
|
|
void summarizeRepositoryStatus();
|
|
|
|
void sendCmdSendVersionToIsmas();
|
|
|
|
void finishUpdateProcess(bool changes);
|
|
|
|
void terminateUpdateProcess();
|
2023-06-16 16:47:13 +02:00
|
|
|
|
|
|
|
public slots:
|
2023-07-11 16:58:49 +02:00
|
|
|
void onIsmasResponseReceived(QJsonObject ismasResponse);
|
2023-07-14 13:32:00 +02:00
|
|
|
void onExecuteOpkgCommands(QStringList opkgCommands);
|
|
|
|
void onExecuteOpkgCommand(QString opkgCommand);
|
2023-07-11 16:58:49 +02:00
|
|
|
|
|
|
|
private slots:
|
2023-07-14 13:32:00 +02:00
|
|
|
void askIsmasForNewData();
|
|
|
|
void onSendCmdSendVersionToIsmas();
|
|
|
|
void onSummarizeRepositoryStatus();
|
|
|
|
void onFinishUpdateProcess(bool changes);
|
|
|
|
void onTerminateUpdateProcess();
|
|
|
|
void onSummarizeUpload(QStringList);
|
|
|
|
void onHandleChangedFiles(QStringList);
|
2023-06-16 16:47:13 +02:00
|
|
|
};
|
|
|
|
|
2023-07-14 13:32:00 +02:00
|
|
|
//Q_DECLARE_METATYPE((QHash<QString, QString>))
|
|
|
|
//Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(QHash)
|
|
|
|
|
2023-06-16 16:47:13 +02:00
|
|
|
#endif // WORKER_H_INCLUDED
|