IoGasStick.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.Ramp(setpoint, 1000);
  58. }
  59. public void Monitor()
  60. {
  61. _DownValve.Monitor();
  62. _mfc.Monitor();
  63. }
  64. public void Terminate()
  65. {
  66. }
  67. public void Reset()
  68. {
  69. }
  70. public void Stop()
  71. {
  72. _DownValve.TurnValve(false, out _);
  73. _mfc.Ramp(0, 1000);
  74. }
  75. }
  76. }