Browse Source

enhance AutoCycle module.

sangwq 1 year ago
parent
commit
c223835b1e

+ 2 - 1
Venus/Framework/Common/IOCore/InterlockManager.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Xml;
 using Aitex.Core.RT.Event;
 using Aitex.Core.Util;
+using Aitex.Core.RT.Log;
 
 namespace Aitex.Core.RT.IOCore
 {
@@ -387,7 +388,7 @@ namespace Aitex.Core.RT.IOCore
 
                 if (!string.IsNullOrEmpty(info))
                 {
-                    EV.PostAlarmLog("System", info.TrimEnd('\n'));
+                    LOG.Write(eEvent.ERR_INTERLOCK_FAIL, "System", info.TrimEnd('\n'));
                 } 
             }
         }

+ 1 - 0
Venus/Venus_Core/EventDefine.cs

@@ -33,6 +33,7 @@ namespace Aitex.Core.RT.Log{
 		EV_SEQUENCE = 32,
 		WARN_SEQUENCE = 33,
 		ERR_SEQUENCE = 34,
+		ERR_INTERLOCK_FAIL = 35,
 		INFO_DEVICE_IO_HEATER = 1000,
 		WARN_DEVICE_IO_HEATER = 1001,
 		ERR_DEVICE_IO_HEATER = 1002,

+ 9 - 0
Venus/Venus_RT/Config/LogDefine.json

@@ -288,6 +288,15 @@
     "Note": "Sequence Failed"
   },
   {
+    "Id": 35,
+    "Level": "Error",
+    "LogEnum": "ERR_INTERLOCK_FAIL",
+    "GlobalDescription_zh": "{0}。",
+    "GlobalDescription_en": "{0}.",
+    "Module": "System",
+    "Note": "Interlock Failed"
+  },
+  {
     "Id": 1000,
     "Level": "Info",
     "LogEnum": "INFO_DEVICE_IO_HEATER",

+ 1 - 0
Venus/Venus_RT/Devices/EFEM/JetEfem.cs

@@ -769,6 +769,7 @@ namespace Venus_RT.Devices.EFEM
         {
             if(message.Operation != EfemOperation.ClearError && message.Operation != EfemOperation.Ready && _currentMsg.Operation != message.Operation && _backroundMsg.Operation != message.Operation)
             {
+                LOG.Write(eEvent.ERR_EFEM_COMMON_FAILED, ModuleName.EfemRobot, $"OnCommandUpdated() unexpected return: {message.Operation}, backround: {_backroundMsg.Operation}");
                 return;
             }
 

+ 7 - 7
Venus/Venus_RT/Devices/TM/SIASUNRobot.cs

@@ -102,7 +102,7 @@ namespace Venus_RT.Devices
 
             _currentOP = OPStep.Goto;
             _status = RState.Running;
-            return _SendCommand($"GOTO N {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
+            return _SendCommand($"GOTO N {_StationNumbers[station]} SLOT {slot + 1} ARM {Hand2Arm(hand)}");
         }
         public bool MoveTo(ModuleName stnFrom, ModuleName stnTo, Hand hand)
         {
@@ -121,7 +121,7 @@ namespace Venus_RT.Devices
             _currentOP = OPStep.PickExtend;
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
-            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT");
+            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} ENRT");
         }
         public bool PickRetract(ModuleName chamber, int slot, Hand hand)
         {
@@ -131,7 +131,7 @@ namespace Venus_RT.Devices
             _currentOP = OPStep.PickRetract;
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
-            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT");
+            return _SendCommand($"PICK {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} STRT");
         }
         public bool PlaceExtend(ModuleName chamber, int slot, Hand hand)
         {
@@ -141,7 +141,7 @@ namespace Venus_RT.Devices
             _currentOP = OPStep.PlaceExtent;
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Extending, hand, chamber);
-            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} ENRT");
+            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} ENRT");
         }
         public bool PlaceRetract(ModuleName chamber, int slot, Hand hand)
         {
@@ -152,7 +152,7 @@ namespace Venus_RT.Devices
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Retracting, hand, chamber);
             
