From b7f53ba61fbc1844d7b92ff852762b140d46ab54 Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期一, 23 六月 2025 19:58:16 +0800
Subject: [PATCH] 最新

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 1335 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 1,063 insertions(+), 272 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
index bb90fe8..d85ccb2 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs"
@@ -1,9 +1,12 @@
-锘縰sing Microsoft.AspNetCore.Components.Routing;
+锘縰sing Autofac.Core;
+using Microsoft.AspNetCore.Components.Routing;
 using Microsoft.AspNetCore.Hosting;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
 using Quartz;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics.CodeAnalysis;
+using System.Diagnostics.Eventing.Reader;
 using System.Linq;
 using System.Reflection.Metadata;
 using System.Text;
@@ -17,6 +20,7 @@
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Service;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
@@ -47,18 +51,44 @@
                 CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams");
                 if (commonStackerCrane != null)
                 {
-                    if (!commonStackerCrane.IsEventSubscribed)
+                    Signalinteraction(commonStackerCrane);  //鍑哄簱淇″彿浜や簰
+                    Siganlinteraction2(commonStackerCrane); //鍏ュ簱淇″彿浜や簰
+                    /*if (!commonStackerCrane.IsEventSubscribed)
                     {
                         commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢
+                    }*/
+                    if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.WorkCompleted)
+                    {
+                        wcs_PLCto07("浠诲姟瀹屾垚", $"浠诲姟鍙凤細{commonStackerCrane.CurrentTaskNum}", $"璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿锛屼换鍔″畬鎴愶紝瀹屾垚鏃堕棿锛歿DateTime.Now}");
+                        //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
+                        WebResponseContent webResponse=_taskService.StackCraneTaskCompleted(commonStackerCrane.CurrentTaskNum);
+                        if (webResponse.Status)
+                        {
+                            
+                            bool ddjfk= commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
+                            wcs_PLCto07("浠诲姟瀹屾垚", $"浠诲姟鍙凤細{commonStackerCrane.CurrentTaskNum}锛屼慨鏀逛换鍔℃垚鍔�", $"淇敼浠诲姟瀹屾垚锛屽苟鍙嶉鍫嗗灈瀹屾垚淇″彿鏄惁鎴愬姛锛歿ddjfk}");
+                        }
+                        else
+                        {
+                            WebResponseContent webRespon = _taskService.StackCraneTashty(commonStackerCrane.CurrentTaskNum);
+                            if (webRespon.Status)
+                            {
+
+                                bool fk = commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
+                                wcs_PLCto07("浠诲姟瀹屾垚", $"浠诲姟鍙凤細{commonStackerCrane.CurrentTaskNum},鍘嗗彶鏌ヨ淇℃伅", $"浠诲姟鏌ユ壘浠诲姟閲嶏紝骞惰繘琛屽弽棣堬細{fk}");
+                            }
+                            else
+                            {
+                                wcs_PLCto07("浠诲姟瀹屾垚鏁呴殰", $"浠诲姟鍙凤細{commonStackerCrane.CurrentTaskNum}锛屽巻鍙蹭换鍔℃煡璇㈡暟鎹�", $"澶辫触鍘熷洜锛歿webResponse.Message}");
+                            }
+
+                        }
                     }
+
 
                     if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal)
                     {
-                        CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams");
-                        Signalinteraction(conveyorLine, commonStackerCrane);
-
-
-                        commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
+                        //commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆�
 
                         if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                         {
@@ -97,9 +127,10 @@
             CommonStackerCrane? commonStackerCrane = sender as CommonStackerCrane;
             if (commonStackerCrane != null)
             {
-                if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5)
+                if (commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.WorkType) != 5 && e.TaskNum !=0)
                 {
-                    Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
+                    wcs_PLCto07("浠诲姟瀹屾垚", $"浠诲姟鍙凤細{e.TaskNum}", $"璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿锛屼换鍔″畬鎴愶紝瀹屾垚鏃堕棿锛歿DateTime.Now}");
+                    //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
                     _taskService.StackCraneTaskCompleted(e.TaskNum);
                     commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                 }
@@ -113,60 +144,113 @@
         /// <returns></returns>
         private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
         {
-            Dt_Task task;
-            if (commonStackerCrane.LastTaskType == null)
+            try
             {
-                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
-            }
-            else
-            {
-                if (commonStackerCrane.LastTaskType.GetValueOrDefault().GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
-                {
-                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
-                    if (task == null)
-                    {
-                        task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
-                    }
-                }
-                else
-                {
-                    task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode);
-                }
-            }
+                //  
+                if (_taskService.CutStackerCraneTask(commonStackerCrane.DeviceCode) != null) return null;
+                //鏌ヨ鍏ㄩ儴浠诲姟锛屾寜鏃堕棿鎺掑簭杩涜鏌ヨ
+                List<Dt_Task> TasksList = _taskService.CraneTaskList(commonStackerCrane.DeviceCode);
+                if (TasksList.Count == 0) return null;
 
-            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
-            {
-                string[] targetCodes = task.SourceAddress.Split("-");
-                if (targetCodes[4] == "02")
+                Dt_Task RELNew= TasksList.Where(x=>x.TaskType== (int)TaskRelocationTypeEnum.Relocation && x.TaskState == (int)TaskOutStatusEnum.ResRestNet).OrderBy(x => x.CreateDate).FirstOrDefault();
+                if( RELNew != null )
                 {
 
-                    task = OutTaskMovelibrary(task);
-                    if (task != null)
+                    string[] targetCodes = RELNew.TargetAddress.Split("-");
+
+                    //濡傛灉涓烘繁搴撲綅锛屽垯鏌ョ湅鏄惁鏈夐渶瑕佹墽琛岀殑浠诲姟
+                    if (targetCodes[4] == "02")
                     {
-                        return task;
-                    }
-                }
-                if (OutTaskStationIsOccupied(task) != null)
-                {
-                    return task;
-                }
-                else
-                {
-                    List<string> otherOutStaionCodes = _routerService.QueryNextRoutes(commonStackerCrane.DeviceCode, task.NextAddress).Select(x => x.ChildPosi).ToList();
-                    List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode, otherOutStaionCodes);
-                    foreach (var item in tasks)
-                    {
-                        if (OutTaskStationIsOccupied(task) != null)
+
+                        Dt_Task taskstrot = InTaskMove(RELNew);
+                        if (taskstrot != null)
                         {
-                            return task;
+                            return taskstrot;
                         }
                     }
-                    task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode);
+                    else
+                    {
+                            return RELNew;
+                    }
                 }
-            }
 
