IoGasStick.cs 2.0 KB

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