| 
					
				 | 
			
			
				@@ -31,6 +31,7 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static System.Timers.Timer timer; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static bool isTimeRuning = false; // MODBUS定时器是否执行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static bool isHeartBeatRuning = false; // 心跳进程是否执行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        private static bool isSetParamRuning = false; // 设参进程是否执行中 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private static Dictionary<string, object> deviceTypes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -66,6 +67,7 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         private void MainForm_TCP_Load(object sender, EventArgs e) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.Text = ConfigurationManager.AppSettings["APPName"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             this.WindowState = FormWindowState.Maximized; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -122,12 +124,12 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     string deviceType = ConfigurationManager.AppSettings["IsHaveModBus"]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 启动处理数据进程 外包和内包两个 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    StartOrResumeSendThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    StartOrResumeInsourcingThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //StartOrResumeSendThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //StartOrResumeInsourcingThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if ("1".Equals(deviceType)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StartOrResumeSetParamThread(); // 启动电池供电设备设参线程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //StartOrResumeSetParamThread(); // 启动电池供电设备设参线程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else if ("2".Equals(deviceType)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -136,7 +138,7 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else if ("3".Equals(deviceType)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        StartOrResumeSetParamThread(); // 启动电池供电设备设参线程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //StartOrResumeSetParamThread(); // 启动电池供电设备设参线程 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         timer = new System.Timers.Timer(Convert.ToInt32(ConfigurationManager.AppSettings["ModBusQueryInterval"])); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         StartModBusSendTimer(); // 启动ModBus定时发送读取数据任务 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -364,21 +366,29 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (!msg.Result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 外包解包失败 \n {msg.Message}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 外包解包失败 \n {msg.Message}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (!string.IsNullOrEmpty(clientInfo.SourceNumber)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            psp.SourceNumber = clientInfo.SourceNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (!string.IsNullOrEmpty(clientInfo.DestNumber)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            clientInfo.DestNumber = psp.DestNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         lock (deveiceConnId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             deveiceConnId[psp.SourceNumber] = connId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        clientInfo.SourceNumber = psp.SourceNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        clientInfo.DestNumber = psp.DestNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //clientInfo.SourceNumber = psp.SourceNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //clientInfo.DestNumber = psp.DestNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         PSProtocol protocol2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         byte[] array = new byte[psp.Data.Length]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         psp.Data.CopyTo(array, 0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 外包解包成功 \n {BitConverter.ToString(psp.Data, 0, psp.Data.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 外包解包成功 \n {BitConverter.ToString(psp.Data, 0, psp.Data.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         // 判断包类型 心跳或数据包 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         if (psp.Type == FrameType.GPRS_Link) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -388,11 +398,11 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (!ProtocolAnalysisTools.OuterPack(protocol2, out byte[] buffer2).Result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 心跳回应打包失败 ", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 心跳回应打包失败 ", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 心跳回应成功 \n {BitConverter.ToString(buffer2, 0, buffer2.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 心跳回应成功 \n {BitConverter.ToString(buffer2, 0, buffer2.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 server.Send(clientInfo.ConnId, buffer2, buffer2.Length);// 发送数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -413,17 +423,18 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (!ProtocolAnalysisTools.OuterPack(protocol2, out buffer3).Result) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应打包失败 ", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应打包失败 ", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({bytes.Length} bytes) 历史记录回应成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     server.Send(clientInfo.ConnId, buffer3, buffer3.Length);// 发送数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 StartOrResumeSendThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                StartOrResumeSetParamThread(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -618,7 +629,6 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     isHeartBeatRuning = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         // 获取所有连接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         IntPtr[] allConnIds = server.GetAllConnectionIDs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -897,7 +907,7 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     if (server.Send(clientInfo.ConnId, buffer3, buffer3.Length)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                        AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({buffer3.Length} bytes) 阀门状态上报回复成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                        AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({buffer3.Length} bytes) 阀门状态上报回复成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -928,14 +938,17 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                         if (server.Send(clientInfo.ConnId, buffer3, buffer3.Length)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                                            AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {psp.SourceNumber} ({buffer3.Length} bytes) 读阀门状态回复成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                            AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber} ({buffer3.Length} bytes) 读阀门状态回复成功 \n {BitConverter.ToString(buffer3, 0, buffer3.Length).Replace("-", " ")} ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            // 写参返回指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                            else if (cjt._controlCode == 0xA4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        else if (cjt._cmdType == ParamCmdType.WriteNetParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            if (cjt._controlCode == 0xA4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {psp.SourceNumber}  设参成功响应 \n ", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 insourcingData.CJT188 = cjt; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 // 加入内包数据处理队列 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                                 insourcingQueue.Enqueue(insourcingData); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -962,12 +975,12 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber} ({psp.Data.Length} bytes) CD_CellMonitor内包解包失败 \n {msg.Message}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {sourceNumber} ({psp.Data.Length} bytes) CD_CellMonitor内包解包失败 \n {msg.Message}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber} ({psp.Data.Length} bytes) CD_CellMonitor内包解包成功 \n {BitConverter.ToString(psp.Data, 0, psp.Data.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {sourceNumber} ({psp.Data.Length} bytes) CD_CellMonitor内包解包成功 \n {BitConverter.ToString(psp.Data, 0, psp.Data.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 insourcingData.DataType = "1"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1050,12 +1063,12 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             if (!unPackFlag) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber} ({psp.Data.Length} bytes) CD_PSController内包解包失败,数据类型{code} \n {unPackRs}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {sourceNumber} ({psp.Data.Length} bytes) CD_PSController内包解包失败,数据类型{code} \n {unPackRs}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             else 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber} ({psp.Data.Length} bytes) CD_PSController内包解包成功,数据类型{code} \n {BitConverter.ToString(modbus.UpDataArea, 0, modbus.UpDataArea.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                AddMsg($" > [{clientInfo.ConnId},OnReceive] -> {clientInfo.IpAddress}:{clientInfo.Port}-{clientInfo.SourceNumber} {sourceNumber} ({psp.Data.Length} bytes) CD_PSController内包解包成功,数据类型{code} \n {BitConverter.ToString(modbus.UpDataArea, 0, modbus.UpDataArea.Length).Replace("-", " ")}", lbReceiveData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 // 设参回包数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 if (code == Modbus.FunctionCode.F10) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1173,7 +1186,7 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                else if (cjt._cmdType == ParamCmdType.ReadWorkMode) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                else if (cjt._cmdType == ParamCmdType.WriteNetParam) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     // 设参参返回指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                     if (cjt._controlCode == 0xA4) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1320,47 +1333,60 @@ namespace NB_IOT_TCP_HP_SOCKET 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             while (this.Visible) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                // 获取所有链接ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                IntPtr[] allConnIds = server.GetAllConnectionIDs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (allConnIds == null || allConnIds.Length == 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Thread.Sleep(1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                foreach (IntPtr connId in allConnIds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ClientInfo clientInfo = (ClientInfo)server.GetExtra(connId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (clientInfo == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // 如果链接中数据包是最后一包进行下发设参和校时指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (!clientInfo.IsEnd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (clientInfo.TranDevice == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Dictionary<string, string> trandevice = clientInfo.TranDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    string destNumber = clientInfo.DestNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    string sourceNumber = clientInfo.SourceNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    // 一个传输设备可能对应多个设备信息及通讯设备 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    foreach (KeyValuePair<string, string> keyValuePair in trandevice) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //if (!isSetParamRuning) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //    isSetParamRuning = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        // 获取所有链接ID 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        IntPtr[] allConnIds = server.GetAllConnectionIDs(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (allConnIds == null || allConnIds.Length > 0) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            // 发送设参指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            SendSetParam(clientInfo, keyValuePair.Key, keyValuePair.Value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            setParamThread.Suspend(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        catch (Exception ex) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        foreach (IntPtr connId in allConnIds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber}  CD_CellMonitor最后发送设参指令失败 \n {ex.StackTrace}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            ClientInfo clientInfo = (ClientInfo)server.GetExtra(connId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (clientInfo == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            // 如果链接中数据包是最后一包进行下发设参和校时指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (!clientInfo.IsEnd) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            if (clientInfo.TranDevice == null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Dictionary<string, string> trandevice = clientInfo.TranDevice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            string destNumber = clientInfo.DestNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            string sourceNumber = clientInfo.SourceNumber; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            // 一个传输设备可能对应多个设备信息及通讯设备 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            foreach (KeyValuePair<string, string> keyValuePair in trandevice) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                try 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    // 发送设参指令 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    SendSetParam(clientInfo, keyValuePair.Key, keyValuePair.Value); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                catch (Exception ex) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    AddMsg($" > [{clientInfo.ConnId},OnSend] -> {clientInfo.IpAddress}:{clientInfo.Port} {sourceNumber}  CD_CellMonitor最后发送设参指令失败 \n {ex.StackTrace}", lbErrorData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        isSetParamRuning = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    catch (Exception) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        isSetParamRuning = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Thread.Sleep(1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |