From 2f75b4c0a67ccc3a443e7cc4f2f0f909defd9a92 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期五, 01 十一月 2024 09:49:23 +0800
Subject: [PATCH] 版本更新

---
 WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ShuttleCar/ShuttleCar.cs |   48 ++++++++++++++++++++----------------------------
 1 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ShuttleCar/ShuttleCar.cs b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ShuttleCar/ShuttleCar.cs
index 2a6e09e..b9c30a1 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ShuttleCar/ShuttleCar.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/ShuttleCar/ShuttleCar.cs
@@ -65,11 +65,7 @@
 
         public string DeviceName => _deviceName;
 
-        public bool IsFault => false;
-
         public bool IsConnected => Communicator.IsConnected && _isConnected;
-
-        public DeviceStatus Status => DeviceStatus.Offline;
         #endregion
 
         #region Constructor Function
@@ -111,6 +107,14 @@
         #endregion
 
         #region Public Method
+
+        public TRsult GetValue<TEnum, TRsult>(TEnum value) where TEnum : Enum
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == value.ToString());
+            return devicePro == null ? throw new Exception() : (TRsult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+        }
+
         /// <summary>
         /// 璇诲彇PLC鍗忚鍦板潃鐨勬暟鎹�
         /// </summary>
@@ -131,7 +135,6 @@
         /// </summary>
         public void Heartbeat()
         {
-            throw new NotImplementedException();
         }
 
         /// <summary>
@@ -165,28 +168,6 @@
         }
 
         /// <summary>
-        /// 璇诲彇PLC鏁版嵁锛岃繑鍥炶嚜瀹氫箟瀵硅薄
-        /// </summary>
-        /// <typeparam name="T">娉涘瀷</typeparam>
-        /// <param name="deviceChildCode">瀛愯澶囩紪鍙�</param>
-        /// <returns>杩斿洖鑷畾涔夊璞℃垨鎶涘嚭寮傚父</returns>
-        /// <exception cref="Exception"></exception>
-        public T ReadCustomer<T>(string deviceChildCode) where T : IDataTransfer, new()
-        {
-            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
-            DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == "ReadDeviceCommand" && x.DeviceChildCode == deviceChildCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
-
-            if (devicePro == null)
-            {
-                throw new Exception("鏈壘鍒板崗璁俊鎭�");
-            }
-            else
-            {
-                return Communicator.ReadCustomer<T>(devicePro.DeviceProAddress);
-            }
-        }
-
-        /// <summary>
         /// 鏍规嵁鍙傛暟鍚嶇О銆佽澶囧瓙缂栧彿鍐欏叆瀵瑰簲鐨勬暟鎹��
         /// </summary>
         /// <typeparam name="TEnum">鍙傛暟鍚嶇О鏋氫妇绫诲瀷銆�</typeparam>
@@ -204,9 +185,20 @@
             return devicePro == null ? throw new Exception() : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
         }
 
+        public bool SetValue<TEnum, TValue>(TEnum @enum, TValue value)
+            where TEnum : Enum
+            where TValue : notnull
+        {
+            if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString());
+            return devicePro == null ? throw new Exception() : Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
+        }
+
         public void Dispose()
         {
-            throw new NotImplementedException();
+            _heartStatr = false;
+            _communicator.Dispose();
+            GC.SuppressFinalize(this);
         }
         #endregion
     }

--
Gitblit v1.9.3