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>
|
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:
|
|
|
|
|
void connectPM3(const QString path, const QString port);
|
2020-04-18 02:01:42 +08:00
|
|
|
|
void setSerialListener(const QString &name, bool state);
|
2020-04-22 16:00:56 +08:00
|
|
|
|
qint64 write(QString data);
|
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;
|
|
|
|
|
signals:
|
2020-04-22 23:13:00 +08:00
|
|
|
|
void PM3StatedChanged(bool st, QString info = "");
|
2020-04-22 16:42:58 +08:00
|
|
|
|
void newOutput(QString output);
|
2020-04-06 23:48:08 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // PM3PROCESS_H
|