瀏覽代碼

new routing algorithm update.

sangwq 1 年之前
父節點
當前提交
9189e1b51f

+ 22 - 0
Venus/Framework/Common/Fsm/Entity.cs

@@ -11,6 +11,7 @@ namespace Aitex.Core.RT.Fsm
     {
         protected Thread thread = null;
         protected IStateMachine fsm = null;
+        protected Dictionary<int, int> _dictStateTime = new Dictionary<int, int>();
         
         public bool Running { get; protected set;}
 
@@ -151,6 +152,27 @@ namespace Aitex.Core.RT.Fsm
             fsm.PostMsg(msg, args);
         }
 
+        public void MarkStateTime()
+        {
+            _dictStateTime[fsm.State] = fsm.ElapsedTime;
+        }
+
+        public virtual int TimeToReady
+        {
+            get
+            {
+                if (_dictStateTime.ContainsKey(fsm.State))
+                {
+                    if ((_dictStateTime[fsm.State] - fsm.ElapsedTime) > 0)
+                        return _dictStateTime[fsm.State] - fsm.ElapsedTime;
+                    else
+                        return 0;
+                }
+                    
+                return int.MaxValue;
+            }
+        }
+
  
     }
 }

+ 72 - 40
Venus/Venus_RT/Modules/LLs/LLEntity.cs

@@ -99,6 +99,22 @@ namespace Venus_RT.Modules
 
         public bool IsATM { get { return _JetTM.IsModuleATM(Module); } }
 
+        public override int TimeToReady
+        {
+            get
+            {
+                switch ((STATE)fsm.State)
+                {
+                    case STATE.Pumping:
+                    case STATE.Venting:
+                        return base.TimeToReady;
+
+                }
+
+                return int.MaxValue;
+            }
+        }
+
         private readonly JetTM _JetTM;
         private readonly MFPumpRoutine _pumpingRoutine;
         private readonly MFVentRoutine _ventingRoutine;
@@ -154,61 +170,61 @@ namespace Venus_RT.Modules
             fsm = new StateMachine<LLEntity>(Module.ToString(), (int)STATE.Init, 50);
             fsm.EnableRepeatedMsg(true);
 
-            EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_TM, fnEnterTMReady, FSM_MSG.NONE, fnExitTMReady);
-            EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_EFEM, fnEnterEFEMReady, FSM_MSG.NONE, fnExitEFEMReady);
+            EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_TM,     fnEnterTMReady,     FSM_MSG.NONE,   fnExitTMReady);
+            EnterExitTransition<STATE, FSM_MSG>(STATE.Ready_For_EFEM,   fnEnterEFEMReady,   FSM_MSG.NONE,   fnExitEFEMReady);
 
             //AnyStateTransition(FSM_MSG.TIMER,   fnMonitor,          FSM_STATE.SAME);
 
 
-            AnyStateTransition(MSG.Error, fnError, STATE.Error);
-            AnyStateTransition(MSG.Online, fnOnline, FSM_STATE.SAME);
-            AnyStateTransition(MSG.Offline, fnOffline, FSM_STATE.SAME);
-            AnyStateTransition(MSG.Home, fnHome, STATE.Initializing);
+            AnyStateTransition(MSG.Error,       fnError,        STATE.Error);
+            AnyStateTransition(MSG.Online,      fnOnline,       FSM_STATE.SAME);
+            AnyStateTransition(MSG.Offline,     fnOffline,      FSM_STATE.SAME);
+            AnyStateTransition(MSG.Home,        fnHome,         STATE.Initializing);
 
             // Home
-            Transition(STATE.Initializing, FSM_MSG.TIMER, fnHoming, STATE.Idle);
+            Transition(STATE.Initializing,      FSM_MSG.TIMER,          fnHoming,               STATE.Idle);
 
-            Transition(STATE.Idle, FSM_MSG.TIMER, fnMonitor, STATE.Idle);
-            Transition(STATE.Init, FSM_MSG.TIMER, fnMonitor, STATE.Init);
+            Transition(STATE.Idle,              FSM_MSG.TIMER,          fnMonitor,              STATE.Idle);
+            Transition(STATE.Init,              FSM_MSG.TIMER,          fnMonitor,              STATE.Init);
 
             //vent sequence
