2023-05-26 13:03:38 +02:00
|
|
|
#ifndef UPDATE_H_INCLUDED
|
|
|
|
#define UPDATE_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
#include <QFile>
|
2023-06-16 16:51:30 +02:00
|
|
|
#include <QDir>
|
|
|
|
#include <QByteArray>
|
2023-06-27 17:25:23 +02:00
|
|
|
#include <QProcess>
|
2023-09-10 16:50:19 +02:00
|
|
|
#include <QPluginLoader>
|
2024-05-15 14:59:08 +02:00
|
|
|
#include <QMap>
|
2023-05-26 13:03:38 +02:00
|
|
|
|
2024-03-15 12:07:15 +01:00
|
|
|
#include <DeviceController/interfaces.h>
|
2023-05-26 13:03:38 +02:00
|
|
|
|
|
|
|
#ifdef PTU5
|
|
|
|
#define SERIAL_PORT "ttymxc2"
|
|
|
|
#else
|
|
|
|
#define SERIAL_PORT "ttyUSB0"
|
|
|
|
#endif
|
|
|
|
|
2023-08-02 15:47:19 +02:00
|
|
|
class Worker;
|
2023-05-26 13:03:38 +02:00
|
|
|
class Update : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2023-11-07 09:14:49 +01:00
|
|
|
Worker *m_worker = nullptr;
|
2023-05-26 13:03:38 +02:00
|
|
|
char const *m_serialInterface;
|
|
|
|
char const *m_baudrate;
|
2023-07-17 16:45:11 +02:00
|
|
|
QString m_customerRepository;
|
|
|
|
QString m_customerNrStr;
|
2023-07-14 13:33:46 +02:00
|
|
|
QString m_branchName;
|
2023-09-06 09:12:25 +02:00
|
|
|
QString m_pluginName;
|
2023-05-26 13:03:38 +02:00
|
|
|
QString m_workingDir;
|
2023-06-20 16:13:11 +02:00
|
|
|
bool m_maintenanceMode;
|
2023-07-14 13:33:46 +02:00
|
|
|
bool m_dryRun;
|
2023-11-24 14:08:54 +01:00
|
|
|
bool m_sys_areDCdataValid;
|
2023-06-16 16:51:30 +02:00
|
|
|
|
2023-09-10 16:50:19 +02:00
|
|
|
static QPluginLoader pluginLoader;
|
|
|
|
|
2023-05-26 13:03:38 +02:00
|
|
|
public:
|
2023-06-16 16:51:30 +02:00
|
|
|
enum class DownloadResult {OK, ERROR, TIMEOUT, NOP};
|
2023-06-22 15:20:21 +02:00
|
|
|
enum class FileTypeJson {CONFIG=1, DEVICE=2, CASH=3, SERIAL=4, TIME=5, PRINTER=6};
|
2023-06-16 16:51:30 +02:00
|
|
|
|
|
|
|
static hwinf *loadDCPlugin(QDir const &plugInDir, QString const &fn);
|
2023-09-10 16:50:19 +02:00
|
|
|
static bool unloadDCPlugin();
|
2023-07-10 16:00:34 +02:00
|
|
|
static QStringList split(QString line, QChar sep = ',');
|
2023-06-16 16:51:30 +02:00
|
|
|
|
|
|
|
|
2023-11-07 09:14:49 +01:00
|
|
|
explicit Update(Worker *worker,
|
2023-07-17 16:45:11 +02:00
|
|
|
QString customerRepository,
|
|
|
|
QString customerNrStr,
|
2023-07-14 13:33:46 +02:00
|
|
|
QString branchName,
|
2023-11-07 09:14:49 +01:00
|
|
|
QString plugInDir,
|
2023-09-06 09:12:25 +02:00
|
|
|
QString pluginName,
|
2023-07-17 16:45:11 +02:00
|
|
|
QString workingDir,
|
2023-07-14 13:33:46 +02:00
|
|
|
bool dryRun = false,
|
2023-05-26 13:03:38 +02:00
|
|
|
QObject *parent = nullptr,
|
|
|
|
char const *serialInterface = SERIAL_PORT,
|
|
|
|
char const *baudrate = "115200");
|
|
|
|
virtual ~Update() override;
|
2023-08-02 15:47:19 +02:00
|
|
|
bool doUpdate(int &displayIndex, QStringList const &linesToWorkOn);
|
2023-12-15 09:30:02 +01:00
|
|
|
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
|
2023-05-26 13:03:38 +02:00
|
|
|
|
2024-05-15 14:59:08 +02:00
|
|
|
QMap<QString, QString>
|
|
|
|
getInstalledJsonVersions(QStringList const& jsonFileNames =
|
|
|
|
QStringList(
|
|
|
|
QList(
|
|
|
|
std::initializer_list<QString>{
|
|
|
|
QString("etc/psa_config/DC2C_conf.json"),
|
|
|
|
QString("etc/psa_config/DC2C_cash.json"),
|
|
|
|
QString("etc/psa_config/DC2C_device.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print01.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print02.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print03.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print04.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print05.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print06.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print07.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print08.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print09.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print10.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print11.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print12.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print13.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print14.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print15.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print16.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print17.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print18.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print19.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print20.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print21.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print22.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print23.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print24.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print25.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print26.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print27.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print28.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print29.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print30.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print31.json"),
|
|
|
|
QString("etc/psa_config/DC2C_print32.json")})));
|
|
|
|
|
2023-07-14 13:33:46 +02:00
|
|
|
QString branchName() { return m_branchName; }
|
|
|
|
QString const branchName() const { return m_branchName; }
|
|
|
|
|
2023-07-17 16:45:11 +02:00
|
|
|
//QString repositoryPath() { return m_repositoryPath; }
|
|
|
|
//QString const repositoryPath() const { return m_repositoryPath; }
|
2023-07-14 13:33:46 +02:00
|
|
|
|
2023-06-16 16:51:30 +02:00
|
|
|
private:
|
2023-06-22 15:20:21 +02:00
|
|
|
static QString jsonType(enum FileTypeJson type);
|
2023-06-16 16:51:30 +02:00
|
|
|
bool openSerial(int br, QString baudrate, QString comPort) const;
|
|
|
|
void closeSerial() const;
|
2023-07-06 14:13:33 +02:00
|
|
|
bool isSerialOpen() const;
|
2023-06-16 16:51:30 +02:00
|
|
|
bool resetDeviceController() const;
|
|
|
|
QByteArray loadBinaryDCFile(QString filename) const;
|
|
|
|
bool downloadBinaryToDC(QString const &bFile) const;
|
2023-06-22 15:20:21 +02:00
|
|
|
bool updatePrinterTemplate(int templateIdx, QString fname) const;
|
2023-11-21 09:56:36 +01:00
|
|
|
bool updateBinary(QString const &fileToSendToDC);
|
2023-06-22 15:20:21 +02:00
|
|
|
bool updateConfig(QString jsFileToSendToDC);
|
|
|
|
bool updateCashConf(QString jsFileToSendToDC);
|
|
|
|
bool updateDeviceConf(QString jsFileToSendToDC);
|
|
|
|
bool downloadJson(enum FileTypeJson type, int templateIdx,
|
|
|
|
QString jsFileToSendToDC) const;
|
2023-09-09 14:43:46 +02:00
|
|
|
QStringList getDcSoftAndHardWareVersion();
|
2023-12-15 09:30:02 +01:00
|
|
|
QString getFileVersion(QString const& jsonFile);
|
2023-06-27 17:25:23 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void readyReadStandardOutput();
|
|
|
|
void readyReadStandardError();
|
|
|
|
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
2024-02-05 16:28:34 +01:00
|
|
|
void onReportDCDownloadStatus(QString const &status);
|
|
|
|
void onReportDCDownloadSuccess(QString const &msg);
|
|
|
|
void onReportDCDownloadFailure(QString const &errorMsg);
|
2023-05-26 13:03:38 +02:00
|
|
|
};
|
|
|
|
#endif // UPDATE_H_INCLUDED
|