| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 | 
							- 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;
 
- namespace Venus_RT.Modules.TM
 
- {
 
-     class MFPlaceRoutine : ModuleRoutineBase, IRoutine
 
-     {
 
-         private enum PlaceStep
 
-         {
 
-             WaitModuleReady,
 
-             ModulePrepare,
 
-             OpenSlitDoor,
 
-             Placing,
 
-             CloseSlitDoor,
 
-             NotifyDone,
 
-         }
 
-         private readonly JetTM _JetTM;
 
-         private readonly ITransferRobot _robot;
 
-         private int _placingTimeout = 120 * 1000;
 
-         private ModuleName _targetModule;
 
-         private LLEntity _llModule;
 
-         int _targetSlot;
 
-         Hand _hand;
 
-         public MFPlaceRoutine(JetTM tm, ITransferRobot robot) : base(ModuleName.TMRobot)
 
-         {
 
-             _JetTM = tm;
 
-             _robot = robot;
 
-             Name = "Place";
 
-         }
 
-         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;
 
-             }
 
-             var placeItem = (Queue<MoveItem>)objs[0];
 
-             _targetModule = placeItem.Peek().DestinationModule;
 
-             _targetSlot = placeItem.Peek().DestinationSlot;
 
-             _hand = placeItem.Peek().RobotHand;
 
-             if (ModuleHelper.IsLoadLock(_targetModule) && ModuleHelper.IsInstalled(_targetModule))
 
-             {
 
-                 _llModule = Singleton<RouteManager>.Instance.GetLL(_targetModule);
 
-             }
 
-             else
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for place action");
 
-                 return RState.Failed;
 
-             }
 
-             if (WaferManager.Instance.CheckNoWafer(ModuleName.TMRobot, (int)_hand))
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"Cannot place as TM Robot Arm: {_hand} has no wafer");
 
-                 return RState.Failed;
 
-             }
 
-             if (WaferManager.Instance.CheckHasWafer(_targetModule, _targetSlot))
 
-             {
 
-                 LOG.Write(eEvent.ERR_TM, Module, $"Cannot place as {_targetModule} Slot {_targetSlot} already has a wafer");
 
-                 return RState.Failed;
 
-             }
 
-             Reset();
 
-             _placingTimeout = SC.GetValue<int>($"TM.PlaceTimeout") * 1000;
 
-             return Runner.Start(Module, $"Place to {_targetModule}");
 
-         }
 
-         public RState Monitor()
 
-         {
 
-             Runner.Wait((int)PlaceStep.WaitModuleReady, () => _llModule.IsIdle, _delay_60s)
 
-                 .Run((int)PlaceStep.ModulePrepare,      ModulePrepare,          IsModulePrepareReady)
 
-                 .Run((int)PlaceStep.OpenSlitDoor,       OpenSlitDoor,           IsSlitDoorOpen)
 
-                 .Run((int)PlaceStep.Placing,            Placing,                WaitPlaceDone)
 
-                 .Run((int)PlaceStep.CloseSlitDoor,      CloseSlitDoor,          IsSlitDoorClosed)
 
-                 .End((int)PlaceStep.NotifyDone,         NotifyLLDone,           _delay_50ms);          
 
-             return Runner.Status;
 
-         }
 
-         private bool ModulePrepare()
 
-         {
 
-             _llModule.PostMsg(LLEntity.MSG.Prepare_TM);
 
-             return true;
 
-         }
 
-         private bool IsModulePrepareReady()
 
-         {
 
-             return _llModule.Status == LLEntity.LLStatus.Ready_For_TM;
 
-         }
 
-         private bool OpenSlitDoor()
 
-         {
 
-             return _JetTM.TurnMFSlitDoor(_targetModule, true, out _);
 
-         }
 
-         private bool CloseSlitDoor()
 
-         {
 
-             return _JetTM.TurnMFSlitDoor(_targetModule, false, out _);
 
-         }
 
-         private bool IsSlitDoorOpen()
 
-         {
 
-             if (_targetModule == ModuleName.LLA)
 
-                 return _JetTM.IsLLASlitDoorOpen;
 
-             else
 
-                 return _JetTM.IsLLBSlitDoorOpen;
 
-         }
 
-         private bool IsSlitDoorClosed()
 
-         {
 
-             if (_targetModule == ModuleName.LLA)
 
-                 return _JetTM.IsLLASlitDoorClosed;
 
-             else
 
-                 return _JetTM.IsLLBSlitDoorClosed;
 
-         }
 
-         private bool Placing()
 
-         {
 
-             return _robot.Place(_targetModule, _targetSlot, _hand);
 
-         }
 
-         private bool WaitPlaceDone()
 
-         {
 
-             if (_robot.Status == RState.Running)
 
-             {
 
-                 return false;
 
-             }
 
-             else if (_robot.Status == RState.End)
 
-             {
 
-                 WaferManager.Instance.WaferMoved(ModuleName.TMRobot, (int)_hand, _targetModule, _targetSlot);
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 Runner.Stop($"TM Robot Place failed, {_robot.Status}");
 
-                 return true;
 
-             }
 
-         }
 
-         private bool NotifyLLDone()
 
-         {
 
-             _llModule.PostMsg(LLEntity.MSG.TM_Exchange_Ready);
 
-             return true;
 
-         }
 
-         public void Abort()
 
-         {
 
-             _robot.Halt();
 
-         }
 
-     }
 
- }
 
 
  |