| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 | 
							- 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 Venus_RT.Modules.PMs;
 
- namespace Venus_RT.Modules.TM
 
- {
 
-     class MFPMExtendRoutine : ModuleRoutineBase, IRoutine
 
-     {
 
-         private enum ExtendStep
 
-         {
 
-             ArmExtend,
 
-             End,
 
-         }
 
-         private readonly JetTM _JetTM;
 
-         private readonly ITransferRobot _robot;
 
-         private int _extendingTimeout = 120 * 1000;
 
-         private ModuleName _targetModule;
 
-         private PMEntity _pmModule;
 
-         int _targetSlot;
 
-         Hand _hand;
 
-         public MFPMExtendRoutine(JetTM tm, ITransferRobot robot) : base(ModuleName.TMRobot)
 
-         {
 
-             _JetTM = tm;
 
-             _robot = robot;
 
-             Name = "Extend to PM";
 
-         }
 
-         public RState Start(params object[] objs)
 
-         {
 
-             if (!_robot.IsHomed)
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"TM Robot is not homed, please home it first");
 
-                 return RState.Failed;
 
-             }
 
-             _targetModule = (ModuleName)objs[0];
 
-             _targetSlot = (int)objs[1];
 
-             _hand = (Hand)objs[2];
 
-             if (ModuleHelper.IsPm(_targetModule) && ModuleHelper.IsInstalled(_targetModule))
 
-             {
 
-                 _pmModule = Singleton<RouteManager>.Instance.GetPM(_targetModule);
 
-             }
 
-             else
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for extending action");
 
-                 return RState.Failed;
 
-             }
 
-             if(_pmModule.IsSlitDoorClose)
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"{_targetModule} slit door closed, can not extend robot arm");
 
-                 return RState.Failed;
 
-             }
 
-             if (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, (int)_hand))
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"Cannot pick as TM Robot Arm: {_hand} already has a wafer");
 
-                 return RState.Failed;
 
-             }
 
-             if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot))
 
-             {
 
-                 if(WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, (int)_hand))
 
-                 {
 
-                     LOG.Write(eEvent.ERR_TM, Module, $"Both {_targetModule} and robot arm {_hand} have wafers");
 
-                     return RState.Failed;
 
-                 }
 
-                 if(_pmModule.LiftPinIsDown)
 
-                 {
 
-                     LOG.Write(eEvent.ERR_TM, Module, $"{_targetModule} has a wafer and Lift Pin is down, can not extend robot arm");
 
-                     return RState.Failed;
 
-                 }
 
-             }
 
-             Reset();
 
-             _extendingTimeout = SC.GetValue<int>("TM.ExtendTimeout") * 1000;
 
-             return Runner.Start(Module, $"Extend to {_targetModule}");
 
-         }
 
-         public RState Monitor()
 
-         {
 
-             Runner.Run((int)ExtendStep.ArmExtend, ArmExtend, WaitRobotExtendDone)
 
-                 .End((int)ExtendStep.End, NullFun, _delay_50ms);
 
-             return Runner.Status;
 
-         }
 
-         private bool ArmExtend()
 
-         {
 
-             if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot))
 
-             {
 
-                 return _robot.PickExtend(_targetModule, _targetSlot, _hand);
 
-             }
 
-             else
 
-             {
 
-                 return _robot.PickExtend(_targetModule, _targetSlot, _hand);
 
-             } 
 
-         }
 
-         private bool WaitRobotExtendDone()
 
-         {
 
-             if (_robot.Status == RState.Running)
 
-             {
 
-                 return false;
 
-             }
 
-             else if (_robot.Status == RState.End)
 
-             {
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 Runner.Stop($"TM Robot Arm Extend failed, {_robot.Status}");
 
-                 return true;
 
-             }
 
-         }
 
-         public void Abort()
 
-         {
 
-             _robot.Halt();
 
-         }
 
-     }
 
- }
 
 
  |