qt/ledset/globalfunc.h
2023-09-01 16:17:33 +08:00

162 lines
4.8 KiB
C++

#ifndef GLOBALFUNC_H
#define GLOBALFUNC_H
#include <QtEndian>
#include "pcaprethread.h"
struct Head {
byte pre[2]{0x55, 0x55};
byte ver{1};
byte srv{0};
quint16_be len{0};
byte tgtAddr[4]{0xff, 0xff, 0xff, 0xff};
byte srcAddr[4]{0, 0, 0, 0};
byte ptr[4]{0, 0, 0, 0};
byte ans[2]{0, 0};
quint32_be chk{0};
byte bodyh[4]{0, 0, 0, 0};
quint16_be bodylen{0};
};
struct Msg1024 : Head {
byte body[1024-sizeof(Head)]{0};
};
static int fi = 0;
inline int ie(int size = 1) {
fi = size;
return 0;
}
inline int ipp(int size = 1) {
auto rtn = fi;
fi += size;
return rtn;
}
enum enum_rcvCardType{
enum_xixun_sync = 0,
enum_xixun_async = 1,
enum_zrf = 2,
enum_mxe
};
struct HeadMap {
byte pre = ipp(2);
byte ver = fi++;
byte srv = fi++;
byte len = ipp(2);
byte tgtAddr = ipp(4);
byte srcAddr = ipp(4);
byte ptr = ipp(4);
byte ans = ipp(2);
byte chk = ipp(4);
byte body = ipp(4);
byte bodylen = ipp(2);
byte end = fi;
};
//added by alahover -s 20230822
struct HeadMap_ZRF {
quint16 pre = ie(2);
quint16 tgtAddr = ipp(6);
quint16 srcAddr = ipp(6);
quint16 protcolFlag = ipp(2);
quint16 pkgType = fi++;
quint16 reserve = fi++;
quint16 netPort = fi++;
quint16 rcvIndex = fi++;
quint16 reserve1 = fi++;
quint16 end = fi;
};
struct St_Zrf_Cmd_Param{
quint16 paramType = ie(19);
quint16 rcvCardPosH = fi++;
quint16 rcvCardPosL = fi++;
quint16 reserve2 = fi++;
quint16 cmd = ipp(4);
quint16 flashSentor = ipp(4);
quint16 flashPage = ipp(4);
quint16 reserve3 = ipp(4);
quint16 paramData = ipp(256);
quint16 end = fi;
};
struct St_Zrf_Base_Param{
quint16 b0_RP = ie(0); //模组信号极性
quint16 b1_xiaoyingTime = ipp(1); //行消影时间
quint16 b2_line_xytime = ipp(1); //行消影时间
quint16 b3_rows1Group = ipp(1); //
quint16 b4_cols1Group = fi++;
quint16 b5_scanNum = fi++;
quint16 b6_emptyPointNum = fi++;
quint16 b7_colorIndex = fi++;
quint16 b8_dataOutModle = fi++;
quint16 b9_brightStatic = fi++;
quint16 b10_brightRed = fi++;
quint16 b11_brightGreen = fi++;
quint16 b12_brightBlue = fi++;
quint16 b13_icType = fi++;
quint16 b14_icParma = fi++;
quint16 b15_redIgain = fi++;
quint16 b16_greenIgain = fi++;
quint16 b17_blueIgain = fi++;
quint16 b18_clkFreq = fi++;
quint16 b19_clkDutyCycle = fi++;
quint16 b20_pwmIcGrayClk = fi++;
quint16 b21_grayLevelMultFreq = fi++;
quint16 b22_MultFreqMode = fi++;
quint16 b23_reserve = fi++;
quint16 b24_freshRate = ipp(2);
quint16 b26_syncGraphicsCard = fi++;
quint16 b27_Ldq = ipp(2);
quint16 b29_reserve = fi++;
quint16 b30_pwmMultFreq = fi++;
quint16 b31_rcvCardCols = ipp(2);
quint16 b33_emptyRowMode = fi++;
quint16 b34_emptyRowPos = fi++;
quint16 b35_xiaoYingEndTime = fi++;
quint16 b36_RowIcParam = fi++;
quint16 b37_reserve = fi++;
quint16 b38_hub1to32Area = ipp(32);
quint16 b70_reserve = fi++;
quint16 b71_imgArea1to32Param = ipp(96);
quint16 b167_syncPreTime = fi++;
quint16 b168_reserve = fi++;
quint16 b169_redIcParam1 = ipp(2);
quint16 b171_redIcParam2 = ipp(2);
quint16 b173_redIcParam3 = ipp(2);
quint16 b175_greenIcParam1 = ipp(2);
quint16 b177_greenIcParam2 = ipp(2);
quint16 b179_greenIcParam3 = ipp(2);
quint16 b181_blueIcParam1 = ipp(2);
quint16 b183_blueIcParam2 = ipp(2);
quint16 b185_blueIcParam3 = ipp(2);
quint16 b187_redIcParam4 = ipp(2);
quint16 b189_greenIcParam4 = ipp(2);
quint16 b191_blueIcParam4 = ipp(2);
quint16 b193_reserve = fi++;
quint16 end = fi;
};
struct St_MiaoDian_Param{
quint16 scanIndex = ie(64); //模组信号极性
quint16 PixelPos = ipp(448); //行消影时间
quint16 end = fi; //行消影时间
};
extern HeadMap headMap;
extern HeadMap_ZRF headMap_zrf;
extern St_Zrf_Base_Param st_zrf_base_param;
extern St_Zrf_Cmd_Param st_zrf_cmd_param;
extern St_MiaoDian_Param st_miaodian_param;
extern byte *sepas;
extern pcap *pcapSend;
class PcapReThread;
extern PcapReThread *reThd;
extern QString gFileHome;
QByteArray getNetDev(QWidget *parent, QByteArray, bool);
inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) {
return reThd->sendMsgNet(msg, size, id, timeout, callback, waitingDlg);
}
inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function<void(int code, const QByteArray)> callback, WaitingDlg *waitingDlg = 0) {
return sendMsg((byte*)msg.data(), msg.size(), id, timeout, callback, waitingDlg);
}
int sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0);
#endif // GLOBALFUNC_H