From 78c49a591404ec32d7c2d2e9f4b9bf6010c51e07 Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期四, 12 九月 2024 16:39:28 +0800
Subject: [PATCH] Revert "读写代码测试,问题调整"

---
 Admin.NET/WCS.Application/PLC/PLCUtil.cs |   57 +--------------------------------------------------------
 1 files changed, 1 insertions(+), 56 deletions(-)

diff --git a/Admin.NET/WCS.Application/PLC/PLCUtil.cs b/Admin.NET/WCS.Application/PLC/PLCUtil.cs
index 794a66c..0caf17a 100644
--- a/Admin.NET/WCS.Application/PLC/PLCUtil.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCUtil.cs
@@ -7,8 +7,6 @@
 using IoTClient.Common.Enums;
 using IoTClient.Enums;
 using IoTClient.Interfaces;
-using System.Text;
-using System.Text.RegularExpressions;
 
 namespace WCS.Application;
 public class PLCUtil
@@ -103,24 +101,7 @@
                     result = _client.ReadDouble(Pos);
                     break;
                 case PLCDataTypeEnum.String:
-                    {
-                        string dpos = IncrementCode(Pos);
-                        Result<byte[]> result1 = _client.ReadString(Pos, 1);
-                        if (result1.IsSucceed)
-                        {
-                            Result<byte[]> result2 = _client.ReadString(dpos, (ushort)(result1.Value[0]));
-                            Result<string> result3 = new Result<string>(result2);
-                            if (result3.IsSucceed)
-                            {
-                                result3.Value = Encoding.ASCII.GetString(result2.Value, 0, result1.Value[0]).Replace("\0", "");
-                                result = result3;
-                            }
-                        }
-                        else
-                        {
-                            result = result1;
-                        }
-                    }
+                    result = _client.ReadString(Pos, Convert.ToUInt16(Length));
                     break;
                 default:
                     result = new IoTClient.Result<object>();
@@ -128,37 +109,6 @@
             }
             return (result, result.Value);
         }
-    }
-    public static string IncrementCode(string code, int index = 2)
-    {
-        // 浣跨敤姝e垯琛ㄨ揪寮忚В鏋愬瓧绗︿覆
-        var match = Regex.Match(code, @"([A-Za-z]+)(\d+)(?:\.(\d+))?");
-
-        if (match.Success)
-        {
-            // 鎻愬彇瀛楁瘝閮ㄥ垎
-            string prefix = match.Groups[1].Value;
-            // 鎻愬彇鏁板瓧閮ㄥ垎
-            int number1 = int.Parse(match.Groups[2].Value);
-            int number2 = match.Groups[3].Success ? int.Parse(match.Groups[3].Value) : 0;
-
-            // 澶勭悊瑙勫垯
-            if (match.Groups[3].Success)
-            {
-                // 濡傛灉鏈夊皬鏁扮偣鍒嗛殧閮ㄥ垎锛屽鍔�2
-                number2 += index;
-                return $"{prefix}{number1}.{number2:D3}";
-            }
-            else
-            {
-                // 娌℃湁灏忔暟鐐瑰垎闅旈儴鍒嗙殑锛屽鍔�2
-                number1 += index;
-                return $"{prefix}{number1}";
-            }
-        }
-
-        // 濡傛灉涓嶅尮閰嶏紝杩斿洖鍘熷瓧绗︿覆
-        return code;
     }
     /// <summary>
     /// 鎵归噺璇诲彇PLC鍊�
@@ -263,11 +213,6 @@
                 return _client.Write(Pos, float.Parse(Value));
             case PLCDataTypeEnum.Double:
                 return _client.Write(Pos, float.Parse(Value));
-            case PLCDataTypeEnum.String:
-                {
-                    string dpos = IncrementCode(Pos, 1);
-                    return _client.Write(dpos, Value);
-                }
             default:
                 return new IoTClient.Result();
         }

--
Gitblit v1.8.0