TransporterHomeRoutine.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.Util;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Routine;
  7. using MECF.Framework.Common.Utilities;
  8. using CyberX8_Core;
  9. using CyberX8_RT.Devices.AXIS;
  10. using CyberX8_RT.Devices.Facilities;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using CyberX8_RT.Devices.Safety;
  17. namespace CyberX8_RT.Modules.Transporter
  18. {
  19. public class TransporterHomeRoutine : RoutineBase, IRoutine
  20. {
  21. private enum HomeAllStep
  22. {
  23. //CheckCDAWithN2,
  24. VerticalHome,
  25. VerticalHomeWait,
  26. VerticalLow,
  27. VerticalLowWait,
  28. GantryHome,
  29. GantryHomeWait,
  30. GantryPark,
  31. GantryParkWait,
  32. End
  33. }
  34. #region 内部变量
  35. private JetAxisBase _gantryAxis;
  36. private JetAxisBase _elevatorAxis;
  37. private SystemFacilities _facilities;
  38. private TransporterEntity _transporterEntity;
  39. #endregion
  40. public TransporterHomeRoutine(string module) : base(module)
  41. {
  42. }
  43. public void Abort()
  44. {
  45. Runner.Stop("Manual Abort");
  46. }
  47. public RState Monitor()
  48. {
  49. Runner
  50. //.Run(HomeAllStep.CheckCDAWithN2, StartEnaleCDAndN2, CheckCDAWithN2, _delay_1s)
  51. .Run(HomeAllStep.VerticalHome, VerticalAxisHome, _delay_1ms)
  52. .WaitWithStopCondition(HomeAllStep.VerticalHomeWait, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  53. .Run(HomeAllStep.VerticalLow, () => { return _elevatorAxis.PositionStation("UP", true); },NullFun,100)
  54. .WaitWithStopCondition(HomeAllStep.VerticalLowWait,CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  55. .Run(HomeAllStep.GantryHome, GantryAxisHome, _delay_1ms)
  56. .WaitWithStopCondition(HomeAllStep.GantryHomeWait,CheckGantryPositionStatus,CheckGantryPositionRunStop)
  57. .Run(HomeAllStep.GantryPark, () => { return _gantryAxis.PositionStation("Park", true); }, NullFun, 100)
  58. .WaitWithStopCondition(HomeAllStep.GantryParkWait, CheckGantryPositionStatus, CheckGantryPositionRunStop)
  59. .End(HomeAllStep.End,NullFun);
  60. return Runner.Status;
  61. }
  62. /// <summary>
  63. /// 检验前置条件
  64. /// </summary>
  65. /// <returns></returns>
  66. private bool CheckPreCondition()
  67. {
  68. //所有运动模块均已Initialized
  69. if(! _gantryAxis.IsSwitchOn)
  70. {
  71. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Gantry is switchoff");
  72. return false;
  73. }
  74. if(!_elevatorAxis.IsSwitchOn)
  75. {
  76. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Elevator is switchoff");
  77. return false;
  78. }
  79. if(_transporterEntity.WaferHolderInfo!=null)
  80. {
  81. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "transporter exsit wafer Shuttle,can not home");
  82. return false;
  83. }
  84. if (Module == ModuleName.Transporter1.ToString())
  85. {
  86. TransporterEntity transporterEntity1 = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(ModuleName.Transporter2.ToString());
  87. if (!transporterEntity1.IsHomed)
  88. {
  89. LOG.WriteLog(eEvent.ERR_TRANSPORTER, Module.ToString(), "Loader Transporter is not homed");
  90. return false;
  91. }
  92. }
  93. return true;
  94. }
  95. /// <summary>
  96. /// 启动CDA和N2
  97. /// </summary>
  98. /// <returns></returns>
  99. private bool StartEnaleCDAndN2()
  100. {
  101. if(!_facilities.CDAEnable)
  102. {
  103. bool result= _facilities.N2EnableOperation("", true);
  104. if(!result)
  105. {
  106. return false;
  107. }
  108. }
  109. if(!_facilities.N2Enable)
  110. {
  111. bool result = _facilities.CDAEnableOperation("", true);
  112. if(!result)
  113. {
  114. return false;
  115. }
  116. }
  117. return true;
  118. }
  119. /// <summary>
  120. /// 检验CDA和N2 Enable
  121. /// </summary>
  122. /// <returns></returns>
  123. private bool CheckCDAWithN2()
  124. {
  125. return _facilities.CDAEnable && _facilities.N2Enable;
  126. }
  127. /// <summary>
  128. /// Vertical Home
  129. /// </summary>
  130. /// <returns></returns>
  131. private bool VerticalAxisHome()
  132. {
  133. return _elevatorAxis.Home();
  134. }
  135. /// <summary>
  136. /// 检验Vertical Home状态
  137. /// </summary>
  138. /// <returns></returns>
  139. private bool CheckVerticalHome()
  140. {
  141. return _elevatorAxis.IsHomed&&_elevatorAxis.Status==RState.End;
  142. }
  143. /// <summary>
  144. /// 检验Vertical移动状态
  145. /// </summary>
  146. /// <returns></returns>
  147. private bool CheckVerticalPositionStatus()
  148. {
  149. return _elevatorAxis.Status == RState.End;
  150. }
  151. /// <summary>
  152. /// 检验Vertical是否还在运动
  153. /// </summary>
  154. /// <returns></returns>
  155. private bool CheckVerticalPositionRunStop()
  156. {
  157. return _elevatorAxis.Status==RState.Failed;
  158. }
  159. /// <summary>
  160. /// Gantry Home
  161. /// </summary>
  162. /// <returns></returns>
  163. private bool GantryAxisHome()
  164. {
  165. return _gantryAxis.Home();
  166. }
  167. /// <summary>
  168. /// 检验Gantry Home状态
  169. /// </summary>
  170. /// <returns></returns>
  171. private bool CheckGantryHome()
  172. {
  173. return _gantryAxis.IsHomed && _gantryAxis.Status == RState.End;
  174. }
  175. /// <summary>
  176. /// 检验Gantry移动状态
  177. /// </summary>
  178. /// <returns></returns>
  179. private bool CheckGantryPositionStatus()
  180. {
  181. return _gantryAxis.Status == RState.End;
  182. }
  183. /// <summary>
  184. /// 检验Gantry是否还在运动
  185. /// </summary>
  186. /// <returns></returns>
  187. private bool CheckGantryPositionRunStop()
  188. {
  189. return _gantryAxis.Status == RState.Failed;
  190. }
  191. /// <summary>
  192. /// 启动
  193. /// </summary>
  194. /// <param name="objs"></param>
  195. /// <returns></returns>
  196. public RState Start(params object[] objs)
  197. {
  198. _transporterEntity = Singleton<RouteManager>.Instance.GetModule<TransporterEntity>(Module);
  199. _gantryAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Gantry");
  200. _elevatorAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Elevator");
  201. _facilities = DEVICE.GetDevice<SystemFacilities>("System.Facilities");
  202. if (!CheckPreCondition())
  203. {
  204. return RState.Failed;
  205. }
  206. return Runner.Start(Module, "Home");
  207. }
  208. }
  209. }