PumpBase.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. return true;
  55. }
  56. public virtual void SetPumpOnOff(bool isOn) { }
  57. public virtual void Terminate() { }
  58. public virtual void Monitor() { }
  59. public virtual void Reset() { }
  60. public virtual bool ReConnect()
  61. {
  62. return false;
  63. }
  64. }
  65. }