ATBUpdateTool/utils.h

47 lines
1.1 KiB
C++

#ifndef UTILS_H_INCLUDED
#define UTILS_H_INCLUDED
#include <QObject>
#include <QString>
#include <QFile>
#include <memory>
#include "interfaces.h"
#include "DCPlugin/include/hwapi.h"
#ifdef PTU5
#define SERIAL_PORT "ttymxc2"
#else
#define SERIAL_PORT "ttyUSB0"
#endif
class Utils : public QObject {
Q_OBJECT
std::unique_ptr<hwinf> m_hw;
char const *m_serialInterface;
char const *m_baudrate;
QFile m_update_ctrl_file;
QFile m_update_ctrl_file_copy;
QTextStream m_in;
QTextStream m_out;
bool m_init;
void updateBinary(char const *fileToSendToDC);
void updatePrinterConf(int nrOfTemplate, char const *fileToSendToDC);
bool finishUpdate(bool finish);
QStringList getOpenLines();
static constexpr QChar SEPARATOR = QChar(',');
public:
explicit Utils(QString update_ctrl_file,
QObject *parent = nullptr,
char const *serialInterface = SERIAL_PORT,
char const *baudrate = "115200");
virtual ~Utils() override;
bool doUpdate();
};
#endif // UTILS_H_INCLUDED