IoBacksideHe.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 AOAccessor _aoPressure;
  21. private AOAccessor _aoCtrlMode;
  22. private eEvent _lastEvent;
  23. private string _lastLogInfo;
  24. public int MinFlowThreshold { get; set;}
  25. public int MaxFlowThreshold { get; set; }
  26. public bool OutOfRange { get; private set; }
  27. public IoBacksideHe(string module, XmlElement node, string ioModule = "")
  28. {
  29. base.Module = module;
  30. base.Name = node.GetAttribute("id");
  31. base.Display = node.GetAttribute("display");
  32. base.DeviceID = node.GetAttribute("schematicId");
  33. _DownValve = ParseDeviceNode<IoValve>(Module, "downvalve", node);
  34. _UpValve = ParseDeviceNode<IoValve>(Module, "upvalve", node);
  35. _Up2Valve = ParseDeviceNode<IoValve>(Module, "up2valve", node);
  36. _mfc = ParseDeviceNode<MfcBase1>(Module, "mfc", node);
  37. _aoPressure = ParseAoNode("aoPressureSP", node, ioModule);
  38. _aoCtrlMode = ParseAoNode("aoControlMode", node, ioModule);
  39. }
  40. public bool Initialize()
  41. {
  42. OutOfRange = false;
  43. return true;
  44. }
  45. public void Monitor()
  46. {
  47. if (_mfc != null)
  48. {
  49. if (MinFlowThreshold > 0 && _mfc.FeedBack <= MinFlowThreshold)
  50. {
  51. OutOfRange = true;
  52. _noRepeatLog(eEvent.WARN_BACKSIDE_HE, $"Backside Helium Flow: {_mfc.FeedBack} exceed min threshold value: {MinFlowThreshold}");
  53. }
  54. else if (MaxFlowThreshold > 0 && _mfc.FeedBack >= MaxFlowThreshold)
  55. {
  56. OutOfRange = true;
  57. _noRepeatLog(eEvent.WARN_BACKSIDE_HE, $"Backside Helium Flow: {_mfc.FeedBack} exceed max threshold value: {MaxFlowThreshold}");
  58. }
  59. else
  60. {
  61. OutOfRange = false;
  62. }
  63. }
  64. _DownValve.Monitor();
  65. _mfc?.Monitor();
  66. }
  67. public void Terminate()
  68. {
  69. }
  70. public void Reset()
  71. {
  72. }
  73. public bool SetBacksideHelium(float mTorr)
  74. {
  75. _SetRealFloat(_aoPressure, mTorr);
  76. if (mTorr >= 0.01)
  77. {
  78. _DownValve.TurnValve(true, out _);
  79. //Kepler2300 not define upvalve up2valve
  80. _UpValve?.TurnValve(true, out _);
  81. _Up2Valve?.TurnValve(true, out _);
  82. //this.FlowSP = setpoint;
  83. }
  84. else
  85. {
  86. _DownValve.TurnValve(false, out _);
  87. //Kepler2300 not define upvalve up2valve
  88. _UpValve?.TurnValve(false, out _);
  89. _Up2Valve?.TurnValve(false, out _);
  90. }
  91. SetESCHeControlMode(true);
  92. return true;
  93. }
  94. public bool SetFlowThreshold(int nMin, int nMax)
  95. {
  96. MinFlowThreshold = nMin;
  97. MaxFlowThreshold = nMax;
  98. return true;
  99. }
  100. public void Flow(double setpoint)
  101. {
  102. //setpoint = setpoint / 100 * 4000;
  103. if (setpoint >= 0.01)
  104. {
  105. _DownValve.TurnValve(true, out _);
  106. //this.FlowSP = setpoint;
  107. }
  108. else
  109. {
  110. _DownValve.TurnValve(false, out _);
  111. }
  112. _mfc.Ramp(setpoint, 1000);
  113. SetESCHeControlMode(false);
  114. }
  115. public void SetESCHeControlMode(bool bPressureMode)
  116. {
  117. if(_aoCtrlMode != null)
  118. _SetRealFloat(_aoCtrlMode, bPressureMode ? 1 : 0);
  119. }
  120. private void _noRepeatLog(eEvent evt, string logInfo)
  121. {
  122. if(evt != _lastEvent || logInfo != _lastLogInfo)
  123. {
  124. LOG.Write(evt, Module, logInfo);
  125. _lastEvent = evt;
  126. _lastLogInfo = logInfo;
  127. }
  128. }
  129. }
  130. }