Browse Source

new routing algorithm with prediction.

sangwq 1 year ago
parent
commit
6d393bb86d

+ 8 - 2
Venus/Venus_RT/Modules/LLs/LLEntity.cs

@@ -236,8 +236,14 @@ namespace Venus_RT.Modules
             switch (function)
             {
                 case "Home":
-                    CheckToPostMessage((int)MSG.Home);
-                    return (int)MSG.Home;
+                case "Vent":
+                case "Pump":
+                    if(Enum.TryParse(function, out MSG message))
+                    {
+                        if (CheckToPostMessage((int)message))
+                            return (int)message;
+                    }
+                    break;
             }
 
             return (int)FSM_MSG.NONE;

+ 2 - 2
Venus/Venus_RT/Modules/RouteManager.cs

@@ -648,8 +648,8 @@ namespace Venus_RT.Modules
             seTM?.Initialize();
 
             _TMCycle = new TMCycle();
-            _AutoCycle = new AutoCycle();
-            //_AutoCycle = new SystemDispatcher();
+            //_AutoCycle = new AutoCycle();
+            _AutoCycle = new SystemDispatcher();
             _manualTransfer = new ManualTransfer();
             _returnWafer = new ReturnAllWafer(_manualTransfer);
 			_seTMCycle = new SETMCycle(ModuleName.SETM);

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

@@ -66,5 +66,15 @@ namespace Venus_RT.Modules.Schedulers
         {
             return  WaferArriveTicks.OrderBy(item => item.Value).ToDictionary(k => k.Key, v => v.Value).Keys.ToList();
         }
+
+        public bool PreVent()
+        {
+            return _entity.Invoke(LLEntity.MSG.Vent.ToString()) == (int)LLEntity.MSG.Vent;
+        }
+
+        public bool PrePump()
+        {
+            return _entity.Invoke(LLEntity.MSG.Pump.ToString()) == (int)LLEntity.MSG.Pump;
+        }
     }
 }

+ 105 - 8
Venus/Venus_RT/Modules/SystemDispatcher.cs

@@ -124,6 +124,7 @@ namespace Venus_RT.Modules
 
                     if (!ModuleHelper.IsTMRobot(nextMod) && !ModuleHelper.IsEFEMRobot(nextMod))
                     {
+                        wafer.NextSequenceStep++;
                         OnWaferArrived(this, new MoveItem(currentMod, currentSlot, nextMod, nextSlot, hand));
                     }
 
@@ -645,6 +646,26 @@ namespace Venus_RT.Modules
         {
             Scheduler.WaferArrived(slot);
         }
+
+        public bool PreVent()
+        {
+            if (Scheduler.IsAvailable && Scheduler.IsVac)
+            {
+                return (Scheduler as SchedulerLoadLock).PreVent();
+            }
+
+            return false;
+        }
+
+        public bool PrePump()
+        {
+            if (Scheduler.IsAvailable && Scheduler.IsAtm)
+            {
+                return (Scheduler as SchedulerLoadLock).PrePump();
+            }
+
+            return false;
+        }
     }
 
     class SystemDispatcher : ICycle
@@ -727,8 +748,17 @@ namespace Venus_RT.Modules
 
         public RState Start(params object[] objs)
         {
-            _efemRobotSingleArmOption = SC.GetValue<int>("EFEM.SingleArmOption");
-            _tmRobotSingleArmOption = SC.GetValue<int>("TM.SingleArmOption");
+            _efemRobotSingleArmOption   = SC.GetValue<int>("EFEM.SingleArmOption");
+            _tmRobotSingleArmOption     = SC.GetValue<int>("TM.SingleArmOption");
+            _isCycleMode                = SC.GetValue<bool>("System.IsCycleMode");
+            _cycleSetPoint              = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
+            _cycledWafer                = 0;
+            _cycledCount                = 0;
+            _throughput                 = 0;
+
+            _cycleWatch.Stop();
+            _lpCycleWafer.Clear();
+            _lpCycleCount.Clear();
 
             return RState.Running;
         }
@@ -740,10 +770,6 @@ namespace Venus_RT.Modules
             RunWaferTask();
             RunModuleTasks();
 
-            //UpdateProcessJobStatus();
-            //UpdateControlJobStatus();
-            //UpdateLLInOutPathProperty();
-
             RoutingATMWafers();
             RoutingVacWafers();
            
@@ -920,6 +946,7 @@ namespace Venus_RT.Modules
 
             _lstControlJobs.Add(cj);
             //AssociatedPMWithLP(cj);
+            _loadportControlJobDic[cj.Module] = cj;
 
             _faCallback.JobCreated(cj, GetFirstProcessJob(cj));
             return true;
@@ -1137,6 +1164,12 @@ namespace Venus_RT.Modules
                 module.Value.Scheduler.ResetTask();
             }
 
+            List<string> keys = _loadportControlJobDic.Keys.ToList();
+            foreach (var key in keys)
+            {
+                _loadportControlJobDic[key] = null;
+            }
+
             _lstWaferTasks.Clear();
             _tmSchdActions.Clear();
             _curTmAction.Clear();
@@ -1300,6 +1333,7 @@ namespace Venus_RT.Modules
             UpdateProcessJobStatus();
             UpdateControlJobStatus();
             UpdateLLInOutPathProperty();
+            PrepareLLPressure();
 
             CreateNewWaferTask();
             _lstWaferTasks.RemoveAll(item => ModuleHelper.IsLoadPort(item.destMod) && ModuleHelper.IsLoadPort(item.currentMod) && item.pressureStatus == RState.End);
