IoBacksideHe.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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(int mTorr)
  67. {
  68. _SetRealFloat(_aoPressure, mTorr);
  69. SetESCHeControlMode(true);
  70. return true;
  71. }
  72. public bool SetFlowThreshold(int nMin, int nMax)
  73. {
  74. MinFlowThreshold = nMin;
  75. MaxFlowThreshold = nMax;
  76. return true;
  77. }
  78. public void Flow(double setpoint)
  79. {
  80. if (setpoint >= 0.01)
  81. {
  82. _DownValve.TurnValve(true, out _);
  83. //this.FlowSP = setpoint;
  84. }
  85. else
  86. {
  87. _DownValve.TurnValve(false, out _);
  88. }
  89. _mfc.Ramp(setpoint, 1000);
  90. SetESCHeControlMode(false);
  91. }
  92. public void SetESCHeControlMode(bool bPressureMode)
  93. {
  94. _SetRealFloat(_aoCtrlMode, bPressureMode ? 1 : 0);
  95. }
  96. private void _noRepeatLog(eEvent evt, string logInfo)
  97. {
  98. if(evt != _lastEvent || logInfo != _lastLogInfo)
  99. {
  100. LOG.Write(evt, Module, logInfo);
  101. _lastEvent = evt;
  102. _lastLogInfo = logInfo;
  103. }
  104. }
  105. }
  106. }