IoPressureControl.cs 7.5 KB

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