分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-11 84f3b1fc2e8f48bbe7749ed90362793b42e0edc4
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/WCSClient/Siemens/SiemensPLCClient.cs
@@ -51,6 +51,7 @@
            siemensPLCClient.Port = Port;
            siemensPLCClient.Slot = (byte)Slot;
            siemensPLCClient.ConnectTimeOut = 1000 * 3;//超时时间
            siemensPLCClient.ReceiveTimeOut = 1000 * 3;
            siemensPLCClient.ConnectClose();
            var coonRes = siemensPLCClient.ConnectServer();
            IsConnected = coonRes.IsSuccess;
@@ -192,7 +193,7 @@
            else if (typeof(DataType) == typeof(string))//字符串
            {
                var str = GetContent(siemensPLCClient.ReadString(item.dbAddress, (ushort)item.dataLen), item).ToString();
                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\n","")?.Replace("?", "")?.Trim();
                str = str.Replace("\0", "")?.Replace("\\", "")?.Replace("\u0014", "")?.Replace("?\u0006", "")?.Replace("\n", "")?.Replace("?", "")?.Trim();
                return (DataType)(str as object);
            }
            else
@@ -256,6 +257,7 @@
                if (!result.IsSuccess)
                {
                    IsConnected = false;
                    WriteLog.Write_Log(PLCName, $"{PLCName}_Write", $"{dbAddress}写入失败," + result.Message);
                    throw new Exception($"{dbAddress}写入失败," + result.Message);
                }
@@ -325,6 +327,7 @@
                if (!result.IsSuccess)
                {
                    IsConnected = false;
                    WriteLog.Write_Log(PLCName, $"{PLCName}_Write", $"{orderName}写入失败," + result.Message, item);
                    throw new Exception($"{PLCName},{orderName}写入失败," + result.Message);
                }