IoPressureControl.cs 10 KB

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