StandardHotRunRecipeRoutine.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 CyberX8_Core;
  6. using CyberX8_RT.Devices.Metal;
  7. using CyberX8_RT.Modules.Metal;
  8. using MECF.Framework.Common.CommonData;
  9. using MECF.Framework.Common.CommonData.Metal;
  10. using MECF.Framework.Common.CommonData.PowerSupplier;
  11. using MECF.Framework.Common.CommonData.SRD;
  12. using MECF.Framework.Common.Device.PowerSupplier;
  13. using MECF.Framework.Common.RecipeCenter;
  14. using MECF.Framework.Common.Routine;
  15. using MECF.Framework.Common.Utilities;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Linq;
  19. using System.Text;
  20. using System.Threading.Tasks;
  21. namespace CyberX8_RT.Modules.Metal
  22. {
  23. public class StandardHotRunRecipeRoutine : RoutineBase, IRoutine
  24. {
  25. private enum RecipeStep
  26. {
  27. LoopStart,
  28. WaferHolderClampOn,
  29. RunRecipe,
  30. RunRecipeWait,
  31. WaferHolderUnclampOn,
  32. LoopEnd,
  33. End
  34. }
  35. #region 常量
  36. private const int ALL_DAY_MILLOSECONDS = 24 * 60 * 60 * 1000;
  37. #endregion
  38. #region 内部变量
  39. /// <summary>
  40. /// recipe
  41. /// </summary>
  42. private DepRecipe _recipe;
  43. /// <summary>
  44. /// cycle次数
  45. /// </summary>
  46. private int _cycle;
  47. /// <summary>
  48. /// 当前完成的Cycle次数
  49. /// </summary>
  50. private int _currentCycle;
  51. /// <summary>
  52. /// 单面
  53. /// </summary>
  54. private string _side;
  55. /// <summary>
  56. /// Metal设备
  57. /// </summary>
  58. private StandardHotMetalDevice _device;
  59. /// <summary>
  60. /// RunRecipe routine
  61. /// </summary>
  62. private ReservoirRunRecipeRoutine _runRecipeRoutine;
  63. #endregion
  64. #region 属性
  65. /// <summary>
  66. /// A面电量
  67. /// </summary>
  68. public double AnodeAUsage { get { return _runRecipeRoutine.AnodeAUsage; } }
  69. /// <summary>
  70. /// B面电量
  71. /// </summary>
  72. public double AnodeBUsage { get { return _runRecipeRoutine.AnodeBUsage; } }
  73. /// <summary>
  74. /// LotTrack数据
  75. /// </summary>
  76. public List<MetalLotTrackData> MetalLotTrackDatas { get { return _runRecipeRoutine.MetalLotTrackDatas; } }
  77. /// <summary>
  78. /// LotTrack文件头数据
  79. /// </summary>
  80. public LotTrackFileHeaderCommonData MetalLotTrackHeaderDatas { get { return _runRecipeRoutine.MetalLotTrackHeaderDatas; } }
  81. #endregion
  82. /// <summary>
  83. /// 构造函数
  84. /// </summary>
  85. /// <param name="module"></param>
  86. public StandardHotRunRecipeRoutine(string module) : base(module)
  87. {
  88. _runRecipeRoutine = new ReservoirRunRecipeRoutine(module);
  89. }
  90. /// <summary>
  91. /// 中止
  92. /// </summary>
  93. public void Abort()
  94. {
  95. _runRecipeRoutine.Abort();
  96. Runner.Stop("Manual Abort");
  97. }
  98. /// <summary>
  99. /// 监控
  100. /// </summary>
  101. /// <returns></returns>
  102. public RState Monitor()
  103. {
  104. Runner.LoopStart(RecipeStep.LoopStart, "Loop Start Cycle StandardHotRunRecipeRoutine", _cycle, NullFun, _delay_1ms)
  105. .LoopRun(RecipeStep.WaferHolderClampOn, () => _device.WaferHolderClampOn("", null), () => _device.MetalDeviceData.WaferHolderClamp, _delay_1s)
  106. .LoopRun(RecipeStep.RunRecipe, () => _runRecipeRoutine.Start(new object[] { _recipe, _side }) == RState.Running, _delay_1ms)
  107. .LoopRunWithStopStatus(RecipeStep.RunRecipeWait, () => CommonFunction.CheckRoutineEndState(_runRecipeRoutine), CheckRunRecipeStopStatus, ALL_DAY_MILLOSECONDS)
  108. .LoopRun(RecipeStep.WaferHolderUnclampOn, () => _device.WaferHolderClampOff("", null), () => !_device.MetalDeviceData.WaferHolderClamp, _delay_1s)
  109. .LoopEnd(RecipeStep.LoopEnd, UpdateCycleCount, _delay_1ms)
  110. .End(RecipeStep.End, NullFun, _delay_1ms);
  111. return Runner.Status;
  112. }
  113. /// <summary>
  114. /// 统计完成的Cycle次数
  115. /// </summary>
  116. /// <returns></returns>
  117. private bool UpdateCycleCount()
  118. {
  119. _currentCycle += 1;
  120. return true;
  121. }
  122. /// <summary>
  123. /// 获取当前Cycle次数
  124. /// </summary>
  125. /// <returns></returns>
  126. public int GetCurrentCycle()
  127. {
  128. return _currentCycle;
  129. }
  130. /// <summary>
  131. /// 启动
  132. /// </summary>
  133. /// <param name="objs"></param>
  134. /// <returns></returns>
  135. public RState Start(params object[] objs)
  136. {
  137. _recipe = (DepRecipe)objs[0];
  138. if (objs.Length > 1)
  139. {
  140. _side = objs[1].ToString();
  141. }
  142. if (objs.Length > 2)
  143. {
  144. _cycle = (int)objs[2];
  145. }
  146. _device = DEVICE.GetDevice<StandardHotMetalDevice>(Module);
  147. if (!CheckPreCondition())
  148. {
  149. return RState.Failed;
  150. }
  151. _currentCycle = 0;
  152. _runRecipeRoutine.clearLotTrack();//清除loaTrack里面的历史数据
  153. return Runner.Start(Module, "Start run recipe");
  154. }
  155. /// <summary>
  156. /// 检验前置条件
  157. /// </summary>
  158. /// <returns></returns>
  159. private bool CheckPreCondition()
  160. {
  161. if (_recipe == null)
  162. {
  163. LOG.WriteLog(eEvent.ERR_METAL, Module, "Recipe is null");
  164. return false;
  165. }
  166. if (_recipe.CurrentRampProfileSteps.Count == 0)
  167. {
  168. LOG.WriteLog(eEvent.ERR_METAL, Module, "Recipe RampProfileSteps count is 0");
  169. return false;
  170. }
  171. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
  172. if (metalEntity != null && metalEntity.WaferHolderInfo == null)
  173. {
  174. LOG.WriteLog(eEvent.ERR_METAL, Module, $"there is no waferShuttle in {Module}");
  175. return false;
  176. }
  177. return true;
  178. }
  179. /// <summary>
  180. /// RunRecipe停止状态
  181. /// </summary>
  182. /// <returns></returns>
  183. public bool CheckRunRecipeStopStatus()
  184. {
  185. bool result = CommonFunction.CheckRoutineStopState(_runRecipeRoutine);
  186. if (result)
  187. {
  188. AddLotTrackData();
  189. if (_device.SideAPowerSupplier != null)
  190. {
  191. _device.SideAPowerSupplier.DisableOperation("", null);
  192. }
  193. if (_device.SideBPowerSupplier != null)
  194. {
  195. _device.SideBPowerSupplier.DisableOperation("", null);
  196. }
  197. }
  198. return result;
  199. }
  200. /// <summary>
  201. /// 获取Lot Track数据
  202. /// </summary>
  203. /// <returns></returns>
  204. public void AddLotTrackData()
  205. {
  206. _runRecipeRoutine.AddLotTrackData();
  207. }
  208. }
  209. }