From 50fd5cc9cfad08714c4daa6d481c5293ff2ae6b1 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 31 一月 2024 18:55:28 +0800
Subject: [PATCH] 逻辑完善

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs |   96 +++++++++++++++++++++++++++++-------------------
 1 files changed, 58 insertions(+), 38 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs"
index 753da87..bec587e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/WCSClient/DBExtension.cs"
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -18,43 +19,62 @@
         /// <exception cref="Exception"></exception>
         public static object Read(dt_plcinfodetail detail, PLCClient client)
         {
-            
-                if (detail.plcdetail_valtype == typeof(int).Name.ToLower())//4瀛楄妭,鏈夌鍙风被鍨�
-                {
-                    return (client.Read<int>(detail.plcdetail_db+"."+detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(uint).Name.ToLower())//4瀛楄妭,鏃犵鍙风被鍨�
-                {
-                    return (client.Read<uint>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(short).Name.ToLower())//2瀛楄妭,鏈夌鍙风被鍨�,鏈�甯哥敤
-                {
-                    return (client.Read<short>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(ushort).Name.ToLower())//2瀛楄妭,鏃犵鍙风被鍨�
-                {
-                    return (client.Read<ushort>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(float).Name.ToLower())//娴偣鍨�
-                {
-                    return (client.Read<float>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(bool).Name.ToLower())
-                {
-                    return (client.Read<bool>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(byte).Name.ToLower())//瀛楄妭
-                {
-                    return (client.Read<byte>(detail.plcdetail_db + "." + detail.plcdetail_value));
-                }
-                else if (detail.plcdetail_valtype == typeof(string).Name.ToLower())//瀛楃涓�
-                {
-                    return (client.Read<string>(detail.plcdetail_db + "." + detail.plcdetail_value, detail.plcdetail_len.GetValueOrDefault()));
-                }
-                else
-                {
-                    throw new Exception($"銆恵detail.plcdetail_remark}銆�,DB鍦板潃{detail.plcdetail_db + "." + detail.plcdetail_value},鏈畾涔夋暟鎹被鍨媨detail.plcdetail_valtype}");
-                }
+
+            if (detail.plcdetail_valtype == typeof(int).Name.ToLower())//4瀛楄妭,鏈夌鍙风被鍨�
+            {
+                return (client.Read<int>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(uint).Name.ToLower())//4瀛楄妭,鏃犵鍙风被鍨�
+            {
+                return (client.Read<uint>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(short).Name.ToLower())//2瀛楄妭,鏈夌鍙风被鍨�,鏈�甯哥敤
+            {
+                return (client.Read<short>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(ushort).Name.ToLower())//2瀛楄妭,鏃犵鍙风被鍨�
+            {
+                return (client.Read<ushort>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(float).Name.ToLower())//娴偣鍨�
+            {
+                return (client.Read<float>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(bool).Name.ToLower())
+            {
+                return (client.Read<bool>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(byte).Name.ToLower())//瀛楄妭
+            {
+                return (client.Read<byte>(detail.plcdetail_db + "." + detail.plcdetail_value));
+            }
+            else if (detail.plcdetail_valtype == typeof(string).Name.ToLower())//瀛楃涓�
+            {
+                return (client.Read<string>(detail.plcdetail_db + "." + detail.plcdetail_value, detail.plcdetail_len.GetValueOrDefault()));
+            }
+            else
+            {
+                throw new Exception($"銆恵detail.plcdetail_remark}銆�,DB鍦板潃{detail.plcdetail_db + "." + detail.plcdetail_value},鏈畾涔夋暟鎹被鍨媨detail.plcdetail_valtype}");
+            }
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="detail"></param>
+        /// <param name="client"></param>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        public static object Write(dt_plcinfodetail detail, PLCClient client, object value)
+        {
+            try
+            {
+                return (client.Write(detail.plcdetail_db + "." + detail.plcdetail_value, value));
+            }
+            catch (Exception ex)
+            {
+                throw;
+            }
         }
     }
 }

--
Gitblit v1.9.3