VpwRecipeRoutine.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.RecipeCenter;
  6. using MECF.Framework.Common.Routine;
  7. using MECF.Framework.Common.Utilities;
  8. using PunkHPX8_Core;
  9. using PunkHPX8_RT.Devices.VpwCell;
  10. using PunkHPX8_RT.Devices.VpwMain;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. namespace PunkHPX8_RT.Modules.VpwCell
  17. {
  18. public class VpwRecipeRoutine : RoutineBase, IRoutine
  19. {
  20. private enum RecipeStep
  21. {
  22. ChamberUp,
  23. CloseDrain,
  24. CheckLoopDO,
  25. VacuumPrewet,
  26. WaitVacuumPrewet,
  27. End
  28. }
  29. #region 内部变量
  30. /// <summary>
  31. /// recipe
  32. /// </summary>
  33. private VpwRecipe _recipe;
  34. /// <summary>
  35. /// 设备
  36. /// </summary>
  37. private VpwCellDevice _vpwCellDevice;
  38. /// <summary>
  39. /// Main设备
  40. /// </summary>
  41. private VpwMainDevice _mainDevice;
  42. /// <summary>
  43. /// Vacuum prewet routine
  44. /// </summary>
  45. private VpwVacuumPrewetRoutine _vacuumPrewetRoutine;
  46. #endregion
  47. /// <summary>
  48. /// 构造函数
  49. /// </summary>
  50. /// <param name="module"></param>
  51. public VpwRecipeRoutine(string module) : base(module)
  52. {
  53. _vacuumPrewetRoutine = new VpwVacuumPrewetRoutine(Module);
  54. }
  55. /// <summary>
  56. /// 中止
  57. /// </summary>
  58. public void Abort()
  59. {
  60. Runner.Stop("Manual stop");
  61. }
  62. /// <summary>
  63. /// 监控
  64. /// </summary>
  65. /// <returns></returns>
  66. public RState Monitor()
  67. {
  68. Runner.Run(RecipeStep.ChamberUp, ChamberUp, CheckChamberClosed)
  69. .Run(RecipeStep.CloseDrain, _vpwCellDevice.DrainValveOff, _delay_1ms)
  70. .Run(RecipeStep.CheckLoopDO, CheckLoopDO, _delay_1ms)
  71. .Run(RecipeStep.VacuumPrewet,VacuumPrewet,_delay_1ms)
  72. .WaitWithStopCondition(RecipeStep.WaitVacuumPrewet,CheckVacuumPrewetEndStatus,CheckVacuumPrewetStopStatus)
  73. .End(RecipeStep.End, NullFun, _delay_1ms);
  74. return Runner.Status;
  75. }
  76. /// <summary>
  77. /// chamber up
  78. /// </summary>
  79. /// <returns></returns>
  80. private bool ChamberUp()
  81. {
  82. bool result = _mainDevice.ChamberUp();
  83. if (!result)
  84. {
  85. NotifyError(eEvent.ERR_VPW, "chamber up failed", 0);
  86. }
  87. return result;
  88. }
  89. /// <summary>
  90. /// 检验Chamber是否关闭
  91. /// </summary>
  92. /// <returns></returns>
  93. private bool CheckChamberClosed()
  94. {
  95. bool result= _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened;
  96. if (!result)
  97. {
  98. NotifyError(eEvent.ERR_VPW, $"Chamber Closed is {_mainDevice.CommonData.ChamberClosed} and opened is {_mainDevice.CommonData.ChamberOpened}",0);
  99. }
  100. return result;
  101. }
  102. /// <summary>
  103. /// Check LoopDO数值
  104. /// </summary>
  105. /// <returns></returns>
  106. private bool CheckLoopDO()
  107. {
  108. double loopDoValue = _vpwCellDevice.LoopDOValue;
  109. bool result = loopDoValue < _recipe.DiwLoopDoSet;
  110. if (!result)
  111. {
  112. NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", 0);
  113. }
  114. return result;
  115. }
  116. /// <summary>
  117. /// Vacuum Prewet
  118. /// </summary>
  119. /// <returns></returns>
  120. private bool VacuumPrewet()
  121. {
  122. bool result = _vacuumPrewetRoutine.Start(_recipe) == RState.Running;
  123. if (!result)
  124. {
  125. NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);
  126. }
  127. return result;
  128. }
  129. /// <summary>
  130. /// 检验Vacuum Prewet结束状态
  131. /// </summary>
  132. /// <returns></returns>
  133. private bool CheckVacuumPrewetEndStatus()
  134. {
  135. bool result = CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine);
  136. return result;
  137. }
  138. /// <summary>
  139. /// 检验Vacuum Prewet异常
  140. /// </summary>
  141. /// <returns></returns>
  142. private bool CheckVacuumPrewetStopStatus()
  143. {
  144. bool result=CommonFunction.CheckRoutineStopState(_vacuumPrewetRoutine);
  145. if (result)
  146. {
  147. NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);
  148. }
  149. return result;
  150. }
  151. /// <summary>
  152. /// 启动
  153. /// </summary>
  154. /// <param name="objs"></param>
  155. /// <returns></returns>
  156. public RState Start(params object[] objs)
  157. {
  158. _recipe = objs[0] as VpwRecipe;
  159. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  160. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  161. return Runner.Start(Module, "start run recipe");
  162. }
  163. /// <summary>
  164. /// 重试
  165. /// </summary>
  166. /// <param name="step"></param>
  167. public RState Retry(int step)
  168. {
  169. if (_recipe == null)
  170. {
  171. NotifyError(eEvent.ERR_RINSE, "recipe is null", -1);
  172. return RState.Failed;
  173. }
  174. List<Enum> preStepIds = new List<Enum>();
  175. return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry");
  176. }
  177. }
  178. }