林豪 左 11 月之前
父節點
當前提交
1dbc05d4e6
共有 1 個文件被更改,包括 165 次插入5 次删除
  1. 165 5
      YWGC/FJK/WCS.WorkEngineering/Systems/环形库/机械臂cs.cs

+ 165 - 5
YWGC/FJK/WCS.WorkEngineering/Systems/环形库/机械臂cs.cs

@@ -140,7 +140,7 @@ namespace WCS.WorkEngineering.Systems
             });
             //获取入库次数
             var inQuantity = obj.Entity.GetFlag<int>("InQuantity");
-            var inMaxQuantity = 2; //出入库的周期检查比为1:3
+            var inMaxQuantity = 5; //出入库的周期检查比为1:3
             //入库任务优先 或 上一个周期是出库任务并且出库任务无优先
             if (inQuantity <= inMaxQuantity) //入库任务
             {
@@ -173,24 +173,32 @@ namespace WCS.WorkEngineering.Systems
                 if (!arrIn.Any())
                 {
                     World.Log($"[{obj.Entity.Code}]等待入库任务输送到位");
-                    obj.Entity.SetFlag("InQuantity", 4); //在无货物的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
+                    obj.Entity.SetFlag("InQuantity", 13); //在无货物的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
                     return;
                 }
 
                 //先按可取货位数量排序,再按任务号排序
                 var devGroup = arrIn.OrderByDescending(x => x.Item2.Count(i => i.Data2.TaskNumber > 0 && i.Data.Status.HasFlag(StationStatus.PH_Status)))
-                    .ThenBy(x => x.Item1.Data2.TaskNumber).First().Item2
+                    .ThenBy(x =>
+                    {
+                        int number;
+                        List<Device<IStation523, IStation524>> devices = new List<Device<IStation523, IStation524>>();
+                        var deviceCodes = GetDeviceCodeList(x.Item1.Entity.Code);
+                        devices = Device.All.Where(x => deviceCodes.Contains(x.Code) ).Select(x => new Device<IStation523, IStation524>(x, World)).ToList();
+                        number = devices.Count(x => x.Data2.TaskNumber > 0 && x.Data.Status.HasFlag(StationStatus.PH_Status) && !x.Data.Status.HasFlag(StationStatus.Run));
+                        return number;
+                    }).First().Item2
                     .Where(x => x.Data2.TaskNumber > 0 && x.Data.Status.HasFlag(StationStatus.PH_Status));
                 //可用取货位数量为1,且出库任务有优先
                 if (devGroup.Count() == 1 && obj.Entity.GetFlag<bool>($"isOut-{obj.Entity.Code}"))
                 {
-                    obj.Entity.SetFlag("InQuantity", 4); //跳过入库任务执行出库任务,下次直接查询是否有出库任务,避免无效检查周期的产生
+                    obj.Entity.SetFlag("InQuantity", 13); //跳过入库任务执行出库任务,下次直接查询是否有出库任务,避免无效检查周期的产生
                     return;
                 }
 
                 if (!devGroup.Any())
                 {
-                    obj.Entity.SetFlag("InQuantity", 4); //在无有效取货位的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
+                    obj.Entity.SetFlag("InQuantity", 13); //在无有效取货位的情况下,只检查一次,下次直接查询是否有出库任务,避免无效检查周期的产生
                     throw new KnownException($"无有效入库取货位", LogLevelEnum.High);
                 }
 
@@ -517,5 +525,157 @@ namespace WCS.WorkEngineering.Systems
         {
             return dev.Code is "Robot1" or "Robot2" or "Robot3" or "Robot4" or "Robot5" or "Robot6";
         }
+
+        public List<string> GetDeviceCodeList(string code)
+        {
+            return code switch
+            {
+                "424" => new List<string>()
+                            {
+                                "424",
+                                "425",
+                                "422",
+                                "426",
+                                "427"
+                            },
+                "433" => new List<string>()
+                            {
+                                "433",
+                                "434",
+                                "431",
+                                "435",
+                                "436"
+                            },
+                "442" => new List<string>()
+                            {
+                                "442",
+                                "443",
+                                "440",
+                                "444",
+                                "445"
+                            },
+                "642" => new List<string>()
+                            {
+                                "642",
+                                "643",
+                                "640",
+                                "644",
+                                "645"
+                            },
+                "633" => new List<string>()
+                            {
+                                "633",
+                                "634",
+                                "631",
+                                "635",
+                                "636"
+                            },
+                "624" => new List<string>()
+                            {
+                                "624",
+                                "625",
+                                "622",
+                                "226",
+                                "627"
+                            },
+                "824" => new List<string>()
+                            {
+                                "824",
+                                "825",
+                                "822",
+                                "826",
+                                "827"
+                            },
+                "833" => new List<string>()
+                            {
+                                "833",
+                                "834",
+                                "831",
+                                "835",
+                                "836"
+                            },
+                "842" => new List<string>()
+                            {
+                                "842",
+                                "843",
+                                "840",
+                                "844",
+                                "845"
+                            },
+                "1042" => new List<string>()
+                            {
+                                "1042",
+                                "1043",
+                                "1040",
+                                "1044",
+                                "1045"
+                            },
+                "1033" => new List<string>()
+                            {
+                                "1033",
+                                "1034",
+                                "1031",
+                                "1035",
+                                "1036"
+                            },
+                "1024" => new List<string>()
+                            {
+                                "1024",
+                                "1025",
+                                "1022",
+                                "1026",
+                                "1027"
+                            },
+                "1224" => new List<string>()
+                            {
+                                "1224",
+                                "1225",
+                                "1222",
+                                "1226",
+                                "1227"
+                            },
+                "1233" => new List<string>()
+                            {
+                                "1233",
+                                "1234",
+                                "1231",
+                                "1235",
+                                "1236"
+                            },
+                "1242" => new List<string>()
+                            {
+                                "1242",
+                                "1243",
+                                "1240",
+                                "1244",
+                                "1245"
+                            },
+                "1442" => new List<string>()
+                            {
+                                "1442",
+                                "1443",
+                                "1440",
+                                "1444",
+                                "1445"
+                            },
+                "1433" => new List<string>()
+                            {
+                                "1433",
+                                "1434",
+                                "1431",
+                                "1435",
+                                "1436"
+                            },
+                "1424" => new List<string>()
+                            {
+                                "1424",
+                                "1425",
+                                "1422",
+                                "1426",
+                                "1427"
+                            },
+                _ => new List<string>()
+            };
+        }
     }
 }