-            return task;
+
+                foreach (var item in TasksList)
+                {
+                    if (item.TaskType == (int)TaskInboundTypeEnum.Inbound)
+                    {
+                        string[] targetCodes = item.TargetAddress.Split("-");
+                        if (targetCodes[4] == "01") return item;        //濡傛灉鏄祬搴撲綅锛屽垯鐩存帴杩斿洖璇ヤ换鍔�
+
+                        //濡傛灉涓烘繁搴撲綅锛屽垯鏌ョ湅鏄惁鏈夐渶瑕佹墽琛岀殑浠诲姟
+                        if (targetCodes[4] == "02")
+                        {
+
+                            Dt_Task taskst = InTaskMove(item);
+                            if (taskst != null)
+                            {
+                                return taskst;
+                            }
+                        }
+                    }
+                    else if (item.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+                    {
+                        string[] targetCodes = item.SourceAddress.Split("-");//杩涜瑙f瀽璐т綅
+                        if (targetCodes[4] == "02")
+                        {
+                            //涓烘繁搴撲綅
+                            Dt_Task taskst = OutTaskMovelibrary(item);  //鍒ゆ柇鏄惁闇�瑕佽繘琛岀Щ搴�
+                            if (taskst != null)
+                            {
+                                if (taskst.TaskType == (int)TaskRelocationTypeEnum.Relocation)
+                                {
+                                    return taskst;
+                                }
+                                else
+                                {
+                                    if (taskst.TargetAddress == "R02-001-021-001-02" || taskst.TargetAddress == "R02-001-022-001-02")
+                                    {
+                                        return taskst;
+                                    }
+                                    else
+                                    {
+                                        if (OutTaskStationIsOccupied(taskst) != null)       //鍒ゆ柇鍑哄簱绔欏彴鏄惁鍙笅鍙�
+                                        {
+                                            return taskst;
+                                        }
+                                    }
+
+                                }
+                            }
+                        }
+                        else
+                        {
+                            if (item.TargetAddress == "R02-001-021-001-02" || item.TargetAddress == "R02-001-022-001-02")
+                            {
+                                return item;
+                            }
+                            else
+                            {
+                                if (OutTaskStationIsOccupied(item) != null)       //鍒ゆ柇鍑哄簱绔欏彴鏄惁鍙笅鍙�
+                                {
+                                    return item;
+                                }
+                            }
+                            
+                        }
+                    }
+                }
+
+                return null;
+            }
+            catch (Exception ex)
+            {
+                WriteLog.Write_Log("鍫嗗灈鏈轰换鍔′笅鍙戞晠闅�", "鏁呴殰", "鏁呴殰", new { 淇℃伅 = ex.Message });
+                return null;
+            } 
         }
+
+       
 
         /// <summary>
         /// 鍑哄簱浠诲姟鍒ゆ柇鍑哄簱绔欏彴鏄惁琚崰鐢�
@@ -175,13 +259,22 @@
         /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns>
         private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task)
         {
-            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1002");
+            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
             if (device != null)
             {
                 CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
-                if (conveyorLine.IsOccupied(task.TargetAddress))//鍑哄簱绔欏彴鏈鍗犵敤
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Event");    //鏍规嵁鍫嗗灈鏈哄湴鍧�锛屽湴鍧�鍚嶇О鎵惧崗璁�
+                if (deviceProDTO != null)
                 {
-                    return task;
+                    int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //鍒ゆ柇杈撻�佺嚎鏄惁鍏佽鏀捐揣淇″彿
+                    if (B_Event_Test == 1)
+                    {
+                        return task;
+                    }
+                    else
+                    {
+                        wcs_PLCto08("鍑哄簱浠诲姟", $"浠诲姟鍙凤細{task.TaskNum}锛岃繘琛屽嚭搴�", $"璇诲彇鍒拌緭閫佺嚎涓嶅彲鏀捐揣淇″彿锛屼笉鍙繘琛屼换鍔′笅鍙�");
+                    }
                 }
             }
             else
@@ -191,6 +284,7 @@
             return null;
         }
 
+        
         /// <summary>
         /// 鍑哄簱浠诲姟鍒ゆ柇鏄惁闇�瑕佽繘琛岀Щ搴揗ove the library
         /// </summary>