-            Transition(STATE.Idle, MSG.Vent, FnStartVent, STATE.Venting);
-            Transition(STATE.Venting, FSM_MSG.TIMER, FnVentTimeout, STATE.Idle);
-            Transition(STATE.Venting, MSG.Abort, FnAbortVent, STATE.Idle);
+            Transition(STATE.Idle,              MSG.Vent,               FnStartVent,            STATE.Venting);
+            Transition(STATE.Venting,           FSM_MSG.TIMER,          FnVentTimeout,          STATE.Idle);
+            Transition(STATE.Venting,           MSG.Abort,              FnAbortVent,            STATE.Idle);
 
             //Pump sequence
-            Transition(STATE.Idle, MSG.Pump, FnStartPump, STATE.Pumping);
-            Transition(STATE.Pumping, FSM_MSG.TIMER, FnPumpTimeout, STATE.Idle);
-            Transition(STATE.Pumping, MSG.Abort, FnAbortPump, STATE.Idle);
+            Transition(STATE.Idle,              MSG.Pump,               FnStartPump,            STATE.Pumping);
+            Transition(STATE.Pumping,           FSM_MSG.TIMER,          FnPumpTimeout,          STATE.Idle);
+            Transition(STATE.Pumping,           MSG.Abort,              FnAbortPump,            STATE.Idle);
 
             // Purge sequence
-            Transition(STATE.Idle, MSG.Purge, FnStartPurge, STATE.Purging);
-            Transition(STATE.Purging, FSM_MSG.TIMER, FnPurgeTimeout, STATE.Idle);
-            Transition(STATE.Purging, MSG.Abort, FnAbortPurge, STATE.Idle);
+            Transition(STATE.Idle,              MSG.Purge,              FnStartPurge,           STATE.Purging);
+            Transition(STATE.Purging,           FSM_MSG.TIMER,          FnPurgeTimeout,         STATE.Idle);
+            Transition(STATE.Purging,           MSG.Abort,              FnAbortPurge,           STATE.Idle);
 
             // Leak check sequence
-            Transition(STATE.Idle, MSG.LeakCheck, FnStartLeakCheck, STATE.LeakCheck);
-            Transition(STATE.LeakCheck, FSM_MSG.TIMER, FnLeakCheckTimeout, STATE.Idle);
-            Transition(STATE.LeakCheck, MSG.Abort, FnAbortLeakCheck, STATE.Idle);
+            Transition(STATE.Idle,              MSG.LeakCheck,          FnStartLeakCheck,       STATE.LeakCheck);
+            Transition(STATE.LeakCheck,         FSM_MSG.TIMER,          FnLeakCheckTimeout,     STATE.Idle);
+            Transition(STATE.LeakCheck,         MSG.Abort,              FnAbortLeakCheck,       STATE.Idle);
 
             // Prepare TM Transfer
