PumpBase.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 PumpBase : BaseDevice, IDevice
  19. {
  20. public virtual bool IsOn { get; set; }
  21. public virtual bool IsError { get; set; }
  22. public virtual bool IsStable { get; set; }
  23. public virtual bool IsRunning { get; set; }
  24. public virtual bool IsControl { get; set; }
  25. public virtual float Speed { get; set; }
  26. public virtual float Temperature { get; set; }
  27. public virtual AITPumpData DeviceData { get; set; }
  28. protected PumpBase() : base()
  29. {
  30. }
  31. protected PumpBase(string module, string name, string display, string id) : base(module, name, display, id)
  32. {
  33. }
  34. public virtual bool Initialize()
  35. {
  36. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  37. DATA.Subscribe($"{Module}.{Name}.IsOn", () => IsOn);
  38. DATA.Subscribe($"{Module}.{Name}.Speed", () => Speed);
  39. DATA.Subscribe($"{Module}.{Name}.Temperature", () => Temperature);
  40. OP.Subscribe($"{Module}.{Name}.SetPumpOn", (function, args) =>
  41. {
  42. SetPumpOnOff(true);
  43. return true;
  44. });
  45. OP.Subscribe($"{Module}.{Name}.SetPumpOff", (function, args) =>
  46. {
  47. SetPumpOnOff(false);
  48. return true;
  49. });
  50. OP.Subscribe($"{Module}.{Name}.PumpOn", (function, args) =>
  51. {
  52. SetPumpOnOff(true);
  53. return true;
  54. });
  55. OP.Subscribe($"{Module}.{Name}.PumpOff", (function, args) =>
  56. {
  57. SetPumpOnOff(false);
  58. return true;
  59. });
  60. return true;
  61. }
  62. public virtual void SetPumpOnOff(bool isOn) { }
  63. public virtual void Terminate() { }
  64. public virtual void Monitor() { }
  65. public virtual void Reset() { }
  66. }
  67. }