-            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot} ARM {Hand2Arm(hand)} STRT");
+            return _SendCommand($"PLACE {_StationNumbers[chamber]} SLOT {slot + 1} ARM {Hand2Arm(hand)} STRT");
         }
         public bool Pick(ModuleName station, int slot, Hand hand)
         {
@@ -162,7 +162,7 @@ namespace Venus_RT.Devices
             _currentOP = OPStep.Pick;
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Picking, hand, station);
-            return _SendCommand($"PICK {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
+            return _SendCommand($"PICK {_StationNumbers[station]} SLOT {slot + 1} ARM {Hand2Arm(hand)}");
         }
         public bool Place(ModuleName station, int slot, Hand hand)
         {
@@ -172,7 +172,7 @@ namespace Venus_RT.Devices
             _currentOP = OPStep.Place;
             _status = RState.Running;
             SetRobotMovingInfo(RobotAction.Placing, hand, station);
-            return _SendCommand($"PLACE {_StationNumbers[station]} SLOT {slot} ARM {Hand2Arm(hand)}");
+            return _SendCommand($"PLACE {_StationNumbers[station]} SLOT {slot + 1} ARM {Hand2Arm(hand)}");
         }
 
         private bool _SendCommand(string cmd)

+ 98 - 30
Venus/Venus_RT/Modules/AutoCycle.cs

@@ -642,7 +642,7 @@ namespace Venus_RT.Modules
                 var inSlots = mod == ModuleName.LLA ? _LLAInSlot : _LLBInSlot;
                 foreach (var slot in inSlots)
                 {
-                    if (WaferManager.Instance.CheckNoWafer(mod, slot) && !_movingItems.Exists(item => item.DestinationModule == mod && item.DestinationSlot == slot))
+                    if (WaferManager.Instance.CheckNoWafer(mod, slot) && !_movingItems.Exists(item => item.DestinationModule == mod && item.DestinationSlot == slot) && !IsSlotReservedByEFEM(mod, slot))
                         validSlot.Add(slot);
 
                     if (WaferManager.Instance.CheckHasWafer(mod, slot) && _movingItems.Exists(item => item.SourceModule == mod && item.SourceSlot == slot))
@@ -662,6 +662,25 @@ namespace Venus_RT.Modules
             return validSlot.Distinct().ToList();
         }
 
