From 7ca9651f81d7b84f054194d3d46fdbd1d9c8b922 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期三, 09 七月 2025 22:55:27 +0800 Subject: [PATCH] 增加质检出入库逻辑 --- 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/AGVsignal.cs | 131 +++++++++++++++++++++++++++++++++++-------- 1 files changed, 107 insertions(+), 24 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/AGVsignal.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/AGVsignal.cs" index 97611b5..68e822b 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/AGVsignal.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/ConveyorLineExtend/AGVsignal.cs" @@ -12,6 +12,7 @@ using WIDESEAWCS_QuartzJob; using WIDESEAWCS_QuartzJob.Service; using WIDESEAWCS_Tasks.ConveyorLineJob.ConveyorLineExtend; +using WIDESEAWCS_Tasks.ProductionLineJob; namespace WIDESEAWCS_Tasks { @@ -29,23 +30,81 @@ { if (conveyor == null) throw new Exception("璇锋眰鏁版嵁涓虹┖"); if (string.IsNullOrEmpty(conveyor.Station)) throw new Exception("绔欑偣缂栧彿涓虹┖"); - CommonConveyorLine conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "杈撻�佺嚎") as CommonConveyorLine; - if (!conveyorLine.IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�"); + switch (conveyor.Station) + { + case "1001": + case "1008": + content = AGVRequestinConveyorLine(conveyor); + break; + case "MDX01": + content = AGVRequestinProductionLine(conveyor); + break; + default: throw new Exception($"鏈畾涔夌珯鍙板彿[Station锛歿conveyor.Station}]"); + } + } + catch (Exception ex) + { + content.Error(ex.Message); + } + return content; + } + + /// <summary> + /// AGV鍜岃緭閫佺嚎浜や簰 + /// </summary> + /// <returns></returns> + public static WebResponseContent AGVRequestinConveyorLine(ConveyorLineDTO conveyor) + { + WebResponseContent content = new WebResponseContent(); + try + { + CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "杈撻�佺嚎") as CommonConveyorLine; + if (conveyorLine == null) throw new Exception("鏈壘鍒拌緭閫佺嚎璁惧淇℃伅"); + if (!conveyorLine.IsConnected) throw new Exception($"杈撻�佺嚎璁惧閫氳寮傚父"); switch (conveyor.Type) { case 1: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestPut, true, conveyor.Station); - if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitPut, conveyor.Station); + { + if (conveyor.Station == "1001") + { + content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestPut, true, conveyor.Station); + if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitPut, conveyor.Station); + } + else + { + content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestTake, true, conveyor.Station); + if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitTake, conveyor.Station); + } + } break; case 2: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVPutComplete, true, conveyor.Station); break; case 3: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestTake, true, conveyor.Station); - if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitTake, conveyor.Station); + { + if (conveyor.Station == "1001") + { + content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVPutComplete, true, conveyor.Station); + //if (content.Status) + //{ + // Thread.Sleep(1000); + // conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestPut, false, conveyor.Station); + // conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVPutComplete, false, conveyor.Station); + //} + } + else + { + content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVTakeComplete, true, conveyor.Station); + //if (content.Status) + //{ + // Thread.Sleep(1000); + // conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestTake, false, conveyor.Station); + // conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVTakeComplete, false, conveyor.Station); + //} + } + } break; case 4: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVTakeComplete, true, conveyor.Station); + break; default: throw new Exception($"绫诲瀷鏈夎[Type锛歿conveyor.Type}]"); } @@ -57,41 +116,65 @@ } return content; } - - public static WebResponseContent AGVRequestin<T>(T conveyor) where T : ConveyorLineDTO, new() + /// <summary> + /// AGV鍜屼骇绾夸氦浜� + /// </summary> + /// <returns></returns> + public static WebResponseContent AGVRequestinProductionLine(ConveyorLineDTO conveyor) { WebResponseContent content = new WebResponseContent(); + OtherDevice? ProductionLine = Storage.Devices.FirstOrDefault(x => x.DeviceCode == conveyor.Station) as OtherDevice; try { - if (conveyor == null) throw new Exception("璇锋眰鏁版嵁涓虹┖"); - if (string.IsNullOrEmpty(conveyor.Station)) throw new Exception("绔欑偣缂栧彿涓虹┖"); - CommonConveyorLine conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "杈撻�佺嚎") as CommonConveyorLine; - if (!conveyorLine.IsConnected) throw new Exception($"閫氳杩炴帴閿欒锛岃妫�鏌ョ綉缁�"); + if (ProductionLine == null) throw new Exception("鏈壘鍒颁骇绾胯澶囦俊鎭�"); + if (!ProductionLine.IsConnected) throw new Exception($"浜х嚎璁惧閫氳寮傚父"); + content.Status = ProductionLine.SetValue(ProductionLineDBName.WagvState, conveyor.Type); + if (!content.Status) throw new Exception("鍐欏叆AGV淇″彿澶辫触"); + var agvState = ProductionLine.GetValue<ProductionLineDBName, short>(ProductionLineDBName.agvState); + if (agvState == 3) throw new Exception("浜х嚎璁惧寮傚父"); switch (conveyor.Type) { case 1: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestPut, true, conveyor.Station); - if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitPut, conveyor.Station); + if (agvState != conveyor.Type) throw new Exception($"AGV鐢宠杩涘叆锛屼骇绾夸笉鍏佽杩涘叆浣滀笟锛屼骇绾夸俊鍙枫�恵agvState}銆�"); + ProductionLine?.Communicator.LogNet.WriteDebug($"AGV鐢宠杩涘叆锛屼骇绾垮厑璁歌繘鍏ヤ綔涓氾紝浜х嚎淇″彿銆恵agvState}銆�"); + content.OK(); break; case 2: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVPutComplete, true, conveyor.Station); + //if (agvState != conveyor.Type) throw new Exception("浜х嚎涓嶅厑璁哥寮�"); + content.OK(); break; case 3: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestTake, true, conveyor.Station); - if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitTake, conveyor.Station); + content.Status = ProductionLine.SetValue(ProductionLineDBName.Wrequest, 2); + ProductionLine?.Communicator.LogNet.WriteDebug($"AGV宸茬寮�锛屼换鍔″畬鎴�"); break; - case 4: - content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVTakeComplete, true, conveyor.Station); - break; - default: throw new Exception($"绫诲瀷鏈夎[Type锛歿conveyor.Type}]"); } - content = content.Status ? content.OK() : content.Error(); + content = content.Status ? content.OK() : content.Error("鍐欏叆澶辫触"); } catch (Exception ex) { content.Error(ex.Message); + ProductionLine?.Communicator.LogNet.WriteDebug(ex.Message); } return content; } + /// <summary> + /// 鍏ュ簱杈撻�佺嚎浜哄伐鏀捐揣瀹屾垚 + /// </summary> + /// <returns></returns> + public static WebResponseContent ReleaseCompleted() + { + try + { + CommonConveyorLine? conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "杈撻�佺嚎") as CommonConveyorLine; + if (conveyorLine == null) throw new Exception("鏈壘鍒拌緭閫佺嚎璁惧淇℃伅"); + if (!conveyorLine.IsConnected) throw new Exception($"杈撻�佺嚎璁惧閫氳寮傚父"); + conveyorLine.SetValue(ConveyorLine_AGV.WriteRGPutComplete, true, "1001");//浜哄伐鏀捐揣瀹屾垚 + return WebResponseContent.Instance.OK(); + } + catch (Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + } } } -- Gitblit v1.9.3