| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 | 
							- using Aitex.Core.RT.Routine;
 
- using Aitex.Core.RT.SCCore;
 
- using Aitex.Sorter.Common;
 
- using Venus_RT.Devices;
 
- using MECF.Framework.Common.Routine;
 
- using MECF.Framework.Common.Equipment;
 
- using MECF.Framework.Common.SubstrateTrackings;
 
- using Venus_Core;
 
- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using MECF.Framework.Common.Schedulers;
 
- using System.Collections.Generic;
 
- using Venus_RT.Devices.EFEM;
 
- namespace Venus_RT.Modules.EFEM
 
- {
 
-     class EfemPlaceRoutine : ModuleRoutineBase, IRoutine
 
-     {
 
-         private enum PlaceStep
 
-         {
 
-             WaitModuleReady,
 
-             Placing1,
 
-             Placing2,
 
-             End,
 
-         }
 
-         private int _moveTimeout = 20 * 1000;
 
-         private ModuleName _targetModule = ModuleName.System;
 
-         int _targetSlot;
 
-         int _targetSlot2;
 
-         Hand _hand;
 
-         Hand _hand2;
 
-         EfemBase _efem;
 
-         bool _bDoublePlace = false;
 
-         public EfemPlaceRoutine(EfemBase efem) : base(ModuleName.EfemRobot)
 
-         {
 
-             _efem = efem;
 
-         }
 
-         public RState Start(params object[] objs)
 
-         {
 
-             if (!_efem.IsHomed)
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"EFEM is not homed, please home it first");
 
-                 return RState.Failed;
 
-             }
 
-             _bDoublePlace = false;
 
-             var placeItem = (Queue<MoveItem>)objs[0];
 
-             _targetModule = placeItem.Peek().DestinationModule;
 
-             _targetSlot = placeItem.Peek().DestinationSlot;
 
-             _hand = placeItem.Peek().RobotHand;
 
-             if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_hand))
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"Efem robot arm{_hand} already has no wafer, cannot do the place action");
 
-                 return RState.Failed;
 
-             }
 
-             if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot))
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"The target: {_targetModule}{_targetSlot} has a wafer, cannot do the place action");
 
-                 return RState.Failed;
 
-             }
 
-             if (placeItem.Count >= 2)
 
-             {
 
-                 if (!ModuleHelper.IsLoadPort(_targetModule))
 
-                 {
 
-                     LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"Wrong double place command, target is not loadport");
 
-                     return RState.Failed;
 
-                 }
 
-                 _hand2 = _hand != Hand.Blade1 ? Hand.Blade1 : Hand.Blade2;
 
-                 if (WaferManager.Instance.CheckNoWafer(ModuleName.EfemRobot, (int)_hand2))
 
-                 {
 
-                     LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"Efem robot arm{_hand2} has no wafer, cannot do the double place action");
 
-                     return RState.Failed;
 
-                 }
 
-                 _targetSlot2 = placeItem.ToArray()[1].DestinationSlot;
 
-                 if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot2))
 
-                 {
 
-                     LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"The target: {_targetModule}{_targetSlot2} has a wafer, cannot do the double pick action");
 
-                     return RState.Failed;
 
-                 }
 
-                 _bDoublePlace = true;
 
-             }
 
-             _moveTimeout = SC.GetValue<int>($"EFEM.MotionTimeout") * 1000;
 
-             return Runner.Start(Module, $"Place to {_targetModule}");
 
-         }
 
-         public RState Monitor()
 
-         {
 
-             if (_bDoublePlace)
 
-             {
 
-                 Runner.Wait(PlaceStep.WaitModuleReady,     WaitModuleReady)
 
-                         .Run(PlaceStep.Placing1,           Place1,         Place1Done,     _moveTimeout)
 
-                         .Run(PlaceStep.Placing2,           Place2,         Place2Done,     _moveTimeout)
 
-                         .End(PlaceStep.End,                ActionDone);
 
-             }
 
-             else
 
-             {
 
-                 Runner.Wait(PlaceStep.WaitModuleReady, WaitModuleReady)
 
-                         .Run(PlaceStep.Placing1,           Place1,         Place1Done,     _moveTimeout)
 
-                         .End(PlaceStep.End,                ActionDone);
 
-             }
 
-             return Runner.Status;
 
-         }
 
-         public void Abort()
 
-         {
 
-             _efem.Halt();
 
-         }
 
-         private bool WaitModuleReady()
 
-         {
 
-             return true;
 
-         }
 
-         private bool Place1()
 
-         {
 
-             return _efem.Place(_targetModule, _targetSlot, _hand);
 
-         }
 
-         private bool Place1Done()
 
-         {
 
-             if (_efem.Status == RState.End)
 
-             {
 
-                 WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)_hand, _targetModule, _targetSlot);
 
-                 return true;
 
-             }
 
-             else if (_efem.Status != RState.Running)
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"Efem robot place failed: {_efem.Status}");
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         private bool Place2()
 
-         {
 
-             return _efem.Place(_targetModule, _targetSlot2, _hand2);
 
-         }
 
-         private bool Place2Done()
 
-         {
 
-             if (_efem.Status == RState.End)
 
-             {
 
-                 WaferManager.Instance.WaferMoved(ModuleName.EfemRobot, (int)_hand2, _targetModule, _targetSlot2);
 
-                 return true;
 
-             }
 
-             else if (_efem.Status != RState.Running)
 
-             {
 
-                 LOG.Write(eEvent.ERR_EFEM_ROBOT, Module, $"Efem robot place failed: {_efem.Status}");
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         private bool ActionDone()
 
-         {
 
-             return true;
 
-         }
 
-     }
 
- }
 
 
  |