BatteryMonitor/appserial.h

53 lines
1.1 KiB
C
Raw Normal View History

2024-10-31 16:48:38 +08:00
#ifndef APPSERIAL_H
#define APPSERIAL_H
/**/
#include <QObject>
#include <QAbstractNativeEventFilter>
#include <windows.h>
class QSerialPort;
class AppSerial : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
public:
explicit AppSerial(QObject *parent = nullptr);
~AppSerial();
public:
QSerialPort *m_SerialPort;
private:
static AppSerial* m_comChange;
HWND m_hwnd;
enum DataType{
TypeRecvData,
TypeSendData
};
public:
// static Serial* getInstance();
static QStringList getAvailablePort();
void setHWND(HWND hwnd);
protected:
2024-11-05 17:00:41 +08:00
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
2024-10-31 16:48:38 +08:00
signals:
/**
* @brief
* @param name
* @param flag true false
*/
void comChangeStatus(QString name, bool flag);
void sig_RecvSerialData(QByteArray recvData, int dataType);
public slots:
void slot_RecvSerialData();
void slot_SendSerialData(const QByteArray &sendData);
};
#endif // APPSERIAL_H