-            Transition(STATE.Idle, MSG.Prepare_TM, FnStartPrepareTM, STATE.Prepare_For_TM);
-            Transition(STATE.Prepare_For_TM, FSM_MSG.TIMER, FnPreparaTMTimeout, STATE.Ready_For_TM);
-            Transition(STATE.Prepare_For_TM, MSG.Prepare_TM, null, STATE.Prepare_For_TM);
-            Transition(STATE.Prepare_For_TM, MSG.Abort, FnAbortPreparaTM, STATE.Idle);
-            Transition(STATE.Ready_For_TM, MSG.TM_Exchange_Ready, null, STATE.Idle);
-            Transition(STATE.Ready_For_TM, MSG.Prepare_TM, null, STATE.Ready_For_TM);
-            Transition(STATE.Ready_For_TM, MSG.Abort, null, STATE.Idle);
-            Transition(STATE.Ready_For_TM, MSG.AutoVent, FnTryAutoVent, STATE.Venting);
+            Transition(STATE.Idle,              MSG.Prepare_TM,         FnStartPrepareTM,       STATE.Prepare_For_TM);
+            Transition(STATE.Prepare_For_TM,    FSM_MSG.TIMER,          FnPreparaTMTimeout,     STATE.Ready_For_TM);
+            Transition(STATE.Prepare_For_TM,    MSG.Prepare_TM,         null,                   STATE.Prepare_For_TM);
+            Transition(STATE.Prepare_For_TM,    MSG.Abort,              FnAbortPreparaTM,       STATE.Idle);
+            Transition(STATE.Ready_For_TM,      MSG.TM_Exchange_Ready,  null,                   STATE.Idle);
+            Transition(STATE.Ready_For_TM,      MSG.Prepare_TM,         null,                   STATE.Ready_For_TM);
+            Transition(STATE.Ready_For_TM,      MSG.Abort,              null,                   STATE.Idle);
+            Transition(STATE.Ready_For_TM,      MSG.AutoVent,           FnTryAutoVent,          STATE.Venting);
 
             // Prepare EFEM Transfer
-            Transition(STATE.Idle, MSG.Prepare_EFEM, FnStartPrepareEFEM, STATE.Prepare_For_EFEM);
-            Transition(STATE.Prepare_For_EFEM, FSM_MSG.TIMER, FnPrepareEFEMTimeout, STATE.Ready_For_EFEM);
-            Transition(STATE.Prepare_For_EFEM, MSG.Abort, FnAbortPrepareEFEM, STATE.Idle);
-            Transition(STATE.Ready_For_EFEM, MSG.EFEM_Exchange_Ready, null, STATE.Idle);
-            Transition(STATE.Ready_For_EFEM, MSG.Prepare_EFEM, null, STATE.Ready_For_EFEM);
-            Transition(STATE.Ready_For_EFEM, MSG.Abort, null, STATE.Idle);
-            Transition(STATE.Ready_For_EFEM, MSG.AutoPump, FnTryAutoPump, STATE.Pumping);
+            Transition(STATE.Idle,              MSG.Prepare_EFEM,       FnStartPrepareEFEM,     STATE.Prepare_For_EFEM);
+            Transition(STATE.Prepare_For_EFEM,  FSM_MSG.TIMER,          FnPrepareEFEMTimeout,   STATE.Ready_For_EFEM);
+            Transition(STATE.Prepare_For_EFEM,  MSG.Abort,              FnAbortPrepareEFEM,     STATE.Idle);
+            Transition(STATE.Ready_For_EFEM,    MSG.EFEM_Exchange_Ready, null,                  STATE.Idle);
+            Transition(STATE.Ready_For_EFEM,    MSG.Prepare_EFEM,       null,                   STATE.Ready_For_EFEM);
+            Transition(STATE.Ready_For_EFEM,    MSG.Abort,              null,                   STATE.Idle);
+            Transition(STATE.Ready_For_EFEM,    MSG.AutoPump,           FnTryAutoPump,          STATE.Pumping);
 
             //AnyStateTransition(FSM_MSG.TIMER, LLControlPressureTimer_Elapsed, FSM_STATE.SAME);
 
@@ -360,6 +376,12 @@ namespace Venus_RT.Modules
 
         private bool fnOnline(object[] param)
         {
+            if (!IsInclude)
+            {
+                LOG.Write(eEvent.WARN_LL, Module, $"{Module} is excluded,can not be put online");
+                return false;
+            }
+
             IsOnline = true;
             return true;
         }
@@ -378,7 +400,6 @@ namespace Venus_RT.Modules
             }
             IsInclude = true;
             LOG.Write(eEvent.INFO_LL, Module, $"{Module}  Set Include Success");
-
             return true;
         }
         private bool FnSetExclude()
@@ -390,7 +411,6 @@ namespace Venus_RT.Modules
             }
             IsInclude = false;
             LOG.Write(eEvent.INFO_LL, Module, $"{Module}  Set Exclude Success");
-
             return true;
         }
         private bool fnAbort(object[] param)
