Browse Source

fix the routing bug while multiple In Out pattern sequence, and the bug for return all wafer.

sangwq 1 year ago
parent
commit
3cb931b12b
1 changed files with 37 additions and 40 deletions
  1. 37 40
      Venus/Venus_RT/Modules/SystemDispatcher.cs

+ 37 - 40
Venus/Venus_RT/Modules/SystemDispatcher.cs

@@ -1255,7 +1255,7 @@ namespace Venus_RT.Modules
                 if (ModuleHelper.IsLoadPort(mod.Key))
                     continue;
 
-                if (!mod.Value.IsIdle)
+                if (!mod.Value.Scheduler.IsIdle)
                 {
                     LOG.Write(eEvent.ERR_ROUTER, mod.Key, $"{mod.Key} is not ready for return wafer.");
                     return RState.Failed;
@@ -1630,7 +1630,6 @@ namespace Venus_RT.Modules
         private bool ActiveControlJob(ControlJobInfo cj)
         {
             cj.JetState = EnumJetCtrlJobState.Processing;
-
             foreach (var pjName in cj.ProcessJobNameList)
             {
                 var pj = _lstProcessJobs.Find(x => x.Name == pjName);
@@ -1766,15 +1765,15 @@ namespace Venus_RT.Modules
 
         private ModuleName GetComingAvailablePM(ControlJobInfo cj)
         {
-            var cjPMs = new List<ModuleName>();
-            foreach (var pj in _lstProcessJobs)
+            var lstInProcessPMs = new List<ModuleName>();
+            foreach (var wafer in cj.LotWafers)
             {
-                if(pj.ControlJobName == cj.Name)
+                if(!wafer.IsEmpty && wafer.NextSequenceStep == 0 && wafer.ProcessJob != null)
                 {
-                    foreach(var pm in pj.Sequence.PMs)
+                    foreach(var pm in wafer.ProcessJob.Sequence.PMs)
                     {
-                        if (!cjPMs.Contains(pm))
-                            cjPMs.Add(pm);
+                        if (!lstInProcessPMs.Contains(pm))
+                            lstInProcessPMs.Add(pm);
                     }
                 }
             }
@@ -1782,7 +1781,7 @@ namespace Venus_RT.Modules
             Dictionary<ModuleName, int> pmAssociatedWaferCount = new Dictionary<ModuleName, int>();
             foreach (var mod in _dictModuleTask)
             {
-                if (ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsOnline && cjPMs.Contains(mod.Key))
+                if (ModuleHelper.IsPm(mod.Key) && mod.Value.Scheduler.IsOnline && lstInProcessPMs.Contains(mod.Key))
                 {
                     pmAssociatedWaferCount[mod.Key] = 0;
                 }
@@ -1791,14 +1790,14 @@ namespace Venus_RT.Modules
             var unprocessedWafer = _lstWaferTasks.Where(task => ModuleHelper.IsPm(task.destMod));
             foreach (var wafer in unprocessedWafer)
             {
-                if (ModuleHelper.IsPm(wafer.destMod) && _dictModuleTask[wafer.destMod].Scheduler.IsOnline)
+                if (ModuleHelper.IsPm(wafer.destMod) && _dictModuleTask[wafer.destMod].Scheduler.IsOnline && lstInProcessPMs.Contains(wafer.destMod))
                 {
                     pmAssociatedWaferCount[wafer.destMod]++;
                 }
             }
 
             var oderedPMCount = pmAssociatedWaferCount.OrderBy(p => p.Value).ToDictionary(p => p.Key, o => o.Value);
-            if (oderedPMCount.First().Value < 2)
+            if (oderedPMCount.Count > 0 && oderedPMCount.First().Value < 2)
                 return oderedPMCount.First().Key;
 
             return ModuleName.System;
@@ -2097,16 +2096,19 @@ namespace Venus_RT.Modules
             {
                 // ready to push in 
                 var readyLLs = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
-                        ((mod.Key != ModuleName.LLA && LLInOutPath == SequenceLLInOutPath.BInBOut) || (mod.Key != ModuleName.LLB && LLInOutPath == SequenceLLInOutPath.AInAOut)) &&
+                        ((mod.Key == ModuleName.LLA && LLInOutPath != SequenceLLInOutPath.BInBOut) || (mod.Key == ModuleName.LLB && LLInOutPath != SequenceLLInOutPath.AInAOut)) &&
                         mod.Value.TimeToReady <= 10 &&
                         !IsLLReservedByTM(mod.Key) &&
-                        GetLLReadyInOutSlots(mod.Key).emptySlot.Count > 1).
+                        GetLLReadyInOutSlots(mod.Key).emptySlot.Count >= 1).
                         OrderBy(mod => mod.Value.TimeToReady).ToList();
 
-                if (readyLLs.Count > 0 && atmWaferCount >= 1)
+                if (atmWaferCount >= 1)
                 {
-                    if (ExchangeWaferWithLL(readyLLs.First().Key))
-                        return;
+                    foreach(var ll in readyLLs)
+                    {
+                        if (ExchangeWaferWithLL(ll.Key))
+                            return;
+                    }
                 }
 
                 // forward wafer to system
@@ -2119,15 +2121,16 @@ namespace Venus_RT.Modules
                 if (_efemSchdActions.Count == 0)
                 {
                     var readyReturnLL = _dictModuleTask.Where(mod => ModuleHelper.IsLoadLock(mod.Key) &&
-                            ((mod.Key != ModuleName.LLA && LLInOutPath == SequenceLLInOutPath.BInBOut) || (mod.Key != ModuleName.LLB && LLInOutPath == SequenceLLInOutPath.AInAOut)) &&
+                            ((mod.Key == ModuleName.LLA && LLInOutPath != SequenceLLInOutPath.BInBOut) || (mod.Key == ModuleName.LLB && LLInOutPath != SequenceLLInOutPath.AInAOut)) &&
                             mod.Value.TimeToReady <= 5 &&
                             !IsLLReservedByTM(mod.Key) &&
                             GetLLReadyInOutSlots(mod.Key).outSlot.Count >= 1).
                             OrderByDescending(mod => GetLLReadyInOutSlots(mod.Key).outSlot.Count).ToList();
 
-                    if (readyReturnLL.Count > 0)
+                    foreach(var ll in readyReturnLL)
                     {
-                        ExchangeWaferWithLL(readyReturnLL.First().Key);
+                        if (ExchangeWaferWithLL(readyReturnLL.First().Key))
+                            return;
                     }
                 }
             }
@@ -2140,9 +2143,10 @@ namespace Venus_RT.Modules
                         GetLLReadyInOutSlots(mod.Key).outSlot.Count > 1).
                         OrderBy(mod => mod.Value.TimeToReady).ToList();
 
-                if (readyDoubleReturnLL.Count > 0)
+
+                foreach(var ll in readyDoubleReturnLL)
                 {
-                    if (ExchangeWaferWithLL(readyDoubleReturnLL.First().Key))
+                    if (ExchangeWaferWithLL(ll.Key))
                         return;
                 }
 
@@ -2153,9 +2157,9 @@ namespace Venus_RT.Modules
                         GetLLReadyInOutSlots(mod.Key).outSlot.Count == 1).
                         OrderBy(mod => mod.Value.TimeToReady).ToList();
 
-                if (readySingleReturnLL.Count > 0)
+                foreach (var ll in readySingleReturnLL)
                 {
-                    if (ExchangeWaferWithLL(readySingleReturnLL.First().Key))
+                    if (ExchangeWaferWithLL(ll.Key))
                         return;
                 }
 
@@ -2169,9 +2173,10 @@ namespace Venus_RT.Modules
                             GetLLReadyInOutSlots(mod.Key).emptySlot.Count > 1).
                             OrderBy(mod => mod.Value.TimeToReady).ToList();
 
