Browse Source

check in new routing algorithm code.

sangwq 1 year ago
parent
commit
20606c1ffb

+ 1 - 1
Venus/Framework/Common/DBCore/PostgresqlDB.cs

@@ -33,7 +33,7 @@ namespace Aitex.Core.RT.DBCore
                 if (_closeTime >= _closeMaxTime)
                     return DataBaseStatus.Error;
                 else
-                    return _conn.State == ConnectionState.Open ? DataBaseStatus.Open : DataBaseStatus.Close;
+                    return (_conn != null && _conn.State == ConnectionState.Open) ? DataBaseStatus.Open : DataBaseStatus.Close;
             }
         }
 

+ 28 - 5
Venus/Framework/Common/Device/ModuleName.cs

@@ -215,7 +215,7 @@ namespace MECF.Framework.Common.Equipment
                    || unit == ModuleName.LP9
                    || unit == ModuleName.LP10;
         }
- 
+
         public static bool IsPm(string unit)
         {
             return IsPm(ModuleHelper.Converter(unit));
@@ -237,7 +237,7 @@ namespace MECF.Framework.Common.Equipment
                    || unit == ModuleName.PME
                    || unit == ModuleName.PMF;
         }
- 
+
         public static bool IsLoadLock(string unit)
         {
             return IsLoadLock(ModuleHelper.Converter(unit));
@@ -245,12 +245,12 @@ namespace MECF.Framework.Common.Equipment
 
         public static bool IsAligner(ModuleName unit)
         {
-            return unit == ModuleName.Aligner || unit == ModuleName.Aligner1 || unit == ModuleName.Aligner2  ;
+            return unit == ModuleName.Aligner || unit == ModuleName.Aligner1 || unit == ModuleName.Aligner2;
         }
 
         public static bool IsCooling(ModuleName unit)
         {
-            return  unit == ModuleName.Cooling1 || unit == ModuleName.Cooling2;
+            return unit == ModuleName.Cooling1 || unit == ModuleName.Cooling2;
         }
 
         public static bool IsLoadLock(ModuleName unit)
@@ -280,6 +280,16 @@ namespace MECF.Framework.Common.Equipment
             return unit == ModuleName.EfemRobot;
         }
 
