浏览代码

Fix the routing bug for fixed slot Loadlock.

sangwq 1 年之前
父节点
当前提交
9cdf232cb1
共有 1 个文件被更改,包括 88 次插入16 次删除
  1. 88 16
      Venus/Venus_RT/Modules/SystemDispatcher.cs

+ 88 - 16
Venus/Venus_RT/Modules/SystemDispatcher.cs

@@ -2068,6 +2068,87 @@ namespace Venus_RT.Modules
             return _efemSchdActions.Count > 0;
         }
 
+        private bool ExchangeWaferWithFixedSlotLL(ModuleName ll)
+        {
+            if (IsLLReservedByTM(ll))
+                return false;
+
+            var llWaferStatus = GetLLFixedReadyInOutSlots(ll);
+            var atmWafers = _lstWaferTasks.Where(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.IsAligned && (ModuleHelper.IsEFEMRobot(wafer.currentMod) || ModuleHelper.IsAligner(wafer.currentMod))).ToList();
+            var freeHands = GetEFEMFreeHand();
+
+            var swapActions = new List<MoveItem>();
+            var validHands = new List<Hand>();
+            int placeCount = 0;
+            if (llWaferStatus.eInSlot.Count > 0 &&
+                 freeHands.Count >= 1 &&
+                 atmWafers.Count(wafer => ModuleHelper.IsAligner(wafer.currentMod)) == 1 &&
+                (atmWafers.Count(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)) == 0 || llWaferStatus.eInSlot.Count >= 2))
+            {
+                var alignerWafer = atmWafers.Where(wafer => ModuleHelper.IsAligner(wafer.currentMod)).First();
+                if (CanWaferGotoLL(alignerWafer, ll))
+                {
+                    alignerWafer.RouteTo(ll, llWaferStatus.eInSlot[placeCount]);
+
+                    _efemSchdActions.Enqueue(new List<MoveItem> { new MoveItem(alignerWafer.currentMod, alignerWafer.currentSlot, ModuleName.EfemRobot, (int)freeHands[0], freeHands[0]) });
+                    swapActions.Add(new MoveItem(ModuleName.EfemRobot, (int)freeHands[0], ll, llWaferStatus.eInSlot[placeCount], freeHands[0]));
+                    validHands.Add(freeHands[0]);
+                    placeCount++;
+                }
+            }
+
+            var armWafers = atmWafers.Where(wafer => ModuleHelper.IsEFEMRobot(wafer.currentMod)).ToArray();
+            foreach (var wafer in armWafers)
+            {
+                if (CanWaferGotoLL(wafer, ll) && placeCount < llWaferStatus.eInSlot.Count)
+                {
+                    wafer.RouteTo(ll, llWaferStatus.eInSlot[placeCount]);
+
+                    swapActions.Add(new MoveItem(wafer.currentMod, wafer.currentSlot, ll, llWaferStatus.eInSlot[placeCount], (Hand)wafer.currentSlot));
+                    if (!validHands.Contains((Hand)wafer.currentSlot))
+                        validHands.Add((Hand)wafer.currentSlot);
+
+                    placeCount++;
+                }
+            }
+
+            if (!validHands.Contains(Hand.Blade1) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade1) && _efemRobotSingleArmOption != 2)
+                validHands.Add(Hand.Blade1);
+
+            if (!validHands.Contains(Hand.Blade2) && WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)Hand.Blade2) && _efemRobotSingleArmOption != 1)
+                validHands.Add(Hand.Blade2);
+
+            int pickCount = 0;
+            var returnActions = new List<MoveItem>();
+            foreach (var slot in llWaferStatus.eOutSlot)
+            {
+                if (pickCount < validHands.Count)
+                {
+                    var outWafer = _lstWaferTasks.Find(wafer => (wafer.movingStatus == RState.End || wafer.movingStatus == RState.Init) && wafer.currentMod == ll && wafer.currentSlot == slot);
+                    if (outWafer != null)
+                    {
+                        outWafer.RouteTo(outWafer.destMod, outWafer.destSlot);
+
+                        swapActions.Add(new MoveItem(ll, llWaferStatus.eOutSlot[pickCount], ModuleName.EfemRobot, (int)validHands[pickCount], validHands[pickCount]));
+                        returnActions.Add(new MoveItem(ModuleName.EfemRobot, (int)validHands[pickCount], outWafer.destMod, outWafer.destSlot, validHands[pickCount]));
+                        pickCount++;
+                    }
+                }
+            }
+
+            if (swapActions.Count > 0)
+            {
+                _efemSchdActions.Enqueue(swapActions);
+            }
+
+            foreach (var action in returnActions)
+            {
+                _efemSchdActions.Enqueue(new List<MoveItem> { action });
+            }
+
+            return _efemSchdActions.Count > 0;
+        }
+
         private void RoutingATMWafers()
         {
             if (_efemSchdActions.Count > 0 || _curEfemAction.Count > 0)
@@ -2202,23 +2283,14 @@ namespace Venus_RT.Modules
             }
 
             // try to match a ll swap action
-            if(_LLASlotNumber == 2)
-            {
-                var readyReturnLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count > 0).OrderBy(ll => ll.Value.TimeToReady);
-                foreach(var ll in readyReturnLL)
-                {
-                    if (ExchangeWaferWithLL(ll.Key))
-                        return;
-                }
-            }
-            else
+            var readyReturnLL = lls.Where(ll => (GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count + GetLLFixedReadyInOutSlots(ll.Key).eInSlot.Count > 0) && ll.Value.TimeToReady <= 10)
+                                            .OrderByDescending(ll => GetLLFixedReadyInOutSlots(ll.Key).eInSlot.Count + GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count)
+                                            .OrderBy(ll => ll.Value.TimeToReady);
+
+            foreach (var ll in readyReturnLL)
             {
-                var readyReturnLL = lls.Where(ll => GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count > 0).OrderByDescending(ll => GetLLFixedReadyInOutSlots(ll.Key).eOutSlot.Count);
-                foreach (var ll in readyReturnLL)
-                {
-                    if (ExchangeWaferWithLL(ll.Key))
-                        return;
-                }
+                if (ExchangeWaferWithFixedSlotLL(ll.Key))
+                    return;
             }
         }