IoGasStick.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.RT.Device;
  4. using Aitex.Core.RT.Device.Unit;
  5. using Aitex.Core.RT.OperationCenter;
  6. using Venus_RT.Devices.IODevices;
  7. namespace Venus_RT.Devices
  8. {
  9. class IoGasStick : BaseDevice, IDevice
  10. {
  11. private readonly IoValve _DownValve;
  12. private readonly IoValve _UpValve;
  13. public readonly MfcBase1 _mfc;
  14. // Properties
  15. //
  16. public double FlowSP
  17. {
  18. get => _mfc.SetPoint;
  19. //set => _mfc.SetPoint = value;
  20. }
  21. public bool IsOutOfRange => _mfc.IsOutOfTolerance;
  22. // Constructor
  23. //
  24. public IoGasStick(string module, XmlElement node, string ioModule = "")
  25. {
  26. base.Module = module;
  27. base.Name = node.GetAttribute("id");
  28. base.Display = node.GetAttribute("display");
  29. base.DeviceID = node.GetAttribute("schematicId");
  30. _DownValve = ParseDeviceNode<IoValve>(Module, "downvalve", node);
  31. _UpValve = ParseDeviceNode<IoValve>(Module, "upvalve", node);
  32. _mfc = ParseDeviceNode<MfcBase1>(Module, "mfc", node);
  33. }
  34. public bool Initialize()
  35. {
  36. OP.Subscribe($"{Module}.{_mfc.Name}", (out string reason, int time, object[] para) =>
  37. {
  38. reason = "";
  39. double sp = Convert.ToDouble((string)para[0]);
  40. Flow(sp);
  41. return true;
  42. });
  43. return true;
  44. }
  45. public void Flow(double setpoint)
  46. {
  47. if (setpoint >= 0.01)
  48. {
  49. _DownValve.TurnValve(true, out _);
  50. _UpValve?.TurnValve(true, out _);
  51. }
  52. else
  53. {
  54. _DownValve.TurnValve(false, out _);
  55. _UpValve?.TurnValve(false, out _);
  56. }
  57. _mfc.SetPoint = setpoint;
  58. //_mfc.Ramp(setpoint, 1000);
  59. }
  60. public void Monitor()
  61. {
  62. _DownValve.Monitor();
  63. _mfc.Monitor();
  64. }
  65. public void Terminate()
  66. {
  67. }
  68. public void Reset()
  69. {
  70. }
  71. public void Stop()
  72. {
  73. _DownValve.TurnValve(false, out _);
  74. _mfc.Ramp(0, 1000);
  75. }
  76. }
  77. }