IoGasStick.cs 2.1 KB

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