LoaderReLeakFlowTestRoutine.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.Log;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using MECF.Framework.Common.Equipment;
  6. using MECF.Framework.Common.Routine;
  7. using CyberX8_Core;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace CyberX8_RT.Devices.Loader
  14. {
  15. public class LoaderReLeakFlowTestRoutine : RoutineBase, IRoutine
  16. {
  17. private enum LeakFlowTestStep
  18. {
  19. FirstDelay,
  20. FlowClampOff,
  21. VacuumOff,
  22. LeakFlowTest,
  23. CheckLeakFlowState,
  24. End
  25. }
  26. #region 内部变量
  27. private LoaderCommonDevice _loaderCommon;
  28. private int _retryDelayms = 5;
  29. private LoaderLeakFirstFlowTestRoutine _routine;
  30. #endregion
  31. public LoaderReLeakFlowTestRoutine(string module) : base(module)
  32. {
  33. }
  34. public void Abort()
  35. {
  36. Runner.Stop("Manual Abort");
  37. }
  38. public RState Monitor()
  39. {
  40. Runner.Delay(LeakFlowTestStep.FirstDelay,_retryDelayms*1000)
  41. .Run(LeakFlowTestStep.FlowClampOff, FlowClampOff, _delay_1ms)
  42. .Run(LeakFlowTestStep.VacuumOff, VacuumOff, _delay_1ms)
  43. .Run(LeakFlowTestStep.LeakFlowTest, FlowTest, NullFun, 100)
  44. .WaitWithStopCondition(LeakFlowTestStep.CheckLeakFlowState,CheckFlowTestStatus,CheckFlowTestStop)
  45. .End(LeakFlowTestStep.End, NullFun);
  46. return Runner.Status;
  47. }
  48. /// <summary>
  49. /// Flow Clamp off
  50. /// </summary>
  51. /// <returns></returns>
  52. private bool FlowClampOff()
  53. {
  54. return _loaderCommon.LeakFlowClampOffAction();
  55. }
  56. /// <summary>
  57. /// Vacuum Off
  58. /// </summary>
  59. /// <returns></returns>
  60. private bool VacuumOff()
  61. {
  62. return _loaderCommon.LeakVacuumOffAction();
  63. }
  64. /// <summary>
  65. /// 确认结束状态
  66. /// </summary>
  67. /// <returns></returns>
  68. private bool CheckEndState()
  69. {
  70. return _loaderCommon.Status == RState.End;
  71. }
  72. /// <summary>
  73. /// Flow Test
  74. /// </summary>
  75. /// <returns></returns>
  76. private bool FlowTest()
  77. {
  78. return _routine.Start() == RState.Running;
  79. }
  80. /// <summary>
  81. /// 检验FlowTest Routine结束状态
  82. /// </summary>
  83. /// <returns></returns>
  84. private bool CheckFlowTestStatus()
  85. {
  86. return _routine.Monitor() == RState.End;
  87. }
  88. /// <summary>
  89. /// 检验FlowTest Routine 失败状态
  90. /// </summary>
  91. /// <returns></returns>
  92. private bool CheckFlowTestStop()
  93. {
  94. RState state = _routine.Monitor();
  95. return state == RState.Failed||state==RState.Timeout;
  96. }
  97. public RState Start(params object[] objs)
  98. {
  99. if (SC.ContainsItem($"{Module}.LeakTestRetryWait"))
  100. {
  101. _retryDelayms = SC.GetValue<int>($"{Module}.LeakTestRetryWait");
  102. }
  103. _loaderCommon = DEVICE.GetDevice<LoaderCommonDevice>($"{Module}.Common");
  104. _routine = new LoaderLeakFirstFlowTestRoutine(Module);
  105. Runner.Start(Module, "Re Leak Flow Test");
  106. return RState.Running;
  107. }
  108. }
  109. }