@@ -198,57 +292,914 @@
         /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns>
         private Dt_Task? OutTaskMovelibrary([NotNull] Dt_Task task)
         {
-            try
+            string[] targetCodes = task.SourceAddress.Split("-");
+            if (targetCodes[1] == "001")
             {
-                string[] targetCodes = task.SourceAddress.Split("-");
-                if (targetCodes[1] == "001")
-                {
-                    targetCodes[1] = "002";
+                targetCodes[1] = "002";
 
-                }
-                else if (targetCodes[1] == "004")
-                {
-                    targetCodes[1] = "003";
-                }
-                targetCodes[4] = "01";
-                string SourceAddress = string.Join("-", targetCodes); //缁勮娴呭簱浣嶅湴鍧�
-                Dt_Task? tasks = _taskService.QueryStationIsOccupiedOutTasks(task.Roadway, SourceAddress).FirstOrDefault();
-                if (tasks != null)
-                {
-                    return task;
-                }
-                else
-                {
-                    //鍚憌ms鐢宠鍒ゆ柇娴呭簱浣嶆槸鍚︽湁璐э紝鏄惁闇�瑕佽繘琛岀Щ搴�
-                    Dt_Task? taskst = _taskService.RequestWMSTaskMovelibrary(task);
-                    if (taskst != null)
-                    {
-                        return taskst;
-                    }
-                }
             }
-            catch (Exception ex)
+            else if (targetCodes[1] == "004")
             {
-
-                throw;
+                targetCodes[1] = "003";
+            }
+            targetCodes[4] = "01";
+            string SourceAddress = string.Join("-", targetCodes); //缁勮娴呭簱浣嶅湴鍧�
+            Dt_Task? tasks = _taskService.QueryStationIsOccupiedOutTasks(task.Roadway, SourceAddress).FirstOrDefault(); //鎵炬祬搴撲綅鏄惁鏈変换鍔�
+            if (tasks != null)
+            {
+                return tasks;
+            }
+            else
+            {
+                //鍚憌ms鐢宠鍒ゆ柇娴呭簱浣嶆槸鍚︽湁璐э紝鏄惁闇�瑕佽繘琛岀Щ搴�
+                Dt_Task? taskst = _taskService.RequestWMSTaskMovelibrary(task);
+                if (taskst != null)
+                {
+                    return taskst;
+                }
             }
             return null;
         }
 
