瀏覽代碼

submit new venus routing algorithm.

sangwq 11 月之前
父節點
當前提交
75b6c4548e

+ 1 - 8
Venus/Venus_RT/Modules/SEManualTransfer.cs

@@ -37,14 +37,7 @@ namespace Venus_RT.Modules
         private float align_angle;
         public SEManualTransfer()
         {
-            if (ModuleHelper.IsInstalled(ModuleName.SETM))
-            {
-                _tmrobot = new SchedulerSETMRobot(ModuleName.SETM);
-            }
-            if (ModuleHelper.IsInstalled(ModuleName.DETM))
-            {
-                _tmrobot = new SchedulerSETMRobot(ModuleName.DETM);
-            }
+            _tmrobot = Singleton<TransferModule>.Instance.GetScheduler(ModuleName.TMRobot) as SchedulerSETMRobot;
         }
 
         public RState Start(params object[] objs)

+ 1 - 1
Venus/Venus_RT/Modules/SETMCycle.cs

@@ -54,7 +54,7 @@ namespace Venus_RT.Modules
         private ModuleName _destinationModule = ModuleName.VCE1;
         private int _sourceSlotNumber = 25;
         //private int _destinationSlotNumber = 25;
-        private SchedulerSETMRobot _TMRobot = (SchedulerSETMRobot)Singleton<TransferModule>.Instance.GetScheduler(ModuleName.SETM);
+        private SchedulerSETMRobot _TMRobot = (SchedulerSETMRobot)Singleton<TransferModule>.Instance.GetScheduler(ModuleName.TMRobot);
         private SchedulerFACallback _faCallback;
         private SchedulerDBCallback _dbCallback;
         //private readonly int INVALID_SLOT = -1;

+ 77 - 2
Venus/Venus_RT/Modules/Schedulers/SchedulerSETMRobot.cs

@@ -58,10 +58,10 @@ namespace Venus_RT.Modules.Schedulers
         private SchedulerItem _currentScheduler = null;
         private int _singleArmOption = 0;
 
-        public SchedulerSETMRobot(ModuleName module) : base(module.ToString())
+        public SchedulerSETMRobot() : base(ModuleName.TMRobot.ToString())
         {
             _entity = Singleton<RouteManager>.Instance.seTM;
-            _singleArmOption = SC.GetValue<int>($"{module}.SingleArmOption");
+            _singleArmOption = SC.GetValue<int>($"SETM.SingleArmOption");
         }
 
         public bool PostMoveItems(MoveItem[] items)
