IoPressureControl.cs 8.8 KB

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