From e2a5657e3a0b8615bcd78a3149e5ba9ce5579bb8 Mon Sep 17 00:00:00 2001 From: huanghongfeng <huanghongfeng@hnkhzn.com> Date: 星期一, 02 十二月 2024 16:25:35 +0800 Subject: [PATCH] 1 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs | 1045 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 978 insertions(+), 67 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 a3b0807..84ea5c9 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,17 +1,26 @@ -锘縰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; using System.Threading.Tasks; +using WIDESEA_Common.Log; +using WIDESEAWCS_Common.TaskEnum; +using WIDESEAWCS_Core; using WIDESEAWCS_Core.Enums; using WIDESEAWCS_ITaskInfoRepository; using WIDESEAWCS_ITaskInfoService; 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; @@ -42,6 +51,8 @@ CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); if (commonStackerCrane != null) { + Signalinteraction(commonStackerCrane); //鍑哄簱淇″彿浜や簰 + Siganlinteraction2(commonStackerCrane); //鍏ュ簱淇″彿浜や簰 if (!commonStackerCrane.IsEventSubscribed) { commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//璁㈤槄浠诲姟瀹屾垚浜嬩欢 @@ -105,7 +116,7 @@ private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane) { Dt_Task task; - if (commonStackerCrane.LastTaskType == null) + /*if (commonStackerCrane.LastTaskType == null) { task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); } @@ -123,18 +134,43 @@ { task = _taskService.QueryStackerCraneOutTask(commonStackerCrane.DeviceCode); } - } + }*/ + task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode); - if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) + if (task != null && task.TaskType== (int)TaskOutboundTypeEnum.Outbound) { - if (OutTaskStationIsOccupied(task) != null) + string[] targetCodes = task.SourceAddress.Split("-"); + if (targetCodes[4] == "02") + { + + task = OutTaskMovelibrary(task); + if (task != null) + { + if (OutTaskStationIsOccupied(task) != null) + { + return task; + } + } + } + else + { + if (OutTaskStationIsOccupied(task) != null) + { + return task; + } + task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); + } + + + /*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); + + List<Dt_Task> tasks = _taskService.QueryStackerCraneOutTasks(commonStackerCrane.DeviceCode); foreach (var item in tasks) { if (OutTaskStationIsOccupied(task) != null) @@ -142,10 +178,9 @@ return task; } } - task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); - } + //task = _taskService.QueryStackerCraneInTask(commonStackerCrane.DeviceCode); + }*/ } - return task; } @@ -156,28 +191,904 @@ /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns> private Dt_Task? OutTaskStationIsOccupied([NotNull] Dt_Task task) { - Dt_Router? router = _routerService.QueryNextRoutes(task.Roadway, task.NextAddress).FirstOrDefault(); - if (router != null) + IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceProDTOs.Exists(x => x.DeviceChildCode == task.TargetAddress)); + if (device != null) { - IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode); - if (device != null) + CommonConveyorLine conveyorLine = (CommonConveyorLine)device; + DeviceProDTO? deviceProDTO = GetDeviceProDTO(conveyorLine, task.TargetAddress, "R_Event"); //鏍规嵁鍫嗗灈鏈哄湴鍧�锛屽湴鍧�鍚嶇О鎵惧崗璁� + if (deviceProDTO != null) { - CommonConveyorLine conveyorLine = (CommonConveyorLine)device; - if (conveyorLine.IsOccupied(router.ChildPosi))//鍑哄簱绔欏彴鏈鍗犵敤 + int B_Event_Test = GetLine(conveyorLine, deviceProDTO.DeviceProDataBlock); //鍒ゆ柇杈撻�佺嚎鏄惁鍏佽鏀捐揣淇″彿 + if (B_Event_Test == 1) { return task; } } + } + else + { + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵task.TargetAddress}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤"); + } + return null; + } + + /// <summary> + /// 鍑哄簱浠诲姟鍒ゆ柇鏄惁闇�瑕佽繘琛岀Щ搴揗ove the library + /// </summary> + /// <param name="task">浠诲姟瀹炰綋</param> + /// <returns>濡傛灉鏈鍗犵敤锛岃繑鍥炰紶鍏ョ殑浠诲姟淇℃伅锛屽惁鍒欙紝杩斿洖null</returns> + private Dt_Task? OutTaskMovelibrary([NotNull] Dt_Task task) + { + try + { + string[] targetCodes = task.SourceAddress.Split("-"); + if (targetCodes[1] == "001") + { + 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 tasks; + } else { - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒板嚭搴撶珯鍙般�恵router.ChildPosiDeviceCode}銆戝搴旂殑閫氳瀵硅薄锛屾棤娉曞垽鏂嚭搴撶珯鍙版槸鍚﹁鍗犵敤"); + //鍚憌ms鐢宠鍒ゆ柇娴呭簱浣嶆槸鍚︽湁璐э紝鏄惁闇�瑕佽繘琛岀Щ搴� + Dt_Task? taskst = _taskService.RequestWMSTaskMovelibrary(task); + if (taskst != null) + { + return taskst; + } + } + } + catch (Exception ex) + { + + throw; + } + return null; + } + + public void Signalinteraction(CommonStackerCrane commonStackerCrane) + { + if (Applyrelease(commonStackerCrane)) //璇诲彇鍫嗗灈鏈烘斁璐х敵璇� + { + Dt_Task task = _taskService.IngStackerCraneTask2(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 == 1) + { + + if (Releasespermitted(commonStackerCrane, task.TargetAddress,true)) //鍐欏叆鍫嗗灈鏈哄厑璁告斁璐т俊 + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鍏佽鏀捐揣淇″彿鎴愬姛锛歵rue", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鍏佽鏀捐揣淇″彿澶辫触", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + } + else + { + if (Releasespermitted(commonStackerCrane, task.TargetAddress,false)) //鍐欏叆鍫嗗灈鏈轰笉鍏佽鏀捐揣淇� + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満涓嶅厑璁告斁璐т俊鍙锋垚鍔燂細false", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満涓嶅厑璁告斁璐т俊鍙峰け璐�", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + } + } + } } } else { - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鏍¢獙绔欏彴"); + Dt_Task task = _taskService.IngStackerCraneTask2(commonStackerCrane.DeviceCode); + if (task !=null && task.TaskType == (int)TaskOutboundTypeEnum.Outbound) + { + 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)) + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ幓鍚戞垚鍔燂紝鍘诲悜涓猴細{PLCtost}", $"鍑烘枡鍙e幓鍚�"); + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ幓鍚戝け璐ワ紝鍘诲悜涓猴細{PLCtost}", $"鍑烘枡鍙e幓鍚�"); + } + } + + 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)) + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氭竻闄ゅ幓鍚戞垚鍔�", $"鍑烘枡鍙e幓鍚�"); + + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氭竻闄ゅ幓鍚戝け璐�", $"鍑烘枡鍙e幓鍚�"); + } + // 娓呴櫎杈撻�佺嚎 + if (PLCSignal(conveyorLine, task.TargetAddress, (byte)0)) + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ヨ緭閫佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔�", $"鍑烘枡鍙e幓鍚�"); + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ヨ緭閫佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�", $"鍑烘枡鍙e幓鍚�"); + } + //鍫嗗灈鏈哄啓瀹屾垚 + if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鏀句笅淇″彿鎴愬姛锛歵rue", $"鍑烘枡鍙e幓鍚�"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鏀句笅淇″彿澶辫触:true", $"鍑烘枡鍙e幓鍚�"); + } + + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬幓鍚戞瘮瀵逛笉涓�鑷达紝杈撻�佺嚎鍘诲悜涓猴細{PLCwcstost}锛寃cs鍐欏叆鍘诲悜涓猴細{task.PLCTo}", $"鍑烘枡鍙e幓鍚�"); + } + } + } + + if (task.TargetAddress != "R02-002-027-011-01" && task.TargetAddress != "R01-002-041-011-01") + { + // 娓呴櫎杈撻�佺嚎 + if (PLCSignal(conveyorLine, task.TargetAddress, 0)) + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ヨ緭閫佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙锋垚鍔�", $"锛堟斁璐э級璇诲彇{task.TargetAddress}"); + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ヨ緭閫佺嚎娓呴櫎-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�", $"锛堟斁璐э級璇诲彇{task.TargetAddress}"); + } + + //鍫嗗灈鏈哄啓瀹屾垚 + if (Releasespermitted4(commonStackerCrane, task.TargetAddress, true)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鏀句笅淇″彿鎴愬姛锛歵rue", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ュ爢鍨涙満鏀句笅淇″彿澶辫触:true", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + } + + + } + else + { + // 娓呴櫎杈撻�佺嚎 + if (PLCSignal(conveyorLine, task.TargetAddress, 0)) + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氭湭璇诲彇鍒拌緭閫佺嚎鍙嶉鍫嗗灈鏈哄畬鎴愬弽棣堜俊鍙凤紝閲嶇疆涓�0", $"锛堟斁璐э級璇诲彇{task.TargetAddress}"); + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氭湭璇诲彇鍒拌緭閫佺嚎鍙嶉鍫嗗灈鏈哄畬鎴愬弽棣堜俊鍙凤紝閲嶇疆涓�0", $"锛堟斁璐э級璇诲彇{task.TargetAddress}"); + } + } + } + } + else + { + WriteLog.GetLog("杈撻�佺嚎").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氬啓鍏ヨ緭閫佺嚎0-鍫嗗灈鏈烘斁涓嬩俊鍙峰け璐�", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + } + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.TargetAddress},浠诲姟鍙凤細{task.TaskNum},淇℃伅锛氭湭璇诲彇鍒板爢鍨涙満鏀捐揣瀹屾垚淇″彿", $"锛堟斁璐э級鍐欏叆{task.TargetAddress}"); + } + } } - return null; + } + + 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)) //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙� + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿鎴愬姛:true", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿澶辫触", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + } + else + { + if (Releasespermitted2(commonStackerCrane, task.SourceAddress,false)) //鍐欏叆鍫嗗灈鏈哄厑璁稿彇璐т俊鍙� + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇鍒拌緭閫佺嚎鍏佽鍙栬揣淇″彿锛屽啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿鎴愬姛:false", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇鍒拌緭閫佺嚎鍏佽鍙栬揣淇″彿锛屽啓鍏ュ爢鍨涙満鍏佽鍙栬揣淇″彿澶辫触", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + + } + } + + if (Completesignal2(commonStackerCrane, task.SourceAddress)) //璇诲彇鍫嗗灈鏈哄彇璐у畬鎴愪俊鍙� + { + if(PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 1)) //鍐欏叆杈撻�佺嚎鍙栬揣瀹屾垚淇″彿 + { + 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)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:true", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:true", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + } + else + { + if (Releasespermitted3(commonStackerCrane, task.SourceAddress,false)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇杈撻�佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:false", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇杈撻�佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:false", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + } + } + } + } + else + { + if (PLCSignal2(conveyorLine, task.SourceAddress, "W_StackerCranePicked", 0)) //鍐欏叆杈撻�佺嚎娓呴櫎淇″彿 + { + 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)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:true", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氬啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:true", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + } + else + { + if (Releasespermitted3(commonStackerCrane, task.SourceAddress, false)) + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇杈撻�佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿鎴愬姛:false", $"锛堝彇璐э級鍐欏叆{task.SourceAddress}"); + } + else + { + WriteLog.GetLog("鍫嗗灈鏈轰俊鍙�").Write($"绔欏彴缂栧彿锛歿task.SourceAddress},淇℃伅锛氭湭璇诲彇杈撻�佺嚎鐨勫爢鍨涙満鍙栬蛋淇″彿锛屽啓鍏ュ爢鍨涙満鍙栬蛋淇″彿澶辫触:false", $"锛堝彇璐э級鍐欏叆{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) + { + 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> @@ -190,76 +1101,76 @@ { StackerCraneTaskCommand stackerCraneTaskCommand = new StackerCraneTaskCommand(); - stackerCraneTaskCommand.Barcode = task.PalletCode; + stackerCraneTaskCommand.Barcode = ""; /*task.PalletCode;*/ stackerCraneTaskCommand.TaskNum = task.TaskNum; stackerCraneTaskCommand.WorkType = 1; stackerCraneTaskCommand.TrayType = 0; if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.InboundGroup)//鍒ゆ柇鏄惁鏄叆搴撲换鍔� { - List<Dt_Router> routers = _routerService.QueryNextRoutes(task.CurrentAddress, task.Roadway); - if (routers.Count > 0) + string[] targetCodest = task.SourceAddress.Split("-"); + if (targetCodest.Length == 5) { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer); - - string[] targetCodes = task.NextAddress.Split("-"); - if (targetCodes.Length == 3) - { - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); - } - else - { - //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); - return null; - } + stackerCraneTaskCommand.StartRow = Convert.ToInt16(targetCodest[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(targetCodest[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(targetCodest[3]); } else { - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鍙栬揣绔欏彴淇℃伅"); + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱璧风偣閿欒锛岃捣鐐癸細銆恵task.SourceAddress}銆�"); + return null; + } + string[] targetCodes = task.NextAddress.Split("-"); + if (targetCodes.Length == 5) + { + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); + } + else + { + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍏ュ簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.NextAddress}銆�"); return null; } } else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup) { - List<Dt_Router> routers = _routerService.QueryNextRoutes(task.Roadway, task.TargetAddress); - if (routers.Count > 0) + string[] sourceCodes = task.CurrentAddress.Split("-"); + if (sourceCodes.Length == 5) { - stackerCraneTaskCommand.EndRow = Convert.ToInt16(routers.FirstOrDefault().SrmRow); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(routers.FirstOrDefault().SrmColumn); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(routers.FirstOrDefault().SrmLayer); - - string[] sourceCodes = task.CurrentAddress.Split("-"); - if (sourceCodes.Length == 3) - { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); - } - else - { - //鏁版嵁閰嶇疆閿欒 - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); - return null; - } + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); } else { - _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鏈壘鍒扮珯鍙般�恵task.NextAddress}銆戜俊鎭紝鏃犳硶鑾峰彇瀵瑰簲鐨勫爢鍨涙満鏀捐揣绔欏彴淇℃伅"); + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟璧风偣閿欒锛岃捣鐐癸細銆恵task.CurrentAddress}銆�"); + return null; + } + string[] sourceCodest = task.TargetAddress.Split("-"); + if (sourceCodest.Length == 5) + { + stackerCraneTaskCommand.EndRow = Convert.ToInt16(sourceCodest[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(sourceCodest[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(sourceCodest[3]); + } + else + { + //鏁版嵁閰嶇疆閿欒 + _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"鍑哄簱浠诲姟缁堢偣閿欒锛岃捣鐐癸細銆恵task.TargetAddress}銆�"); return null; } } else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup) { string[] targetCodes = task.NextAddress.Split("-"); - if (targetCodes.Length == 3) + if (targetCodes.Length == 5) { - stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[0]); - stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]); - stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndRow = Convert.ToInt16(targetCodes[1]); + stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[2]); + stackerCraneTaskCommand.EndLayer = Convert.ToInt16(targetCodes[3]); } else { @@ -268,11 +1179,11 @@ return null; } string[] sourceCodes = task.CurrentAddress.Split("-"); - if (sourceCodes.Length == 3) + if (sourceCodes.Length == 5) { - stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[0]); - stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]); - stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartRow = Convert.ToInt16(sourceCodes[1]); + stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[2]); + stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[3]); } else { -- Gitblit v1.9.3