@@ -434,7 +454,13 @@ namespace Venus_RT.Modules
                 return false;
             }
 
-            return ret == RState.End;
+            if(ret == RState.End)
+            {
+                MarkStateTime();
+                return true;
+            }
+
+            return false;
         }
 
         private bool FnAbortVent(object[] param)
@@ -457,7 +483,13 @@ namespace Venus_RT.Modules
                 return false;
             }
 
-            return ret == RState.End;
+            if (ret == RState.End)
+            {
+                MarkStateTime();
+                return true;
+            }
+
+            return false;
         }
 
         private bool FnAbortPump(object[] param)

+ 47 - 4
Venus/Venus_RT/Modules/PMs/PMEntity.cs

@@ -117,7 +117,6 @@ namespace Venus_RT.Modules.PMs
 
         public ModuleName Module { get; }
         public PMStatus Status { get; private set; }
-        public Action<bool, bool> TransferPrepared;
 
         private readonly PMHomeRoutine              _home;
         private readonly StartDryPumpRoutine        _startDryPumpRoutine;
@@ -196,6 +195,33 @@ namespace Venus_RT.Modules.PMs
             get;
             private set;
         } = true;
+
+
+        private Dictionary<string, int> _dictRecipeTime = new Dictionary<string, int>();
+        public override int TimeToReady
+        {
+            get
+            {
+                switch((PMState)fsm.State)
+                {
+                    case PMState.Processing:
+                    case PMState.Clean:
+                        if(Singleton<RouteManager>.Instance.IsAutoMode && IsOnline)
+                        {
+                            if (_dictRecipeTime.ContainsKey(_processRoutine.currentRecipeResult.RecipeName))
+                            {
+                                return Math.Max(_dictRecipeTime[_processRoutine.currentRecipeResult.RecipeName] - fsm.ElapsedTime, 0);
+                            }
+                        }
+
+                        break;
+
+                }
+
+                return int.MaxValue;
+            }
+        }
+
         public bool IsAutoMode => _AutoMode == AutoFlag.Auto;
         public bool IsSlitDoorOpen => _chamber.CheckSlitDoorOpen();
         public bool IsSlitDoorClose => _chamber.CheckSlitDoorClose();
@@ -242,6 +268,11 @@ namespace Venus_RT.Modules.PMs
             return fsm.CheckExecuted(msg);
         }
 
+        public void ResetRecipeTime()
+        {
+            _dictRecipeTime.Clear();
+        }
+
         public bool IsPrepareTransferReady(ModuleName robot, EnumTransferType type, int slot, Hand blade)
         {
             //if (type == EnumTransferType.Pick)
@@ -358,9 +389,9 @@ namespace Venus_RT.Modules.PMs
                 LOG.Write(eEvent.WARN_PM, Module, $"{Module} is online,can not set Exclude");
                 return false;
             }
+            IsInclude = false;
             LOG.Write(eEvent.INFO_PM, Module, $"{Module}  Set Exclude Success");
 
-            IsInclude = false;
             return true;
         }
         private bool FnSetOnline(object[] param)
@@ -371,6 +402,12 @@ namespace Venus_RT.Modules.PMs
             //    return false;
             //}
 
+            if(!IsInclude)
+            {
+                LOG.Write(eEvent.WARN_PM, Module, $"{Module} is excluded,can not be put online");
+                return false;
+            }
+
             if (!_chamber.CheckSlitDoorClose())
             {
                 EV.PostWarningLog(Module.ToString(), $"{Module} slit door is open,can not set online.");
@@ -526,7 +563,7 @@ namespace Venus_RT.Modules.PMs
             Transition(PMState.Processing,      FSM_MSG.TIMER,      FnProcessTimeout,           PMState.Idle);
             Transition(PMState.Processing,      MSG.Abort,          FnAbortProcess,             PMState.Idle);
 
-            // Process
+            // Clean
             Transition(PMState.Idle,            MSG.Clean,          FnRunRecipe,                PMState.Clean);
             Transition(PMState.Clean,           FSM_MSG.TIMER,      FnProcessTimeout,           PMState.Idle);
             Transition(PMState.Clean,           MSG.Abort,          FnAbortProcess,             PMState.Idle);
@@ -1177,7 +1214,13 @@ namespace Venus_RT.Modules.PMs
                 return false;
             }
 
