StandardHotRunRecipeRoutine.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 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. _runRecipeRoutine.resetMetalUsage();//清除usage历史数据
  154. return Runner.Start(Module, "Start run recipe");
  155. }
  156. /// <summary>
  157. /// 检验前置条件
  158. /// </summary>
  159. /// <returns></returns>
  160. private bool CheckPreCondition()
  161. {
  162. if (_recipe == null)
  163. {
  164. LOG.WriteLog(eEvent.ERR_METAL, Module, "Recipe is null");
  165. return false;
  166. }
  167. if (_recipe.CurrentRampProfileSteps.Count == 0)
  168. {
  169. LOG.WriteLog(eEvent.ERR_METAL, Module, "Recipe RampProfileSteps count is 0");
  170. return false;
  171. }
  172. MetalEntity metalEntity = Singleton<RouteManager>.Instance.GetModule<MetalEntity>(Module);
  173. if (metalEntity != null && metalEntity.WaferHolderInfo == null)
  174. {
  175. LOG.WriteLog(eEvent.ERR_METAL, Module, $"there is no waferShuttle in {Module}");
  176. return false;
  177. }
  178. return true;
  179. }
  180. /// <summary>
  181. /// RunRecipe停止状态
  182. /// </summary>
  183. /// <returns></returns>
  184. public bool CheckRunRecipeStopStatus()
  185. {
  186. bool result = CommonFunction.CheckRoutineStopState(_runRecipeRoutine);
  187. if (result)
  188. {
  189. AddLotTrackData();
  190. if (_device.SideAPowerSupplier != null)
  191. {
  192. _device.SideAPowerSupplier.DisableOperation("", null);
  193. }
  194. if (_device.SideBPowerSupplier != null)
  195. {
  196. _device.SideBPowerSupplier.DisableOperation("", null);
  197. }
  198. }
  199. return result;
  200. }
  201. /// <summary>
  202. /// 获取Lot Track数据
  203. /// </summary>
  204. /// <returns></returns>
  205. public void AddLotTrackData()
  206. {
  207. _runRecipeRoutine.AddLotTrackData();
  208. }
  209. }
  210. }