From 8f392cc88b0768b74efca3b68785cf5aa1c38e70 Mon Sep 17 00:00:00 2001 From: wangxinhui <wangxinhui@hnkhzn.com> Date: 星期三, 06 十一月 2024 14:28:20 +0800 Subject: [PATCH] 代码更新 --- wcs-server-hbf/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs | 27 ++++----------------------- 1 files changed, 4 insertions(+), 23 deletions(-) diff --git a/wcs-server-hbf/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs b/wcs-server-hbf/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs index c09e85d..10f75ef 100644 --- a/wcs-server-hbf/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs +++ b/wcs-server-hbf/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs @@ -128,31 +128,12 @@ /// </summary> public string Connect() { - if (PLCIPAddress == "127.0.0.3") - { - Port = 103; - } - if (PLCIPAddress == "127.0.0.4") - { - Port = 104; - } - List<string> specialSlotIp = new List<string>() - { - "192.168.12.166", - "192.168.12.160", - "192.168.12.161", - "192.168.12.163", - "192.168.12.164", - }; - if (specialSlotIp.Contains(PLCIPAddress)) - { - Slot = 1; - } this.SiemensS7NetClient.IpAddress = PLCIPAddress; this.SiemensS7NetClient.Port = Port; this.SiemensS7NetClient.Rack = Rack; this.SiemensS7NetClient.Slot = Slot; - this.SiemensS7NetClient.ConnectTimeOut = 5; + this.SiemensS7NetClient.ConnectTimeOut = 2000; + this.SiemensS7NetClient.ReceiveTimeOut = 2000; this.SiemensS7NetClient?.ConnectClose(); logNet = new LogNetFileSize(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log2"), 2 * 1024 * 1024); @@ -162,7 +143,7 @@ if (!result.IsSuccess) { - WIDESEA_Common.Tools.WriteLog.GetLog().Write($"Error锛歿PLCName}杩炴帴澶辫触{Environment.NewLine}閿欒淇℃伅锛歿result.Message}", PLCName); + WIDESEA_Common.Tools.WriteLog.GetLog().Write($"Error锛歿PLCName}杩炴帴澶辫触---{DateTime.Now}{Environment.NewLine}閿欒淇℃伅锛歿result.Message}", PLCName); IsConnected = false; logNet.WriteInfo($"{PLCIPAddress}杩炴帴澶辫触,閿欒淇℃伅锛歿result.Message}"); return $"杩炴帴澶辫触,閿欒淇℃伅锛歿result.Message}"; @@ -170,7 +151,7 @@ else { IsConnected = true; - WIDESEA_Common.Tools.WriteLog.GetLog().Write($"Info锛歿PLCName}杩炴帴鎴愬姛锛�", PLCName); + WIDESEA_Common.Tools.WriteLog.GetLog().Write($"Info锛歿PLCName}杩炴帴鎴愬姛锛�---{DateTime.Now}", PLCName); logNet.WriteInfo($"{PLCIPAddress}杩炴帴鎴愬姛"); return $"杩炴帴鎴愬姛"; } -- Gitblit v1.9.3