IoGasStick.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 Monitor()
  62. {
  63. _DownValve.Monitor();
  64. _mfc.Monitor();
  65. }
  66. public void Terminate()
  67. {
  68. }
  69. public void Reset()
  70. {
  71. }
  72. public void Stop()
  73. {
  74. _DownValve.TurnValve(false, out _);
  75. //_mfc.Ramp(0, 1000);
  76. _mfc.SetPoint = 0;
  77. }
  78. }
  79. }