From b698a2085fd090e90abedb1e91266ec496574b29 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 16 四月 2026 23:31:35 +0800
Subject: [PATCH] 1

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
index 5e746e7..4e70c2f 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/StackerCrane/Common/CommonStackerCrane.cs
@@ -24,6 +24,7 @@
 using WIDESEAWCS_QuartzJob.DeviceBase;
 using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.StackerCrane;
+using WIDESEAWCS_QuartzJob.StackerCrane.Common;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 
 namespace WIDESEAWCS_QuartzJob
@@ -32,7 +33,7 @@
     /// 涓�鑸爢鍨涙満瀹炵幇绫伙紝瀹炵幇鍫嗗灈鏈烘帴鍙e眰
     /// </summary>
     [Description("鍫嗗灈鏈�")]
-    public class CommonStackerCrane : IStackerCrane
+    public class CommonStackerCrane : StackerCraneBase, IStackerCrane
     {
         #region Private Member
 
@@ -157,6 +158,11 @@
         public bool IsConnected => Communicator.IsConnected && _isConnected;
 
         /// <summary>
+        /// 鍫嗗灈鏈哄畬鎴愪簨浠舵槸鍚﹀凡璁㈤槄
+        /// </summary>
+        public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null;
+
+        /// <summary>
         /// 鍫嗗灈鏈轰换鍔″畬鎴愪簨浠�
         /// </summary>
         public event EventHandler<StackerCraneTaskCompletedEventArgs> StackerCraneTaskCompletedEventHandler;
@@ -166,10 +172,6 @@
         /// </summary>
         public object StackerCraneTaskCommand { get; set; }
 
-        /// <summary>
-        /// 鍫嗗灈鏈哄畬鎴愪簨浠舵槸鍚﹀凡璁㈤槄
-        /// </summary>
-        public bool IsEventSubscribed => StackerCraneTaskCompletedEventHandler != null;
 
         /// <summary>
         /// 涓婁竴娆′换鍔$殑绫诲瀷
@@ -223,7 +225,7 @@
                 {
                     return DeviceStatus.Idle;
                 }
-                else if (StackerCraneWorkStatusValue == StackerCraneWorkStatus.Putting || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUp || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUpCompleted || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutCompleted)
+                else if (StackerCraneWorkStatusValue == StackerCraneWorkStatus.Putting || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PickUp || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutMove || StackerCraneWorkStatusValue == StackerCraneWorkStatus.PutCompleted)
                 {
                     return DeviceStatus.Working;
                 }
@@ -234,7 +236,11 @@
         private int GetCurrentTaskNum()
         {
             DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(CurrentTaskNum));
-            return devicePro == null ? throw new Exception($"璇诲彇褰撳墠浠诲姟鍙烽敊璇�,鏈幏鍙栧埌鍗忚淇℃伅,璇锋鏌ラ厤缃弬鏁板悕绉版槸鍚﹂厤缃�,涓旈厤缃负涓簕nameof(CurrentTaskNum)}") : (int)Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+            if (devicePro == null)
+                throw new Exception($"璇诲彇褰撳墠浠诲姟鍙烽敊璇�,鏈幏鍙栧埌鍗忚淇℃伅,璇锋鏌ラ厤缃弬鏁板悕绉版槸鍚﹂厤缃�,涓旈厤缃负{nameof(CurrentTaskNum)}");
+
+            object value = Communicator.ReadAsObj(devicePro.DeviceProAddress, devicePro.DeviceDataType);
+            return Convert.ToInt32(value);  // 缁熶竴杞崲涓� int
         }
 
         /// <summary>
@@ -309,10 +315,10 @@
                     {
                         return deviceProtocolDetail.ProtocolDetailType;
                     }
-                    return StackerCraneStatus.Unkonw.ToString();
+                    return StackerCraneStatus.Unknown.ToString();
                 }
             }
-            return StackerCraneStatus.Unkonw.ToString();
+            return StackerCraneStatus.Unknown.ToString();
         }
 
         private void CheckConnect()
@@ -353,7 +359,7 @@
             if (Communicator is SiemensS7)
             {
                 if (!IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�");
-                DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand)).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+                DeviceProDTO? devicePro = _deviceProDTOs.Where(x => x.DeviceProParamType == nameof(DeviceCommand) && x.DeviceProParamName == "InputTaskNum")/*.OrderBy(x=>x.DeviceProOffset)*/.FirstOrDefault();
                 if (devicePro == null)
                 {
                     return false;
@@ -385,10 +391,10 @@
                 _isChecked = true;
                 try
                 {
-                    DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneWorkStatus));
+                    DeviceProDTO? devicePro = _deviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == nameof(StackerCraneCompleted));
                     if (devicePro != null)
                     {
-                        DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneWorkStatus.WorkCompleted.ToString());
+                        DeviceProtocolDetailDTO? deviceProtocolDetail = _deviceProtocolDetailDTOs.FirstOrDefault(x => x.DeviceProParamName == devicePro.DeviceProParamName && x.ProtocolDetailType == StackerCraneCompleted.Completed.ToString());
                         if (deviceProtocolDetail != null)
                         {
                             OperateResult<TimeSpan> operateResult = new OperateResult<TimeSpan>();

--
Gitblit v1.9.3