+        private int GetModuleSlotCount(ModuleName mod)
+        {
+            int nSlotCount = 1;
+            if(ModuleHelper.IsLoadLock(mod))
+            {
+                nSlotCount = mod == ModuleName.LLA ? _LLASlotNumber : _LLBSlotNumber;
+            }
+            else if(ModuleHelper.IsLoadPort(mod))
+            {
+                nSlotCount = SC.GetValue<int>("EFEM.LoadPort.SlotNumber");
+            }
+            else if(ModuleHelper.IsTMRobot(mod) || ModuleHelper.IsEFEMRobot(mod))
+            {
+                nSlotCount = 2;
+            }
+
+            return nSlotCount;
+        }
+
         List<MoveItem> SearchWaitInSlots(ModuleName inModule)
         {
             List<MoveItem> inSlots = new List<MoveItem>();
@@ -725,7 +744,7 @@ namespace Venus_RT.Modules
 
                 foreach(var slot in _vacReadyOutSlots)
                 {
-                    if (_vacModules[slot.Module].MovingStatus == MovingStatus.Moving)
+                    if (_vacModules[slot.Module].MovingStatus != MovingStatus.Idle)
                         continue;
 
                     if (ModuleHelper.IsLoadLock(slot.Module))
@@ -778,10 +797,10 @@ namespace Venus_RT.Modules
                             {
                                 // check whether match double move pattern
                                 var same_dest = SearchWaitInSlots(destSlot.Module);
-                                foreach (var item in same_dest)
+                                if(same_dest.Count > 0)
                                 {
-                                    _movingItems.Add(item);
-                                    UpdateItemMovingStatus(item);
+                                    _movingItems.Add(same_dest[0]);
+                                    UpdateItemMovingStatus(same_dest[0]);
                                 }
                             }
 
@@ -1020,7 +1039,7 @@ namespace Venus_RT.Modules
             {
                 if(robotSlots.Count >= 1)
                 {
-                    if(WaferManager.Instance.CheckNoWafer(ll, slot))
+                    if(WaferManager.Instance.CheckNoWafer(ll, slot) && !IsSlotReservedByTM(ll, slot))
                     {
                         _efemMovingItems.Add(new MoveItem(ModuleName.EfemRobot, robotSlots.First(), ll, slot, (Hand)robotSlots.First()));
                         robotSlots.RemoveAt(0);
@@ -1074,6 +1093,22 @@ namespace Venus_RT.Modules
             return (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 0) ? 1 : 0) + (WaferManager.Instance.CheckHasWafer(ModuleName.EfemRobot, 1) ? 1 : 0);
         }
 
+        private bool IsSlotReservedByEFEM(ModuleName ll, int slot)
+        {
+            if (_efemMovingItems.Exists(item => item.DestinationModule == ll && item.DestinationSlot == slot))
+                return true;
+
+            return false;
+        }
+
+        private bool IsSlotReservedByTM(ModuleName ll, int slot)
+        {
+            if (_movingItems.Exists(item => item.DestinationModule == ll && item.DestinationSlot == slot))
+                return true;
+
+            return false;
+        }
+
         private Tuple<int, int>  GetLLProcessStatusCount(ModuleName ll)
         {
             int processedCount = 0;
@@ -1126,6 +1161,25 @@ namespace Venus_RT.Modules
             return true;
         }
 
+        private bool IsForwardPathBlocking(ModuleName mod, int slot)
+        {
+            var wafer = WaferManager.Instance.GetWafer(mod, slot);
+            if (wafer.IsEmpty || wafer.ProcessJob == null || wafer.ProcessJob.Sequence == null || wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count)
+                return false;
+
+            foreach (var next_module in wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules)
+            {
+                var SlotNumber = GetModuleSlotCount(next_module);
+                for(int i = 0; i < SlotNumber; i++)
+                {
+                    if (WaferManager.Instance.CheckNoWafer(next_module, i))
+                        return false;
+                }
+            }
+
+            return true;
+        }
+
         private bool ProcessLPEFEMRobotTask(ModuleName lp)
         {
             // check return
@@ -1150,14 +1204,20 @@ namespace Venus_RT.Modules
             if(_efemMovingItems.Count == 0 && IsReadyPushWaferIn())
             {
                 var outSlots = GetNextWaferInJobQueue(lp);
-                foreach (var slot in outSlots)
+
+                var hand = GetEFEMRobotFreeHand();
+                if (hand != Hand.None && outSlots.Count > 0)
                 {
-                    var hand = GetEFEMRobotFreeHand();
-                    if (hand != Hand.None)
-                    {
-                        _efemMovingItems.Add(new MoveItem(lp, slot, ModuleName.EfemRobot, (int)hand, hand));
-                    }
+                    _efemMovingItems.Add(new MoveItem(lp, outSlots[0], ModuleName.EfemRobot, (int)hand, hand));
                 }
+
+
+                hand = GetEFEMRobotFreeHand();
+                if (hand != Hand.None && outSlots.Count> 1 && !IsForwardPathBlocking(lp, outSlots[1]))
+                {
+                    _efemMovingItems.Add(new MoveItem(lp, outSlots[1], ModuleName.EfemRobot, (int)hand, hand));
+                }
+
             }
 
             return _efemMovingItems.Count > 0;
@@ -1473,6 +1533,25 @@ namespace Venus_RT.Modules
             return result;
         }
 
+        private void UpateSequenceStep(List<MoveItem> items)
+        {
+            foreach(var item in items)
+            {
+                if(!ModuleHelper.IsTMRobot(item.DestinationModule) && !ModuleHelper.IsEFEMRobot(item.DestinationModule))
+                {
+                    var wafer = WaferManager.Instance.GetWafer(item.DestinationModule, item.DestinationSlot);
+                    if(!wafer.IsEmpty && (wafer.NextSequenceStep >= wafer.ProcessJob.Sequence.Steps.Count ||  wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(item.DestinationModule)))
+                    {
+                        wafer.NextSequenceStep++;
+                    }
+                    else
+                    {
+                        // should not go here
+                        LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"UpateSequenceStep() failed, location: {item.DestinationModule}:{item.DestinationSlot}, NextSequenceStep: {wafer.NextSequenceStep}");
+                    }
+                }
+            }
+        }
         private void CheckWaferArrived()
         {
             if (_cycleState != RState.Running)
@@ -1493,18 +1572,12 @@ namespace Venus_RT.Modules
                         {
                             // wafer arrive
                             _vacWaferTargets.Remove(tar.Key);
-                            if(!ModuleHelper.IsTMRobot(tar.Key.Module))
-                                wafer.NextSequenceStep++;
-                            else
+
+                            if (ModuleHelper.IsPm(tar.Key.Module))
                             {
-                                LOG.Write(eEvent.WARN_ROUTER, ModuleName.System, $"Wafer {wafer.WaferOrigin} Skip increase NextSequenceStep while move to {tar.Key.Module}");
+                                _vacModules[tar.Key.Module].MovingStatus = MovingStatus.WaitProcess;
                             }
                         }
-                        else
-                        {
-                            // should not go here 
-                            LOG.Write(eEvent.ERR_ROUTINE_FAILED, ModuleName.System, $"wafer {wafer.WaferOrigin} iner id dismatch, before move{tar.Value}, after move {wafer.InnerId}.");
-                        }
                     }
                 }
             }