+        public static bool IsEFEM(ModuleName unit)
+        {
+            return unit == ModuleName.EFEM;
+        }
+
+        public static bool isSETM(ModuleName unit)
+        {
+            return unit == ModuleName.SETM;
+        }
+
         public static bool IsVCE(ModuleName unit)
         {
             return unit == ModuleName.VCE1;
@@ -301,7 +311,7 @@ namespace MECF.Framework.Common.Equipment
 
         public static ModuleName Converter(string module)
         {
-            return (ModuleName) Enum.Parse(typeof(ModuleName), module);
+            return (ModuleName)Enum.Parse(typeof(ModuleName), module);
         }
 
         /// <summary>
@@ -321,6 +331,19 @@ namespace MECF.Framework.Common.Equipment
 
         private static List<ModuleName> _lstModules = new List<ModuleName>();
         private static readonly object _lock = new object();
+        public static List<ModuleName> InstalledModules
+        {
+            get
+            {
+                if (_lstModules.Count == 0)
+                {
+                    LoadModules();
+                }
+
+                return _lstModules;
+            }
+        }
+
         public static bool IsInstalled(ModuleName module)
         {
             if (_lstModules.Count == 0)

+ 2 - 1
Venus/Framework/Common/Event/EventManager.cs

@@ -9,6 +9,7 @@ using Aitex.Core.RT.DataCenter;
 using Aitex.Core.WCF;
 using Aitex.Core.RT.Log;
 using Aitex.Core.RT.OperationCenter;
+using Aitex.Core.RT.DBCore;
 
 namespace Aitex.Core.RT.Event
 {
@@ -444,7 +445,7 @@ namespace Aitex.Core.RT.Event
             {
                 try
                 {
-                    if (_eventDB!= null)
+                    if (_eventDB!= null && Singleton<DatabaseManager>.Instance.DataBaseStatus != DataBaseStatus.Error)
                         _eventDB.WriteEvent(ev);
 
                     //_writerToLog.WriteEvent(ev);

+ 24 - 0
Venus/Framework/Common/Routine/IRoutine.cs

@@ -5,6 +5,7 @@ using System.Text;
 using Aitex.Core.RT.Log;
 using MECF.Framework.Common.Routine;
 using MECF.Framework.Common.Equipment;
+using MECF.Framework.Common.Jobs;
 
 using Venus_Core;
 namespace Aitex.Core.RT.Routine
@@ -17,6 +18,29 @@ namespace Aitex.Core.RT.Routine
         void Abort();
     }
 
+    public interface ICycle : IRoutine
+    {
+         SequenceLLInOutPath LLInOutPath { get; }
+         bool HasJobRunning { get; }
+         RState CycleState { get; }
+
+
+        void AbortJob(string jobName);
+        void StopJob(string jobName);
+        void ResumeJob(string jobName);
+        void PauseJob(string jobName);
+        void StartJob(string jobName);
+        void CreateJob(Dictionary<string, object> param);
+        void Clear();
+
+        bool ManualReturnWafer(object[] objs);
+        RState CheckManualReturnWafer();
+        RState ReturnAllWafers();
+
+        bool CheckJobJustDone(out string sJobName);
+        bool CheckAllJobDone();
+    }
+
     public class ModuleRoutineBase
     {
         public ModuleName Module { get; set; }

+ 4 - 6
Venus/Venus_RT/Modules/AutoCycle.cs

@@ -40,7 +40,6 @@ namespace Venus_RT.Modules
         Idle,
         Waiting,
         Moving,
-        Moved,
 
         // PM Status
         WaitProcess,
@@ -83,7 +82,7 @@ namespace Venus_RT.Modules
         }
     }
 
-    class AutoCycle : IRoutine
+    class AutoCycle : ICycle
     {
         private List<ControlJobInfo> _lstControlJobs = new List<ControlJobInfo>();
         private List<ProcessJobInfo> _lstProcessJobs = new List<ProcessJobInfo>();
@@ -112,8 +111,6 @@ namespace Venus_RT.Modules
         int _LLASlotNumber = 4;
         int _LLBSlotNumber = 4;
         int _efemRobotSingleArmOption = 0;
-        SequenceLLInOutPath _LLInOutPath = SequenceLLInOutPath.DInDOut;
-        public SequenceLLInOutPath LLInOutPath { get { return _LLInOutPath; } }
 
         List<MoveItem> _movingItems = new List<MoveItem>();
         List<MoveItem> _efemMovingItems = new List<MoveItem>();
@@ -142,6 +139,9 @@ namespace Venus_RT.Modules
 
         private List<Guid> _lstReturnWafers = new List<Guid>();
 
+        SequenceLLInOutPath _LLInOutPath = SequenceLLInOutPath.DInDOut;
+        public SequenceLLInOutPath LLInOutPath { get { return _LLInOutPath; } }
+
         public bool HasJobRunning => _lstControlJobs.Count > 0;
         public RState CycleState => _cycleState;
 
@@ -177,7 +177,6 @@ namespace Venus_RT.Modules
 
         public RState Start(params object[] objs)
         {
-            Clear();
             _isCycleMode = SC.GetValue<bool>("System.IsCycleMode");
             _cycleSetPoint = _isCycleMode ? SC.GetValue<int>("System.CycleCount") : 0;
             _cycledWafer = 0;
@@ -186,7 +185,6 @@ namespace Venus_RT.Modules
             _cycleWatch.Stop();
             _lpCycleWafer.Clear();
             _lpCycleCount.Clear();
-            _cycleWatch.Start();  
 
             return RState.Running;
         }

+ 3 - 0
Venus/Venus_RT/Modules/EFEM/EfemEntity.cs

@@ -476,6 +476,7 @@ namespace Venus_RT.Modules
             if (ret == RState.Failed || ret == RState.Timeout)
             {
                 PostMsg(MSG.Error);
+                Singleton<RouteManager>.Instance.InvokeAbort(new object[] { ModuleName.EFEM });
                 return false;
             }
 
@@ -498,6 +499,7 @@ namespace Venus_RT.Modules
             if (ret == RState.Failed || ret == RState.Timeout)
             {
                 PostMsg(MSG.Error);
+                Singleton<RouteManager>.Instance.InvokeAbort(new object[] { ModuleName.EFEM });
                 return false;
             }
 
@@ -521,6 +523,7 @@ namespace Venus_RT.Modules
             if (ret == RState.Failed || ret == RState.Timeout)
             {
                 PostMsg(MSG.Error);
+                Singleton<RouteManager>.Instance.InvokeAbort(new object[] { ModuleName.EFEM });
                 return false;
             }
 

+ 48 - 31
Venus/Venus_RT/Modules/RouteManager.cs

@@ -161,7 +161,7 @@ namespace Venus_RT.Modules
         public SequenceLLInOutPath LLInOutPath => _AutoCycle.LLInOutPath;
 
         private TMCycle _TMCycle;
-        private AutoCycle _AutoCycle;
+        private ICycle _AutoCycle;
         private ManualTransfer _manualTransfer;
         private ReturnAllWafer _returnWafer;
 		private SETMCycle _seTMCycle;
@@ -455,6 +455,7 @@ namespace Venus_RT.Modules
             OP.Subscribe("System.ReturnAllSEWafer", (cmd, args) => CheckToPostMessage((int)MSG.SEReturnWafer, args));
             OP.Subscribe("System.SEAbort", (cmd, args) => CheckToPostMessage((int)MSG.SEAbort, args));
         }
+
         public bool CheckToPostMessage(int msg, params object[] args)
         {
             if (!fsm.FindTransition(fsm.State, msg))
@@ -469,6 +470,11 @@ namespace Venus_RT.Modules
             return true;
         }
 
+        public bool InvokeAbort(object[] args)
+        {
+            return CheckToPostMessage((int)MSG.ABORT, args);
+        }
+
         private bool InvokeCreateWafer(string arg1, object[] args)
         {
             ModuleName chamber = ModuleHelper.Converter(args[0].ToString());
@@ -617,14 +623,11 @@ namespace Venus_RT.Modules
             return null;
         }
 
-        
-
         public TMEntity GetTM()
         {
             return TM;
         }
     
-
         protected override bool Init()
         {
             PMA?.Initialize();
@@ -641,6 +644,7 @@ namespace Venus_RT.Modules
 
             _TMCycle = new TMCycle();
             _AutoCycle = new AutoCycle();
+            //_AutoCycle = new SystemDispatcher();
             _manualTransfer = new ManualTransfer();
             _returnWafer = new ReturnAllWafer(_manualTransfer);
 			_seTMCycle = new SETMCycle(ModuleName.SETM);
@@ -749,49 +753,62 @@ namespace Venus_RT.Modules
 
         private bool FsmStartHome(object[] objs)
         {
-            PMA?.Invoke("Home");
-            PMB?.Invoke("Home");
-            PMC?.Invoke("Home");
-            PMD?.Invoke("Home");
             TM?.Invoke("Home");
-            LLA?.Invoke("Home");
-            LLB?.Invoke("Home");
             EFEM?.Invoke("Home");
             seTM?.Invoke("Home");
             VCE?.Invoke("Home");
 
+            foreach(var mod in ModuleHelper.InstalledModules)
+            {
+                if(ModuleHelper.IsPm(mod))
+                {
+                    if(GetPM(mod).IsInclude)
+                    {
+                        GetPM(mod).Invoke("Home");
+                    }
+                }
+                else if (ModuleHelper.IsLoadLock(mod))
+                {
+                    if(GetLL(mod).IsInclude)
+                    {
+                        GetLL(mod).Invoke("Home");
+                    }
+                }
+            }
+
             return true;
         }
 
         private bool FsmMonitorHome(object[] objs)
         {
-            bool CheckHomed(string name, bool bValid, bool bDone)
+            ModuleName notReadyModule = ModuleName.System;
+            foreach(var mod in ModuleHelper.InstalledModules)
             {
-                if (bValid && !bDone)
+                if ((ModuleHelper.IsPm(mod)&& GetPM(mod).IsInclude && !GetPM(mod).IsIdle) || 
+                    (ModuleHelper.IsLoadLock(mod) && GetLL(mod).IsInclude && !GetLL(mod).IsIdle) ||
+                    (ModuleHelper.IsTM(mod) && !GetTM().IsIdle) ||
+                    (ModuleHelper.IsVCE(mod) && !GetVCE(mod).IsIdle) ||
+                    (ModuleHelper.IsEFEM(mod) && !EFEM.IsIdle) ||
+                    (ModuleHelper.isSETM(mod) && !seTM.IsIdle))
                 {
-                    if (fsm.ElapsedTime > 100 * 1000)
-                    {
-                        LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"{name} home timeout");
-                        PostMsg(MSG.ERROR);
-                        return true;
-                    }
-                    else
-                        return false;
+                    notReadyModule = mod;
+                    break;
                 }
+            }
 
-                return true;
+            if(notReadyModule != ModuleName.System)
+            {
+                if (fsm.ElapsedTime > 100 * 1000)
+                {
+                    LOG.Write(eEvent.ERR_ROUTER, ModuleName.System, $"{notReadyModule} home timeout");
+                    PostMsg(MSG.ERROR);
+                    return true;
+                }
+                else
+                    return false;
             }
 
-            return CheckHomed("PMA", ModuleHelper.IsInstalled(ModuleName.PMA) && PMA != null, ModuleHelper.IsInstalled(ModuleName.PMA) && PMA != null&&PMA.IsIdle) &&
-                CheckHomed("PMB", ModuleHelper.IsInstalled(ModuleName.PMB) && PMB != null, ModuleHelper.IsInstalled(ModuleName.PMB) && PMB != null&&PMB.IsIdle) &&
-                CheckHomed("PMC", ModuleHelper.IsInstalled(ModuleName.PMC) && PMC != null, ModuleHelper.IsInstalled(ModuleName.PMC) && PMC != null&&PMC.IsIdle) &&
-                CheckHomed("PMD", ModuleHelper.IsInstalled(ModuleName.PMD) && PMD != null, ModuleHelper.IsInstalled(ModuleName.PMD) && PMD != null&&PMD.IsIdle) &&
-                CheckHomed("LLA", ModuleHelper.IsInstalled(ModuleName.LLA) && LLA != null, ModuleHelper.IsInstalled(ModuleName.LLA) && LLA != null&&LLA.IsIdle) &&
-                CheckHomed("LLB", ModuleHelper.IsInstalled(ModuleName.LLB) && LLB != null, ModuleHelper.IsInstalled(ModuleName.LLB) && LLB != null&&LLB.IsIdle) &&
-                CheckHomed("TM", ModuleHelper.IsInstalled(ModuleName.TM) && TM != null, ModuleHelper.IsInstalled(ModuleName.TM) && TM != null&&TM.IsIdle) &&
-                CheckHomed("EFEM", ModuleHelper.IsInstalled(ModuleName.EFEM) && EFEM != null, ModuleHelper.IsInstalled(ModuleName.EFEM) && EFEM != null && EFEM.IsIdle) &&
-                CheckHomed("SETM", ModuleHelper.IsInstalled(ModuleName.SETM) && seTM != null, ModuleHelper.IsInstalled(ModuleName.SETM) && seTM != null && seTM.IsIdle) &&
-                CheckHomed("VCE1", ModuleHelper.IsInstalled(ModuleName.VCE1) && VCE != null, ModuleHelper.IsInstalled(ModuleName.VCE1) && VCE != null && VCE.IsIdle);
+            return true;
         }
 
 

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

@@ -330,6 +330,71 @@ namespace Venus_RT.Modules.Schedulers
             return true;
         }
 
+        public bool SendMoveItems(MoveItem[] items)
+        {
+            for(int i = 1; i < items.Length; i++)
+            {
+                if(items[i - 1].Module != items[i].Module)
+                {
+                    LOG.Write(eEvent.ERR_ROUTER, ModuleName.TMRobot, $"the actions for {items[i - 1].Module} and for {items[i].Module} should not put together");
+                    return false;
+                }
+            }
+
+            void PackMoveItems(TMEntity.MSG cmdType, MoveItem[] actions)
+            {
+                SchedulerItem schItem = new SchedulerItem();
+                schItem.MoveType = cmdType;
+                schItem.target = actions[0].DestinationModule;
+                schItem.moveList = new Queue<MoveItem>();
+                foreach(var ac in actions)
+                {
+                    schItem.moveList.Enqueue(ac);
+                }
+                _schedulerList.Enqueue(schItem);
+            }
+
+            if (ModuleHelper.IsTMRobot(items[0].DestinationModule))  // pick
+            {
+                if(ModuleHelper.IsLoadLock(items[0].Module))
+                {
+                    PackMoveItems(items.Length > 1 ? TMEntity.MSG.Swap : TMEntity.MSG.Pick, items);
+                }
+                else
+                {
+                    PackMoveItems(items.Length > 1 ? TMEntity.MSG.PMSwap : TMEntity.MSG.PMPick, items);
+                }
+            }
+            else if (ModuleHelper.IsTMRobot(items[0].SourceModule)) // place
+            {
+                if (ModuleHelper.IsLoadLock(items[0].Module))
+                {
+                    PackMoveItems(items.Length > 1 ? TMEntity.MSG.Swap : TMEntity.MSG.Place, items);
+                }
+                else
+                {
+                    if(items.Length == 1)
+                    {
+                        PackMoveItems(TMEntity.MSG.PMPlace, items);
+                    }
+                    else
+                    {
+                        LOG.Write(eEvent.ERR_ROUTER, ModuleName.TMRobot, $"multi actons for PM place command");
+                        return false;
+                    }
+                }
+            }
+            else
+                return false;
+
+            foreach (var item in items)
+            {
+                LOG.Write(eEvent.EV_ROUTER, ModuleName.TMRobot, $"Post Moving Item: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
+            }
+
+            return true;
+        }
+
         Hand SelectFreeHand()
         {
             if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, 0) && _singleArmOption != 2)

+ 1 - 0
Venus/Venus_RT/Venus_RT.csproj

@@ -313,6 +313,7 @@
     <Compile Include="Modules\Schedulers\TransferModule.cs" />
     <Compile Include="Modules\SEManualTransfer.cs" />
     <Compile Include="Modules\SETMCycle.cs" />
+    <Compile Include="Modules\SystemDispatcher.cs" />
     <Compile Include="Modules\TMCycle.cs" />
     <Compile Include="Modules\TM\MFHomeRoutine.cs" />
     <Compile Include="Modules\TM\MFLeakCheckRoutine.cs" />