ThrottleValveBase.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Configuration;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8. using Aitex.Core.Common.DeviceData;
  9. using Aitex.Core.RT.DataCenter;
  10. using Aitex.Core.RT.Device;
  11. using Aitex.Core.RT.Event;
  12. using Aitex.Core.RT.IOCore;
  13. using Aitex.Core.RT.OperationCenter;
  14. using Aitex.Core.RT.SCCore;
  15. using Aitex.Core.Util;
  16. namespace MECF.Framework.Common.Device.Bases
  17. {
  18. public abstract class ThrottleValveBase : BaseDevice, IDevice
  19. {
  20. public virtual PressureCtrlMode Mode { get; set; }
  21. public virtual float PositionFeedback { get; set; }
  22. public virtual float PressureFeedback { get; set; }
  23. public virtual float PressureSetPoint { get; set; }
  24. public virtual float PositionSetPoint { get; set; }
  25. public virtual AITThrottleValveData DeviceData { get; set; }
  26. public uint MaxValuePressure = 100;
  27. public float PressureParam = 0.1f;
  28. public uint MaxValuePosi = 5000;
  29. public float PosiParam = 0.1f;
  30. protected ThrottleValveBase() : base()
  31. {
  32. }
  33. protected ThrottleValveBase(string module, string name) : base(module, name, name, name)
  34. {
  35. }
  36. public virtual bool Initialize()
  37. {
  38. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  39. DATA.Subscribe($"{Module}.{Name}.ControlMode", () => (int)Mode);
  40. DATA.Subscribe($"{Module}.{Name}.PositionFeedback", () => PositionFeedback);
  41. DATA.Subscribe($"{Module}.{Name}.PressureFeedback", () => PressureFeedback);
  42. DATA.Subscribe($"{Module}.{Name}.PositionSetPoint", () => PositionSetPoint);
  43. DATA.Subscribe($"{Module}.{Name}.PressureSetPoint", () => PressureSetPoint);
  44. OP.Subscribe($"{Module}.{Name}.SetPressure", (function, args) =>
  45. {
  46. SetPressure((float)args[0]);
  47. return true;
  48. });
  49. OP.Subscribe($"{Module}.{Name}.SetPosition", (function, args) =>
  50. {
  51. SetPosition((float)args[0]);
  52. return true;
  53. });
  54. OP.Subscribe($"{Module}.{Name}.SetOpen", (function, args) =>
  55. {
  56. SetOpen( );
  57. return true;
  58. });
  59. OP.Subscribe($"{Module}.{Name}.SetClose", (function, args) =>
  60. {
  61. SetClose( );
  62. return true;
  63. });
  64. OP.Subscribe($"{Module}.{Name}.SetMode", (function, args) =>
  65. {
  66. if (!Enum.TryParse((string)args[0], out PressureCtrlMode mode))
  67. {
  68. EV.PostWarningLog(Module, $"Argument {args[0]}not valid");
  69. return false;
  70. }
  71. SetControlMode(mode);
  72. return true;
  73. });
  74. return true;
  75. }
  76. public virtual void SetClose()
  77. {
  78. throw new NotImplementedException();
  79. }
  80. public virtual void SetOpen()
  81. {
  82. throw new NotImplementedException();
  83. }
  84. public virtual void SetControlMode(PressureCtrlMode mode)
  85. {
  86. }
  87. public virtual void SetPressure(float isOn)
  88. {
  89. }
  90. public virtual void SetPosition(float position)
  91. {
  92. }
  93. public virtual void Terminate()
  94. {
  95. }
  96. public virtual void Monitor()
  97. {
  98. }
  99. public virtual void Reset()
  100. {
  101. }
  102. }
  103. }