@@ -1514,21 +1587,18 @@ namespace Venus_RT.Modules
             {
                 foreach(var item in _movingItems)
                 {
-                    if(ModuleHelper.IsPm(item.DestinationModule))
-                    {
-                        _vacModules[item.DestinationModule].MovingStatus = MovingStatus.WaitProcess;
-                    }
-                    else if(ModuleHelper.IsLoadLock(item.DestinationModule))
+                    if(_vacModules[item.DestinationModule].MovingStatus == MovingStatus.Moving)
                     {
                         _vacModules[item.DestinationModule].MovingStatus = MovingStatus.Idle;
                     }
 
-                    if(ModuleHelper.IsLoadLock(item.SourceModule) || (ModuleHelper.IsPm(item.SourceModule) && _vacModules[item.SourceModule].MovingStatus == MovingStatus.Moving))
+                    if(_vacModules[item.SourceModule].MovingStatus == MovingStatus.Moving)
                     {
                         _vacModules[item.SourceModule].MovingStatus = MovingStatus.Idle;
                     }
                 }
 
+                UpateSequenceStep(_movingItems);
                 _movingItems.Clear();
             }
 
@@ -1547,9 +1617,6 @@ namespace Venus_RT.Modules
                         {
                             // wafer arrive
                             _atmWaferTargets.Remove(tar.Key);
-
-                            if (!ModuleHelper.IsEFEMRobot(tar.Key.Module))
-                                wafer.NextSequenceStep++;
                         }
                     }
                 }
@@ -1566,6 +1633,7 @@ namespace Venus_RT.Modules
                     }
                 }
 
+                UpateSequenceStep(_efemMovingItems);
                 _efemMovingItems.Clear();
             }
         }

+ 2 - 1
Venus/Venus_RT/Modules/ManualTransfer.cs

