StandardHotRunRecipeRoutine.cs 7.4 KB

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