@@ -330,6 +330,81 @@ namespace Venus_RT.Modules.Schedulers
             RunSchedulers();
             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(SETMEntity.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(items.Length == 1)
+                {
+                    PackMoveItems(ModuleHelper.IsPm(items[0].SourceModule) ? SETMEntity.MSG.PMPick : SETMEntity.MSG.Pick, items);
+                }
+                else
+                {
+                    if (ModuleHelper.IsPm(items[0].SourceModule))
+                    {
+                        if(items.Length == 2 && items[0].SourceModule == items[1].DestinationModule && ModuleHelper.IsTMRobot(items[1].SourceModule))
+                        {
+                            PackMoveItems(SETMEntity.MSG.PMSwap, items);    
+                        }
+                    }
+                    else if (ModuleHelper.IsLoadPort(items[0].SourceModule) && !items.ToList().Exists(mv => mv.SourceModule != items[0].SourceModule && mv.DestinationModule != items[0].SourceModule))
+                    {
+                        PackMoveItems(SETMEntity.MSG.Swap, items);  
+                    }
+                }
+            }
+            else if (ModuleHelper.IsTMRobot(items[0].SourceModule)) // place
+            {
+                if(items.Length == 1)
+                {
+                    PackMoveItems(ModuleHelper.IsPm(items[0].DestinationModule) ? SETMEntity.MSG.PMPlace : SETMEntity.MSG.Place, items);
+                }
+                else if (ModuleHelper.IsLoadPort(items[0].DestinationModule) && !items.ToList().Exists(mv => mv.SourceModule != items[0].DestinationModule && mv.DestinationModule != items[0].DestinationModule))
+                {
+                    PackMoveItems(SETMEntity.MSG.Swap, items);
+                }
+            }
+
+            if(_schedulerList.Count == 0)
+            {
+                foreach (var item in items)
+                {
+                    LOG.Write(eEvent.WARN_ROUTER, ModuleName.TMRobot, $"Wrong move action package: {item.SourceModule} Slot {item.SourceSlot + 1} => {item.DestinationModule} Slot {item.DestinationSlot + 1}");
+                    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;
+        }
         bool RunSchedulers()
         {
             //非运行状态

+ 9 - 9
Venus/Venus_RT/Modules/Schedulers/TransferModule.cs

@@ -11,7 +11,7 @@ namespace Venus_RT.Modules
     {
         protected SchedulerEfemRobot _efemRobot = new SchedulerEfemRobot();
         protected SchedulerTMRobot _tmRobot = new SchedulerTMRobot();
-        protected SchedulerSETMRobot _setm ;
+        protected SchedulerSETMRobot _setm = new SchedulerSETMRobot() ;
 
         protected SchedulerLoadPort _lp1 = new SchedulerLoadPort(ModuleName.LP1);
         protected SchedulerLoadPort _lp2 = new SchedulerLoadPort(ModuleName.LP2);
@@ -33,10 +33,6 @@ namespace Venus_RT.Modules
 
         public TransferModule()
         {
-            if(ModuleHelper.IsInstalled(ModuleName.SETM))
-                _setm = new SchedulerSETMRobot(ModuleName.SETM);
-            if (ModuleHelper.IsInstalled(ModuleName.DETM))
-                _setm = new SchedulerSETMRobot(ModuleName.DETM);
         }
 
 
@@ -74,7 +70,14 @@ namespace Venus_RT.Modules
                     return _llb;
 
                 case ModuleName.TMRobot:
-                    return _tmRobot;
+                    switch(RtInstance.ConfigType)
+                    {
+                        case ConfigType.VenusSE:
+                        case ConfigType.VenusDE:
+                            return _setm;
+                        default:
+                            return _tmRobot;
+                    }
 
                 case ModuleName.PMA:
                     return _pma;
@@ -84,9 +87,6 @@ namespace Venus_RT.Modules
                     return _pmc;
                 case ModuleName.PMD:
                     return _pmd;
-                case ModuleName.SETM:
-                case ModuleName.DETM:
-                    return _setm;
 
             }
 

+ 23 - 17
Venus/Venus_RT/Modules/TM/VenusEntity/SETMEntity.cs

@@ -109,6 +109,21 @@ namespace Venus_RT.Modules.TM.VenusEntity
         {
             get { return !IsInit && !IsError && !IsIdle; }
         }
+        public RState RobotStatus
+        {
+            get
+            {
+                if (_robot.Status != RState.Running)
+                {
+                    if (_robotWatch.ElapsedMilliseconds < 100)
+                        return RState.Running;
+                    else
+                        return _robot.Status;
+                }
+                else
+                    return RState.Running;
+            }
+        }
 
         /// <summary>
         /// VCE部分的内容从变量转化为查询方法
@@ -171,22 +186,6 @@ namespace Venus_RT.Modules.TM.VenusEntity
             }
         }
 
-        public RState RobotStatus
-        {
-            get
-            {
-                if (_robot.Status != RState.Running)
-                {
-                    if (_robotWatch.ElapsedMilliseconds < 100)
-                        return RState.Running;
-                    else
-                        return _robot.Status;
-                }
-                else
-                    return RState.Running;
-            }
-        }
-
         private bool _IsOnline;
         public bool IsOnline => _IsOnline;
 
@@ -219,7 +218,7 @@ namespace Venus_RT.Modules.TM.VenusEntity
         //private bool stopControlPressureFlag = false;
 
         private Stopwatch _robotWatch = new Stopwatch();
-        //private R_TRIG _robotIdleTrigger = new R_TRIG();
+        private R_TRIG _robotIdleTrigger = new R_TRIG();
 
         //private int _controlPressureCheckPoint = 100;
         //private int _controlPressureSetPoint = 90;
@@ -712,6 +711,13 @@ namespace Venus_RT.Modules.TM.VenusEntity
         /// <returns></returns>
         private bool ControlPressureTimer_Elapsed(object[] param)
         {
+            // robot idle check
+            _robotIdleTrigger.CLK = _robot.Status != RState.Running;
+            if (_robotIdleTrigger.Q)
+            {
+                _robotWatch.Restart();
+            }
+
             if (RouteManager.IsATMMode)
                 return true;
 

File diff suppressed because it is too large
+ 1849 - 0
Venus/Venus_RT/Modules/VenusDispatcher.cs


+ 1 - 0
Venus/Venus_RT/Venus_RT.csproj

@@ -358,6 +358,7 @@
     <Compile Include="Modules\VCE\UnloadRoutine.cs" />
     <Compile Include="Modules\VCE\UnloadWithSMIFRoutine.cs" />
     <Compile Include="Modules\VCE\VceEntity.cs" />
+    <Compile Include="Modules\VenusDispatcher.cs" />
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>