IoBacksideHe.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.IOCore;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Venus_RT.Devices.IODevices;
  8. using Aitex.Core.RT.Device.Unit;
  9. namespace Venus_RT.Devices
  10. {
  11. /// <summary>
  12. /// 先送Setpoint, 然后再设置控制模式, 切换设置模式后立即生效
  13. /// </summary>
  14. public class IoBacksideHe : BaseDevice, IDevice
  15. {
  16. private readonly MfcBase1 _mfc;
  17. private readonly IoValve _DownValve;
  18. private readonly IoValve _UpValve;
  19. private readonly IoValve _Up2Valve;
  20. private readonly IoValve _PumpValve;
  21. private AOAccessor _aoPressure;
  22. private AOAccessor _aoCtrlMode;
  23. private eEvent _lastEvent;
  24. private string _lastLogInfo;
  25. public float MinFlowThreshold { get; set;}
  26. public float MaxFlowThreshold { get; set; }
  27. public bool OutOfRange { get; private set; }
  28. public IoBacksideHe(string module, XmlElement node, string ioModule = "")
  29. {
  30. base.Module = module;
  31. base.Name = node.GetAttribute("id");
  32. base.Display = node.GetAttribute("display");
  33. base.DeviceID = node.GetAttribute("schematicId");
  34. _DownValve = ParseDeviceNode<IoValve>(Module, "downvalve", node);
  35. _UpValve = ParseDeviceNode<IoValve>(Module, "upvalve", node);
  36. _Up2Valve = ParseDeviceNode<IoValve>(Module, "up2valve", node);
  37. _PumpValve = ParseDeviceNode<IoValve>(Module, "pumpvalve", node);
  38. _mfc = ParseDeviceNode<MfcBase1>(Module, "mfc", node);
  39. _aoPressure = ParseAoNode("aoPressureSP", node, ioModule);
  40. _aoCtrlMode = ParseAoNode("aoControlMode", node, ioModule);
  41. }
  42. public bool Initialize()
  43. {
  44. OutOfRange = false;
  45. return true;
  46. }
  47. public void Monitor()
  48. {
  49. if (_mfc != null)
  50. {
  51. if (MinFlowThreshold > 0 && _mfc.FeedBack <= MinFlowThreshold)
  52. {
  53. OutOfRange = true;
  54. _noRepeatLog(eEvent.WARN_BACKSIDE_HE, $"Backside Helium Flow: {_mfc.FeedBack} exceed min threshold value: {MinFlowThreshold}");
  55. }
  56. else if (MaxFlowThreshold > 0 && _mfc.FeedBack >= MaxFlowThreshold)
  57. {
  58. OutOfRange = true;
  59. _noRepeatLog(eEvent.WARN_BACKSIDE_HE, $"Backside Helium Flow: {_mfc.FeedBack} exceed max threshold value: {MaxFlowThreshold}");
  60. }
  61. else
  62. {
  63. OutOfRange = false;
  64. }
  65. }
  66. _DownValve.Monitor();
  67. _mfc?.Monitor();
  68. }
  69. public void Terminate()
  70. {
  71. }
  72. public void Reset()
  73. {
  74. }
  75. public bool HeliumPumpOn(bool On)
  76. {
  77. if (On)
  78. {
  79. _UpValve?.TurnValve(true, out _);
  80. _PumpValve?.TurnValve(true, out _);
  81. }
  82. else
  83. {
  84. _UpValve?.TurnValve(false, out _);
  85. _PumpValve?.TurnValve(false, out _);
  86. }
  87. return true;
  88. }
  89. public bool SetBacksideHelium(float mTorr)
  90. {
  91. _SetRealFloat(_aoPressure, mTorr);
  92. if (mTorr >= 0.01)
  93. {
  94. _DownValve.TurnValve(true, out _);
  95. //Kepler2300 not define upvalve up2valve
  96. _UpValve?.TurnValve(true, out _);
  97. _Up2Valve?.TurnValve(true, out _);
  98. //this.FlowSP = setpoint;
  99. }
  100. else
  101. {
  102. _DownValve.TurnValve(false, out _);
  103. //Kepler2300 not define upvalve up2valve
  104. _UpValve?.TurnValve(false, out _);
  105. _Up2Valve?.TurnValve(false, out _);
  106. }
  107. SetESCHeControlMode(true);
  108. return true;
  109. }
  110. public bool SetFlowThreshold(float nMin, float nMax)
  111. {
  112. MinFlowThreshold = nMin;
  113. MaxFlowThreshold = nMax;
  114. return true;
  115. }
  116. public void Flow(double setpoint)
  117. {
  118. //setpoint = setpoint / 100 * 4000;
  119. if (setpoint >= 0.01)
  120. {
  121. _DownValve.TurnValve(true, out _);
  122. //this.FlowSP = setpoint;
  123. }
  124. else
  125. {
  126. _DownValve.TurnValve(false, out _);
  127. }
  128. // _mfc.Ramp(setpoint, 1000);
  129. _mfc.SetPoint=setpoint;
  130. SetESCHeControlMode(false);
  131. }
  132. public void SetESCHeControlMode(bool bPressureMode)
  133. {
  134. if(_aoCtrlMode != null)
  135. _SetRealFloat(_aoCtrlMode, bPressureMode ? 1 : 0);
  136. }
  137. private void _noRepeatLog(eEvent evt, string logInfo)
  138. {
  139. if(evt != _lastEvent || logInfo != _lastLogInfo)
  140. {
  141. LOG.Write(evt, Module, logInfo);
  142. _lastEvent = evt;
  143. _lastLogInfo = logInfo;
  144. }
  145. }
  146. }
  147. }