From 13a442afefdddf1ec9ecd1e22c81735bf5c6a465 Mon Sep 17 00:00:00 2001
From: Administrator <Administrator@DESKTOP-JIE70N9>
Date: 星期二, 10 六月 2025 16:08:24 +0800
Subject: [PATCH] 修改问题

---
 Admin.NET/WCS.Application/PLC/ModbusUtil.cs |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/Admin.NET/WCS.Application/PLC/ModbusUtil.cs b/Admin.NET/WCS.Application/PLC/ModbusUtil.cs
index 1c77885..d34c77c 100644
--- a/Admin.NET/WCS.Application/PLC/ModbusUtil.cs
+++ b/Admin.NET/WCS.Application/PLC/ModbusUtil.cs
@@ -1,4 +1,5 @@
-锘縰sing IoTClient;
+锘縰sing Furion.Logging;
+using IoTClient;
 using IoTClient.Clients.Modbus;
 using IoTClient.Common.Enums;
 using IoTClient.Enums;
@@ -270,4 +271,37 @@
                 return new IoTClient.Result();
         }
     }
+
+    /// <summary>
+    /// 寰幆鍐欏叆PLC鍊硷紙骞惰鍙栧�煎垽鏂拰鍐欏叆鐨勫�兼槸鍚︿竴鑷达紝鍐欏叆鎺у埗瀛椾笉鑳界敤姝ゆ柟娉曪級
+    /// </summary>
+    public IoTClient.Result SetDBValueRepeat(PLCDataTypeEnum PosType, string Pos, string Value)
+    {
+        IoTClient.Result _result = new IoTClient.Result();
+
+        int setCount = 0;//鍐欏叆娆℃暟
+        while (setCount < 5)
+        {
+            _result = this.SetDBValue(PosType, Pos, Value);//鍐欏叆鍊�
+
+            //绱鍐欏叆娆℃暟
+            setCount++;
+
+            if (_result.IsSucceed)
+            {
+                //璇诲彇鍐欏叆鐨勫��
+                var (res, val) = GetDBValue(PosType, Pos);
+                if (val.ToString() == Value)
+                {
+                    //璇诲彇鐨勫�煎拰鍐欏叆鐨勫�间竴鑷达紝鐩存帴璺冲嚭寰幆
+                    break;
+                }
+            }
+        }
+        //鍐欏叆鏃ュ織
+        Log.Information($"鍐欏叆PLC锛孭os:{Pos},Value:{Value},setCount:{setCount}");
+
+        return _result;
+    }
+
 }

--
Gitblit v1.8.0