Browse Source

Return wafers functions.

sangwq 10 months ago
parent
commit
02c63fca6d

+ 9 - 0
Venus/Venus_RT/Modules/Schedulers/SchedulerSETMRobot.cs

@@ -510,5 +510,14 @@ namespace Venus_RT.Modules.Schedulers
         {
             _schedulerList.Clear();
         }
+
+        public override void ResetTask()
+        {
+            base.ResetTask();
+
+            _entityTaskToken = (int)FSM_MSG.NONE;
+            _schedulerList.Clear();
+
+        }
     }
 }

+ 51 - 11
Venus/Venus_RT/Modules/VenusDispatcher.cs

@@ -501,7 +501,7 @@ namespace Venus_RT.Modules
             _cycledCount = 0;
             _throughput = 0;
 
-
+            Clear();
             _cycleWatch.Stop();
             _lpCycleWafer.Clear();
             _lpCycleCount.Clear();
@@ -682,7 +682,7 @@ namespace Venus_RT.Modules
         {
             foreach (var cj in _lstControlJobs)
             {
-                if (cj.State == EnumControlJobState.Executing || cj.State == EnumControlJobState.Paused)
+                if (cj.State != EnumControlJobState.Completed)
                     return false;
             }
 
@@ -968,24 +968,18 @@ namespace Venus_RT.Modules
                 return RState.Failed;
             }
 
-            if (!_dictModuleTask[ModuleName.EfemRobot].Scheduler.IsIdle)
-            {
-                LOG.Write(eEvent.ERR_ROUTER, ModuleName.EfemRobot, $"The EFEM Robot is not ready for return wafer.");
-                return RState.Failed;
-            }
-
             foreach (var mod in _dictModuleTask)
             {
                 if (ModuleHelper.IsLoadPort(mod.Key))
                     continue;
 
-                if (!mod.Value.Scheduler.IsIdle)
+                if (!ModuleHelper.IsAligner(mod.Key) && !mod.Value.Scheduler.IsIdle)
                 {
                     LOG.Write(eEvent.ERR_ROUTER, mod.Key, $"{mod.Key} is not ready for return wafer.");
                     return RState.Failed;
                 }
 
-                int nSlotNumber = (ModuleHelper.IsTMRobot(mod.Key) || ModuleHelper.IsEFEMRobot(mod.Key) ? 2 : 1);
+                int nSlotNumber = (ModuleHelper.IsTMRobot(mod.Key) ? 2 : 1);
                 for (int slot = 0; slot < nSlotNumber; slot++)
                 {
                     var wafer = WaferManager.Instance.GetWafer(mod.Key, slot);
@@ -1383,6 +1377,15 @@ namespace Venus_RT.Modules
             }
         }
 
+        private bool isReturnActionsDone(List<MoveItem> items)
+        {
+            foreach (var item in items)
+            {
+                if (WaferManager.Instance.CheckHasWafer(item.SourceModule, item.SourceSlot) || WaferManager.Instance.CheckNoWafer(item.DestinationModule, item.DestinationSlot))
+                    return false;
+            }
+            return true;
+        }
         private bool IsMovingActionsDone(List<MoveItem> actions)
         {
             bool CheckWaferExistence(ModuleName mod, int slot)
@@ -1502,7 +1505,16 @@ namespace Venus_RT.Modules
 
         private void ReturnInternalWafers()
         {
-            for(int i = 0; i < 2; i++) 
+            if (_tmSchdActions.Count > 0 || _curTmAction.Count > 0)
+            {
+                RunSchdTMReturnActions();
+                return;
+            }
+
+            if (_tmRobotStatus != RState.End)
+                return;
+
+            for (int i = 0; i < 2; i++) 
             {
                 if(WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, i))
                 {
@@ -1894,6 +1906,34 @@ namespace Venus_RT.Modules
             return false;
         }
 
+        private void RunSchdTMReturnActions()
+        {
+            var tmRobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.TMRobot) as SchedulerSETMRobot;
+            if (tmRobot == null || !tmRobot.IsAvailable)
+                return;
+
+            if (_tmSchdActions.Count > 0)
+            {
+                if (_curTmAction.Count == 0 || isReturnActionsDone(_curTmAction))
+                {
+                    var nextActions = _tmSchdActions.First();
+
+                    var nextModule = nextActions.First().Module;
+
+                    if (!_dictModuleTask[nextModule].IsIdle)
+                        return;
+
+                    _curTmAction = _tmSchdActions.Dequeue();
+
+                    tmRobot.SendMoveItems(_curTmAction.ToArray());
+                }
+            }
+            else if (_curTmAction.Count >= 0 && isReturnActionsDone(_curTmAction)) // all scheduled actions done
+            {
+                _curTmAction.Clear();
+            }
+        }
+
 
         #endregion internal implementation