VpwRecipeRoutine.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 PunkHPX8_Core;
  8. using PunkHPX8_RT.Devices.VpwCell;
  9. using PunkHPX8_RT.Devices.VpwMain;
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. namespace PunkHPX8_RT.Modules.VpwCell
  16. {
  17. public class VpwRecipeRoutine : RoutineBase, IRoutine
  18. {
  19. private enum RecipeStep
  20. {
  21. ChamberUp,
  22. CloseDrain,
  23. CheckLoopDO,
  24. End
  25. }
  26. #region 内部变量
  27. /// <summary>
  28. /// recipe
  29. /// </summary>
  30. private VpwRecipe _recipe;
  31. /// <summary>
  32. /// 设备
  33. /// </summary>
  34. private VpwCellDevice _vpwCellDevice;
  35. /// <summary>
  36. /// Main设备
  37. /// </summary>
  38. private VpwMainDevice _mainDevice;
  39. #endregion
  40. /// <summary>
  41. /// 构造函数
  42. /// </summary>
  43. /// <param name="module"></param>
  44. public VpwRecipeRoutine(string module) : base(module)
  45. {
  46. }
  47. /// <summary>
  48. /// 中止
  49. /// </summary>
  50. public void Abort()
  51. {
  52. Runner.Stop("Manual stop");
  53. }
  54. /// <summary>
  55. /// 监控
  56. /// </summary>
  57. /// <returns></returns>
  58. public RState Monitor()
  59. {
  60. Runner.Run(RecipeStep.ChamberUp, ChamberUp, CheckChamberClosed)
  61. .Run(RecipeStep.CloseDrain, _vpwCellDevice.DrainValveOff, _delay_1ms)
  62. .Run(RecipeStep.CheckLoopDO, CheckLoopDO, _delay_1ms)
  63. .End(RecipeStep.End, NullFun, _delay_1ms);
  64. return Runner.Status;
  65. }
  66. /// <summary>
  67. /// chamber up
  68. /// </summary>
  69. /// <returns></returns>
  70. private bool ChamberUp()
  71. {
  72. bool result = _mainDevice.ChamberUp();
  73. if (!result)
  74. {
  75. NotifyError(eEvent.ERR_VPW, "chamber up failed", -1);
  76. }
  77. return result;
  78. }
  79. /// <summary>
  80. /// 检验Chamber是否关闭
  81. /// </summary>
  82. /// <returns></returns>
  83. private bool CheckChamberClosed()
  84. {
  85. return _mainDevice.CommonData.ChamberClosed && !_mainDevice.CommonData.ChamberOpened;
  86. }
  87. /// <summary>
  88. /// Check LoopDO数值
  89. /// </summary>
  90. /// <returns></returns>
  91. private bool CheckLoopDO()
  92. {
  93. double loopDoValue = _vpwCellDevice.LoopDOValue;
  94. bool result = loopDoValue < _recipe.DiwLoopDoSet;
  95. if (!result)
  96. {
  97. NotifyError(eEvent.ERR_VPW, $"LoopDO value {loopDoValue} is less than {_recipe.DiwLoopDoSet}", -1);
  98. }
  99. return result;
  100. }
  101. /// <summary>
  102. /// 启动
  103. /// </summary>
  104. /// <param name="objs"></param>
  105. /// <returns></returns>
  106. public RState Start(params object[] objs)
  107. {
  108. _recipe = objs[0] as VpwRecipe;
  109. _vpwCellDevice = DEVICE.GetDevice<VpwCellDevice>(Module);
  110. _mainDevice = DEVICE.GetDevice<VpwMainDevice>(ModuleName.VPWMain1.ToString());
  111. return Runner.Start(Module, "start run recipe");
  112. }
  113. /// <summary>
  114. /// 重试
  115. /// </summary>
  116. /// <param name="step"></param>
  117. public RState Retry(int step)
  118. {
  119. if (_recipe == null)
  120. {
  121. NotifyError(eEvent.ERR_RINSE, "recipe is null", -1);
  122. return RState.Failed;
  123. }
  124. List<Enum> preStepIds = new List<Enum>();
  125. return Runner.Retry(RecipeStep.ChamberUp, preStepIds, Module, "Run recipe Retry");
  126. }
  127. }
  128. }