UpdatePTUDevCtrl/worker.h

101 lines
2.6 KiB
C
Raw Normal View History

2023-06-16 16:47:13 +02:00
#ifndef WORKER_H_INCLUDED
#define WORKER_H_INCLUDED
#include <QObject>
#include <QString>
#include <QStringList>
2023-06-16 16:47:13 +02:00
#include <QTimer>
#include <QFile>
#include <QJsonObject>
#include <QHash>
2023-06-16 16:47:13 +02:00
#include "worker_thread.h"
#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
#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;
QTimer m_startUpdateProcess;
Update *m_update;
ApismClient m_apismClient;
GitClient m_gc;
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-06-16 16:47:13 +02:00
public:
explicit Worker(hwinf *hw,
QString update_ctrl_file,
QString repositoryPath,
QString customerId,
QString branchName,
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:
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:
void onIsmasResponseReceived(QJsonObject ismasResponse);
void onExecuteOpkgCommands(QStringList opkgCommands);
void onExecuteOpkgCommand(QString opkgCommand);
private slots:
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
};
//Q_DECLARE_METATYPE((QHash<QString, QString>))
//Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(QHash)
2023-06-16 16:47:13 +02:00
#endif // WORKER_H_INCLUDED