@@ -302,6 +302,7 @@ namespace Venus_RT.Modules
 
         public RState Start(params object[] objs)
         {
+            Singleton<TransferModule>.Instance.GetScheduler(ModuleName.TMRobot).ResetTask();
             foreach(var mod in _moduleList)
             {
                 if (ModuleHelper.IsInstalled(mod) && Singleton<TransferModule>.Instance.GetScheduler(mod).IsAvailable)
@@ -345,7 +346,7 @@ namespace Venus_RT.Modules
             }
             else if (ret == RState.Failed || ret == RState.Timeout)
             {
-                LOG.Write(eEvent.ERR_ROUTINE_FAILED, ModuleName.System, $"Return Wafer {_current_item.SourceModule}{_current_item.SourceSlot} failed");
+                LOG.Write(eEvent.ERR_ROUTINE_FAILED, ModuleName.System,"Manual Transfer",  $"Return Wafer {_current_item.SourceModule}{_current_item.SourceSlot} failed");
                 return RState.Failed;
             }
 

+ 2 - 1
Venus/Venus_RT/Modules/PMs/PMProcess_FA.cs

@@ -196,7 +196,8 @@ namespace Venus_RT.Modules.PMs
                     {DVIDName.PortID, PortId[wafer.OriginStation]},
                     {DVIDName.SlotID, (wafer.OriginSlot + 1).ToString()},
                     {DVIDName.LotID, wafer.LotId},
-                    {DVIDName.CarrierID,wafer.OriginCarrierID.ToString() }
+                    //{DVIDName.CarrierID,wafer.OriginCarrierID.ToString() }
+                    {DVIDName.CarrierID,"" }
                 });
             }
             else

+ 11 - 2
Venus/Venus_RT/Modules/Schedulers/SchedulerEfemRobot.cs

@@ -45,7 +45,7 @@ namespace Venus_RT.Scheduler
 
 
         private SchedulerItem _currentScheduler = null;
-        private int _entityTaskToken = (int)TaskType.None;
+        private int _entityTaskToken = (int)FSM_MSG.NONE;
 
 
         public ModuleName PreviousTarget { get; set; }
@@ -84,7 +84,7 @@ namespace Venus_RT.Scheduler
             bool ret = false;
             switch (_entityTaskToken)
             {
-                case (int)TaskType.None:
+                case (int)FSM_MSG.NONE:
                     ret = true;
                     break;
                 case (int)EfemEntity.MSG.Pick:
@@ -182,5 +182,14 @@ namespace Venus_RT.Scheduler
 
             return true;
         }
+
+        public override void ResetTask()
+        {
+            base.ResetTask();
+
+            _entityTaskToken = (int)FSM_MSG.NONE;
+            _currentScheduler.Status = RState.End;
+
+        }
     }
 }

+ 1 - 1
Venus/Venus_RT/Modules/Schedulers/SchedulerModule.cs

@@ -136,7 +136,7 @@ namespace Venus_RT.Scheduler
         {
             EV.PostInfoLog("Scheduler", $"Task done:{_module}, {cmd}, {message}");
         }
-        public void ResetTask()
+        public virtual void ResetTask()
         {
             _task = TaskType.None;
         }

+ 9 - 1
Venus/Venus_RT/Modules/Schedulers/SchedulerPM.cs

@@ -363,7 +363,15 @@ namespace Venus_RT.Scheduler
         {
             WaferInfo wafer = WaferManager.Instance.GetWafer(Module, 0);
             string attr = $"{Module}Recipe";
-            var recipeName = wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep - 1].StepParameter[attr];
+            string recipeName = string.Empty;
+            if(wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepModules.Contains(Module))
+            {
+                recipeName = (string)wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep].StepParameter[attr];
+            }
+            else
+            {
+                recipeName = (string)wafer.ProcessJob.Sequence.Steps[wafer.NextSequenceStep - 1].StepParameter[attr];
+            }
 
             Process((string)recipeName, false, true, wafer);
         }

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

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