LeakCheckRoutine.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms.VisualStyles;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.RT.Routine;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.Util;
  11. using Aitex.RT.Properties;
  12. using Aitex.Triton160.Common;
  13. using Aitex.Triton160.RT.Device;
  14. using Aitex.Triton160.RT.Module;
  15. namespace Aitex.Triton160.RT.Routine.PM
  16. {
  17. public class LeakCheckRoutine : CommonRoutine
  18. {
  19. private enum RoutineStep
  20. {
  21. CheckDoor,
  22. CheckDryPump,
  23. CloseAllVavle,
  24. OpenPumpingValve,
  25. OpenGasFinalValve,
  26. CheckVAC,
  27. PumpDownDelay,
  28. ClosePumpValve,
  29. LeakCheckDelay,
  30. CalcLeakCheck,
  31. End,
  32. };
  33. private int _leakCheckPumpDownTime;
  34. private int _leakCheckWaitTime;
  35. private LeakCheckMode _mode;
  36. private double _beginPressure;
  37. private bool[] _enableGasLine = new bool[10];
  38. private double _basePressure;
  39. private double _pumpTimeLimit;
  40. public int ElapseTime
  41. {
  42. get
  43. {
  44. return (int)(counter.GetElapseTime()/1000.0);
  45. }
  46. }
  47. public LeakCheckRoutine(string module, string name)
  48. {
  49. Module = module;
  50. Name = name;
  51. Display = Resources.LeakCheckRoutine_LeakCheckRoutine_LeakCheck;
  52. bUINotify = true;
  53. }
  54. public bool Initialize()
  55. {
  56. InitCommon();
  57. return true;
  58. }
  59. public void Terminate()
  60. {
  61. }
  62. public Result Start(params object[] objs)
  63. {
  64. Reset();
  65. UpdateSCValue();
  66. delayTimer.Start(0);
  67. _basePressure = SC.GetSC<double>(SCName.System_PumpBasePressure).Value;
  68. _pumpTimeLimit = SC.GetSC<double>(SCName.System_PumpTimeLimit).Value;
  69. try
  70. {
  71. _leakCheckPumpDownTime = Convert.ToInt32(objs[0].ToString()) * 60;
  72. _leakCheckWaitTime = Convert.ToInt32(objs[1].ToString())*60;
  73. _mode = (LeakCheckMode)Enum.Parse(typeof (LeakCheckMode), objs[2].ToString());
  74. for (int i = 0; i < 5; i++)
  75. _enableGasLine[i] = Convert.ToBoolean(objs[3 + i].ToString());
  76. }
  77. catch (Exception ex)
  78. {
  79. LOG.Write(ex);
  80. return Result.FAIL;
  81. }
  82. return Result.RUN;
  83. }
  84. public Result Monitor()
  85. {
  86. try
  87. {
  88. //检查Door
  89. CheckDoor((int)RoutineStep.CheckDoor, Resources.PumpDownRoutine_Monitor_CheckDoorStatus, Notify, Stop);
  90. //检查 Dry Pump
  91. CheckDryPump((int)RoutineStep.CheckDryPump, Resources.PumpDownRoutine_Monitor_CheckPumpStatus, Notify, Stop);
  92. //关闭所有阀门
  93. CloseAllValve((int)RoutineStep.CloseAllVavle, Resources.PumpDownRoutine_Monitor_CloseAllTheValves, 10, Notify, Stop);
  94. //打开
  95. OpenPumpingValve((int)RoutineStep.OpenPumpingValve, Resources.PumpDownRoutine_Monitor_OpenPumpingValve, 10, Notify, Stop);
  96. if (_mode == LeakCheckMode.ChamberAndGasLine && DeviceModel.ValveProcessGasFinal!=null)
  97. OpenValve((int)RoutineStep.OpenGasFinalValve, Resources.LeakCheckRoutine_Monitor_OpenGasFinalValve, DeviceModel.ValveProcessGasFinal, 10, Notify, Stop);
  98. //检查VAC
  99. CheckVAC((int)RoutineStep.CheckVAC, string.Format(Resources.PumpDownRoutine_Monitor_WaitChamberPressureUntilBelow0, _basePressure), _basePressure, (int)_pumpTimeLimit, Notify, Stop);
  100. //pump down delay
  101. Delay((int)RoutineStep.PumpDownDelay, string.Format(Resources.LeakCheckRoutine_Monitor_PumpDelay0Seconds, _leakCheckPumpDownTime), _leakCheckPumpDownTime, Notify, Stop);
  102. ClosePumpValve((int)RoutineStep.ClosePumpValve, Resources.StopPumpRoutine_Monitor_ClosePumpValve, valveOpenCloseTimeout, Notify, Stop);
  103. DelayLeakCheck((int)RoutineStep.LeakCheckDelay, string.Format(Resources.LeakCheckRoutine_Monitor_LeakCheckDelay0Seconds, _leakCheckWaitTime), _leakCheckWaitTime, Notify, Stop);
  104. CalcLeakCheck((int) RoutineStep.CalcLeakCheck, Resources.LeakCheckRoutine_Monitor_CalculateLeakCheckRate, _leakCheckWaitTime, Notify,
  105. Stop);
  106. End((int)RoutineStep.End, Resources.LeakCheckRoutine_Monitor_LeakCheckFinished, Notify, Stop);
  107. }
  108. catch (RoutineBreakException)
  109. {
  110. return Result.RUN;
  111. }
  112. catch (RoutineFaildException)
  113. {
  114. return Result.FAIL;
  115. }
  116. return Result.DONE;
  117. }
  118. public void DelayLeakCheck(int id, string name, double time, Action<string> notify, Action<string> error)
  119. {
  120. Tuple<bool, Result> ret = Delay(id, () =>
  121. {
  122. notify(name);
  123. _beginPressure = DeviceModel.PressureMeterChamber.Value;
  124. return true;
  125. }, time * 1000);
  126. if (ret.Item1)
  127. {
  128. if (ret.Item2 == Result.RUN)
  129. {
  130. throw (new RoutineBreakException());
  131. }
  132. }
  133. }
  134. public void CalcLeakCheck(int id, string name, int time, Action<string> notify, Action<string> error)
  135. {
  136. Tuple<bool, Result> ret = Execute(id, () =>
  137. {
  138. double endPressure = DeviceModel.PressureMeterChamber.Value;
  139. double leakRate = (endPressure - _beginPressure) / (time / 60.0);
  140. LeakCheckResultManager.Instance.AddLeakCheck(DateTime.Now, time / 60, (int)_beginPressure, (int)endPressure, leakRate, LeakCheckStatus.Succeed.ToString(), _mode.ToString());
  141. EV.PostMessage(ModuleNameString.System, EventEnum.GeneralInfo, string.Format(Resources.LeakCheckRoutine_CalcLeakCheck_LeakCheckTime0StartPressure1StopPressure2LeakTime3LeakRate4, DateTime.Now.ToString("F"), _beginPressure, endPressure, time, leakRate));
  142. return true;
  143. });
  144. }
  145. public void AbortLeakCheck()
  146. {
  147. try
  148. {
  149. LeakCheckResultManager.Instance.AddLeakCheck(DateTime.Now, (int)(delayTimer.GetElapseTime()/1000/60), (int)_beginPressure, (int)DeviceModel.PressureMeterChamber.Value, 0, LeakCheckStatus.Aborted.ToString(), _mode.ToString());
  150. }
  151. catch (Exception ex)
  152. {
  153. LOG.Write(ex);
  154. }
  155. }
  156. }
  157. }