-                    if (readyLLs.Count > 0)
+                    foreach(var ll in readyLLs)
                     {
-                        ForwardATMWafers(readyLLs.First().Key);
+                        if (ForwardATMWafers(ll.Key))
+                            return;
                     }
                 }
             }
@@ -2508,7 +2513,7 @@ namespace Venus_RT.Modules
                         }
                     }
 
-                    llValues[ll] = returnWafers[ll].Count * 2 + llSwapActions[ll].Count + (_dictModuleTask[ll].Scheduler.IsVac ? 3 : 0);
+                    llValues[ll] = returnWafers[ll].Count * 2 + llSwapActions[ll].Count + (_dictModuleTask[ll].Scheduler.IsVac && returnWafers[ll].Count > 0 ? 2 : 0);
                 }
             }
 
@@ -3487,27 +3492,19 @@ namespace Venus_RT.Modules
             if (_lstControlJobs.Count == 0)
                 return;
 
-            List<SequenceLLInOutPath> inOutPaths = new List<SequenceLLInOutPath>();
-            foreach (var cj in _lstControlJobs)
+            var inOutPaths = new List<SequenceLLInOutPath>(); 
+            foreach(var wt in _lstWaferTasks)
             {
-                if (cj.State == EnumControlJobState.Executing)
-                {
-                    foreach (var pjName in cj.ProcessJobNameList)
-                    {
-                        var pj = _lstProcessJobs.Find(x => x.Name == pjName);
-                        if (pj == null || pj.State != EnumProcessJobState.Processing)
-                            continue;
-
-                        if (!inOutPaths.Exists(item => item == pj.Sequence.LLInOutPath))
-                            inOutPaths.Add(pj.Sequence.LLInOutPath);
-                    }
-                }
+                if (!inOutPaths.Contains(wt.llInOutPath))
+                    inOutPaths.Add(wt.llInOutPath);
             }
 
             if (inOutPaths.Count == 1)
             {
                 _LLInOutPath = inOutPaths[0];
             }
+            else
+                _LLInOutPath = SequenceLLInOutPath.DInDOut;
         }
 
         #endregion