From 42bb5b84ff935e0a3efb46f56d4ff5ca5ed9e592 Mon Sep 17 00:00:00 2001
From: chengsc <11752@DESKTOP-DS49RCP>
Date: 星期三, 16 四月 2025 15:54:52 +0800
Subject: [PATCH] 修改问题,添加备注

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

diff --git a/Admin.NET/WCS.Application/PLC/PLCUtil.cs b/Admin.NET/WCS.Application/PLC/PLCUtil.cs
index babe138..9b72835 100644
--- a/Admin.NET/WCS.Application/PLC/PLCUtil.cs
+++ b/Admin.NET/WCS.Application/PLC/PLCUtil.cs
@@ -1,6 +1,7 @@
 锘縰sing DocumentFormat.OpenXml.Bibliography;
 using DocumentFormat.OpenXml.Drawing;
 using Elastic.Clients.Elasticsearch;
+using Furion.Logging;
 using IoTClient;
 using IoTClient.Clients.Modbus;
 using IoTClient.Clients.PLC;
@@ -332,4 +333,43 @@
         }
         return _client.BatchWrite(addresses);
     }
+
+    /// <summary>
+    /// 寰幆鍐欏叆PLC鍊硷紙骞惰鍙栧�煎垽鏂拰鍐欏叆鐨勫�兼槸鍚︿竴鑷达紝鍐欏叆鎺у埗瀛椾笉鑳界敤姝ゆ柟娉曪級
+    /// </summary>
+    public IoTClient.Result SetPlcDBValueRepeat(PLCDataTypeEnum PosType, string DbNumber, string Pos, string Value)
+    {
+        IoTClient.Result _result = new IoTClient.Result();
+
+        int setCount = 0;//鍐欏叆娆℃暟
+        while (setCount < 5)
+        {
+            string address;
+            if (DbNumber.StartsWith("DB"))
+                address = DbNumber + "." + Pos;
+            else
+                address = DbNumber + Pos;
+            _result = this.SetPlcDBValue(PosType, address, Value);//鍐欏叆鍊�
+
+            //绱鍐欏叆娆℃暟
+            setCount++;
+
+            if (_result.IsSucceed)
+            {
+                //璇诲彇鍐欏叆鐨勫��
+                var (res, val) = GetPlcDBValue(PosType, DbNumber, Pos);
+                if (val.ToString() == Value)
+                {
+                    //璇诲彇鐨勫�煎拰鍐欏叆鐨勫�间竴鑷达紝鐩存帴璺冲嚭寰幆
+                    break;
+                }
+            }
+        }
+        //鍐欏叆鏃ュ織
+        Log.Information($"66666666鍐欏叆PLC锛孌bNumber锛歿DbNumber}锛孭os:{Pos},Value:{Value},setCount:{setCount}");
+
+        return _result;
+    }
+     
+
 }

--
Gitblit v1.8.0