Procházet zdrojové kódy

指令下发优化

yinyujing před 3 roky
rodič
revize
a1d2d3fd52
1 změnil soubory, kde provedl 14 přidání a 5 odebrání
  1. 14 5
      NB_IOT_TCP_HP_SOCKET/MainForm_TCP.cs

+ 14 - 5
NB_IOT_TCP_HP_SOCKET/MainForm_TCP.cs

@@ -491,7 +491,7 @@ namespace NB_IOT_TCP_HP_SOCKET
                                 }
 
                                 StartOrResumeSendThread();
-                                StartOrResumeSetParamThread();
+                                //StartOrResumeSetParamThread();
                             }
                         }
                     }
@@ -1001,7 +1001,7 @@ namespace NB_IOT_TCP_HP_SOCKET
                                                 }
                                             }
                                         }
-                                        else if (cjt._cmdType == ParamCmdType.WriteNetParam)
+                                        else //if (cjt._cmdType == ParamCmdType.WriteNetParam)
                                         {
                                             if (cjt._controlCode == 0xA4)
                                             {
@@ -1049,6 +1049,9 @@ namespace NB_IOT_TCP_HP_SOCKET
                                     clientInfo.DestNumber = psp.DestNumber;
                                     clientInfo.SourceNumber = psp.SourceNumber;
                                     server.SetExtra(clientInfo.ConnId, clientInfo);
+                                    
+                                    // 启动设参线程
+                                    StartOrResumeSetParamThread();
                                 }
 
                                 insourcingData.CellMonitor = cm;
@@ -1243,7 +1246,7 @@ namespace NB_IOT_TCP_HP_SOCKET
                                         }
                                     }
                                 }
-                                else if (cjt._cmdType == ParamCmdType.WriteNetParam)
+                                else //if (cjt._cmdType == ParamCmdType.WriteNetParam)
                                 {
                                     // 设参参返回指令
                                     if (cjt._controlCode == 0xA4)
@@ -1339,7 +1342,7 @@ namespace NB_IOT_TCP_HP_SOCKET
                         else if ("CD_PSController".Equals(insourcingData.Type))
                         {
                             // 读参返回数据
-                            if ("1".Equals(insourcingData.DataType))
+                            if ("0".Equals(insourcingData.DataType))
                             {
                                 // 解析参数数据包并展示参数信息
                                 DeviceControlForm.showParamData(insourcingData.Data);
@@ -1397,8 +1400,9 @@ namespace NB_IOT_TCP_HP_SOCKET
                     {
                         // 获取所有链接ID
                         IntPtr[] allConnIds = server.GetAllConnectionIDs();
-                        if (allConnIds == null || allConnIds.Length > 0)
+                        if (allConnIds == null || allConnIds.Length == 0)
                         {
+                            AddMsg($" > 设参时没有链接,线程挂起", lbErrorData);
                             setParamThread.Suspend();
                         }
 
@@ -1407,15 +1411,18 @@ namespace NB_IOT_TCP_HP_SOCKET
                             ClientInfo clientInfo = (ClientInfo)server.GetExtra(connId);
                             if (clientInfo == null)
                             {
+                                //AddMsg($" > 设参时链接信息为空:{connId}", lbErrorData);
                                 continue;
                             }
                             // 如果链接中数据包是最后一包进行下发设参和校时指令
                             if (!clientInfo.IsEnd)
                             {
+                                //AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {clientInfo.SourceNumber}  CD_CellMonitor 设参时不是最后一包", lbErrorData);
                                 continue;
                             }
                             if (clientInfo.TranDevice == null)
                             {
+                                //AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {clientInfo.SourceNumber}  CD_CellMonitor 设参时不是没有设备信息", lbErrorData);
                                 continue;
                             }
                             Dictionary<string, string> trandevice = clientInfo.TranDevice;
@@ -1548,6 +1555,7 @@ namespace NB_IOT_TCP_HP_SOCKET
             remoteTask.GetTaskList(id, name);
             if (remoteTask.Tasklist == null || remoteTask.Tasklist.Count == 0)
             {
+                //AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {clientInfo.SourceNumber}  CD_CellMonitor 设参时没有设参指令,校时关机", lbErrorData);
                 // 没有设参指令则校时关机
                 TimingShutDown(clientInfo);
                 return;
@@ -1577,6 +1585,7 @@ namespace NB_IOT_TCP_HP_SOCKET
                     }
                     else
                     {
+                        AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {clientInfo.SourceNumber} ({buffer3.Length} bytes) CD_CellMonitor下发设参打包成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbErrorData);
                         // 下发设参数
                         bool sendFlag = server.Send(clientInfo.ConnId, buffer3, buffer3.Length);
                         // 发送成功更新发送次数和发送时间