-        public void Signalinteraction(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane)
+        private Dt_Task? InTaskMove([NotNull] Dt_Task task)
         {
-            //鍏ュ簱淇″彿浜や簰
-            int B_Event = conveyorLine.Communicator.Read<int>("PLC_WCS_B.01_EVENT");
-            int B_Event2 = conveyorLine.Communicator.Read<int>("PLC_WCS_C.03_EVENT");
-            if (B_Event == 1 || B_Event2 == 1)
+            string[] targetCodes = task.TargetAddress.Split("-");
+            if (targetCodes[1] == "001")
             {
-                Stackerstatic(conveyorLine,commonStackerCrane);
-            }
+                targetCodes[1] = "002";
 
-            //鍑哄簱淇″彿浜や簰
-            //Stackerstatic2(conveyorLine, commonStackerCrane);
+            }
+            else if (targetCodes[1] == "004")
+            {
+                targetCodes[1] = "003";
+            }
+            targetCodes[4] = "01";
+            string TargetAddress = string.Join("-", targetCodes);  //鐢ㄦ繁搴撲綅缁勮娴呭簱浣嶇紪鍙�
+            Dt_Task? tasks = _taskService.QueryStationIsOccupiedOutTasks2(task.Roadway, TargetAddress).FirstOrDefault(); //鎵炬祬搴撲綅鏄惁鏈夊嚭搴撲换鍔℃垨绉诲簱浠诲姟
+            if(tasks != null) { return tasks; }     //濡傛灉鏈夛紝鍒欏厛涓嬪彂鑷冲爢鍨涙満
+
+            //鍚憌ms鐢宠鍒ゆ柇娴呭簱浣嶆槸鍚︽湁璐э紝鏄惁闇�瑕佽繘琛岀Щ搴�
+            Dt_Task? taskst = _taskService.RequestWMSTaskMovelibrary2(task);
+            if (taskst != null)
+            {
+                return taskst;
+            }
+            return null;    
+        }
+
+       
+
+        public void Signalinteraction(CommonStackerCrane commonStackerCrane)
+        {
+            if (Applyrelease(commonStackerCrane)) //璇诲彇鍫嗗灈鏈烘斁璐х敵璇�
+            {
+                Dt_Task task = _taskService.IngStackerCraneTask2(commonStackerCrane.DeviceCode);
+                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound && (task.TargetAddress != "R02-001-021-001-02" && task.TargetAddress != "R02-001-022-001-02"))
+                {
+                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
+                    if (device != null)
+                    {
+                        CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                        DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Event");    //鏍规嵁鍫嗗灈鏈哄湴鍧�锛屽湴鍧�鍚嶇О鎵惧崗璁�
+                        if (deviceProDTO != null)
+                        {
+                            int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //鍒ゆ柇杈撻�佺嚎鏄惁鍏佽鏀捐揣淇″彿
+                            if (B_Event_Test == 1)
+                            {
+
+                                if (Releasespermitted(commonStackerCrane, task.TargetAddress,true))  //鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊
+                                {
+
+                                    wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", "鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙锋垚鍔燂細true");
+                                }
+                                else
+                                {
+                                    wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", "鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙峰け璐�");
+                                }
+                            }
+                            else
+                            {
+                                if (Releasespermitted(commonStackerCrane, task.TargetAddress,false))  //鍐欏叆鍫嗗灈鏈轰笉鍏佽鏀捐揣淇�
+                                {
+
+                                    wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", "鍐欏叆鍫嗗灈鏈轰笉鍏佽鏀捐揣淇″彿鎴愬姛锛歠alse");
+                                }
+                                else
+                                {
+                                    wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", "鍐欏叆鍫嗗灈鏈轰笉鍏佽鏀捐揣淇″彿澶辫触");
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            else
+            {
+                Dt_Task task = _taskService.IngStackerCraneTask2(commonStackerCrane.DeviceCode);
+                if (task !=null && task.TaskType == (int)TaskOutboundTypeEnum.Outbound &&(task.TargetAddress != "R02-001-021-001-02" && task.TargetAddress != "R02-001-022-001-02"))
+                {
+                    if (Completesignal(commonStackerCrane, task.TargetAddress))        //璇诲彇鍒版斁璐у畬鎴愪俊鍙�
+                    {
+                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress));
+                        if (device != null)
+                        {
+                            CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                            if (task.TargetAddress == "R02-002-027-011-01" || task.TargetAddress == "R01-002-041-011-01")   //鍐欏叆杈撻�佺嚎鍘诲悜
+                            {
+                                byte PLCtost = (byte)task.PLCTo;
+                                if (PLCSignal2(conveyorLine, task.TargetAddress, "W_Destination", PLCtost))
+                                {
+
+                                    wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍘诲悜鎴愬姛锛屽幓鍚戜负锛歿PLCtost}");
+                                }
+                                else
+                                {
+                                    wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍘诲悜澶辫触锛屽幓鍚戜负锛歿PLCtost}");
+                                }
+                            }
+
+                            if (PLCSignal(conveyorLine, task.TargetAddress, (byte)1)) //鍐欏叆杈撻�佺嚎 鍫嗗灈鏈烘斁璐� 淇″彿
+                            {
+                                //璇诲彇杈撻�佺嚎鍙嶉  鍫嗗灈鏈烘斁涓嬩俊鍙�
+                                DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_StackerCraneLowered");    //杈撻�佺嚎鍗忚鎵捐鍙栦俊鍙�
+                                if (deviceProDTO2 != null)
+                                {
+                                    int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //璇诲彇杈撻�佺嚎鐨�  鍫嗗灈鏈烘斁涓� 淇″彿
+                                    WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氳鍙栧埌杈撻�佺嚎-鍫嗗灈鏈烘斁涓嬩俊鍙凤細{B_TAKE}", $"锛堟斁璐э級璇诲彇{task.TargetAddress}");
+
+                                    if (B_TAKE == 1)
+                                    {
+                                        if (task.TargetAddress == "R02-002-027-011-01" || task.TargetAddress == "R01-002-041-011-01")
+                                        {
+                                            DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Destination");
+                                            if (deviceProDTO3 != null)
+                                            {
+                                                int PLCwcstost = GetLine(conveyorLine, deviceProDTO3.DeviceProDataBlock);
+                                                if (PLCwcstost == task.PLCTo)
+                                                {
+                                                    byte PLCtost2 = 0;
+                                                    if (PLCSignal2(conveyorLine, task.TargetAddress, "W_Destination", PLCtost2))
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"娓呴櫎鍘诲悜鎴愬姛");
+                                                    }
+                                                    else
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"娓呴櫎鍘诲悜澶辫触");
+                                                    }
+                                                    // 娓呴櫎杈撻�佺嚎
+                                                    if (PLCSignal(conveyorLine, task.TargetAddress, (byte)0))
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔�");
+                                                    }
+                                                    else
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�");
+                                                    }
+                                                    //鍫嗗灈鏈哄啓瀹屾垚
+                                                    if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true))
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔燂細true");
+                                                    }
+                                                    else
+                                                    {
+                                                        wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�:true");
+                                                    }
+
+                                                }
+                                                else
+                                                {
+                                                    wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍘诲悜姣斿涓嶄竴鑷达紝杈撻�佺嚎鍘诲悜涓猴細{PLCwcstost}锛寃cs鍐欏叆鍘诲悜涓猴細{task.PLCTo}");
+                                                }
+                                            }
+                                        }
+                                        
+                                        if (task.TargetAddress != "R02-002-027-011-01" && task.TargetAddress != "R01-002-041-011-01")
+                                        {
+                                            // 娓呴櫎杈撻�佺嚎
+                                            if (PLCSignal(conveyorLine, task.TargetAddress, 0))
+                                            {
+                                                wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔�");
+                                            }
+                                            else
+                                            {
+                                                wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�");
+                                            }
+
+                                            //鍫嗗灈鏈哄啓瀹屾垚
+                                            if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true))
+                                            {
+
+                                                wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔燂細true");
+                                            }
+                                            else
+                                            {
+                                                wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�:true");
+
+                                            }
+                                        }
+
+                                            
+                                    }
+                                    else
+                                    {
+                                        // 娓呴櫎杈撻�佺嚎
+                                        if (PLCSignal(conveyorLine, task.TargetAddress, 0))
+                                        {
+                                            wcs_PLCto06(task.TargetAddress + "鎴愬姛淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栧埌杈撻�佺嚎鍙嶉鍫嗗灈鏈哄畬鎴愬弽棣堜俊鍙凤紝閲嶇疆涓�0");
+                                        }
+                                        else
+                                        {
+                                            wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栧埌杈撻�佺嚎鍙嶉鍫嗗灈鏈哄畬鎴愬弽棣堜俊鍙凤紝閲嶇疆涓�0澶辫触");
+                                        }
+                                    }
+                                }
+                            }
+                            else
+                            {
+                                wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎0-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�");
+
+                            }
+                        }
+                    }
+                    else
+                    {
+                        wcs_PLCto06(task.TargetAddress + "閿欒淇℃伅", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栧埌鍫嗗灈鏈烘斁璐у畬鎴愪俊鍙�");
+                    }
+                }
+            }
+        }
+
+        public void Siganlinteraction2(CommonStackerCrane commonStackerCrane)
+        {
+            Dt_Task task = _taskService.IngStackerCraneTask(commonStackerCrane.DeviceCode);
+            if (task != null && task.TaskType == (int)TaskInboundTypeEnum.Inbound)
+            {
+                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.SourceAddress));
+                if (device != null)
+                {
+                    CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
+                    DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_Event");    //鏍规嵁鍫嗗灈鏈哄湴鍧�锛屽湴鍧�鍚嶇О鎵惧崗璁�
+                    if (deviceProDTO != null)
+                    {
+                        int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock);        //鍒ゆ柇杈撻�佺嚎鏄惁鍏佽鍙栬揣淇″彿
+                        if (B_Event_Test == 1)
+                        {
+                            if (Releasespermitted2(commonStackerCrane, task.SourceAddress,true))  //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙�
+                            {
+                                wcs_PLCto05(task.SourceAddress+"锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙锋垚鍔�:true");
+                            }
+                            else
+                            {
+                                wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙锋垚鍔�:true");
+                            }
+                        }
+                        else
+                        {
+                            if (Releasespermitted2(commonStackerCrane, task.SourceAddress,false))  //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙�
+                            {
+                                wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栧埌杈撻�佺嚎鍏佽鍙栬揣淇″彿锛屽啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿鎴愬姛:false");
+                            }
+                            else
+                            {
+
+                                wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栧埌杈撻�佺嚎鍏佽鍙栬揣淇″彿锛屽啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿澶辫触");
+                            }
+                           
+                        }
+                    }
+
+                    if (Completesignal2(commonStackerCrane, task.SourceAddress))    //璇诲彇鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙�
+                    {
+                        if(PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 1))    //鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿
+                        {
+                            wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿锛屽湴鍧�锛歿conveyorLine}");
+                            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCranePicked");    //杈撻�佺嚎鍗忚鎵捐鍙栦俊鍙�
+                            if (deviceProDTO != null)
+                            {
+                                int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //璇诲彇杈撻�佺嚎鐨�  鍫嗗灈鏈哄彇璧� 淇″彿
+                                if (B_TAKE == 1)
+                                {
+                                    //鍐欏叆缁欏爢鍨涙満锛岃緭閫佺嚎鐨�  鍫嗗灈鏈哄彇璧� 淇″彿
+                                    if(Releasespermitted3(commonStackerCrane, task.SourceAddress,true))
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙锋垚鍔�:true");
+                                    }
+                                    else
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙峰け璐�:true");
+                                    }
+                                }
+                                else
+                                {
+                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress,false))
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:false");
+                                    }
+                                    else
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:false");
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+                            wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿澶辫触锛屽湴鍧�锛歿conveyorLine}");
+                        }
+                    }
+                    else
+                    {
+                        if (PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 0))    //鍐欏叆杈撻�佺嚎娓呴櫎淇″彿
+                        {
+                            wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎淇″彿鎴愬姛锛屽湴鍧�锛歿conveyorLine}");
+                            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCranePicked");    //杈撻�佺嚎鍗忚鎵捐鍙栦俊鍙�
+                            if (deviceProDTO != null)
+                            {
+                                int B_TAKE = GetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock);        //璇诲彇杈撻�佺嚎鐨�  鍫嗗灈鏈哄彇璧� 淇″彿
+                                if (B_TAKE == 0)
+                                {
+                                    //鍐欏叆缁欏爢鍨涙満锛岃緭閫佺嚎鐨�  鍫嗗灈鏈哄彇璧� 淇″彿
+                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress, false))
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙锋垚鍔�:true");
+                                    }
+                                    else
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙峰け璐�:true");
+                                    }
+                                }
+                                else
+                                {
+                                    if (Releasespermitted3(commonStackerCrane, task.SourceAddress, false))
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氭垚鍔熶俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:false");
+                                    }
+                                    else
+                                    {
+                                        wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:false");
+                                    }
+                                }
+                            }
+                        }
+                        else
+                        {
+                            wcs_PLCto05(task.SourceAddress + "锛氶敊璇俊鎭�", $"浠诲姟鍙凤細{task.TaskNum}锛屾墭鐩樻潯鐮侊細{task.PalletCode}", $"鍐欏叆杈撻�佺嚎娓呴櫎淇″彿澶辫触锛屽湴鍧�锛歿conveyorLine}");
+                        }
+                    }
+                }
+            } 
 
         }
