PMRoutineBase.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System.Diagnostics;
  2. using Venus_RT.Devices;
  3. using Aitex.Core.RT.Log;
  4. using MECF.Framework.Common.Equipment;
  5. using MECF.Framework.Common.Routine;
  6. using System;
  7. namespace Venus_RT.Modules.PMs
  8. {
  9. class PMRoutineBase
  10. {
  11. public ModuleName Module { get; set; }
  12. public string Name { get; set; }
  13. public bool NullFun() => true;
  14. protected readonly JetPM _chamber;
  15. protected Stopwatch _timer = new Stopwatch();
  16. protected RoutineRunner Runner = new RoutineRunner();
  17. protected readonly int _delay_50ms = 50;
  18. protected readonly int _delay_1s = 1000;
  19. protected readonly int _delay_2s = 2000;
  20. protected readonly int _delay_3s = 3000;
  21. protected readonly int _delay_4s = 4000;
  22. protected readonly int _delay_5s = 5000;
  23. protected readonly int _delay_10s = 10000;
  24. protected readonly int _delay_20s = 20000;
  25. public PMRoutineBase(JetPM chamber)
  26. {
  27. Module = chamber.Module;
  28. _chamber = chamber;
  29. Runner.Reset();
  30. }
  31. protected void Notify(string message)
  32. {
  33. LOG.Write(eEvent.EV_ROUTINE_NOTIFY, Module, Name, message);
  34. }
  35. protected void Stop(string failReason)
  36. {
  37. LOG.Write(eEvent.ERR_ROUTINE_FAILED, Module, Name, failReason);
  38. }
  39. public void Reset()
  40. {
  41. Runner.Reset();
  42. _timer.Reset();
  43. }
  44. public bool CheckLid()
  45. {
  46. if (!_chamber.IsLidClosed)
  47. {
  48. this.Stop("Chamber 盖子必须关");
  49. return false;
  50. }
  51. return true;
  52. }
  53. public bool CheckLidLoadLock()
  54. {
  55. if (!_chamber.IsLidLoadlockClosed)
  56. {
  57. this.Stop("LoadLock 盖子必须关");
  58. return false;
  59. }
  60. return true;
  61. }
  62. protected bool CheckSlitDoor()
  63. {
  64. if (!_chamber.IsSlitDoorClosed)
  65. {
  66. Stop("传送门必须关");
  67. return false;
  68. }
  69. return true;
  70. }
  71. protected bool CheckDryPump()
  72. {
  73. if (!_chamber.IsPumpRunning)
  74. {
  75. Stop("干泵没有启动");
  76. return false;
  77. }
  78. if (_chamber.HasPumpError)
  79. {
  80. Stop("干泵状态有错误");
  81. return false;
  82. }
  83. return true;
  84. }
  85. protected bool CheckTurboPump()
  86. {
  87. if (!_chamber.IsTurboPumpRunning)
  88. {
  89. Stop("分子泵没有启动");
  90. return false;
  91. }
  92. if (_chamber.HasTurboPumpError)
  93. {
  94. Stop("分子泵状态有错误");
  95. return false;
  96. }
  97. return true;
  98. }
  99. protected bool CheckCDA()
  100. {
  101. if (!_chamber.IsCDA_OK)
  102. {
  103. Stop("CDA 压力信号不正确");
  104. return false;
  105. }
  106. return true;
  107. }
  108. public bool CheckATM()
  109. {
  110. if (_chamber.IsATM)
  111. {
  112. this.Stop("Chamber 是ATM状态");
  113. return false;
  114. }
  115. return true;
  116. }
  117. protected bool CloseAllValves()
  118. {
  119. Notify("关闭所有的阀门");
  120. _chamber.CloseValves();
  121. return true;
  122. }
  123. protected bool TurnValve(ValveType vlv, bool bOpen)
  124. {
  125. _chamber.OpenValve(vlv, bOpen);
  126. Notify($"{(bOpen ? "打开" : "关闭")} {vlv} 阀");
  127. return true;
  128. }
  129. protected bool CheckValve(ValveType vlv, bool bOpen)
  130. {
  131. if (vlv == ValveType.FastPump)
  132. return _chamber.IsFastPumpOpened == bOpen;
  133. else if (vlv == ValveType.SoftPump)
  134. return _chamber.IsSoftPumpOpened == bOpen;
  135. return true;
  136. }
  137. protected bool SetCoolantTemp(double target, double offset)
  138. {
  139. if (!_chamber.CheckChillerStatus())
  140. {
  141. Stop("Chiller status error");
  142. return false;
  143. }
  144. if (_chamber.CoolantOutletTempFB > target)
  145. {
  146. Notify($"水冷当前温度{_chamber.CoolantOutletTempFB} ℃, 大于目标 {target.ToString()} ℃");
  147. }
  148. _chamber.HeatChiller(target, offset);
  149. Notify($"检查水冷温度值,当前温度{_chamber.CoolantOutletTempFB} ℃, 目标 {target.ToString()} ℃");
  150. return true;
  151. }
  152. protected bool CheckCoolantTemp(double target, double tolerance)
  153. {
  154. return Math.Abs(_chamber.CoolantOutletTempFB - target) <= tolerance;
  155. }
  156. }
  157. }