SlitValveBase.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. using Aitex.Core.Common.DeviceData;
  8. using Aitex.Core.RT.DataCenter;
  9. using Aitex.Core.RT.Device;
  10. using Aitex.Core.RT.Event;
  11. using Aitex.Core.RT.IOCore;
  12. using Aitex.Core.RT.Log;
  13. using Aitex.Core.RT.SCCore;
  14. using Aitex.Core.Util;
  15. namespace MECF.Framework.Common.Device.Bases
  16. {
  17. public abstract class SlitValveBase : BaseDevice, IDevice
  18. {
  19. public virtual bool OpenFeedback { get; set; }
  20. public virtual bool CloseFeedback { get; set; }
  21. public virtual bool OpenSetPoint { get; set; }
  22. public virtual bool CloseSetPoint { get; set; }
  23. public virtual AITCylinderData DeviceData { get; set; }
  24. protected SlitValveBase() : base()
  25. {
  26. }
  27. protected SlitValveBase(string module, string name) : base(module, name, name, name)
  28. {
  29. }
  30. public virtual bool Initialize()
  31. {
  32. DATA.Subscribe($"{Module}.{Name}.OpenFeedback", () => OpenFeedback);
  33. DATA.Subscribe($"{Module}.{Name}.OpenSetPoint", () => OpenSetPoint);
  34. DATA.Subscribe($"{Module}.{Name}.CloseFeedback", () => CloseFeedback);
  35. DATA.Subscribe($"{Module}.{Name}.CloseSetPoint", () => CloseSetPoint);
  36. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  37. DEVICE.Register($"{Module}.{Name}.Open", (out string reason, int time, object[] param) =>
  38. {
  39. reason = "";
  40. return SetSlitValve(true, out reason);
  41. });
  42. DEVICE.Register($"{Module}.{Name}.Close", (out string reason, int time, object[] param) =>
  43. {
  44. reason = "";
  45. return SetSlitValve(false, out reason);
  46. });
  47. return true;
  48. }
  49. public virtual void Monitor()
  50. {
  51. }
  52. public virtual void Terminate()
  53. {
  54. }
  55. public virtual bool CheckIsClose()
  56. {
  57. return CloseFeedback && !OpenFeedback;
  58. }
  59. public virtual bool CheckIsOpen()
  60. {
  61. return !CloseFeedback && OpenFeedback;
  62. }
  63. public virtual bool SetSlitValve(bool open, out string reason)
  64. {
  65. reason = "";
  66. return true;
  67. }
  68. public virtual void Reset()
  69. {
  70. }
  71. }
  72. }