+
+        //鑾峰彇杈撻�佺嚎瀹炰緥
+        public DeviceProDTO? GetDeviceProDTO(CommonConveyorLine conveyorLine,string SCAddress,string Interactivet)
+        {
+            return conveyorLine.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet);
+        }
+
+        //鑾峰彇鍫嗗灈鏈轰緥
+        public DeviceProDTO? GetDeviceProDTO2(CommonStackerCrane commonStackerCrane, string DeviceName, string Interactivet)
+        {
+            return commonStackerCrane.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == DeviceName && x.DeviceProParamName == Interactivet);
+        }
+
+        //璇诲彇鍫嗗灈鏈虹敵璇锋斁璐т俊鍙�
+        public bool Applyrelease(CommonStackerCrane commonStackerCrane)
+        {
+            if (commonStackerCrane.DeviceCode == "SC02")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Bout");
+                if (deviceProDTO != null)
+                {
+                    if(GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+                DeviceProDTO? deviceProDTO2 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout");
+                if (deviceProDTO2 != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO2.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            if (commonStackerCrane.DeviceCode == "SC01")
+            {
+                DeviceProDTO? deviceProDTO4 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Cout");
+                if (deviceProDTO4 != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO4.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+                DeviceProDTO? deviceProDTO3 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout");
+                if (deviceProDTO3 != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO3.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+                DeviceProDTO? deviceProDTO5 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Aout");
+                if (deviceProDTO5 != null)
+                {
+                    if(GetStacker(commonStackerCrane, deviceProDTO5.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+                DeviceProDTO? deviceProDTO6 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_A2in");  //绌烘墭鍑哄叆搴�
+                if (deviceProDTO6 != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO6.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+
+        }
+        
+        //鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙�
+        public bool Releasespermitted(CommonStackerCrane commonStackerCrane, string Destinationaddress,bool SCcrane)
+        {
+            if (Destinationaddress == "R02-002-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Bout");
+                if (deviceProDTO != null)
+                {
+                    if(SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R02-002-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-002-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Cout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-044-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Aout");
+                if (deviceProDTO != null)
+                {
+                   if(SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            return false;
+        }
+        
+        //璇诲彇鍫嗗灈鏈虹殑鏀捐揣瀹屾垚淇″彿
+        public bool Completesignal(CommonStackerCrane commonStackerCrane,string Destinationaddress)
+        {
+            if (Destinationaddress == "R02-002-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Bout");
+                if (deviceProDTO != null)
+                {
+                    if(GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                    
+                }
+            }
+            if (Destinationaddress == "R02-002-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-002-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Cout");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            if (Destinationaddress == "R01-002-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-044-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Aout");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            return false;
+
+        }
+        
+        //鍐欏叆鍫嗗灈鏈烘斁璐х‘璁や俊鍙�
+        public bool Releasespermitted4(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
+        {
+            if (Destinationaddress == "R02-002-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Bout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R02-002-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-002-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Cout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Dout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-044-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Aout");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            return false;
+        }
+
+
+        //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙�
+        public bool Releasespermitted2(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
+        {
+            if (Destinationaddress == "R02-003-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Bin");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R02-003-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-003-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Cin");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-003-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-042-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Ain");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            return false;
+        }
+        
+        //璇诲彇鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙�
+        public bool Completesignal2(CommonStackerCrane commonStackerCrane, string Destinationaddress)
+        {
+            if (Destinationaddress == "R02-003-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Bin");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            if (Destinationaddress == "R02-003-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-003-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Cin");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+            if (Destinationaddress == "R01-003-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-042-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Ain");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress).Status)
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+
+        }
+
+        //鍐欏叆鍫嗗灈鏈哄彇璐х‘璁や俊鍙�
+        public bool Releasespermitted3(CommonStackerCrane commonStackerCrane, string Destinationaddress, bool SCcrane)
+        {
+            if (Destinationaddress == "R02-003-027-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Bin");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R02-003-027-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            //1鍙�
+            if (Destinationaddress == "R01-003-041-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Cin");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-003-041-011-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            if (Destinationaddress == "R01-002-042-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Ain");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+            if (Destinationaddress == "R01-002-043-001-01")
+            {
+                DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_A2in");
+                if (deviceProDTO != null)
+                {
+                    if (SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, SCcrane).Status) { return true; }
+                }
+            }
+
+            return false;
+        }
+        
+
+        //鍐欏叆杈撻�佺嚎鏀捐揣瀹屾垚淇″彿锛屾潯鐮侊紝灞傛暟锛岀被鍨�
+        public bool PLCSignal(CommonConveyorLine conveyorLine,string TargetAddress,byte staLow)
+        {
+            //澶勭悊鍑哄簱鏀炬枡瀹屾垚鍚庨�昏緫
+            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_StackerCraneLowered");    //鏀捐揣瀹屾垚淇″彿
+            if (deviceProDTO2 != null)
+            {
+                if (SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, staLow))
+                {
+                    return true;
+
+                }
+            }
+            return false;
+        }
+
+        //鍐欏叆杈撻�佺嚎 鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙�
+        public bool PLCSignal2(CommonConveyorLine conveyorLine, string SourceAddress,string DeviceProParamName,Byte stock)
+        {
+            DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, SourceAddress, DeviceProParamName);    //鍙栬揣瀹屾垚淇″彿
+            if (deviceProDTO2 != null)
+            {
+                return SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, stock);
+            }
+            return false;
+        }
+
+        
+        /// <summary>
+        /// 鏍规嵁鍗忚锛屽湴鍧�锛屽�硷紝鍐欏叆杈撻�佺嚎淇℃伅,
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="DeviceProDataBlock"></param>
+        /// <param name="Pali"></param>
+        /// <returns></returns>
+        public bool SetLine(CommonConveyorLine conveyorLine,string DeviceProDataBlock,byte Pali)
+        {
+            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
+        }
+        public bool SetLinestring(CommonConveyorLine conveyorLine, string DeviceProDataBlock, string Pali)
+        {
+            return conveyorLine.Communicator.Write(DeviceProDataBlock, Pali);
+        }
+        /// <summary>
+        /// 鏍瑰湴鍧�璇诲彇杈撻�佺嚎淇℃伅
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="DeviceProDataBlock"></param>
+        /// <returns></returns>
+        public int GetLine(CommonConveyorLine conveyorLine, string DeviceProDataBlock)
+        {
+            return conveyorLine.Communicator.Read<byte>(DeviceProDataBlock);
+        }
+
+        /// <summary>
+        /// 璇诲彇鍫嗗灈鏈哄湴鍧�
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="DeviceProDataBlock"></param>
+        /// <returns></returns>
+        public WebResponseContent GetStacker(CommonStackerCrane commonStackerCrane,string DeviceProDataBlock)
+        {
+            WebResponseContent content= new WebResponseContent();
+            if (commonStackerCrane.Communicator.Read<bool>(DeviceProDataBlock))
+            {
+                return content.OK();
+            }
+            else
+            {
+                return content.Error();
+            }
+            
+        }
+
+        /// <summary>
+        /// 鍐欏叆鍫嗗灈鏈轰俊鍙�
+        /// </summary>
+        /// <param name="conveyorLine"></param>
+        /// <param name="DeviceProDataBlock"></param>
+        /// <returns></returns>
+        public WebResponseContent SetStacker(CommonStackerCrane commonStackerCrane, string DeviceProDataBlock,bool Pali)
+        {
+            WebResponseContent content = new WebResponseContent();
+            if (commonStackerCrane.Communicator.Write(DeviceProDataBlock, Pali))
+            {
+                return content.OK();
+            }
+            else
+            {
+                return content.Error();
+            }
+        }
+
         /// <summary>
         /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel
         /// </summary>
@@ -259,7 +1210,7 @@
         {
             StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand();
 
-            stackerCraneTaskCommand.Barcode = task.PalletCode;
+            stackerCraneTaskCommand.Barcode = ""; /*task.PalletCode;*/
             stackerCraneTaskCommand.TaskNum = task.TaskNum;
             stackerCraneTaskCommand.WorkType = 1;
             stackerCraneTaskCommand.TrayType = 0;
@@ -268,9 +1219,9 @@
                 string[] targetCodest = task.SourceAddress.Split("-");
                 if (targetCodest.Length == 5)
                 {
-                    stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodest[1]);
-                    stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodest[2]);
-                    stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodest[3]);
+                    stackerCraneTaskCommand.StartRow = Convert.ToInt16(targetCodest[1]);
+                    stackerCraneTaskCommand.StartColumn = Convert.ToInt16(targetCodest[2]);
+                    stackerCraneTaskCommand.StartLayer = Convert.ToInt16(targetCodest[3]);
                 }
                 else
                 {
@@ -353,188 +1304,28 @@
             return stackerCraneTaskCommand;
         }
 
-        /// <summary>
-        /// 鏍规嵁绔欏彴鍚嶇О鍐欏叆
-        /// </summary>
-        /// <param name="commonStackerCrane"></param>
-        /// <param name="platform"></param>
-        public void Stackerstatic(CommonConveyorLine conveyorLine,CommonStackerCrane commonStackerCrane)
-        {
-            // 璋冪敤鏂规硶澶勭悊涓嶅悓 SourceAddress 鐨勪换鍔�
-            Dt_Task task = _taskService.IngStackerCraneTask(commonStackerCrane.DeviceName);
 
-            if (task.SourceAddress == "R01-003-027-001-01")
-            {
-                HandleStackerCraneTask(conveyorLine,commonStackerCrane,task, StackerCraneDBName.Requestpickup.ToString(), StackerCraneDBName.toRequestpickup.ToString(), "WCS_PLC_B.01_WCS_TAKE");
-            }
-            else if (task.SourceAddress == "R01-003-041-001-01")
-            {
-                HandleStackerCraneTask(conveyorLine, commonStackerCrane,task, StackerCraneDBName.Requestpickuptwo.ToString(), StackerCraneDBName.toRequestpickuptwo.ToString(), "WCS_PLC_C.03_WCS_TAKE");
-            }
+        public void wcs_PLCto05(string SCLLinStack, string Logtype, string Magessadd)
+        {
+            WriteLog.Write_Log("鍏ュ簱浜や簰淇℃伅", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
+        }
+        public void wcs_PLCto06(string SCLLinStack, string Logtype, string Magessadd)
+        {
+            WriteLog.Write_Log("鍑哄簱浜や簰淇℃伅", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
         }
 
-
-        /// <summary>
-        /// 鍑哄簱淇℃伅浜や簰
-        /// </summary>
-        /// <param name="commonStackerCrane"></param>
-        /// <param name="platform"></param>
-        public void Stackerstatic2(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane)
+        public void wcs_PLCto07(string SCLLinStack, string Logtype, string Magessadd)
         {
-            //璇诲彇鍫嗗灈鏈轰袱涓珯鍙版槸鍚︽湁鏀捐揣鐢宠
-            // 妫�鏌ュ爢鍨涙満鏄惁璇锋眰鏀捐揣淇″彿
-            if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Requestpickupout))
-            {
-                LogSignalStatus("璇诲彇鍒板爢鍨涙満鐢宠鏀捐揣淇″彿", "R01-002-027-001-01");
-                Dt_Task? task = _taskService.IngStackerCraneTask(commonStackerCrane.DeviceName);
-                WriteLogAndHandleConveyorSignal(conveyorLine, commonStackerCrane, task, StackerCraneDBName.toRequestpickupout, "R01-002-027-001-01");
-            }
-
-            
-
-            // 鍒ゆ柇涓嶅悓鐨勭珯鍙�
-            /*if (task.SourceAddress == "R01-002-027-001-01")
-            {
-                HandleStackerCraneForAddress027001(conveyorLine, commonStackerCrane, task);
-            }
-            else if (task.SourceAddress == "R01-002-041-001-01")
-            {
-                HandleStackerCraneForAddress041001(conveyorLine, commonStackerCrane, task);
-            }*/
+            WriteLog.Write_Log("浠诲姟淇℃伅瀹屾垚璁板綍", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
+        }
+        public void wcs_PLCto07_1(string SCLLinStack, string Logtype, string Magessadd)
+        {
+            WriteLog.Write_Log("浠诲姟淇℃伅瀹屾垚淇敼璁板綍", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
         }
 
-        // 灏佽鍏ュ簱绔欏彴
-        // 瀹氫箟涓�涓柟娉曟潵澶勭悊閲嶅鐨勫爢鍨涙満涓嶱LC浜や簰鎿嶄綔
-        private void HandleStackerCraneTask(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane,Dt_Task task, string requestSignal, string completionSignal, string writeAddress)
+        public void wcs_PLCto08(string SCLLinStack, string Logtype, string Magessadd)
         {
-            // 灏� completionSignal 杞崲涓� StackerCraneDBName 鏋氫妇鍊�
-            if (Enum.TryParse(completionSignal, out StackerCraneDBName completionEnum))
-            {
-                // 鑾峰彇鍫嗗灈鏈哄畬鎴愪俊鍙�
-                if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(completionEnum))
-                {
-                    WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿涓� true锛岀珯鍙扮紪鍙凤細{task.SourceAddress}", "绔欏彴淇℃伅");
-
-                    // 鍚戣緭閫佺嚎鍐欏叆鍙栬揣瀹屾垚淇″彿
-                    if (conveyorLine.Communicator.Write(writeAddress, 1))
-                    {
-                        WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿鎴愬姛锛�1锛岀珯鍙扮紪鍙凤細{task.SourceAddress}", "绔欏彴淇℃伅");
-                    }
-                    else
-                    {
-                        WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿澶辫触锛岀珯鍙扮紪鍙凤細{task.SourceAddress}", "绔欏彴淇℃伅");
-                    }
-                }
-                else
-                {
-                    WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿涓� false锛岀珯鍙扮紪鍙凤細{task.SourceAddress}", "绔欏彴淇℃伅");
-                }
-            }
-            else
-            {
-                WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鏃犳硶灏哻ompletionSignal瀛楃涓瞷completionSignal}杞崲涓烘湁鏁堢殑鏋氫妇鍊�", "绔欏彴淇℃伅");
-            }
-
-            if(Enum.TryParse(requestSignal, out StackerCraneDBName completionEnum2)){
-                // 鍐欏叆璇锋眰淇″彿
-                if (commonStackerCrane.SetValue(completionEnum2, true))
-                {
-                    WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆淇″彿鎴愬姛锛寋requestSignal}", "绔欏彴淇℃伅");
-                }
-                else
-                {
-                    WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆淇″彿澶辫触锛寋requestSignal}", "绔欏彴淇℃伅");
-                }
-            }
-            else
-            {
-                WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鏃犳硶灏哻ompletionSignal瀛楃涓瞷completionSignal}杞崲涓烘湁鏁堢殑鏋氫妇鍊�", "绔欏彴淇℃伅");
-            }
-            
-        }
-
-        private void HandleStackerCraneForAddress027001(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane, Dt_Task task)
-        {
-            // 妫�鏌ュ爢鍨涙満鏄惁璇锋眰鏀捐揣淇″彿
-            if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.Requestpickupout))
-            {
-                WriteLogAndHandleConveyorSignal(conveyorLine, commonStackerCrane, task, StackerCraneDBName.toRequestpickupout, "R01-002-027-001-01");
-            }
-            else
-            {
-                LogSignalStatus("鏈鍙栧埌鍫嗗灈鏈虹敵璇锋斁璐т俊鍙�", task.SourceAddress);
-            }
-
-            // 妫�鏌ュ爢鍨涙満瀹屾垚淇″彿
-            if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.toRequestpickup))
-            {
-                WriteLogAndHandleConveyorSignal(conveyorLine, commonStackerCrane, task, StackerCraneDBName.toRequestpickup, "R01-002-027-001-01");
-            }
-            else
-            {
-                LogSignalStatus("璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿涓猴紝false", task.SourceAddress);
-            }
-        }
-
-        private void HandleStackerCraneForAddress041001(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane, Dt_Task task)
-        {
-            if (commonStackerCrane.SetValue(StackerCraneDBName.Requestpickuptwo, true))
-            {
-                WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆淇″彿鎴愬姛锛孯equestpickup", "绔欏彴淇℃伅");
-            }
-            else
-            {
-                WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"鍐欏叆淇″彿澶辫触锛孯equestpickup", "绔欏彴淇℃伅");
-            }
-
-            // 妫�鏌ュ爢鍨涙満瀹屾垚淇″彿
-            if (commonStackerCrane.GetValue<StackerCraneDBName, bool>(StackerCraneDBName.toRequestpickuptwo))
-            {
-                WriteLogAndHandleConveyorSignal(conveyorLine, commonStackerCrane, task, StackerCraneDBName.toRequestpickuptwo, "R01-002-041-001-01");
-            }
-            else
-            {
-                LogSignalStatus("璇诲彇鍒板爢鍨涙満瀹屾垚淇″彿涓猴紝false", task.SourceAddress);
-            }
-        }
-
-        private void WriteLogAndHandleConveyorSignal(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane, Dt_Task task, StackerCraneDBName signalType, string sourceAddress)
-        {
-            // 璇诲彇杈撻�佺嚎淇″彿
-            int events = conveyorLine.Communicator.Read<int>("PLC_WCS_B.01_EVENT");
-            if (events == 0)
-            {
-                LogSignalStatus("璇诲彇鍒拌緭閫佺嚎鍏佽鏀捐揣淇″彿", sourceAddress);
-
-                // 鍐欏叆鍫嗗灈鏈轰俊鍙�
-                if (commonStackerCrane.SetValue(signalType, true))
-                {
-                    LogSignalStatus($"鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙�", sourceAddress);
-                }
-                else
-                {
-                    LogSignalStatus($"鏈啓鍏ュ爢鍨涙満鍏佽鏀捐揣淇″彿", sourceAddress);
-                }
-            }
-            else
-            {
-                LogSignalStatus($"鏈鍙栧埌杈撻�佺嚎鍏佽鏀捐揣淇″彿", sourceAddress);
-            }
-
-            // 鍐欏叆鍙栬揣瀹屾垚淇″彿
-            if (conveyorLine.Communicator.Write("WCS_PLC_B.01_WCS_TAKE", 1))
-            {
-                LogSignalStatus($"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿鎴愬姛", sourceAddress);
-            }
-            else
-            {
-                LogSignalStatus($"鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿澶辫触", sourceAddress);
-            }
-        }
-
-        private void LogSignalStatus(string message, string sourceAddress)
-        {
-            WriteLog.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"{message}锛岀珯鍙扮紪鍙凤細{sourceAddress}", "绔欏彴淇℃伅");
+            WriteLog.Write_Log("鍑哄簱绔欏彴淇℃伅", SCLLinStack, Logtype, new { 淇℃伅 = Magessadd });
         }
     }
 }

--
Gitblit v1.9.3