Преглед на файлове

Enhance Auto pump/vent algorithm.

sangwq преди 1 година
родител
ревизия
c3bef13a6e

+ 225 - 6
Venus/Venus_RT/Modules/AutoCycle.cs

@@ -113,6 +113,7 @@ namespace Venus_RT.Modules
         int _LLBSlotNumber = 4;
         int _efemRobotSingleArmOption = 0;
         SequenceLLInOutPath _LLInOutPath = SequenceLLInOutPath.DInDOut;
+        public SequenceLLInOutPath LLInOutPath { get { return _LLInOutPath; } }
 
         List<MoveItem> _movingItems = new List<MoveItem>();
         List<MoveItem> _efemMovingItems = new List<MoveItem>();
@@ -630,7 +631,8 @@ namespace Venus_RT.Modules
         private void driveVacSystem()
         {
             PumpingTMRobotTask();
-            ProcessTMRobotTask();
+            //ProcessTMRobotTask();
+            RoutingInnerPart();
             RuningTMRobotTask();
         }
 
@@ -704,7 +706,7 @@ namespace Venus_RT.Modules
 
                     foreach (var inItem in _vacReadyInSlots)
                     {
-                        if (inItem.Key.Module == next_module && inItem.Key.Slot == nSlot && _vacModules[next_module].MovingStatus != MovingStatus.Moving)
+                        if (inItem.Key.Module == next_module && inItem.Key.Slot == nSlot && _vacModules[next_module].MovingStatus == MovingStatus.Idle && _vacSchedulers[next_module].IsAvailable)
                         {
                             destSlot.Module = next_module;
                             destSlot.Slot = nSlot;
@@ -758,7 +760,6 @@ namespace Venus_RT.Modules
                             validSlot.Add(slot);
                     }
                 }
-
             }
             else if (ModuleHelper.IsPm(mod))
             {
@@ -769,7 +770,6 @@ namespace Venus_RT.Modules
                     validSlot.Add(0);
             }
 
-
             return validSlot.Distinct().ToList();
         }
 
@@ -985,6 +985,199 @@ namespace Venus_RT.Modules
             }
         }
 
