PlatingCellVerticalPositionRoutine.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. using Aitex.Core.Common;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Log;
  4. using Aitex.Core.RT.Routine;
  5. using Aitex.Core.RT.SCCore;
  6. using Aitex.Core.Util;
  7. using MECF.Framework.Common.Equipment;
  8. using MECF.Framework.Common.Routine;
  9. using MECF.Framework.Common.SubstrateTrackings;
  10. using PunkHPX8_Core;
  11. using PunkHPX8_RT.Devices.AXIS;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.Diagnostics.Eventing.Reader;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows.Media.Imaging;
  19. namespace PunkHPX8_RT.Modules.PlatingCell
  20. {
  21. public class PlatingCellVerticalPositionRoutine : RoutineBase, IRoutine
  22. {
  23. private enum PositionStep
  24. {
  25. WaitMatcher,
  26. GotoPosition,
  27. GoToPositionCheck,
  28. End
  29. }
  30. #region 内部变量
  31. /// <summary>
  32. /// vertical axis
  33. /// </summary>
  34. private JetAxisBase _verticalAxis;
  35. /// <summary>
  36. /// matcher集合
  37. /// </summary>
  38. private List<string> _matcher = new List<string>();
  39. /// <summary>
  40. /// cell集合
  41. /// </summary>
  42. private List<PlatingCellEntity> _cellEntities=new List<PlatingCellEntity>();
  43. /// <summary>
  44. /// 位置
  45. /// </summary>
  46. private string _station;
  47. /// <summary>
  48. /// 偏移量
  49. /// </summary>
  50. private double _offset;
  51. /// <summary>
  52. /// 移动速度
  53. /// </summary>
  54. private int _speed;
  55. /// <summary>
  56. /// 加速度
  57. /// </summary>
  58. private int _accelerate;
  59. #endregion
  60. /// <summary>
  61. /// 构造函数
  62. /// </summary>
  63. /// <param name="module"></param>
  64. public PlatingCellVerticalPositionRoutine(string module) : base(module)
  65. {
  66. }
  67. /// <summary>
  68. /// 中止
  69. /// </summary>
  70. public void Abort()
  71. {
  72. Runner.Stop("Manual Abort");
  73. }
  74. /// <summary>
  75. /// 监控
  76. /// </summary>
  77. /// <returns></returns>
  78. public RState Monitor()
  79. {
  80. Runner.Wait(PositionStep.WaitMatcher,CheckMatcher,_delay_2s)
  81. .Run(PositionStep.GotoPosition, VerticalGotoPosition, 100)
  82. .WaitWithStopCondition(PositionStep.GoToPositionCheck, CheckVerticalPositionStatus, CheckVerticalPositionRunStop)
  83. .End(PositionStep.End, NullFun, _delay_1ms);
  84. return Runner.Status;
  85. }
  86. /// <summary>
  87. /// 检验匹配
  88. /// </summary>
  89. /// <returns></returns>
  90. private bool CheckMatcher()
  91. {
  92. if (_cellEntities.Count<=1)
  93. {
  94. return true;
  95. }
  96. foreach (PlatingCellEntity item in _cellEntities)
  97. {
  98. if (!WaferManager.Instance.CheckHasWafer(item.Module, 0))
  99. {
  100. return false;
  101. }
  102. }
  103. WaferInfo firstWafer = WaferManager.Instance.GetWafer(_cellEntities[0].Module, 0);
  104. WaferInfo secondWafer = WaferManager.Instance.GetWafer(_cellEntities[1].Module, 0);
  105. if (firstWafer == null || secondWafer == null || firstWafer.IsEmpty || secondWafer.IsEmpty)
  106. {
  107. return false;
  108. }
  109. string firstCurrentStep = _cellEntities[0].CurrentStepState;
  110. string secondCurrentStep = _cellEntities[1].CurrentStepState;
  111. bool hasDoubleProductionWafer = firstWafer.WaferType == secondWafer.WaferType;
  112. if (hasDoubleProductionWafer)
  113. {
  114. return firstCurrentStep == secondCurrentStep;
  115. }
  116. else
  117. {
  118. //dummy reclaim/rinse/dry与生产片一致
  119. if (secondCurrentStep.StartsWith("Reclaim") || secondCurrentStep.StartsWith("Rinse") || secondCurrentStep.StartsWith("Dry"))
  120. {
  121. return firstCurrentStep==secondCurrentStep;
  122. }
  123. else
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. /// <summary>
  130. /// vertical 运动到位置
  131. /// </summary>
  132. /// <returns></returns>
  133. private bool VerticalGotoPosition()
  134. {
  135. if(_verticalAxis != null )
  136. {
  137. if (!_verticalAxis.IsSwitchOn)
  138. {
  139. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Power On");
  140. return false;
  141. }
  142. else if (!_verticalAxis.IsHomed)
  143. {
  144. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Home,Home vertical first");
  145. return false;
  146. }
  147. return _verticalAxis.PositionStation(_station,_offset,false,_speed,_accelerate);
  148. }
  149. else
  150. {
  151. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "vertical axis is null");
  152. return false;
  153. }
  154. }
  155. /// <summary>
  156. /// 检验Vertical移动状态
  157. /// </summary>
  158. /// <returns></returns>
  159. private bool CheckVerticalPositionStatus()
  160. {
  161. return _verticalAxis.Status == RState.End;
  162. }
  163. /// <summary>
  164. /// 检验Vertical是否还在运动
  165. /// </summary>
  166. /// <returns></returns>
  167. private bool CheckVerticalPositionRunStop()
  168. {
  169. return _verticalAxis.Status == RState.Failed;
  170. }
  171. /// <summary>
  172. /// 启动
  173. /// </summary>
  174. /// <param name="objs"></param>
  175. /// <returns></returns>
  176. public RState Start(params object[] objs)
  177. {
  178. _station=objs[0].ToString();
  179. _offset = (double)objs[1];
  180. if(objs.Length > 2)
  181. {
  182. _speed = (int)objs[2];
  183. }
  184. if (objs.Length > 3)
  185. {
  186. _accelerate = (int)objs[3];
  187. }
  188. _matcher = ModuleMatcherManager.Instance.GetMatcherListByVertical(Module); //获取电机所在的platingcell 列表
  189. _cellEntities.Clear();
  190. foreach (string str in _matcher)
  191. {
  192. if(!Enum.TryParse(str, out ModuleName moduleName))
  193. {
  194. continue;
  195. }
  196. if (!ModuleHelper.IsInstalled(moduleName))
  197. {
  198. continue;
  199. }
  200. PlatingCellEntity cellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(str);
  201. if (cellEntity.IsDisable)
  202. {
  203. continue;
  204. }
  205. if (cellEntity.IsError)
  206. {
  207. continue;
  208. }
  209. if (cellEntity.IsAuto)
  210. {
  211. _cellEntities.Add(cellEntity);
  212. }
  213. }
  214. _verticalAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Vertical");
  215. return Runner.Start(Module, "Start PlatingCell Vertical Initialize");
  216. }
  217. }
  218. }