VpwRecipeRoutine.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. if(_recipe.DiwLoopDoSet == 0)
  109. {
  110. return true;
  111. }
  112. double loopDoValue = _vpwCellDevice.LoopDOValue;
  113. bool result = loopDoValue < _recipe.DiwLoopDoSet;
  114. if (!result)
  115. {
  116. NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", 0);
  117. }
  118. return result;
  119. }
  120. /// <summary>
  121. /// Vacuum Prewet
  122. /// </summary>
  123. /// <returns></returns>
  124. private bool VacuumPrewet()
  125. {
  126. bool result = _vacuumPrewetRoutine.Start(_recipe) == RState.Running;
  127. if (!result)
  128. {
  129. NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);
  130. }
  131. return result;
  132. }
  133. /// <summary>
  134. /// 检验Vacuum Prewet结束状态
  135. /// </summary>
  136. /// <returns></returns>
  137. private bool CheckVacuumPrewetEndStatus()
  138. {
  139. bool result = CommonFunction.CheckRoutineEndState(_vacuumPrewetRoutine);
  140. return result;
  141. }
  142. /// <summary>
  143. /// 检验Vacuum Prewet异常
  144. /// </summary>
  145. /// <returns></returns>
  146. private bool CheckVacuumPrewetStopStatus()
  147. {
  148. bool result=CommonFunction.CheckRoutineStopState(_vacuumPrewetRoutine);
  149. if (result)
  150. {
  151. NotifyError(eEvent.ERR_VPW, _vacuumPrewetRoutine.ErrorMsg, 1);
  152. }
  153. return result;
  154. }
  155. /// <summary>
  156. /// 启动
  157. /// </summary>
  158. /// <param name="objs"></param>
  159. /// <returns></returns>
  160. public RState Start(params object[] objs)
  161. {
  162. _recipe = objs[0] as VpwRecipe;
  163. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  164. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  165. return Runner.Start(Module, "start run recipe");
  166. }
  167. /// <summary>
  168. /// 重试
  169. /// </summary>
  170. /// <param name="step"></param>
  171. public RState Retry(int step)
  172. {
  173. if (_recipe == null)
  174. {
  175. NotifyError(eEvent.ERR_VPW, "recipe is null", -1);
  176. return RState.Failed;
  177. }
  178. List<Enum> preStepIds = new List<Enum>();
  179. return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry");
  180. }
  181. }
  182. }