+        bool PushTMRobotWafers()
+        {
+            if (_tmRobot.IsAvailable && _tmRobot.RobotStatus != RState.Running)
+            {
+                for (int i = 0; i < 2; i++)
+                {
+                    if (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, i))
+                    {
+                        if (SearchWaferDestination(new SlotItem(ModuleName.TMRobot, i), out SlotItem destSlot))
+                        {
+                            _movingItems.Add(new MoveItem(ModuleName.TMRobot, i, destSlot.Module, destSlot.Slot, (Hand)i));
+                            UpdateModuleMovingStatus(destSlot.Module);
+                        }
+                    }
+                }
+            }
+                    
+            return _movingItems.Count > 0;
+        }
+
+        bool PushPmWafers()
+        {
+            if (_tmRobot.IsAvailable && _tmRobot.RobotStatus != RState.Running)
+            {
+                foreach (var slot in _vacReadyOutSlots)
+                {
+                    if (_vacModules[slot.Key.Module].MovingStatus != MovingStatus.Idle)
+                        continue;
+
+                    if (ModuleHelper.IsPm(slot.Key.Module))
+                    {
+                        if (SearchWaferDestination(slot.Key, out SlotItem destSlot))
+                        {
+                            _movingItems.Add(new MoveItem(slot.Key.Module, slot.Key.Slot, destSlot.Module, destSlot.Slot, Hand.None));
+                            UpdateModuleMovingStatus(slot.Key.Module);
+                            UpdateModuleMovingStatus(destSlot.Module);
+
+
+                            // check whether match double move pattern
+                            int inCount = 0;
+                            var same_dest = SearchWaitInSlots(destSlot.Module);
+                            foreach (var in_slot in same_dest)
+                            {
+                                if (_vacModules[in_slot.SourceModule].MovingStatus == MovingStatus.Idle && inCount < 1)
+                                {
+                                    _movingItems.Add(in_slot);
+                                    UpdateItemMovingStatus(in_slot);
+                                    inCount++;
+                                }
+                            }
+
+                            // check whether match swap pattern
+                            if (inCount == 0 && !IsPMNeedWTWClean(slot.Key.Module))
+                            {
+                                int swapCount = 0;
+                                var in_slots = SearchWaitInSlots(slot.Key.Module);
+                                foreach (var swap_slot in in_slots)
+                                {
+                                    if (_vacModules[swap_slot.SourceModule].MovingStatus == MovingStatus.Idle && swapCount < 1)
+                                    {
+                                        _movingItems.Add(swap_slot);
+                                        UpdateItemMovingStatus(swap_slot);
+                                        swapCount++;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+
+            return _movingItems.Count > 0;
+        }
+
+        private bool PushLoadlockWafers()
+        {
+            if (_tmRobot.IsAvailable && _tmRobot.RobotStatus != RState.Running)
+            {
+                foreach (var slot in _vacReadyOutSlots)
+                {
+                    if (_vacModules[slot.Key.Module].MovingStatus != MovingStatus.Idle)
+                        continue;
+
+                    if (ModuleHelper.IsLoadLock(slot.Key.Module))
+                    {
+                        if (IsLoadLockReservedByEFEM(slot.Key.Module))
+                            continue;
+
+                        var llStatus = GetLLProcessStatusCount(slot.Key.Module);
+                        if (SearchWaferDestination(slot.Key, out SlotItem destSlot))
+                        {
+                            _movingItems.Add(new MoveItem(slot.Key.Module, slot.Key.Slot, destSlot.Module, destSlot.Slot, Hand.None));
+                            UpdateModuleMovingStatus(slot.Key.Module);
+                            UpdateModuleMovingStatus(destSlot.Module);
+
+                            if (llStatus.Item2 > 1)
+                            {
+                                // check whether match double pick pattern
+                                foreach (var item in _vacReadyOutSlots)
+                                {
+                                    if (item.Key.Module == slot.Key.Module && item.Key.Slot != slot.Key.Slot)
+                                    {
+                                        if (SearchWaferDestination(item.Key, out SlotItem destSlot_2))
+                                        {
+                                            _movingItems.Add(new MoveItem(item.Key.Module, item.Key.Slot, destSlot_2.Module, destSlot_2.Slot, Hand.None));
+                                            UpdateModuleMovingStatus(destSlot_2.Module);
+                                            break;
+                                        }
+                                    }
+                                }
+
+                                if (_movingItems.Count == 1)
+                                {
+                                    foreach (var item in _vacReadyOutSlots)
+                                    {
+                                        if (item.Key.Module == slot.Key.Module && item.Key.Slot != slot.Key.Slot)
+                                        {
+                                            if (SearchCanReplaceSlot(item.Key, out SlotItem replaceSlot, out SlotItem destSlot_2))
+                                            {
+                                                _movingItems.Add(new MoveItem(item.Key.Module, item.Key.Slot, replaceSlot.Module, replaceSlot.Slot, Hand.None));
+                                                _movingItems.Add(new MoveItem(replaceSlot.Module, replaceSlot.Slot, destSlot_2.Module, destSlot_2.Slot, Hand.None));
+                                                UpdateModuleMovingStatus(replaceSlot.Module);
+                                                UpdateModuleMovingStatus(destSlot.Module);
+                                                return true;
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+
+
+                            // check whether match swap pattern
+                            int inCount = 0;
+                            var in_slots = SearchWaitInSlots(slot.Key.Module);
+                            foreach (var in_slot in in_slots)
+                            {
+                                if (_vacModules[in_slot.DestinationModule].MovingStatus == MovingStatus.Idle && inCount < 2)
+                                {
+                                    _movingItems.Add(in_slot);
+                                    UpdateItemMovingStatus(in_slot);
+                                    inCount++;
+                                }
+                            }
+
+                            return true;
+                        }
+                    }
+                }
+            }
+
+            return _movingItems.Count > 0;
+        }
+
+        private void RoutingInnerPart()
+        {
+            if (PushTMRobotWafers())
+                return;
+
+            var pmSlotStaus = GetPMValidSlotsStatus();
+            if (pmSlotStaus.Processed + pmSlotStaus.Empty == 0)
+                return;
+
+            if(pmSlotStaus.Empty == 0)
+            {
+                if (PushPmWafers())
+                    return;
+            }
+            else if(pmSlotStaus.Processed == 0)
+            {
+                if (PushLoadlockWafers())
+                    return;
+            }
+            else
+            {
+                if(pmSlotStaus.Processed >= pmSlotStaus.Empty)
+                {
+                    if (PushPmWafers())
+                        return;
+
+                    if (PushLoadlockWafers())
+                        return;
+                }
+                else
+                {
+                    if (PushLoadlockWafers())
+                        return;
+
+                    if (PushPmWafers())
+                        return;
+                }
+            }
+        }
+
         private void RuningTMRobotTask()
         {
             if (_tmRobot.IsAvailable)
@@ -1197,8 +1390,11 @@ namespace Venus_RT.Modules
         #region Atm System
         private void driveAtmSystem()
         {
-            PumpingEFEMRobotTask();
-            RuningEFEMRobotTask();
+            if(_efemMovingItems.Count == 0)
+            {
+                PumpingEFEMRobotTask();
+                RuningEFEMRobotTask();
+            }
         }
 
         private void PumpingEFEMRobotTask()
@@ -1382,6 +1578,29 @@ namespace Venus_RT.Modules
             return new Tuple<int, int>(exist, empty);
         }
 
+        private (int Processed, int Empty) GetPMValidSlotsStatus()
+        {
+            int Processed = 0;
+            int Empty = 0;
+            foreach (var module in _vacModules)
+            {
+                if (ModuleHelper.IsPm(module.Key) && _vacSchedulers[module.Key].IsAvailable)
+                {
+                    var wafer = WaferManager.Instance.GetWafer(module.Key, 0);
+                    if(wafer.IsEmpty)
+                    {
+                        Empty++;
+                    }
+                    else if(wafer.ProcessState == EnumWaferProcessStatus.Completed)
+                    {
+                        Processed++;
+                    }
+                }
+            }
+
+            return (Processed, Empty);
+        }
+
         private int GetTMRobotWaferCount()
         {
             return (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 0) ? 1 : 0) + (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, 1) ? 1 : 0);

+ 1 - 1
Venus/Venus_RT/Modules/EFEM/EfemEntity.cs

@@ -121,7 +121,7 @@ namespace Venus_RT.Modules
             {
                 if (_efem.Status != RState.Running)
                 {
-                    if (_robotWatch.ElapsedMilliseconds < 100)
+                    if (_robotWatch.ElapsedMilliseconds < 200)
                         return RState.Running;
                     else
                         return _efem.Status;

+ 26 - 8
Venus/Venus_RT/Modules/EFEM/EfemSwapRoutine.cs

@@ -2,6 +2,7 @@
 using Aitex.Core.RT.SCCore;
 using Aitex.Sorter.Common;
 using Venus_RT.Devices;
+using MECF.Framework.Common.Jobs;
 using MECF.Framework.Common.Routine;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.SubstrateTrackings;
@@ -213,14 +214,31 @@ namespace Venus_RT.Modules.EFEM
         private bool NotifyLLDone()
         {
             var waferStatus = _llModule.GetWaferProcessStatus();
-            if (waferStatus.unprocessed >= _autoPumpOptInWafer && waferStatus.processed <= _autoPumpOptOutWafer)
-            {
-                _llModule.PostMsg(LLEntity.MSG.AutoPump);
-            }
-            else
-            {
-                _llModule.PostMsg(LLEntity.MSG.EFEM_Exchange_Ready);
-            }
+
+            bool bAutoPump = false;
+            if (Singleton<RouteManager>.Instance.IsAutoMode)
+            {
+                if (((Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.AInBOut && _targetModule == ModuleName.LLA) ||
+                     (Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.BInAOut && _targetModule == ModuleName.LLB)) &&
+                      waferStatus.unprocessed >= _autoPumpOptInWafer)
+                {
+                    bAutoPump = true;
+                }
+                else if (((Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.AInBOut && _targetModule == ModuleName.LLB) ||
+                          (Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.BInAOut && _targetModule == ModuleName.LLA)) &&
+                           waferStatus.processed <= _autoPumpOptOutWafer)
+                {
+                    bAutoPump = true;
+                }
+                else if (Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.DInDOut &&
+                    waferStatus.processed   >= _autoPumpOptOutWafer &&
+                    waferStatus.unprocessed <= _autoPumpOptInWafer)
+                {
+                    bAutoPump = true;
+                }
+            }
+
+            _llModule.PostMsg(bAutoPump ? LLEntity.MSG.AutoPump : LLEntity.MSG.EFEM_Exchange_Ready);
             
             return true;
         }

+ 4 - 1
Venus/Venus_RT/Modules/LLs/LLEntity.cs

@@ -90,6 +90,10 @@ namespace Venus_RT.Modules
 
         public bool IsOnline { get; internal set; }
 
+        public bool IsVac { get { return _JetTM.IsModuleVaccum(Module); } }
+
+        public bool IsATM { get { return _JetTM.IsModuleATM(Module); } }
+
         private readonly JetTM _JetTM;
         private readonly MFPumpRoutine _pumpingRoutine;
         private readonly MFVentRoutine _ventingRoutine;
@@ -99,7 +103,6 @@ namespace Venus_RT.Modules
         public LLEntity(ModuleName module)
         {
             Module = module;
-            //_JetTM = Singleton<JetTM>.Instance;
             _JetTM= DEVICE.GetDevice<JetTM>("TM");
 
             _pumpingRoutine     = new MFPumpRoutine(_JetTM, Module);

+ 3 - 0
Venus/Venus_RT/Modules/PMs/PMEntity.cs

@@ -199,6 +199,9 @@ namespace Venus_RT.Modules.PMs
         public bool LiftPinIsUp => _chamber.LiftPinIsUp;
 		public double ChamberPressure => _chamber.ChamberPressure;
 
+        public bool IsVac => _chamber.IsVAC;
+        public bool IsAtm => _chamber.IsATM;
+
         public bool Check(int msg, out string reason, object[] objs)
         {
             reason = "";

+ 3 - 0
Venus/Venus_RT/Modules/RouteManager.cs

@@ -12,6 +12,7 @@ using Aitex.Core.RT.OperationCenter;
 using Aitex.Core.RT.Routine;
 using Aitex.Core.RT.SCCore;
 using Aitex.Core.Util;
+using MECF.Framework.Common.Jobs;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.SubstrateTrackings;
 using Venus_Core;
@@ -143,6 +144,8 @@ namespace Venus_RT.Modules
             }
         }
 
+        public SequenceLLInOutPath LLInOutPath => _AutoCycle.LLInOutPath;
+
         private TMCycle _TMCycle;
         private AutoCycle _AutoCycle;
         private ManualTransfer _manualTransfer;

+ 10 - 0
Venus/Venus_RT/Modules/Schedulers/SchedulerLoadLock.cs

@@ -31,6 +31,16 @@ namespace Venus_RT.Modules.Schedulers
 
         }
 
+        public override bool IsVac
+        {
+            get { return _entity.IsVac; }
+        }
+
+        public override bool IsAtm
+        {  
+            get { return _entity.IsATM; } 
+        }
+
         private LLEntity _entity = null;
         public SchedulerLoadLock(ModuleName module) : base(module.ToString())
         {

+ 2 - 0
Venus/Venus_RT/Modules/Schedulers/SchedulerModule.cs

@@ -97,6 +97,8 @@ namespace Venus_RT.Scheduler
         public virtual bool IsAvailable { get; }
         public virtual bool IsOnline { get; }
         public virtual bool IsError { get; }
+        public virtual bool IsAtm { get { return true; } }
+        public virtual bool IsVac { get { return false; } }
 
         public int InTransferSlot
         {

+ 10 - 0
Venus/Venus_RT/Modules/Schedulers/SchedulerPM.cs

@@ -50,6 +50,16 @@ namespace Venus_RT.Scheduler
 
         }
 
+        public override bool IsVac
+        {
+            get { return _entity.IsVac; }
+        }
+
+        public override bool IsAtm
+        {
+            get { return _entity.IsAtm; }
+        }
+
         public TaskType Task => _task;
         private PMEntity _entity = null;
 

+ 10 - 0
Venus/Venus_RT/Modules/Schedulers/SchedulerTMRobot.cs

@@ -46,6 +46,16 @@ namespace Venus_RT.Modules.Schedulers
             get { return _entity.RobotStatus;}
         }
 
+        public override bool IsVac
+        {
+            get { return _entity.IsTMVac; }
+        }
+
+        public override bool IsAtm
+        {
+            get { return _entity.IsTMVac; }
+        }
+
         private TMEntity _entity = null;
         public int _entityTaskToken = (int)FSM_MSG.NONE;
         private Queue<SchedulerItem> _schedulerList = new Queue<SchedulerItem>();

+ 23 - 7
Venus/Venus_RT/Modules/TM/MFSwapRoutine.cs

@@ -2,6 +2,7 @@
 using Aitex.Core.RT.SCCore;
 using Aitex.Sorter.Common;
 using Venus_RT.Devices;
+using MECF.Framework.Common.Jobs;
 using MECF.Framework.Common.Routine;
 using MECF.Framework.Common.Equipment;
 using MECF.Framework.Common.SubstrateTrackings;
@@ -244,15 +245,30 @@ namespace Venus_RT.Modules.TM
         private bool NotifyLLDone()
         {
             var waferStatus = _llModule.GetWaferProcessStatus();
-            if(waferStatus.processed >= _autoVentOptOutWafer && waferStatus.unprocessed <= _autoVentOptInWafer)
+            bool bAutoVent = false;
+            if(Singleton<RouteManager>.Instance.IsAutoMode)
             {
-                _llModule.PostMsg(LLEntity.MSG.AutoVent);
+                if (((Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.AInBOut && _targetModule == ModuleName.LLA) || 
+                     (Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.BInAOut && _targetModule == ModuleName.LLB)) &&
+                      waferStatus.unprocessed <= _autoVentOptInWafer)
+                {
+                    bAutoVent = true;
+                }
+                else if (((Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.AInBOut && _targetModule == ModuleName.LLB) ||
+                          (Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.BInAOut && _targetModule == ModuleName.LLA)) &&
+                           waferStatus.processed >= _autoVentOptOutWafer)
+                {
+                    bAutoVent = true;
+                }
+                else if(Singleton<RouteManager>.Instance.LLInOutPath == SequenceLLInOutPath.DInDOut && 
+                    waferStatus.processed   >= _autoVentOptOutWafer && 
+                    waferStatus.unprocessed <= _autoVentOptInWafer)
+                {
+                    bAutoVent = true;
+                }
             }
-            else
-            {
-                _llModule.PostMsg(LLEntity.MSG.TM_Exchange_Ready);
-            }
-            
+
+            _llModule.PostMsg(bAutoVent ? LLEntity.MSG.AutoVent : LLEntity.MSG.TM_Exchange_Ready);
             return true;
         }