-            return ret == RState.End;
+            if(ret == RState.End)
+            {
+                _dictRecipeTime[_processRoutine.currentRecipeResult.RecipeName] = fsm.ElapsedTime;
+                return true;
+            }
+            
+            return false;
         }
         private bool FnAbortProcess(object[] param)
         {

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

@@ -46,6 +46,11 @@ namespace Venus_RT.Modules.Schedulers
             get { return _entity.IsATM; } 
         }
 
+        public override int TimeToReady
+        {
+            get { return _entity.TimeToReady; }
+        }
+
         private LLEntity _entity = null;
         public SchedulerLoadLock(ModuleName module) : base(module.ToString())
         {

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

@@ -261,9 +261,12 @@ namespace Venus_RT.Scheduler
             return new SlotItem(ModuleName.System, -1);
         }
 
-        public virtual int GetTimeToReady()
+        public virtual int TimeToReady
         {
-            return 0;
+            get
+            {
+                return int.MaxValue;
+            }
         }
 
         public virtual void WaferArrived(int slot)

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

@@ -60,6 +60,11 @@ namespace Venus_RT.Scheduler
             get { return _entity.IsAtm; }
         }
 
+        public override int TimeToReady
+        {
+            get { return _entity.TimeToReady; }
+        }
+
         public TaskType Task => _task;
         private PMEntity _entity = null;
 
@@ -380,6 +385,12 @@ namespace Venus_RT.Scheduler
             }
         }
 
+        public override void ResetTask()
+        {
+            _entity.ResetRecipeTime();
+            base.ResetTask();
+        }
+
         #region clean task
 
         private void LoadIdleCleanOpt()

+ 9 - 10
Venus/Venus_RT/Modules/SystemDispatcher.cs

@@ -298,6 +298,11 @@ namespace Venus_RT.Modules
             WTWClean,
         }
 
+        public override int TimeToReady
+        {
+            get { return Scheduler.IsAvailable ? 0 : (Scheduler.TimeToReady + 500) / 1000; }
+        }
+
         private WaferTask _wafer;
         private SchedulerPM _pmScheduler => Scheduler as SchedulerPM;
 
@@ -633,13 +638,7 @@ namespace Venus_RT.Modules
 
         public override int TimeToReady
         {
-            get
-            {
-                if (Scheduler.IsAvailable)
-                    return 0;
-
-                return int.MaxValue;
-            }
+            get { return Scheduler.IsAvailable ? 0 : (Scheduler.TimeToReady + 500) / 1000; }
         }
 
         public override void WaferArrived(WaferTask wafer, int slot)
@@ -769,7 +768,6 @@ namespace Venus_RT.Modules
             string[] slotSequence = (string[])param["SlotSequence"];
             string jobId = (string)param["JobId"];
             string module = (string)param["Module"];
-
             if (string.IsNullOrEmpty(jobId))
             {
                 jobId = "CJ_Local_" + module;
@@ -960,7 +958,8 @@ namespace Venus_RT.Modules
 
             return null;
         }
-        public bool AbortJob(string jobName,out string reason)
+
+        public bool AbortJob(string jobName, out string reason)
         {
             reason = "";
             ControlJobInfo cj = _lstControlJobs.Find(x => x.Name == jobName);
@@ -1478,7 +1477,7 @@ namespace Venus_RT.Modules
                 if (totolCycleWafer != _cycledWafer || _lpCycleCount.Sum(item => item.Value) > 0 && _throughput < 0.01)  // refresh _throughput in time
                 {
                     _cycledWafer = totolCycleWafer;
-                    if (_cycledCount > 0)
+                    if (_cycledCount > 0 || allControlJobComplete)
                     {
                         _throughput = (float)(_cycledWafer / _cycleWatch.Elapsed.TotalHours);
                     }