You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB
C++

#ifndef UDPDATATHREAD_H
#define UDPDATATHREAD_H
#include <QObject>
#include <QThread>
#include "udpsocketworker.h"
typedef enum {
SIGNAL_EMPTY = 0,
SIGNAL_SN , //SN号
SIGNAL_DONE , //成功
SIGNAL_CLOSE , //关闭
SIGNAL_BEATSRC, //注KEY状态
SIGNAL_BEATDST //外挂软件状态
}SIGNALTYPE;
#define CONSTHEAD 59 //数据头
class UdpDataHandler : public QObject
{
Q_OBJECT
public:
UdpDataHandler(QObject *parent = nullptr);
~UdpDataHandler();
// 循环发送产品SN号
void sendSnId(const QString &data);
// 停止发送产品SN号
void sendStop();
// 发送关闭信号
void sendClose();
// 停止发送关闭信号
void stopClose();
signals:
// 连接状态信号
void GetConnStatusSig(bool);
// 注KEY是否完成信号
void GetDoneSig(bool);
private slots:
void recvData(const QByteArray &data);
void checkConnectSlot();
private:
QThread *m_workerThread;
UdpSocketWorker *m_udpWorker;
QHostAddress m_hostAddr;
QTimer *m_checkConnectTimer;
// 判断注KEY软件状态
std::atomic<bool> m_connectStatus;
volatile bool m_isSending;
QString m_currSn;
};
#endif // UDPDATATHREAD_H