IoPressureControl.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. // Properties
  92. //
  93. public double TargetPressure { get; set; }
  94. private string PressureOutOfTolerance = "PressureOutOfTolerance";
  95. // Constructor
  96. //
  97. public IoPressureControl(string module, XmlElement node, string ioModule = "")
  98. {
  99. base.Module = module;
  100. base.Name = node.GetAttribute("id");
  101. base.Display = node.GetAttribute("display");
  102. base.DeviceID = node.GetAttribute("schematicId");
  103. _diLogicProcessGasFlowing = ParseDiNode("diLogicProcessGasFlowing", node, ioModule);
  104. _scAlarmRange = SC.GetConfigItem($"{Module}.GasFlowPressureAlarmRange");
  105. _scAlarmTime = SC.GetConfigItem($"{Module}.GasFlowPressureAlarmTime");
  106. _scIsIndependentControl = SC.GetConfigItem($"{Module}.IsIndependentControl");
  107. _scIsBoostPumpInstalled = SC.GetConfigItem($"{Module}.EnableBoosterPump");
  108. _scTvInstalled = SC.GetConfigItem($"{Module}.EnableThrottleValve");
  109. //_enableTolerance = true;
  110. PressureGauge = ParseDeviceNode<IoPressureMeter>(Module, "pressureMeter", node);
  111. ProcessGauge = ParseDeviceNode<IoPressureMeter>(Module, "processMeter", node);
  112. ForelineGauge = ParseDeviceNode<IoPressureMeter>(Module, "forelineMeter", node);
  113. LoadLockGauge = ParseDeviceNode<IoPressureMeter>(Module, "loadlockMeter", node);
  114. ESCHeGauge = ParseDeviceNode<IoPressureMeter>(Module, "escHeGauge", node);
  115. ProcessHigh = ParseDeviceNode<IoPressureMeter>(Module, "processPressureHigh", node);
  116. ProcessLow = ParseDeviceNode<IoPressureMeter>(Module, "processPressureLow", node);
  117. //DryPump = ParseDeviceNode<IoPump>(Module, "drypump", node);
  118. }
  119. public bool Initialize()
  120. {
  121. //DEVICE.Register($"{Module}.{Name}.{AITPressureControlOperation.SetBoostPressure}", _setBoostPressure);
  122. DEVICE.Register($"{Module}.{Name}.{AITPressureControlOperation.SetChamberPressure}", _setChamberPressure);
  123. OP.Subscribe($"{Module}.{Name}.{AITPressureControlOperation.SetChamberPressure}", (out string reason, int time, object[] param) =>
  124. {
  125. _setChamberPressure(out reason, 0, param);
  126. return true;
  127. });
  128. EV.Subscribe(new EventItem("Event", PressureOutOfTolerance, "Pressure Out Of Tolerance", EventLevel.Alarm, EventType.HostNotification));
  129. return true;
  130. }
  131. //public void StartPump(bool on)
  132. //{
  133. // this.DryPump?.Start(on);
  134. //}
  135. private bool? _setChamberPressure(out string reason, int time, object[] param)
  136. {
  137. double setpoint = Convert.ToDouble((string)param[0]);
  138. TargetPressure = setpoint;
  139. reason = $"Chamber pressure set to {setpoint} mTorr";
  140. return true;
  141. }
  142. public void Terminate()
  143. {
  144. }
  145. public void Monitor()
  146. {
  147. CheckTolerance();
  148. _trigProcessGauge.CLK = ProcessGauge.GaugeAlarm;
  149. if (_trigProcessGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Process pressure gauge Alarm");
  150. _trigPressureGauge.CLK = PressureGauge.GaugeAlarm;
  151. if (_trigPressureGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Chamber pressure gauge Alarm");
  152. _trigForelineGauge.CLK = ForelineGauge.GaugeAlarm;
  153. if (_trigForelineGauge.Q) LOG.Write(eEvent.ERR_DEVICE_INFO, Module, "Foreline pressure gauge Alarm");
  154. }
  155. public void CheckTolerance()
  156. {
  157. if (!EnableTolerance)
  158. return;
  159. //if (ThrottleValve != null && IsTvInstalled && ThrottleValve.PressureMode == PressureCtrlMode.TVPositionCtrl)
  160. // return;
  161. _tolerance.Monitor(PressureGauge.Value,
  162. TargetPressure - Math.Abs(_scAlarmRange.DoubleValue),
  163. TargetPressure + Math.Abs(_scAlarmRange.DoubleValue), _scAlarmTime.DoubleValue);
  164. if (_tolerance.Trig)
  165. {
  166. EV.Notify(PressureOutOfTolerance);
  167. LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"Gas Flow Pressure Alarm Out of range in {_scAlarmTime.Value:0} seconds");
  168. }
  169. }
  170. public void Reset()
  171. {
  172. _trigProcessGauge.RST = true;
  173. _trigPressureGauge.RST = true;
  174. _trigForelineGauge.RST = true;
  175. if (_scAlarmTime != null)
  176. {
  177. _tolerance.Reset(_scAlarmTime.DoubleValue);
  178. }
  179. }
  180. }
  181. }