IoPressureControl.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Event;
  6. using Aitex.Core.RT.IOCore;
  7. using Aitex.Core.RT.OperationCenter;
  8. using Aitex.Core.RT.SCCore;
  9. using Aitex.Core.RT.Tolerance;
  10. using Aitex.Core.Util;
  11. using Venus_RT.Devices.IODevices;
  12. using Aitex.Core.RT.Log;
  13. using Venus_Core;
  14. namespace Venus_RT.Devices
  15. {
  16. public class IoPressureControl : BaseDevice, IDevice
  17. {
  18. private bool _enableTolerance;
  19. public bool EnableTolerance
  20. {
  21. get
  22. {
  23. return _enableTolerance;
  24. }
  25. set
  26. {
  27. if (_enableTolerance != value)
  28. {
  29. LOG.Write(eEvent.EV_DEVICE_INFO, Module, value ? "Start monitor pressure stability" : "Stop monitor pressure stability");
  30. if (value)
  31. {
  32. _tolerance.Reset(_scAlarmTime.DoubleValue);
  33. }
  34. }
  35. _enableTolerance = value;
  36. }
  37. }
  38. public bool IsIndependentControl
  39. {
  40. get
  41. {
  42. if (_scIsIndependentControl != null)
  43. return _scIsIndependentControl.BoolValue;
  44. return false;
  45. }
  46. }
  47. public bool IsTvInstalled
  48. {
  49. get
  50. {
  51. if (_scTvInstalled != null)
  52. return _scTvInstalled.BoolValue;
  53. return false;
  54. }
  55. }
  56. public bool IsBoostPumpInstalled
  57. {
  58. get
  59. {
  60. if (_scIsBoostPumpInstalled != null)
  61. return _scIsBoostPumpInstalled.BoolValue;
  62. return false;
  63. }
  64. }
  65. public bool EnableBoostControl
  66. {
  67. get
  68. {
  69. return _diLogicProcessGasFlowing == null || _diLogicProcessGasFlowing.Value;
  70. }
  71. }
  72. //public readonly IoThrottleValve ThrottleValve;
  73. public readonly IoPressureMeter PressureGauge;
  74. public readonly IoPressureMeter ProcessGauge;
  75. public readonly IoPressureMeter ForelineGauge;
  76. public readonly IoPressureMeter LoadLockGauge;
  77. public readonly IoPressureMeter ESCHeGauge;
  78. public readonly IoPressureMeter ProcessHigh;
  79. public readonly IoPressureMeter ProcessLow;
  80. //public readonly IoBoostPump _boost;
  81. //public readonly IoPump DryPump;
  82. private readonly ToleranceChecker _tolerance = new ToleranceChecker();
  83. private readonly SCConfigItem _scAlarmRange;
  84. private readonly SCConfigItem _scAlarmTime;
  85. private readonly SCConfigItem _scIsIndependentControl;
  86. private readonly SCConfigItem _scIsBoostPumpInstalled;
  87. private readonly SCConfigItem _scTvInstalled;
  88. private readonly DIAccessor _diLogicProcessGasFlowing;
  89. private readonly R_TRIG _trigPressureGauge = new R_TRIG();
  90. private readonly R_TRIG _trigProcessGauge = new R_TRIG();
  91. private readonly R_TRIG _trigForelineGauge = new R_TRIG();
  92. private readonly R_TRIG _trigProcessHighGauge = new R_TRIG();
  93. private readonly R_TRIG _trigProcessLowGauge = new R_TRIG();
  94. private readonly R_TRIG _trigESCHePressureGauge = new R_TRIG();
  95. private readonly R_TRIG _trigLoadLockGaugePressureGauge = new R_TRIG();
  96. // Properties
  97. //
  98. public double TargetPressure { get; set; }
  99. private string PressureOutOfTolerance = "PressureOutOfTolerance";
  100. // Constructor
  101. //
  102. public IoPressureControl(string module, XmlElement node, string ioModule = "")
  103. {
  104. base.Module = module;
  105. base.Name = node.GetAttribute("id");
  106. base.Display = node.GetAttribute("display");
  107. base.DeviceID = node.GetAttribute("schematicId");
  108. _diLogicProcessGasFlowing = ParseDiNode("diLogicProcessGasFlowing", node, ioModule);
  109. _scAlarmRange = SC.GetConfigItem($"{Module}.GasFlowPressureAlarmRange");
  110. _scAlarmTime = SC.GetConfigItem($"{Module}.GasFlowPressureAlarmTime");
  111. _scIsIndependentControl = SC.GetConfigItem($"{Module}.IsIndependentControl");
  112. _scIsBoostPumpInstalled = SC.GetConfigItem($"{Module}.EnableBoosterPump");
  113. _scTvInstalled = SC.GetConfigItem($"{Module}.EnableThrottleValve");
  114. //_enableTolerance = true;
  115. PressureGauge = ParseDeviceNode<IoPressureMeter>(Module, "pressureMeter", node);
  116. ProcessGauge = ParseDeviceNode<IoPressureMeter>(Module, "processMeter", node);
  117. ForelineGauge = ParseDeviceNode<IoPressureMeter>(Module, "forelineMeter", node);
  118. LoadLockGauge = ParseDeviceNode<IoPressureMeter>(Module, "loadlockMeter", node);
  119. ESCHeGauge = ParseDeviceNode<IoPressureMeter>(Module, "escHeGauge", node);
  120. ProcessHigh = ParseDeviceNode<IoPressureMeter>(Module, "processPressureHigh", node);
  121. ProcessLow = ParseDeviceNode<IoPressureMeter>(Module, "processPressureLow", node);
  122. //DryPump = ParseDeviceNode<IoPump>(Module, "drypump", node);
  123. }
  124. public bool Initialize()
  125. {
  126. //DEVICE.Register($"{Module}.{Name}.{AITPressureControlOperation.SetBoostPressure}", _setBoostPressure);
  127. DEVICE.Register($"{Module}.{Name}.{AITPressureControlOperation.SetChamberPressure}", _setChamberPressure);
  128. OP.Subscribe($"{Module}.{Name}.{AITPressureControlOperation.SetChamberPressure}", (out string reason, int time, object[] param) =>
  129. {
  130. _setChamberPressure(out reason, 0, param);
  131. return true;
  132. });
  133. EV.Subscribe(new EventItem("Event", PressureOutOfTolerance, "Pressure Out Of Tolerance", EventLevel.Alarm, EventType.HostNotification));
  134. return true;
  135. }
  136. //public void StartPump(bool on)
  137. //{
  138. // this.DryPump?.Start(on);
  139. //}
  140. private bool? _setChamberPressure(out string reason, int time, object[] param)
  141. {
  142. double setpoint = Convert.ToDouble((string)param[0]);
  143. TargetPressure = setpoint;
  144. reason = $"Chamber pressure set to {setpoint} mTorr";
  145. return true;
  146. }
  147. public void Terminate()
  148. {
  149. }
  150. public void Monitor()
  151. {
  152. CheckTolerance();
  153. JetChamber jetChamber = (JetChamber)(SC.GetValue<int>("System.ChamberSelect"));//Venus or Kepler
  154. if (jetChamber == JetChamber.Venus)
  155. {
  156. _trigPressureGauge.CLK = PressureGauge.GaugeAlarm;
  157. if (_trigPressureGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Chamber pressure gauge Alarm");
  158. _trigLoadLockGaugePressureGauge.CLK = LoadLockGauge.GaugeAlarm;
  159. if (_trigLoadLockGaugePressureGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "LoadLock Pressure Gauge Alarm");
  160. }
  161. _trigProcessGauge.CLK = ProcessGauge.GaugeAlarm;
  162. if (_trigProcessGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Process pressure gauge Alarm");
  163. _trigForelineGauge.CLK = ForelineGauge.GaugeAlarm;
  164. if (_trigForelineGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Foreline pressure gauge Alarm");
  165. _trigProcessHighGauge.CLK = ProcessHigh.GaugeAlarm;
  166. if (_trigProcessHighGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Process High Gauge Alarm");
  167. _trigProcessLowGauge.CLK = ProcessLow.GaugeAlarm;
  168. if (_trigProcessLowGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Process Low Gauge Alarm");
  169. _trigESCHePressureGauge.CLK = ESCHeGauge.GaugeAlarm;
  170. if (_trigESCHePressureGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "ESC He Pressure Gauge Alarm");
  171. }
  172. public void CheckTolerance()
  173. {
  174. if (!EnableTolerance)
  175. return;
  176. //if (ThrottleValve != null && IsTvInstalled && ThrottleValve.PressureMode == PressureCtrlMode.TVPositionCtrl)
  177. // return;
  178. _tolerance.Monitor(PressureGauge.Value,
  179. TargetPressure - Math.Abs(_scAlarmRange.DoubleValue),
  180. TargetPressure + Math.Abs(_scAlarmRange.DoubleValue), _scAlarmTime.DoubleValue);
  181. if (_tolerance.Trig)
  182. {
  183. EV.Notify(PressureOutOfTolerance);
  184. LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"Gas Flow Pressure Alarm Out of range in {_scAlarmTime.Value:0} seconds");
  185. }
  186. }
  187. public void Reset()
  188. {
  189. _trigProcessGauge.RST = true;
  190. _trigPressureGauge.RST = true;
  191. _trigForelineGauge.RST = true;
  192. if (_scAlarmTime != null)
  193. {
  194. _tolerance.Reset(_scAlarmTime.DoubleValue);
  195. }
  196. }
  197. }
  198. }