2020-04-06 23:48:08 +08:00
|
|
|
|
#ifndef PM3PROCESS_H
|
|
|
|
|
#define PM3PROCESS_H
|
|
|
|
|
|
|
|
|
|
#include <QProcess>
|
2020-04-21 19:12:44 +08:00
|
|
|
|
#include <QThread>
|
2020-04-06 23:48:08 +08:00
|
|
|
|
#include <QString>
|
|
|
|
|
#include <QDebug>
|
2020-04-18 02:01:42 +08:00
|
|
|
|
#include <QTimer>
|
2020-04-07 18:16:00 +08:00
|
|
|
|
#include <QtSerialPort/QSerialPortInfo>
|
|
|
|
|
#include <QtSerialPort/QSerialPort>
|
2021-02-15 18:38:34 +08:00
|
|
|
|
#include <QProcessEnvironment>
|
2021-02-17 01:26:14 +08:00
|
|
|
|
#include <QDir>
|
2020-04-06 23:48:08 +08:00
|
|
|
|
|
2020-08-05 19:08:02 +08:00
|
|
|
|
#include "util.h"
|
|
|
|
|
|
2020-04-06 23:48:08 +08:00
|
|
|
|
class PM3Process : public QProcess
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2020-04-22 23:13:00 +08:00
|
|
|
|
explicit PM3Process(QThread* thread, QObject* parent = nullptr);
|
2020-04-16 00:39:10 +08:00
|
|
|
|
bool waitForReadyRead(int msecs = 2000);
|
2020-04-21 19:12:44 +08:00
|
|
|
|
|
|
|
|
|
void testThread();
|
|
|
|
|
|
|
|
|
|
public slots:
|
2021-02-21 23:00:07 +08:00
|
|
|
|
void connectPM3(const QString& path, const QStringList args);
|
2020-08-13 09:30:47 +08:00
|
|
|
|
void setSerialListener(const QString& name, bool state);
|
2021-02-21 23:00:07 +08:00
|
|
|
|
void setSerialListener(bool state);
|
2020-04-22 16:00:56 +08:00
|
|
|
|
qint64 write(QString data);
|
2021-02-15 18:38:34 +08:00
|
|
|
|
void reconnectPM3();
|
|
|
|
|
void setProcEnv(const QStringList* env);
|
2021-02-17 01:26:14 +08:00
|
|
|
|
void setWorkingDir(const QString& dir);
|
2021-02-22 12:47:55 +08:00
|
|
|
|
void killPM3();
|
2020-04-18 02:01:42 +08:00
|
|
|
|
private slots:
|
|
|
|
|
void onTimeout();
|
2020-04-22 16:42:58 +08:00
|
|
|
|
void onReadyRead();
|
2020-04-11 23:53:06 +08:00
|
|
|
|
private:
|
|
|
|
|
bool isRequiringOutput;
|
2020-04-22 21:14:33 +08:00
|
|
|
|
QString* requiredOutput; // It only works in this class now
|
|
|
|
|
void setRequiringOutput(bool st);// It only works in this class now
|
2020-04-18 02:01:42 +08:00
|
|
|
|
QTimer* serialListener;
|
|
|
|
|
QSerialPortInfo* portInfo;
|
2021-02-15 18:38:34 +08:00
|
|
|
|
QString currPath;
|
2021-02-21 23:00:07 +08:00
|
|
|
|
QString currPort = "";
|
2021-02-15 18:38:34 +08:00
|
|
|
|
QStringList currArgs;
|
|
|
|
|
|
2020-04-18 02:01:42 +08:00
|
|
|
|
signals:
|
2020-08-13 09:30:47 +08:00
|
|
|
|
void PM3StatedChanged(bool st, const QString& info = "");
|
|
|
|
|
void newOutput(const QString& output);
|
2020-08-05 19:08:02 +08:00
|
|
|
|
void changeClientType(Util::ClientType);
|
2020-04-06 23:48:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PM3PROCESS_H
|