IoBacksideHe.cs 3.8 KB

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