qt/LedOK/communication/network.h
2022-01-04 18:11:48 +08:00

87 lines
2.6 KiB
C++

#ifndef NETWORK_H
#define NETWORK_H
#include <QObject>
#include <QUdpSocket>
#include <QNetworkInterface>
#include <QList>
#include <wDevicesManager/ledcard.h>
#include <communication/hpptclient.h>
#include <globaldefine.h>
#include <QTimer>
#include<windows.h>
//元亨
class NetComm : public QObject
{
Q_OBJECT
public:
NetComm(QObject *p = nullptr);
~NetComm();
QHostAddress getHostIPV4Address();
STREAM_PACKET LedOkMakeStreamPacket(int iComType,int iLen,unsigned char *ucBuf,QString str);
QList<LedCard *> LedCardList;
public:
LedCard * GetLedCardPoint()const {return m_pLedCard;}
void SetLedCardPoint(LedCard * p){m_pLedCard=p;}
void StartUpdCheck();
void StopUpdCheck();
void HttpGetFuncByPort(QString strFunc,QString strIp);
void CheckSpecifyIpRange(QString strFromIp,QString strToIp);
void CheckSpecifyIp(QString strIp);
void RestoreLedCardIpByUdpCmdBefore(QString strNetworkName);
void RestoreLedCardIpToDhcpByUdpCmd(QString strNetworkName);
void StopAllCheck();
void ClearAllLedcardList();
static DWORD WINAPI send(void *);
public slots:
void OnStartUdpTimer(bool b);
signals:
// void LedCardChanged(LedCard *);
void sigwDeviceItemHttpPost(LedCard *);
void addLedCard(LedCard *);
void ClearHeartbeatFlagByUdp(LedCard *);
void sigGetSpecifyIpResponse(LedCard *);
void sigGetSpecifyIpTimerOut();
private slots:
void onUdpTimeout();
void onSpecifyIpTimeout();
void UdpRecveive();
void CheckControllersInLanByUdpCmd();
void CheckControllersInLanByUdp255Cmd();
void CheckControllersInLanByUdpSelfBroadcastCmd();
void OnProHttpGetResponse(QString url, QByteArray data);
void RestoreLedCardIpByUdpCmd();
void RestoreLedCardIpToDhcpByUdpCmd();
private:
QString m_strCardId;
qint32 m_iWidth;
LedCard *m_pLedCard;
QString m_strCurSpecifyIp="";
int m_intSpecifyIpGetNumber=0;
QString m_strDirectlyConnectNetworkName="";
private:
QUdpSocket *udpSocket=nullptr;
int m_port=31296;
QTimer *m_pUdpTimer=nullptr;
HpptClient *pHpptClient = nullptr;
QString m_strUrl="";
QTimer *m_pHttpGetTimer=nullptr;
QTimer *m_pGetSpecifyIpTimer=nullptr;
int m_UdpTimerInterval=500;
int m_iEnableQuitFlag=0;
void JieXiQJsonObjectOfLedCardInfo(const QJsonObject &subObj,const QString &strIp);
void JieXiQJsonObjectOfLedCardInfoOld(const QString &strId,const QString &strIp);
// QListObject <QUdpSocket > myUdpSocketList;
// QList<QHostAddress *> ipAddressesList = QNetworkInterface::allAddresses();
};
extern NetComm *p_globaNetComm;
#endif // NETWORK_H