@@ -1746,7 +1780,7 @@ namespace Venus_RT.Modules
                         if (wafer.IsEmpty || wafer.ProcessJob == null)
                             continue;
 
-                        if (wafer.ProcessJob.Sequence.PMs.Contains(pm) && wafer.ProcessState == EnumWaferProcessStatus.Idle && !_lstWaferTasks.Exists(task => task.sourceMod == (ModuleName)wafer.OriginStation && task.sourceSlot == wafer.OriginSlot))
+                        if (wafer.ProcessJob.Sequence.PMs.Contains(pm) && wafer.NextSequenceStep == 0 && !_lstWaferTasks.Exists(task => task.sourceMod == (ModuleName)wafer.OriginStation && task.sourceSlot == wafer.OriginSlot))
                         {
                             CreateWaferTasks(wafer, pm,  wafer.ProcessJob.Sequence.LLDelayTime);
                             return;
@@ -3075,7 +3109,7 @@ namespace Venus_RT.Modules
             var emptySlots = new List<int>();
             for(int slot = 0; slot < (ll == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber); slot++)
             {
-                if(WaferManager.Instance.CheckNoWafer(ll, slot) && !_lstWaferTasks.Exists(wafer => (wafer.routedMod == ll && wafer.routedSlot == slot)|| (wafer.currentMod == ll && wafer.currentSlot == slot) || (wafer.nextMod == ll && wafer.nextSlot == slot)))
+                if(WaferManager.Instance.CheckNoWafer(ll, slot) && !_lstWaferTasks.Exists(wafer => (wafer.routedMod == ll && wafer.routedSlot == slot) || (wafer.currentMod == ll && wafer.currentSlot == slot) || (wafer.nextMod == ll && wafer.nextSlot == slot)))
                 {
                     emptySlots.Add(slot);
                 }
@@ -3118,6 +3152,69 @@ namespace Venus_RT.Modules
             return (lstWafers, lstEmptySlots);
         }
 
+        private void PrepareLLPressure()
+        {
+            var preaparedLLs = new List<ModuleName>();
+            var lls = _efemSchdActions.Where(acs => ModuleHelper.IsLoadLock(acs.First().Module)).Select(item => item.First().Module).ToList();
+            if (_curEfemAction.Count == 0 && _efemSchdActions.Count > 0 && ModuleHelper.IsLoadLock(_efemSchdActions.First().First().Module))
+                lls.Remove(_efemSchdActions.First().First().Module);
+
+            foreach(var ll in lls)
+            {
+                if(_dictModuleTask[ll].Scheduler.IsAvailable && _dictModuleTask[ll].Scheduler.IsVac && !preaparedLLs.Contains(ll))
+                {
+                    (_dictModuleTask[ll].Scheduler as SchedulerLoadLock).PreVent();
+                    preaparedLLs.Add(ll);
+                }
+            }
+
+            lls = _tmSchdActions.Where(acs => ModuleHelper.IsLoadLock(acs.First().Module)).Select(item => item.First().Module).ToList();
+            if(_curTmAction.Count == 0 && _tmSchdActions.Count > 0 && ModuleHelper.IsLoadLock(_tmSchdActions.First().First().Module))
+                lls.Remove(_tmSchdActions.First().First().Module);
+
+            foreach (var ll in lls)
+            {
+                if (_dictModuleTask[ll].Scheduler.IsAvailable && _dictModuleTask[ll].Scheduler.IsAtm && !preaparedLLs.Contains(ll))
+                {
+                    (_dictModuleTask[ll].Scheduler as SchedulerLoadLock).PrePump();
+                    preaparedLLs.Add(ll);
+                }
+            }
+
+            if (_efemSchdActions.Count > 0 || _curEfemAction.Count > 0 || _tmSchdActions.Count > 0 || _curTmAction.Count > 0)
+                return;
+
+            if (LLInOutPath == SequenceLLInOutPath.AInBOut || LLInOutPath == SequenceLLInOutPath.BInAOut)
+            {
+                var inLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLA : ModuleName.LLB;
+                var outLL = LLInOutPath == SequenceLLInOutPath.AInBOut ? ModuleName.LLB : ModuleName.LLA;
+                var inLLWaferCount = _lstWaferTasks.Where(wafer => wafer.currentMod == inLL).Count();
+                var outLLWaferCount = _lstWaferTasks.Where(wafer => wafer.currentMod == outLL).Count();
+
+                if (inLLWaferCount == 0 && !preaparedLLs.Contains(inLL))
+                {
+                    (_dictModuleTask[inLL] as LoadlockTask).PreVent();
+                    preaparedLLs.Add(inLL);
+                }
+                else if(inLLWaferCount == (LLInOutPath == SequenceLLInOutPath.AInBOut ? _LLASlotNumber : _LLBSlotNumber) && !preaparedLLs.Contains(inLL))
+                {
+                    (_dictModuleTask[inLL] as LoadlockTask).PrePump();
+                    preaparedLLs.Add(inLL);
+                }
+
+                if(outLLWaferCount == 0 && !preaparedLLs.Contains(outLL))
+                {
+                    (_dictModuleTask[outLL] as LoadlockTask).PrePump();
+                    preaparedLLs.Add(outLL);
+                }
+                else if(outLLWaferCount == (LLInOutPath == SequenceLLInOutPath.BInAOut ? _LLASlotNumber : _LLBSlotNumber) && !preaparedLLs.Contains(outLL))
+                {
+                    (_dictModuleTask[outLL] as LoadlockTask).PreVent();
+                    preaparedLLs.Add(outLL);
+                }
+            }
+        }
+
         private void ReturnVacWafers()
         {
             if (_tmSchdActions.Count > 0 || _curTmAction.Count > 0)