SEMFPickRoutine.cs 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using Aitex.Core.RT.Log;
  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.Common.SubstrateTrackings;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using Venus_Core;
  15. using Venus_RT.Devices;
  16. using Venus_RT.Devices.PreAligner;
  17. using Venus_RT.Modules.VCE;
  18. namespace Venus_RT.Modules.TM.VenusEntity
  19. {
  20. public class SEMFPickRoutine : ModuleRoutineBase, IRoutine
  21. {
  22. private enum PickStep
  23. {
  24. seWaitModuleReady,
  25. sePrepareModule,
  26. sePicking,
  27. seNotifyDone,
  28. }
  29. private HongHuTM _tm;
  30. private IPreAlign _vpa;
  31. private ITransferRobot _robot;
  32. private VceEntity _vceModule;
  33. private ModuleName _targetModule;
  34. private int _targetSlot;
  35. private int _pickingTimeout;
  36. public int currentStepNo;
  37. Hand _hand;
  38. /// <summary>
  39. /// 完整pick动作仅可vce vpa取片
  40. /// </summary>
  41. /// <param name="tm"></param>
  42. /// <param name="robot"></param>
  43. /// <param name="vpa"></param>
  44. public SEMFPickRoutine(HongHuTM tm, ITransferRobot robot, IPreAlign vpa) : base(ModuleName.TM)
  45. {
  46. _tm = tm;
  47. _robot = robot;
  48. _vpa = vpa;
  49. }
  50. public RState Start(params object[] objs)
  51. {
  52. if (!_robot.IsHomed)
  53. {
  54. LOG.Write(eEvent.ERR_TM, Module, $"TM Robot is not homed, please home it first");
  55. return RState.Failed;
  56. }
  57. //MoveItem pickItem = new MoveItem() { SourceModule = , };
  58. Enum.TryParse(objs[0].ToString(), out _targetModule);
  59. _targetSlot = Convert.ToInt32(objs[1]);
  60. Enum.TryParse(objs[2].ToString(), out _hand);
  61. //如果目标是Vce 否则是vpa
  62. if (ModuleHelper.IsVCE(_targetModule) && ModuleHelper.IsInstalled(_targetModule))
  63. {
  64. _vceModule = Singleton<RouteManager>.Instance.GetVCE(_targetModule);
  65. //如果vce有错误 报错
  66. if (_vceModule.IsError)
  67. {
  68. LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} is Error! Please solve Error first!");
  69. return RState.Failed;
  70. }
  71. //如果VCE门是关闭的 说明还未进行pump 无法取片等
  72. //if (_tm.VCESlitDoorClosed)
  73. //{
  74. // LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} slitdoor not open! Please pump down vce and open it first!");
  75. // return RState.Failed;
  76. //}
  77. }
  78. //如果目标又不是VPA 报错
  79. else if (!ModuleHelper.IsVPA(_targetModule))
  80. {
  81. LOG.Write(eEvent.ERR_TM, Module, $"Invalid target module : {_targetModule} for pick action");
  82. return RState.Failed;
  83. }
  84. //检查目标手臂上没有wafer
  85. if (WaferManager.Instance.CheckHasWafer(ModuleName.TMRobot, (int)_hand))
  86. {
  87. LOG.Write(eEvent.ERR_TM, Module, $"Cannot pick as TM Robot Arm: {_hand} already has a wafer");
  88. return RState.Failed;
  89. }
  90. //检查目标槽位上有wafer
  91. if (WaferManager.Instance.CheckNoWafer(_targetModule, _targetSlot))
  92. {
  93. LOG.Write(eEvent.ERR_TM, Module, $"Cannot pick as {_targetModule} Slot {_targetSlot + 1} has no wafer");
  94. return RState.Failed;
  95. }
  96. //2023/10/13 朱永吉 atm mode的判断不允许自动pump vent 信号不满足手动pump vent
  97. //if (RouteManager.IsATMMode && _targetModule == ModuleName.VCE1)
  98. //{
  99. // if (!_tm.IsVCEATM)
  100. // {
  101. // LOG.Write(eEvent.ERR_TM, Module, $"System in ATM Mode but VCE is not ATM!");
  102. // return RState.Failed;
  103. // }
  104. //
  105. // if (!_tm.IsTMATM)
  106. // {
  107. // LOG.Write(eEvent.ERR_TM, Module, $"System in ATM Mode but TM is not ATM!");
  108. // return RState.Failed;
  109. // }
  110. //}
  111. //else
  112. //{
  113. // if (_tm.IsVCEATM)
  114. // {
  115. // LOG.Write(eEvent.ERR_TM, Module, $"System not in ATM Mode but VCE is ATM!");
  116. // return RState.Failed;
  117. // }
  118. //
  119. // if (_tm.IsTMATM)
  120. // {
  121. // LOG.Write(eEvent.ERR_TM, Module, $"System not in ATM Mode but TM is ATM!");
  122. // return RState.Failed;
  123. // }
  124. //}
  125. Reset();
  126. _pickingTimeout = SC.GetValue<int>("TM.PickTimeout") * 1000;
  127. return Runner.Start(Module, $"Pick from {_targetModule}");
  128. }
  129. public RState Monitor()
  130. {
  131. Runner.Wait(PickStep.seWaitModuleReady, CheckModuleReady, _delay_60s)
  132. .Run(PickStep.sePrepareModule, PrepareModule, CheckModuleReady)
  133. .Run (PickStep.sePicking, Picking, WaitPickDone, _pickingTimeout)
  134. .End (PickStep.seNotifyDone, NullFun, 500);
  135. return Runner.Status;
  136. }
  137. private bool PrepareModule()
  138. {
  139. switch (_targetModule)
  140. {
  141. case ModuleName.VCE1:
  142. _vceModule.PostMsg(VceMSG.Goto, _targetSlot);
  143. return true;//移动到目标槽位
  144. case ModuleName.VPA:
  145. return true;//10/17暂时为true 后可能要求旋转到0
  146. default:
  147. return false;
  148. }
  149. }
  150. private bool WaitPickDone()
  151. {
  152. if (_robot.Status == RState.Running)
  153. {
  154. return false;
  155. }
  156. else if (_robot.Status == RState.End)
  157. {
  158. WaferManager.Instance.WaferMoved(_targetModule, _targetSlot, ModuleName.TMRobot, (int)_hand);
  159. return true;
  160. }
  161. else
  162. {
  163. Runner.Stop($"TM Robot Picking failed, {_robot.Status}");
  164. return true;
  165. }
  166. }
  167. private bool Picking()
  168. {
  169. //到达目标点位 pick固定槽位点的wafer
  170. return _robot.Pick(_targetModule, 0, _hand);
  171. }
  172. private bool CheckModuleReady()
  173. {
  174. switch (_targetModule)
  175. {
  176. case ModuleName.VCE1:
  177. return _vceModule.IsIdle;
  178. case ModuleName.VPA:
  179. return _vpa.Status == RState.End;
  180. default:
  181. return false;
  182. }
  183. }
  184. public void Abort() { }
  185. }
  186. }