PlatingCellVerticalPositionRoutine.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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_60s)
  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. int count = 0;
  97. foreach (PlatingCellEntity item in _cellEntities)
  98. {
  99. if (WaferManager.Instance.CheckHasWafer(item.Module, 0))
  100. {
  101. count++;
  102. }
  103. }
  104. if (count == 1)
  105. {
  106. return true;
  107. }
  108. WaferInfo firstWafer = WaferManager.Instance.GetWafer(_cellEntities[0].Module, 0);
  109. WaferInfo secondWafer = WaferManager.Instance.GetWafer(_cellEntities[1].Module, 0);
  110. if (firstWafer == null || secondWafer == null || firstWafer.IsEmpty || secondWafer.IsEmpty)
  111. {
  112. return false;
  113. }
  114. string firstCurrentStep = _cellEntities[0].CurrentStepState;
  115. string secondCurrentStep = _cellEntities[1].CurrentStepState;
  116. bool hasDoubleProductionWafer = firstWafer.WaferType == secondWafer.WaferType;
  117. if (hasDoubleProductionWafer)
  118. {
  119. return firstCurrentStep == secondCurrentStep;
  120. }
  121. else
  122. {
  123. //dummy reclaim/rinse/dry与生产片一致
  124. if (secondCurrentStep.StartsWith("Reclaim") || secondCurrentStep.StartsWith("Rinse") || secondCurrentStep.StartsWith("Dry"))
  125. {
  126. return firstCurrentStep==secondCurrentStep;
  127. }
  128. else
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. /// <summary>
  135. /// vertical 运动到位置
  136. /// </summary>
  137. /// <returns></returns>
  138. private bool VerticalGotoPosition()
  139. {
  140. if(_verticalAxis != null )
  141. {
  142. if (!_verticalAxis.IsSwitchOn)
  143. {
  144. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Power On");
  145. return false;
  146. }
  147. else if (!_verticalAxis.IsHomed)
  148. {
  149. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "Vertical is not Home,Home vertical first");
  150. return false;
  151. }
  152. return _verticalAxis.PositionStation(_station,_offset,false,_speed,_accelerate);
  153. }
  154. else
  155. {
  156. LOG.WriteLog(eEvent.ERR_PLATINGCELL, Module, "vertical axis is null");
  157. return false;
  158. }
  159. }
  160. /// <summary>
  161. /// 检验Vertical移动状态
  162. /// </summary>
  163. /// <returns></returns>
  164. private bool CheckVerticalPositionStatus()
  165. {
  166. return _verticalAxis.Status == RState.End;
  167. }
  168. /// <summary>
  169. /// 检验Vertical是否还在运动
  170. /// </summary>
  171. /// <returns></returns>
  172. private bool CheckVerticalPositionRunStop()
  173. {
  174. return _verticalAxis.Status == RState.Failed;
  175. }
  176. /// <summary>
  177. /// 启动
  178. /// </summary>
  179. /// <param name="objs"></param>
  180. /// <returns></returns>
  181. public RState Start(params object[] objs)
  182. {
  183. _station=objs[0].ToString();
  184. _offset = (double)objs[1];
  185. if(objs.Length > 2)
  186. {
  187. _speed = (int)objs[2];
  188. }
  189. if (objs.Length > 3)
  190. {
  191. _accelerate = (int)objs[3];
  192. }
  193. _matcher = ModuleMatcherManager.Instance.GetMatcherListByVertical(Module); //获取电机所在的platingcell 列表
  194. _cellEntities.Clear();
  195. foreach (string str in _matcher)
  196. {
  197. if(!Enum.TryParse(str, out ModuleName moduleName))
  198. {
  199. continue;
  200. }
  201. if (!ModuleHelper.IsInstalled(moduleName))
  202. {
  203. continue;
  204. }
  205. PlatingCellEntity cellEntity = Singleton<RouteManager>.Instance.GetModule<PlatingCellEntity>(str);
  206. if (cellEntity.IsDisable)
  207. {
  208. continue;
  209. }
  210. if (cellEntity.IsError)
  211. {
  212. continue;
  213. }
  214. _cellEntities.Add(cellEntity);
  215. }
  216. _verticalAxis = DEVICE.GetDevice<JetAxisBase>($"{Module}.Vertical");
  217. return Runner.Start(Module, "Start PlatingCell Vertical Position");
  218. }
  219. }
  220. }