EfemRetractRoutine.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System;
  2. using Aitex.Core.RT.Routine;
  3. using Aitex.Core.RT.SCCore;
  4. using Aitex.Core.Util;
  5. using Aitex.Sorter.Common;
  6. using MECF.Framework.Common.Equipment;
  7. using MECF.Framework.Common.Schedulers;
  8. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Robots;
  9. using MECF.Framework.RT.EquipmentLibrary.LogicUnits;
  10. using MECF.Framework.RT.ModuleLibrary.PMModules;
  11. using MECF.Framework.RT.ModuleLibrary.SystemModules;
  12. namespace JetEfemLib.Efems
  13. {
  14. class EfemRetractRoutine : ModuleRoutineBase, IStepRoutine
  15. {
  16. enum RoutineStep
  17. {
  18. CheckBeforeRetract,
  19. Retract,
  20. WaitCloseSlitValveInterlock,
  21. CloseSlitValve,
  22. PostTransfer,
  23. End,
  24. }
  25. private ModuleName _source;
  26. private int _sourceSlot;
  27. private Hand _blade;
  28. private int _timeout;
  29. // private TMSlitValveRoutine _closeSlitValveRoutine = new TMSlitValveRoutine();
  30. private EfemModule _robotModule;
  31. //private RobotPostionEnum postiontype;
  32. private ITransferTarget _target;
  33. public EfemRetractRoutine(EfemModule robotModule) : base(ModuleName.EfemRobot.ToString())
  34. {
  35. Name = "Retract";
  36. _robotModule = robotModule;
  37. }
  38. private string _type;
  39. public void Init(ModuleName source, int sourceSlot, string blade,string type)
  40. {
  41. _source = source;
  42. _sourceSlot = sourceSlot;
  43. _blade = (Hand)Enum.Parse(typeof(Hand), blade);
  44. _type = type;
  45. //_closeSlitValveRoutine.Init(source.ToString(), false);
  46. }
  47. public void Init(ModuleName source, int sourceSlot, int blade)
  48. {
  49. Init(source, sourceSlot, blade);
  50. }
  51. public RState Start(params object[] objs)
  52. {
  53. Reset();
  54. _timeout = SC.GetValue<int>("EFEM.EfemRobot.PickTimeout");
  55. //if (ModuleHelper.IsLoadLock(_source))
  56. //{
  57. // LoadLock ll = DEVICE.GetDevice<LoadLock>(_source.ToString());
  58. // if (!ll.CheckEnableTransfer(EnumTransferType.Extend))
  59. // {
  60. // EV.PostWarningLog(Module, $"can not retract, {_source} not ready for transfer");
  61. // return Result.FAIL;
  62. // }
  63. //}
  64. if (ModuleHelper.IsPm(_source))
  65. {
  66. if (_type=="Pick")
  67. {
  68. //postiontype = RobotPostionEnum.PickRetracted;// _blade == Hand.Blade1 ?RobotPostionEnum.PickRetractLow: RobotPostionEnum.PickRetractUp;
  69. }
  70. else
  71. {
  72. //postiontype = RobotPostionEnum.PlaceRetract;//_blade == Hand.Blade1 ? RobotPostionEnum.PlaceRetractLow : RobotPostionEnum.PlaceRetractUp;
  73. }
  74. // PMModuleBase pm = DEVICE.GetDevice<PMModule>(_source.ToString()+"."+ _source.ToString());
  75. _target = EquipmentManager.Modules[_source] as ITransferTarget;
  76. //if (!pm.CheckReadyForTransfer(ModuleName.EfemRobot, _blade, _sourceSlot, EnumTransferType.Retract, out _))
  77. //{
  78. // EV.PostWarningLog(Module, $"can not retract, {_source} not ready for transfer");
  79. // return Result.FAIL;
  80. //}
  81. }
  82. Notify($"Start, retract from {_source} slot {_sourceSlot + 1} with {_blade}");
  83. return Runner.Start(ModuleName.EfemRobot.ToString(), Name);
  84. }
  85. public void Abort()
  86. {
  87. Notify("Abort");
  88. }
  89. public RState Monitor()
  90. {
  91. Runner.Run(RoutineStep.Retract, RobotRetract, CheckRobotRetract, _timeout * 1000)
  92. .Run(RoutineStep.PostTransfer, PostTransfer, CheckPostTransfer, _timeout * 1000)
  93. .End(RoutineStep.End, NullFun, _delay_50ms);
  94. if (Runner.Status == RState.End)
  95. Notify($"Finish, retract from {_source} slot {_sourceSlot + 1} with {_blade}");
  96. return Runner.Status;
  97. }
  98. bool RobotRetract()
  99. {
  100. Notify("robot execute goto command");
  101. //string reason;
  102. //if (!_robotModule.RobotDevice.GotoRE(chamber, hand, slot, postiontype, out reason))
  103. //{
  104. // Stop(reason);
  105. // return false;
  106. //}
  107. return true;
  108. }
  109. bool CheckRobotRetract()
  110. {
  111. return !_robotModule.RobotDevice.IsError && _robotModule.RobotDevice.IsIdle;
  112. }
  113. bool PostTransfer()
  114. {
  115. if (ModuleHelper.IsPm(_source))
  116. {
  117. var pm = _target as PMModuleBase;
  118. var type = EnumTransferType.Retract;
  119. Notify($"{pm.Name} post transfer ");
  120. if (!pm.PostTransfer(ModuleName.EfemRobot, _blade, new int[] { _sourceSlot }, type, out string reason))
  121. {
  122. Stop(reason);
  123. return false;
  124. }
  125. return true;
  126. }
  127. return true;
  128. }
  129. bool CheckPostTransfer()
  130. {
  131. if (ModuleHelper.IsPm(_source))
  132. {
  133. var pm = _target as PMModuleBase;
  134. return !pm.IsError && pm.IsReady;
  135. }
  136. return true;
  137. }
  138. }
  139. }