PumpBase.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Timers;
  5. using Aitex.Core.Common.DeviceData;
  6. using Aitex.Core.RT.DataCenter;
  7. using Aitex.Core.RT.Device;
  8. using Aitex.Core.RT.OperationCenter;
  9. namespace MECF.Framework.Common.Device.Bases
  10. {
  11. public abstract class PumpBase: BaseDevice, IDevice
  12. {
  13. public virtual bool IsOn { get; set; }
  14. public virtual bool IsError { get; set; }
  15. public virtual bool IsStable { get; set; }
  16. public virtual bool IsRunning { get; set; }
  17. public virtual bool IsControl { get; set; }
  18. public virtual float Speed { get; set; }
  19. public virtual float Temperature { get; set; }
  20. public virtual AITPumpData DeviceData { get; set; }
  21. public virtual bool IsConnected { get; }
  22. protected PumpBase() : base()
  23. {
  24. }
  25. protected PumpBase(string module, string name, string display, string id) : base(module, name, display, id)
  26. {
  27. }
  28. public virtual bool Initialize()
  29. {
  30. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  31. //DATA.Subscribe($"{Module}.{Name}.IsOn", () => IsOn);
  32. //DATA.Subscribe($"{Module}.{Name}.Speed", () => Speed);
  33. //DATA.Subscribe($"{Module}.{Name}.Temperature", () => Temperature);
  34. OP.Subscribe($"{Module}.{Name}.SetPumpOn", (function, args) =>
  35. {
  36. SetPumpOnOff(true);
  37. return true;
  38. });
  39. OP.Subscribe($"{Module}.{Name}.SetPumpOff", (function, args) =>
  40. {
  41. SetPumpOnOff(false);
  42. return true;
  43. });
  44. OP.Subscribe($"{Module}.{Name}.PumpOn", (function, args) =>
  45. {
  46. SetPumpOnOff(true);
  47. return true;
  48. });
  49. OP.Subscribe($"{Module}.{Name}.PumpOff", (function, args) =>
  50. {
  51. SetPumpOnOff(false);
  52. return true;
  53. });
  54. OP.Subscribe($"{Module}.{Name}.ResetPumpStats", (function, args) =>
  55. {
  56. ResetPumpStats();
  57. return true;
  58. });
  59. return true;
  60. }
  61. public virtual void ResetPumpStats()
  62. {
  63. }
  64. public virtual void SetPumpOnOff(bool isOn) { }
  65. public virtual void Terminate() { }
  66. public virtual void Monitor() { }
  67. public virtual void Reset() { }
  68. public virtual bool ReConnect()
  69. {
  70. return false;
  71. }
  72. }
  73. }