From 3ecd03b3a0a30a57153468beaed3199bfe906772 Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期一, 11 十一月 2024 16:58:37 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 828 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 628 insertions(+), 200 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..343e84a 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,5 +1,6 @@ 锘縰sing Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.Hosting; +using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup; using Quartz; using System; using System.Collections.Generic; @@ -17,6 +18,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,6 +49,8 @@ CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); if (commonStackerCrane != null) { + //Signalinteraction(commonStackerCrane); //鍑哄簱淇″彿浜や簰 + Siganlinteraction2(commonStackerCrane); //鍏ュ簱淇″彿浜や簰 if (!commonStackerCrane.IsEventSubscribed) { commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 @@ -54,10 +58,6 @@ if (commonStackerCrane.StackerCraneAutoStatusValue == StackerCraneAutoStatus.Automatic && commonStackerCrane.StackerCraneStatusValue == StackerCraneStatus.Normal) { - CommonConveyorLine conveyorLine = (CommonConveyorLine)context.JobDetail.JobDataMap.Get("JobParams"); - Signalinteraction(conveyorLine, commonStackerCrane); - - commonStackerCrane.CheckStackerCraneTaskCompleted();//闃叉浠诲姟瀹屾垚浜嬩欢鐩戞祴瓒呮椂锛屽啀鎵嬪姩瑙﹀彂涓�娆� if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby) @@ -175,13 +175,18 @@ /// <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 == 0) + { + return task; + } } } else @@ -235,20 +240,623 @@ return null; } - public void Signalinteraction(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane) + public void Signalinteraction(CommonStackerCrane commonStackerCrane) { - //鍏ュ簱淇″彿浜や簰 - 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) + if (Applyrelease(commonStackerCrane)) //璇诲彇鍫嗗灈鏈烘斁璐х敵璇� { - Stackerstatic(conveyorLine,commonStackerCrane); - } + Dt_Task task = _taskService.IngStackerCraneTask(commonStackerCrane.DeviceCode); + if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound) + { + 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 == 0) + { + if (Releasespermitted(commonStackerCrane, task.TargetAddress)) //鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊 + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙峰け璐�", task.TargetAddress); + } + } + else + { + LogSignalStatus("鏈鍙栧埌杈撻�佺嚎鍏佽鏀捐揣淇″彿", task.TargetAddress); + } + } - //鍑哄簱淇″彿浜や簰 - //Stackerstatic2(conveyorLine, commonStackerCrane); + if (Completesignal(commonStackerCrane, task.TargetAddress)) //璇诲彇鍒版斁璐у畬鎴愪俊鍙� + { + if(PLCSignal(conveyorLine, task.TargetAddress, task.PalletCode, (byte)task.PalletCodequantity)) //鍐欏叆杈撻�佺嚎 鍫嗗灈鏈烘斁璐� 鎵樼洏鏉$爜锛屽眰鏁帮紝绫诲瀷 + { + //璇诲彇杈撻�佺嚎鍙嶉 鍫嗗灈鏈烘斁涓嬩俊鍙� + DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCraneLowered"); //杈撻�佺嚎鍗忚鎵捐鍙栦俊鍙� + if (deviceProDTO != null) + { + int B_TAKE = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock); //璇诲彇杈撻�佺嚎鐨� 鍫嗗灈鏈烘斁涓� 淇″彿 + if (B_TAKE == 1) + { + //鍐欏叆缁欏爢鍨涙満锛岃緭閫佺嚎鐨� 鍫嗗灈鏈烘斁涓嬬‘璁� 淇″彿 + if (Releasespermitted4(commonStackerCrane, task.SourceAddress)) + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔�", task.SourceAddress); + } + else + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�", task.SourceAddress); + } + } + else + { + LogSignalStatus("鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鏀句笅淇″彿", task.SourceAddress); + } + } + + + } + else + { + LogSignalStatus("鍐欏叆杈撻�佺嚎鍫嗗灈鏈烘斁璐� 鎵樼洏鏉$爜锛屽眰鏁帮紝绫诲瀷澶辫触", task.TargetAddress); + } + } + else + { + LogSignalStatus("鏈鍙栧埌鍫嗗灈鏈烘斁璐у畬鎴愪俊鍙�", task.TargetAddress); + } + } + } + } + } + + 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)) //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙� + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙峰け璐�", task.SourceAddress); + } + } + else + { + LogSignalStatus("鏈鍙栧埌杈撻�佺嚎鍏佽鍙栬揣淇″彿", task.SourceAddress); + } + } + + if (Completesignal2(commonStackerCrane, task.SourceAddress)) //璇诲彇鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙� + { + if(PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked")) //鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿 + { + DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, task.SourceAddress, "R_StackerCranePicked"); //杈撻�佺嚎鍗忚鎵捐鍙栦俊鍙� + if (deviceProDTO != null) + { + int B_TAKE = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock); //璇诲彇杈撻�佺嚎鐨� 鍫嗗灈鏈哄彇璧� 淇″彿 + if (B_TAKE == 1) + { + //鍐欏叆缁欏爢鍨涙満锛岃緭閫佺嚎鐨� 鍫嗗灈鏈哄彇璧� 淇″彿 + if(Releasespermitted3(commonStackerCrane, task.SourceAddress)) + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙锋垚鍔�", task.SourceAddress); + } + else + { + LogSignalStatus("鍐欏叆鍫嗗灈鏈哄彇璧颁俊鍙峰け璐�", task.SourceAddress); + } + } + else + { + LogSignalStatus("鏈鍙栬緭閫佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿", task.SourceAddress); + } + } + } + } + else + { + LogSignalStatus("鏈鍙栧埌鍫嗗灈鏈烘斁璐у畬鎴愪俊鍙�", task.SourceAddress); + + } + } + } } + + //鑾峰彇杈撻�佺嚎瀹炰緥 + 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) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + DeviceProDTO? deviceProDTO2 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout"); + if (deviceProDTO2 != null) + { + return GetStacker(commonStackerCrane, deviceProDTO2.DeviceProAddress); + } + } + + if (commonStackerCrane.DeviceCode == "SC01") + { + DeviceProDTO? deviceProDTO3 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Dout"); + if (deviceProDTO3 != null) + { + return GetStacker(commonStackerCrane, deviceProDTO3.DeviceProAddress); + } + DeviceProDTO? deviceProDTO4 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Cout"); + if (deviceProDTO4 != null) + { + return GetStacker(commonStackerCrane, deviceProDTO4.DeviceProAddress); + } + DeviceProDTO? deviceProDTO5 = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryRequest_Aout"); + if (deviceProDTO5 != null) + { + return GetStacker(commonStackerCrane, deviceProDTO5.DeviceProAddress); + } + } + return false; + + } + + //鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊鍙� + public bool Releasespermitted(CommonStackerCrane commonStackerCrane, string Destinationaddress) + { + if (Destinationaddress == "R02-002-027-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Bout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R02-002-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + //1鍙� + if (Destinationaddress == "R01-002-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Cout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-003-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Dout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + + if (Destinationaddress == "R01-002-044-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryPermission_Aout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, 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) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + if (Destinationaddress == "R02-002-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + //1鍙� + if (Destinationaddress == "R01-002-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Cout"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + if (Destinationaddress == "R01-002-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Dout"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + + if (Destinationaddress == "R01-002-044-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompleted_Aout"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + + return false; + + } + + //鍐欏叆鍫嗗灈鏈烘斁璐х‘璁や俊鍙� + public bool Releasespermitted4(CommonStackerCrane commonStackerCrane, string Destinationaddress) + { + if (Destinationaddress == "R02-002-027-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Bout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R02-002-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Din"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + //1鍙� + if (Destinationaddress == "R01-002-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Cout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-002-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Dout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-002-043-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "DeliveryCompletion_Aout"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + + return false; + } + + + //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙� + public bool Releasespermitted2(CommonStackerCrane commonStackerCrane, string Destinationaddress) + { + if (Destinationaddress == "R02-003-027-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Bin"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R02-003-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + //1鍙� + if (Destinationaddress == "R01-003-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Cin"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-003-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Din"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + + if (Destinationaddress == "R01-002-042-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_Ain"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-002-043-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupRequest_A2in"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, 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) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + if (Destinationaddress == "R02-003-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + //1鍙� + if (Destinationaddress == "R01-003-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Cin"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + if (Destinationaddress == "R01-003-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Din"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + + if (Destinationaddress == "R01-002-042-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_Ain"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + + if (Destinationaddress == "R01-002-043-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompleted_A2in"); + if (deviceProDTO != null) + { + return GetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress); + } + } + + return false; + + } + + //鍐欏叆鍫嗗灈鏈哄彇璐х‘璁や俊鍙� + public bool Releasespermitted3(CommonStackerCrane commonStackerCrane, string Destinationaddress) + { + if (Destinationaddress == "R02-003-027-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Bin"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R02-003-027-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + //1鍙� + if (Destinationaddress == "R01-003-041-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Cin"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-003-041-011-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Din"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + + if (Destinationaddress == "R01-002-042-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_Ain"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + if (Destinationaddress == "R01-002-043-001-01") + { + DeviceProDTO? deviceProDTO = GetDeviceProDTO2(commonStackerCrane, commonStackerCrane.DeviceCode, "PickupCompletion_A2in"); + if (deviceProDTO != null) + { + return SetStacker(commonStackerCrane, deviceProDTO.DeviceProAddress, true); + } + } + + return false; + } + + + //鍐欏叆杈撻�佺嚎鏀捐揣瀹屾垚淇″彿锛屾潯鐮侊紝灞傛暟锛岀被鍨� + public bool PLCSignal(CommonConveyorLine conveyorLine,string TargetAddress,string PalletCode,byte PalletLayers) + { + byte PalletType = 2; + if (TargetAddress == "R02-002-027-001-01" || TargetAddress == "R01-002-041-001-01") + { + PalletType = 1; + } + + //澶勭悊鍑哄簱鏀炬枡瀹屾垚鍚庨�昏緫 + try + { + DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_StackerCraneLowered"); //鏀捐揣瀹屾垚淇″彿 + DeviceProDTO? deviceProDTO3 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_PalletBarcode"); //鍐欏叆鏉$爜 + DeviceProDTO? deviceProDTO4 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_PalletLayers"); //灞傛暟 + DeviceProDTO? deviceProDTO5 = GetDeviceProDTO(conveyorLine, TargetAddress, "W_PalletType"); //绫诲瀷 + if(deviceProDTO2 !=null && deviceProDTO3 != null && deviceProDTO4 != null && deviceProDTO5 != null) + { + if(SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, 1) && SetLinestring(conveyorLine, deviceProDTO3.DeviceProDataBlock,PalletCode) && SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, PalletLayers) && SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, PalletType)) + { + + LogSignalStatus($"鍐欏叆鏀捐揣瀹屾垚淇℃伅锛屾墭鐩樻潯鐮侊紝灞傛暟锛岀被鍨嬩俊鎭垚鍔�", TargetAddress); + return true; + + } + else + { + LogSignalStatus($"鍐欏叆鏀捐揣瀹屾垚淇℃伅锛屾墭鐩樻潯鐮侊紝灞傛暟锛岀被鍨嬩俊鎭け璐�", TargetAddress); + + } + } + else + { + LogSignalStatus($"鏈壘鍒拌緭閫佺嚎鍗忚淇℃伅", TargetAddress); + + } + } + catch (Exception ex) + { + LogSignalStatus($"鍐欏叆澶辫触锛岄敊璇俊鎭細{ex.Message}", TargetAddress); + throw; + } + return false; + } + + //鍐欏叆杈撻�佺嚎 鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙� + public bool PLCSignal2(CommonConveyorLine conveyorLine, string SourceAddress,string DeviceProParamName) + { + DeviceProDTO? deviceProDTO2 = GetDeviceProDTO(conveyorLine, SourceAddress, DeviceProParamName); //鍙栬揣瀹屾垚淇″彿 + if (deviceProDTO2 != null) + { + return SetLine(conveyorLine, deviceProDTO2.DeviceProDataBlock, 1); + } + else + { + LogSignalStatus($"鏈壘鍒拌緭閫佺嚎鍗忚淇℃伅", SourceAddress); + + } + 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 bool GetStacker(CommonStackerCrane commonStackerCrane,string DeviceProDataBlock) + { + return commonStackerCrane.Communicator.Read<bool>(DeviceProDataBlock); + } + + /// <summary> + /// 鍐欏叆鍫嗗灈鏈轰俊鍙� + /// </summary> + /// <param name="conveyorLine"></param> + /// <param name="DeviceProDataBlock"></param> + /// <returns></returns> + public bool SetStacker(CommonStackerCrane commonStackerCrane, string DeviceProDataBlock,bool Pali) + { + return commonStackerCrane.Communicator.Write(DeviceProDataBlock, Pali); + } + /// <summary> /// 浠诲姟瀹炰綋杞崲鎴愬懡浠odel /// </summary> @@ -268,9 +876,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 { @@ -352,189 +960,9 @@ } 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"); - } - } - - - /// <summary> - /// 鍑哄簱淇℃伅浜や簰 - /// </summary> - /// <param name="commonStackerCrane"></param> - /// <param name="platform"></param> - public void Stackerstatic2(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane) - { - //璇诲彇鍫嗗灈鏈轰袱涓珯鍙版槸鍚︽湁鏀捐揣鐢宠 - // 妫�鏌ュ爢鍨涙満鏄惁璇锋眰鏀捐揣淇″彿 - 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); - }*/ - } - - // 灏佽鍏ュ簱绔欏彴 - // 瀹氫箟涓�涓柟娉曟潵澶勭悊閲嶅鐨勫爢鍨涙満涓嶱LC浜や簰鎿嶄綔 - private void HandleStackerCraneTask(CommonConveyorLine conveyorLine, CommonStackerCrane commonStackerCrane,Dt_Task task, string requestSignal, string completionSignal, string writeAddress) - { - // 灏� 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.GetLog("鍫嗗灈鏈轰笌plc浜や簰淇″彿").Write($"绔欏彴缂栧彿锛歿sourceAddress},淇℃伅锛歿message}", $"{sourceAddress}"); } } } -- Gitblit v1.9.3