IoGasStick.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Security.Cryptography;
  3. using System.Xml;
  4. using Aitex.Core.RT.Device;
  5. using Aitex.Core.RT.Device.Unit;
  6. using Aitex.Core.RT.OperationCenter;
  7. using Venus_RT.Devices.IODevices;
  8. namespace Venus_RT.Devices
  9. {
  10. class IoGasStick : BaseDevice, IDevice
  11. {
  12. private readonly IoValve _DownValve;
  13. private readonly IoValve _UpValve;
  14. public readonly MfcBase1 _mfc;
  15. // Properties
  16. //
  17. public double FlowSP
  18. {
  19. get => _mfc.SetPoint;
  20. //set => _mfc.SetPoint = value;
  21. }
  22. public bool IsOutOfRange => _mfc.IsOutOfTolerance;
  23. // Constructor
  24. //
  25. public IoGasStick(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. _UpValve = ParseDeviceNode<IoValve>(Module, "upvalve", node);
  33. _mfc = ParseDeviceNode<MfcBase1>(Module, "mfc", node);
  34. }
  35. public bool Initialize()
  36. {
  37. OP.Subscribe($"{Module}.{_mfc.Name}", (out string reason, int time, object[] para) =>
  38. {
  39. reason = "";
  40. double sp = Convert.ToDouble((string)para[0]);
  41. Flow(sp);
  42. return true;
  43. });
  44. return true;
  45. }
  46. public void Flow(double setpoint)
  47. {
  48. if (setpoint >= 0.01)
  49. {
  50. _DownValve.TurnValve(true, out _);
  51. _UpValve?.TurnValve(true, out _);
  52. }
  53. else
  54. {
  55. _DownValve.TurnValve(false, out _);
  56. _UpValve?.TurnValve(false, out _);
  57. }
  58. _mfc.SetPoint = setpoint;
  59. //_mfc.Ramp(setpoint, 1000);
  60. }
  61. public void Pump()
  62. {
  63. _UpValve?.TurnValve(true, out _);
  64. _mfc.SetPoint = _mfc.Scale;
  65. }
  66. public void Monitor()
  67. {
  68. _DownValve.Monitor();
  69. if (_mfc.Name == "MfcN2" && _DownValve?.Status==false)
  70. {
  71. return;
  72. }
  73. _mfc.Monitor();
  74. }
  75. public void Terminate()
  76. {
  77. }
  78. public void Reset()
  79. {
  80. }
  81. public void Stop()
  82. {
  83. _DownValve.TurnValve(false, out _);
  84. _UpValve?.TurnValve(false, out _);
  85. //_mfc.Ramp(0, 1000);
  86. _mfc.SetPoint = 0;
  87. }
  88. }
  89. }