diff --git a/ledset/EffFrefr.dll b/ledset/EffFrefr.dll new file mode 100644 index 0000000..4f134fb Binary files /dev/null and b/ledset/EffFrefr.dll differ diff --git a/ledset/EffFrefr.lib b/ledset/EffFrefr.lib new file mode 100644 index 0000000..9ae5fd9 Binary files /dev/null and b/ledset/EffFrefr.lib differ diff --git a/ledset/efffrefr.h b/ledset/efffrefr.h new file mode 100644 index 0000000..e4709e7 --- /dev/null +++ b/ledset/efffrefr.h @@ -0,0 +1,35 @@ +#ifndef EFFFREFR_H +#define EFFFREFR_H + + + +#include + +#if defined(EFFFREFR_LIBRARY) +# define EFFFREFR_EXPORT Q_DECL_EXPORT +#else +# define EFFFREFR_EXPORT Q_DECL_IMPORT +#endif + + +class EFFFREFR_EXPORT EffFrefr +{ +public: + EffFrefr(); +}; +extern "C" Q_DECL_EXPORT float Get_Eff(int L/*小数权值*/ , int Npwm/*灰度位宽*/); +extern "C" Q_DECL_EXPORT float Get_Frefr(int L/*小数权值*/ , int Npwm/*灰度位宽*/ , int fdclk/*移位时钟频率*/ , int N/*扫描长度*/ , int H/*扫描类型*/ , int K/*倍频*/ ); +extern "C" Q_DECL_EXPORT int Make_GryModulationTable(int L/*小数权值*/ , int Npwm/*灰度位宽*/, char * cFilePathAndName); +extern "C" Q_DECL_EXPORT int Make_GryModulationTableFromJsonFile( char * cJsonFile, char * cBinModuleBuf); +extern "C" Q_DECL_EXPORT int Make_XiaoYinTime(int L/*小数权值*/ , int Npwm/*灰度位宽*/ , int fdclk/*移位时钟频率*/ , int N/*扫描长度*/ , int H/*扫描类型*/ , int K/*倍频*/ ); +extern "C" Q_DECL_EXPORT int Make_GryModulationTableFromJsonFile( char * cJsonFile , char * cBinModuleBuf); +extern "C" Q_DECL_EXPORT int Get_ScanIndexFromJsonFile(char * cJsonFile , char * cScanIndexBuf, int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_ScanIndexFromJsonObject(QJsonObject obj , char * cScanBuf, int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_MiaoDianFromJsonFile(char * cJsonFile , char * cMiaoDianBuf , int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_MiaoDianFromJsonObject(QJsonObject obj , char * cJsonFile, int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_JiLianFromJsonFile(char * cJsonFile , char * cJiLianBuf, int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_JiLianFromJsonObject(QJsonObject obj , char * cJiLianBuf, int FpgaVer); +extern "C" Q_DECL_EXPORT int Get_DriverIcParamFromInputParam(char * cJsonFile , int * inParamBuf, int inLen ,int IC_code , int * outParamBuf); +extern "C" Q_DECL_EXPORT int Get_DriverIcParamFromJsonFile(char * cJsonFile , int IC_code , int * outParamBuf); +extern "C" Q_DECL_EXPORT int Get_DriverIcParamFromJsonObject(QJsonObject obj , int IC_code , int * outParamBuf); +#endif // EFFFREFR_H diff --git a/ledset/expertsmartpointsetwin.cpp b/ledset/expertsmartpointsetwin.cpp index 525999e..9f98b39 100644 --- a/ledset/expertsmartpointsetwin.cpp +++ b/ledset/expertsmartpointsetwin.cpp @@ -824,8 +824,8 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg); - if(res==5) {QMessageBox::critical(this, "Error", tr("请求超时")); return;} - else if(res) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} + if(res.code==5) {QMessageBox::critical(this, "Error", tr("请求超时")); return;} + else if(res.code) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} waitingDlg->close(); } else if(idx==1) { DataPolarity = fdDataPolarity->checkedId(); @@ -905,10 +905,10 @@ int ExpertSmartPointSetWin::send(uint ptr, const std::initializer_list &da auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); auto res = sendMsgSync(msg, 0x1EA, 10000, waitingDlg); - if(res==5) QMessageBox::critical(this, "Error", tr("请求超时")); - else if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); + if(res.code==5) QMessageBox::critical(this, "Error", tr("请求超时")); + else if(res.code) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); else waitingDlg->close(); - return res; + return res.code; } void ExpertSmartPointSetWin::save() { @@ -960,8 +960,28 @@ void ExpertSmartPointSetWin::save() { expertWin->fdChipType->setText(ChipType); expertWin->fdDecodeMode->setText(DecodeMode); + QString strLine1,strLine2,strLine3,strLine4; + int iLine_1=(ColorMap & 0b11000000) >> 6; + int iLine_2=(ColorMap & 0b00110000) >> 4; + int iLine_3=(ColorMap & 0b00001100) >> 2; + int iLine_4=(ColorMap & 0b00000011) >> 0; + switch(iLine_1) { + case 0b00: strLine1="黑"; break; case 0b01: strLine1="红"; break; case 0b10: strLine1="绿"; break; case 0b11: strLine1="蓝"; break; } + switch(iLine_2) { + case 0b00: strLine2="黑"; break; case 0b01: strLine2="红"; break; case 0b10: strLine2="绿"; break; case 0b11: strLine2="蓝"; break; } + switch(iLine_3) { + case 0b00: strLine3="黑"; break; case 0b01: strLine3="红"; break; case 0b10: strLine3="绿"; break; case 0b11: strLine3="蓝"; break; } + switch(iLine_4) { + case 0b00: strLine4="黑"; break; case 0b01: strLine4="红"; break; case 0b10: strLine4="绿"; break; case 0b11: strLine4="蓝"; break; } + + expertWin->fdDataGroupColor->setText(strLine1+strLine2+strLine3+strLine4); + expertWin->fdChouDian->setText(""); + expertWin->fdCardWidth->setValue(ModuleWidth); expertWin->fdCardHeight->setValue(ModuleHeight); + //added by alahover -s 20230830 + expertWin->changeValueBySmart(); + //added by alahover -o 20230830 auto appDir = QApplication::applicationDirPath(); QDir(appDir).mkdir("ModuleFiles"); diff --git a/ledset/expertwin.h b/ledset/expertwin.h index 6a494b3..a39bb7f 100644 --- a/ledset/expertwin.h +++ b/ledset/expertwin.h @@ -6,6 +6,7 @@ #include #include #include +#include #include class ExpertWin : public BaseWin { @@ -19,7 +20,7 @@ public: int screenWidth{1280}, screenHeight{720}; double rate{1}; - QLabel *fdModuleWidth, *fdModuleHeight, *fdGroupNum, *fdScanNum; + QLabel *fdModuleWidth, *fdModuleHeight, *fdGroupNum, *fdScanNum, *fdDataGroupColor ,*fdChouDian; QLabel *fdChipType, *fdDecodeMode; JObj cfg; JObj mBox { @@ -42,8 +43,20 @@ public: QComboBox *fdDirection, *fdSectorCount; QRadioButton *fdAdvacned; + //added by alahover -s 20230830 + QPushButton *btnReadBack,*btn_OpenCfg,*btn_SaveCfg,*btn_SaveMap,*btn_SendData,*btn_GuhuaData; + QTabWidget * m_tab; + QSpinBox *spinGclkXw,*spinGclkZkb,*spinLineNs,*spinLineWz,*spinLineXy,*spinPointsOnePort; + QComboBox *cbDCLKf,*cbDclkXw, *cbDclkZkb,*freshBeiLv,*cbGCLKf,*cbGryLevel,*cbNoSign,*cbStb,*cbDE,*cbABC,*cbXiaoYinDianPing,*cbSTB,*cbSRowOut; + QLabel * m_ctrlFreshRate,*m_ctrlBrightEff,*m_ctrlMinOE; + QCheckBox * checkSyncXianKa,*checkJianLiang,*checkDoubleCopy,*checkDsignalAsCLk; + + + //added by alahover -o 20230830 //added by alahover -s 20230817 int m_iRcvCardType; + int m_tab1firstClick=0; + int m_tab2firstClick=0; struct St_Rcv_Pos{ unsigned char imgXL8 = 0;//接收卡图像列起始低八位 @@ -60,7 +73,7 @@ public: /////////////////描点参数成员变量//////////////// unsigned char b0_7 = 0b0; //DAT信号 方式 0:高有效(共阴) 1:低有效(共阳); unsigned char b0_6 = 0b0; //STB信号有效方式 0:正向 1:反向; - unsigned char b0_5 = 0b0; //OE信号有效0 :低有 效1 :高有效; + unsigned char b0_5 = 0b1; //OE信号有效0 :低有 效1 :高有效; unsigned char b0_4 = 0b0; //行有效方式:0 :低有效1 :高有效; unsigned char b0_3_1 = 0b000; //行译码方式bit2~bit0与地址0x01 bit7~bit6 表示 bit4~bit3。0:普通,常规138译码;00001:SM5266;00010:SM5366;01000::ICN2013;00100:无译码;00101:595译码;0110::5958译码;01110:ICND2018;其他:保留; unsigned char b0_0 = 0b0; //0 :全色;1 :单双色; @@ -112,13 +125,14 @@ public: // unsigned char b18 = (b18_7_4<<4 & 0b11110000) | (b18_3_0 & 0b00001111); //数据时钟相位及占空比 unsigned char b19_7_4 = 0b0000; //输出数据时钟相位:0000:0 度; 0001:- 90 度; 0010:+90 度; 其他暂时保留; - unsigned char b19_3_0 = 0b0101; //输出数据时钟占空比:0000:50%; 0001:25%; 0010:75%; 其他暂时保留; + unsigned char b19_3_0 = 0b0000; //输出数据时钟占空比:0000:50%; 0001:25%; 0010:75%; 其他暂时保留; // unsigned char b19 = (b19_7_4<<4 & 0b11110000) | (b19_3_0 & 0b00001111); //PWM芯片灰度时钟周期 unsigned char b20 = 0x20; //PWM 类智能芯片的灰度时钟周期设定:MBI5042 芯片,软件计算; MY9268,MBI5050,用户设定;设定有效值范围 4~128, 其他不支持; //灰度等级及倍频模式 - unsigned char b21_7_5 = 0b000; //输出数据时钟相位:0000:0 度; 0001:- 90 度; 0010:+90 度; 其他暂时保留; - unsigned char b21_4_0 = 0b10111; //输出数据时钟占空比:0000:50%; 0001:25%; 0010:75%; 其他暂时保留; + unsigned char b21_7_5 = 0b000; //倍频模式: 000:普通模式; 001:2 倍频; 010:4 倍频; 011:8 倍频; 100:16 倍频; 101:MBI5042 倍频模式,4096; 110:MBI5042 倍频模式,16384; 110:MBI5042 倍频模式,32768 + unsigned char b21_4_0 = 0b11111; //灰度等级选择0:无灰度1:无 OE8 级2:无 OE16 级3:无 OE32 级4:无 OE64 级5:正常 16 级6:高亮 16 级7:正常 32 级8:高亮 32 级9:正常 64 级10:高亮 64 级11:正常 128 级12:高亮 128 级13:正常 256 级14:高亮 256 级15:正常 512 级16:高亮 512 级 + //17:正常 1024 级 18:高亮 1024 级19:低亮 2048 级20:正常 2048 级21:高亮 2048 级22:低亮 4096 级23:正常 4096 级24:高亮 4096 级25:低亮 8192 级26:正常 8192 级27:高亮 8192 级28:低亮 16384 级29:正常 16384 级30:正常 32768 级31:正常 65536 级 // unsigned char b21 = (b21_7_5 << 5 & 0b11100000) | (b21_4_0 & 0b00011111); //倍频模式 、低灰优化 unsigned char b22_7_6 = 0b00; //倍频模式:00:无倍频;01:VPWM;10:VPWM2;11:VPWM3; @@ -153,8 +167,8 @@ public: // unsigned char b29 = (b29_7_4<<4 & 0b11110000) | (b29_3_2<<2 &0b00001100) | (b29_1_0 & 0b00000011); unsigned char b30 = 0x00; //DPWM 芯片刷新倍频数 ICND2055/ICND2065 刷新倍频数 b7~b0 - unsigned char b31 = 0x00; //接收卡带载列数低字节 - unsigned char b32 = 0x80; //接收卡带载列数高字节 + unsigned char b31 = 0x80; //接收卡带载列数低字节 + unsigned char b32 = 0x00; //接收卡带载列数高字节 //空行模式 unsigned char b33_7_4 = 0b0000; //偶数图像区空行4bit @@ -223,45 +237,128 @@ public: 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F}; - unsigned char m_pixelPos[1024][2];//描点参数中一点占用 2字节(8bit 列 + 8 bit 行) + unsigned char m_pixelPos[2048][2];//描点参数中一点占用 2字节(8bit 列 + 8 bit 行) /////////////////排序参数成员变量//////////////// - unsigned char p0_cardIndexInNet;//当前卡在网线内的序号 - unsigned char p1_SendCardCode;//当前网线所在的发送卡编号 - unsigned char p2_netIndexInSendCard;//当前网线所在发送卡输出口编号 - unsigned char p3_fenXianNum;//当前分线号 - unsigned char p4_rcvCardsNumInNet;//当前网线内接收卡总数 - unsigned char p5_netScreenIndex;//当前网线所在屏号 - unsigned char p6_reserve;//保留 - unsigned char p7_reserve1;//保留 + unsigned char p0_cardIndexInNet=0;//当前卡在网线内的序号 + unsigned char p1_SendCardCode=0;//当前网线所在的发送卡编号 + unsigned char p2_netIndexInSendCard=0;//当前网线所在发送卡输出口编号 + unsigned char p3_fenXianNum=0;//当前分线号 + unsigned char p4_rcvCardsNumInNet=0;//当前网线内接收卡总数 + unsigned char p5_netScreenIndex=0;//当前网线所在屏号 + unsigned char p6_reserve=0;//保留 + unsigned char p7_reserve1=0;//保留 St_Rcv_Pos p8_st_rcv_pos[256]; - unsigned short p_x[256]; - unsigned short p_y[256]; - unsigned short p_w[256]; - unsigned short p_h[256]; - unsigned short p_posNum[256]; + unsigned short p_x[256]={0}; + unsigned short p_y[256]={0}; + unsigned short p_w[256]={256}; + unsigned short p_h[256]={1024}; + unsigned short p_posNum[256]={0}; /////////////////gamma参数成员变量//////////////// unsigned short g_all[256]; unsigned short g_red[256]; unsigned short g_green[256]; unsigned short g_blue[256]; + //其他中间成员变量 + unsigned char ucZheHuiCiShu;//折回次数 + int m_pwmFlag=0; }; zrf_rcv_card zrf_rcv_obj; void classToBaseMsg(); void classToGammaMsg(int iColorType,quint8 flashPage); - void classToPaiXuSMsg(quint8 flashPage,bool bInitP8_st_rcv_pos); + void classToPaiXuSMsg(quint8 flashPage); void classToMiaoDianMsg(quint8 flashPage); void baseMsgToClass(quint8 * data); void gammaMsgToClass(quint8 * data , quint8 flashPage); - void paiXuMsgToClass(quint8 * data , quint8 flashPage,bool bInitFromP8_st_rcv_pos); - void miaoDianMsgToClass(quint8 * data); + void paiXuMsgToClass(quint8 * data , quint8 flashPage ); + void miaoDianMsgToClass(quint8 * data, quint8 flashPage); + //added by alahover -s 20230830 + void changeValueBySmart(); + void changeValueByEffectControler(); + void SetEffectControlerValueByClass(); + int GetIcTypeIndexFromName(QString strName); + int GetRowYiMaIndexFromName(QString strName); + //added by alahover -o 20230830 //added by alahover -o 20230823 protected: void closeEvent(QCloseEvent *) override; }; + + +#define MACRO_FUNC_SEND_PARAM(TIP_MESSAGE,FUNC,SEND_FLASHPAGE_NUM,FLASH_ADDR) \ +for(int iSendCount=0;iSendCount=2) {QMessageBox::critical(this, "提示", tr(TIP_MESSAGE)+tr("超时")); return;} }\ + else if(res.code) {if(i>=2) {QMessageBox::critical(this, "Error", QString(tr("sendMsgSync发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} }\ + else {\ + int ioffset=headMap_zrf.paramStart+st_zrf_rb_param.param;\ + QByteArray return_msg=res.msg.mid(ioffset,256);\ + int iCmpLen=256;\ + if(flashPage == 0x00)\ + iCmpLen=st_zrf_base_param.end;\ + else \ + iCmpLen=256;\ + if(memcmp((quint8 *)zrf_param_msg.data(),(quint8 *)return_msg.data(),iCmpLen)==0)\ + {\ + qDebug()<< tr(TIP_MESSAGE)+tr("成功")<sendMsgNet((byte*)msg.data(), msg.size(), id, timeout, [=, &loop, &resmsg](int code, const QByteArray data) { + resmsg = data; loop.exit(code); - }, waitingDlg); + }, true, waitingDlg); if(res==0) res = loop.exec(QEventLoop::ExcludeUserInputEvents); if(res && waitingDlg) waitingDlg->close(); - return res; + return {res, resmsg}; } QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) { @@ -145,3 +148,47 @@ QByteArray getNetDev(QWidget *parent, QByteArray def, bool justReturnIfHave) { return name; } } + +//added by alahover -s 20230829 +#define GAMMA_GRAY_DEPTH_NUM (256) +void GammaGen(unsigned short pGammaDataBuffer[],float fGamma,unsigned int uiGray) +{ + unsigned int i=0; + + float fGray=0; + float k=0; + fGray=(float)uiGray; + k=(fGray/GAMMA_GRAY_DEPTH_NUM); + + for (i=0;i=uiGray) + { + pGammaDataBuffer[i]=(unsigned int)uiGray-1; + } + } + if (0) + printf("G[%d]=%d\r\n",i,pGammaDataBuffer[i]); + } +} +//added by alahover -o 20230829 diff --git a/ledset/globalfunc.h b/ledset/globalfunc.h index bcfbf8b..06e2fa4 100644 --- a/ledset/globalfunc.h +++ b/ledset/globalfunc.h @@ -52,32 +52,49 @@ struct HeadMap { }; //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 pre = ie(2);//0 + quint16 tgtAddr = ipp(6);//2 + quint16 srcAddr = ipp(6);//8 + quint16 protcolFlag = ipp(2);//14 + quint16 pkgType = fi++;//16 + quint16 reserve = fi++;//17 + quint16 rcvIndex = fi++;//18 + quint16 netPort = fi++;//19 + quint16 end = fi;//20 + quint16 paramStart = fi;//20 +}; +//added by alahover -s 20230825 +struct St_Zrf_rb_Param { + quint16 rbParamType = ie(1); + quint16 deviceNameLen = fi++; + quint16 deviceName = ipp(11); + quint16 deviceVerLen = fi++; + quint16 deviceVer = ipp(8); + quint16 posInfoLen = fi++; + quint16 posInfo = ipp(8); + quint16 statusInfoLen = fi++; + quint16 statusInfo = ipp(16); + quint16 param = ipp(256); quint16 end = fi; }; +//added by alahover -s 20230825 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 reserve1 = ie(1);//0 + quint16 paramType = fi++;//1 + quint16 rcvCardPosH = fi++;//2 + quint16 rcvCardPosL = fi++;//3 + quint16 reserve2 = fi++;//4 + quint16 cmd = ipp(4);//8 + quint16 flashSentor = ipp(4);//12 + quint16 flashPage = ipp(4);//16 + quint16 reserve3 = ipp(4);//20 + quint16 param = ipp(256);//21 + quint16 reserve4 = ipp(4); quint16 end = fi; }; struct St_Zrf_Base_Param{ - quint16 b0_RP = ie(0); //模组信号极性 + quint16 b0_RP = ie(1); //模组信号极性 quint16 b1_xiaoyingTime = ipp(1); //行消影时间 quint16 b2_line_xytime = ipp(1); //行消影时间 quint16 b3_rows1Group = ipp(1); // @@ -129,7 +146,6 @@ struct St_Zrf_Base_Param{ quint16 b187_redIcParam4 = ipp(2); quint16 b189_greenIcParam4 = ipp(2); quint16 b191_blueIcParam4 = ipp(2); - quint16 b193_reserve = fi++; quint16 end = fi; }; @@ -140,6 +156,7 @@ struct St_MiaoDian_Param{ }; extern HeadMap headMap; extern HeadMap_ZRF headMap_zrf; +extern St_Zrf_rb_Param st_zrf_rb_param;//added by alahover 20230825 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; @@ -148,14 +165,19 @@ extern pcap *pcapSend; class PcapReThread; extern PcapReThread *reThd; extern QString gFileHome; +extern void GammaGen(unsigned short pGammaDataBuffer[],float fGamma,unsigned int uiGray);//added by alahover 20230829 QByteArray getNetDev(QWidget *parent, QByteArray, bool); inline int sendMsg(const byte *msg, int size, int id, qint64 timeout, std::function callback, WaitingDlg *waitingDlg = 0) { - return reThd->sendMsgNet(msg, size, id, timeout, callback, waitingDlg); + return reThd->sendMsgNet(msg, size, id, timeout, callback, false, waitingDlg); } inline int sendMsg(QByteArray &msg, int id, qint64 timeout, std::function 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); +struct SyncResp { + int code = 0; + QByteArray msg; +}; +SyncResp sendMsgSync(QByteArray &msg, int id, qint64 timeout, WaitingDlg *waitingDlg = 0); #endif // GLOBALFUNC_H diff --git a/ledset/ledset.pro b/ledset/ledset.pro index 80838e8..830cedb 100644 --- a/ledset/ledset.pro +++ b/ledset/ledset.pro @@ -51,6 +51,8 @@ LIBS += -L$$PWD/npcap-sdk-1.13/Lib/\ -lwpcap\ -lpacket +LIBS += -L$$PWD -lefffrefr + RESOURCES += res.qrc SOURCES += \ @@ -78,6 +80,7 @@ HEADERS += \ basewin.h \ brightwin.h \ crc.h \ + efffrefr.h \ expertboxlayoutwin.h \ expertscreenconnwin.h \ expertsmartpointsetwin.h \ diff --git a/ledset/mainwin.cpp b/ledset/mainwin.cpp index fd65f4f..b93ce7e 100644 --- a/ledset/mainwin.cpp +++ b/ledset/mainwin.cpp @@ -235,17 +235,31 @@ MainWin::MainWin() { }); reThd->addMultiCallback(0x105B14, [=](int, const QByteArray data) { auto rr = table->rowCount(); - table->setRowCount(rr+1); - int virtualVCM = *(quint8*)(data.data()+headMap_zrf.netPort); unsigned short ver = *(quint16_be *)(data.data()+headMap_zrf.protcolFlag); unsigned char pkgType = *(quint8 *)(data.data()+headMap_zrf.pkgType); if(ver!=0x105B || pkgType != 0x14) return; + auto strDeviceName = QString(QLatin1String(data.data()+headMap_zrf.paramStart+st_zrf_rb_param.deviceName, 9)); + for(int i=0;itext(i,1)==strDeviceName) { + rr = i; + goto end; + } + table->setRowCount(rr+1); + end: + char cDevicaNameVer[8]; + memcpy(cDevicaNameVer,(char *)data.data()+headMap_zrf.paramStart+st_zrf_rb_param.deviceVer,8); + QString strDeviceVer = QString(QLatin1String(cDevicaNameVer)); + strDeviceVer=strDeviceVer.left(8); + + int virtualVCM = *(quint8*)(data.data()+headMap_zrf.netPort)+1; + int rcvIdex = *(quint8*)(data.data()+headMap_zrf.rcvIndex)+1; + if(rcvIdex > maxNetPort_zrf) maxNetPort_zrf = rcvIdex; table->setData(rr, "type", enum_zrf)->setText(tr("PC虚拟卡V1.0")); - table->setText(rr, "name", tr("网口:")+QString::number(virtualVCM)); + table->setText(rr, "name", strDeviceName); table->setText(rr, "link", "千兆网直连"); - table->setText(rr, "vcsNum", QString::number(*(quint8*)(data.data()+headMap_zrf.rcvIndex))); + table->setText(rr, "vcsNum", QString::number(maxNetPort_zrf)); table->setText(rr, "netPorts", "P:"+QString::number(virtualVCM)); - table->setText(rr, "info", "备注:可直接配屏,无需发送卡"); + table->setText(rr, "info", "版本: "+strDeviceVer+" [备注:可直接配屏,无需发送卡]"); + if(rr==0) table->selectRow(0); }); getCard(); } @@ -278,8 +292,8 @@ void MainWin::getCard() { if(! err.endsWith("(2150891551)")) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); } //modified by alahover -s 20230822 - //查询105B协议类型ZRF版本fpga的接收卡, 0x105B14 表示是zrf协议类型并且是回读数据包 - msg = QByteArray::fromHex("5555 001122334455 001122334455 105A 13 00 00 00 00 e0 ff ff 00 f2 f2 f2 f2 00 00 00 00 20 20 20 20 00 00 00 00"); + //查询105B协议类型ZRF版本fpga的接收卡, 0x105B1400 表示是zrf协议类型并且是回读数据包 + msg = QByteArray::fromHex("5555 001122334455 001122334455 105A 13 00 00 00 00 e0 ff ff 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); res = pcap_sendpacket(pcapSend, (const u_char *)msg.data(), msg.size()); if(res) { QString err = pcap_geterr(pcapSend); diff --git a/ledset/mainwin.h b/ledset/mainwin.h index b49da2b..afc020c 100644 --- a/ledset/mainwin.h +++ b/ledset/mainwin.h @@ -14,6 +14,7 @@ public: QByteArray net_name; Table *table{0}; QUdpSocket mUdpSocket; + int maxNetPort_zrf = 0; public slots: void getCard(); diff --git a/ledset/pcaprethread.cpp b/ledset/pcaprethread.cpp index a14b866..53efbb3 100644 --- a/ledset/pcaprethread.cpp +++ b/ledset/pcaprethread.cpp @@ -13,7 +13,7 @@ PcapReThread::~PcapReThread() { pcap_close(pcap); } -int PcapReThread::sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, WaitingDlg *waitingDlg) { +int PcapReThread::sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, bool isFront, WaitingDlg *waitingDlg) { int res; PcapResp *resp; { @@ -22,7 +22,8 @@ int PcapReThread::sendMsgNet(const byte *msg, int size, int id, qint64 timeout, if(res==0) { if(timeout==0) timeout = 30000; timeout += std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); - resps.append(resp = new PcapResp{callback, id, timeout}); + if(isFront) resps.prepend(resp = new PcapResp{callback, id, timeout}); + else resps.append(resp = new PcapResp{callback, id, timeout}); } } if(waitingDlg) { @@ -54,17 +55,16 @@ void PcapReThread::run() { if(cnt && data[0]==0x55 && data[1]==0x55) { //modified by alahover -s 20230823 if(data[2]==0x00 && data[3]==0x11 && data[4]==0x22 && data[5]==0x33 && data[6]==0x44 && data[7]==0x55 ) { - int id = data[headMap_zrf.protcolFlag]<<16 | data[headMap_zrf.protcolFlag+1]<<8 | data[headMap_zrf.pkgType]; - //qDebug()<<"id="<id==id) { - auto resp = resps[i]; - if(resp->notCancelled) emit onCallback(resp->callback, 0, QByteArray((char*)data, header->caplen)); - if(! resp->isMulti) { - resps.removeAt(i); - delete resp; - } - break; - } + int id = data[headMap_zrf.protcolFlag]<<16 | data[headMap_zrf.protcolFlag+1]<<8 | data[headMap_zrf.pkgType]; + if(id == 0x105B14) for(int i=0; iid==id) { + auto resp = resps[i]; + if(resp->notCancelled) emit onCallback(resp->callback, 0, QByteArray((char*)data, header->caplen)); + if(! resp->isMulti) { + resps.removeAt(i); + delete resp; + } + break; + } } else { int id = data[2]<<8 | data[3]; for(int i=0; iid==id) { diff --git a/ledset/pcaprethread.h b/ledset/pcaprethread.h index d2543a6..decc1ef 100644 --- a/ledset/pcaprethread.h +++ b/ledset/pcaprethread.h @@ -21,7 +21,7 @@ public: explicit PcapReThread(pcap *pcap); ~PcapReThread(); - int sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, WaitingDlg *waitingDlg = 0); + int sendMsgNet(const byte *msg, int size, int id, qint64 timeout, FuncIntByte callback, bool = false, WaitingDlg *waitingDlg = 0); void addMultiCallback(int id, FuncIntByte callback); QList resps; std::mutex mtx;