From 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期三, 12 三月 2025 14:11:33 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
index d6e577e..30ab2c4 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
@@ -17,7 +17,6 @@
 
 using HslCommunication;
 using Microsoft.AspNetCore.Http;
-using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -169,7 +168,11 @@
         /// </summary>
         public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null;
 
+        /// <summary>
+        /// 涓婁竴娆′换鍔$殑绫诲瀷
+        /// </summary>
         public int? LastTaskType { get; set; } = null;
+
         #endregion
 
         #region Constructor Function
@@ -431,15 +434,15 @@
         /// 鏍规嵁鍙傛暟鍚嶇О璇诲彇鍫嗗灈鏈哄搴旂殑鏁版嵁銆�
         /// </summary>
         /// <typeparam name="TEnum">鍙傛暟鍚嶇О鏋氫妇绫诲瀷銆�</typeparam>
-        /// <typeparam name="TRsult">璇诲彇缁撴灉鐨勮繑鍥炲�肩被鍨嬨��</typeparam>
+        /// <typeparam name="TResult">璇诲彇缁撴灉鐨勮繑鍥炲�肩被鍨嬨��</typeparam>
         /// <param name="value">鍙傛暟鍚嶇О銆�</param>
         /// <returns>杩斿洖璇诲彇鍒扮殑鏁版嵁銆�</returns>
         /// <exception cref="Exception"></exception>
-        public TRsult GetValue<TEnum, TRsult>(TEnum value) where TEnum : Enum
+        public TResult GetValue<TEnum, TResult>(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);
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == value.ToString()) ?? throw new Exception($"璇诲彇鏁版嵁閿欒,鏈湪鍗忚淇℃伅閲岄潰鎵惧埌鍙傛暟{value.ToString()}");
+            return (TResult)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
         }
 
         /// <summary>
@@ -464,14 +467,20 @@
             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);
+            DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == @enum.ToString()) ?? throw new Exception($"鍐欏叆鏁版嵁閿欒,鏈湪鍗忚淇℃伅閲岄潰鎵惧埌鍙傛暟{value.ToString()}");
+            return Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, value);
         }
 
+        /// <summary>
+        /// 瀹炵幇IDisposable鎺ュ彛鐨凞ispose鏂规硶
+        /// </summary>
         public void Dispose()
         {
+            // 灏哶heartStatr璁剧疆涓篺alse
             _heartStatr = false;
+            // 璋冪敤_communicator鐨凞ispose鏂规硶
             _communicator.Dispose();
+            // 鍛婅瘔鍨冨溇鍥炴敹鍣ㄤ笉鍐嶈皟鐢ㄦ瀵硅薄鐨勭粓缁撳櫒
             GC.SuppressFinalize(this);
         }
         #endregion

--
Gitblit v1.9.3