From 70233af5426b0d1c343ebe87183303a34a9aaa58 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期三, 20 十一月 2024 09:05:38 +0800 Subject: [PATCH] WIDESEAWCS_QuartzJob更新版本 --- WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs | 18 +++++++++++------- 1 files changed, 11 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..04e16dc 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; @@ -170,6 +169,7 @@ public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null; public int? LastTaskType { get; set; } = null; + #endregion #region Constructor Function @@ -431,15 +431,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 +464,18 @@ 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); } + // 瀹炵幇IDisposable鎺ュ彛鐨凞ispose鏂规硶 public void Dispose() { + // 灏哶heartStatr璁剧疆涓篺alse _heartStatr = false; + // 璋冪敤_communicator鐨凞ispose鏂规硶 _communicator.Dispose(); + // 鍛婅瘔鍨冨溇鍥炴敹鍣ㄤ笉鍐嶈皟鐢ㄦ瀵硅薄鐨勭粓缁撳櫒 GC.SuppressFinalize(this); } #endregion -- Gitblit v1.9.3