IoPump3.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using System;
  2. using System.Xml;
  3. using Aitex.Core.Common.DeviceData;
  4. using Aitex.Core.RT.DataCenter;
  5. using Aitex.Core.RT.Device;
  6. using Aitex.Core.RT.Event;
  7. using Aitex.Core.RT.IOCore;
  8. using Aitex.Core.RT.Log;
  9. using Aitex.Core.RT.OperationCenter;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.Event;
  12. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps;
  13. namespace FurnaceRT.Equipments.Systems
  14. {
  15. public class IoPump3 : BaseDevice, IDevice
  16. {
  17. private DIAccessor _diPowerOn;
  18. private DOAccessor _doPowerOn;
  19. public IoPump3(string module, XmlElement node, string ioModule = "")
  20. {
  21. var attrModule = node.GetAttribute("module");
  22. base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
  23. base.Name = node.GetAttribute("id");
  24. base.Display = node.GetAttribute("display");
  25. base.DeviceID = node.GetAttribute("schematicId");
  26. _diPowerOn = ParseDiNode("diPowerOn", node, ioModule);
  27. _doPowerOn = ParseDoNode("doPowerOn", node, ioModule);
  28. }
  29. public bool Initialize()
  30. {
  31. DATA.Subscribe($"{Module}.{Name}.IsPumpRunning", () => _diPowerOn.Value);
  32. OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.SetOnOff}" , SetPumpOnOff);
  33. OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOn}", SetPumpOn);
  34. OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOff}", SetPumpOff);
  35. return true;
  36. }
  37. private bool SetPumpOn(out string reason, int time, object[] param)
  38. {
  39. return SetPump(out reason, time, true);
  40. }
  41. private bool SetPumpOff(out string reason, int time, object[] param)
  42. {
  43. return SetPump(out reason, time, false);
  44. }
  45. private bool SetPumpOnOff(out string reason, int time, object[] param)
  46. {
  47. return SetPump(out reason, time, Convert.ToBoolean((string)param[0]));
  48. }
  49. public bool SetPump(out string reason, int time, bool isOn)
  50. {
  51. reason = "";
  52. if (isOn)
  53. {
  54. }
  55. _doPowerOn.Value = isOn;
  56. return true;
  57. }
  58. public bool SetMainPowerOnOff(bool isOn, out string reason)
  59. {
  60. reason = string.Empty;
  61. return true;
  62. }
  63. public void Terminate()
  64. {
  65. }
  66. public void Monitor()
  67. {
  68. try
  69. {
  70. //_trigWarning.CLK = IsWarning;
  71. //if (_trigWarning.Q)
  72. //{
  73. // PumpWarning.Set();
  74. //}
  75. //_trigError.CLK = IsError;
  76. //if (_trigError.Q)
  77. //{
  78. // PumpError.Set();
  79. // if (_doPowerOn != null && _doPowerOn.Value)
  80. // {
  81. // _doPowerOn.Value = false;
  82. // EV.PostInfoLog(Module, $"set {Name} power off");
  83. // }
  84. // if (_doStart != null && _doStart.Value)
  85. // {
  86. // _doStart.Value = false;
  87. // EV.PostInfoLog(Module, $"set {Name} off");
  88. // }
  89. //}
  90. //_trigOverload.CLK = IsPumpOverloadAlarm;
  91. //if (_trigOverload.Q)
  92. //{
  93. // PumpOverload.Set();
  94. // if (_doPowerOn != null && _doPowerOn.Value)
  95. // {
  96. // _doPowerOn.Value = false;
  97. // EV.PostInfoLog(Module, $"set {Name} power off");
  98. // }
  99. // if (_doStart != null && _doStart.Value)
  100. // {
  101. // _doStart.Value = false;
  102. // EV.PostInfoLog(Module, $"set {Name} off");
  103. // }
  104. //}
  105. //_trigN2OK.CLK = !IsN2OK;
  106. //if (_trigN2OK.Q)
  107. //{
  108. // PumpN2NotOK.Set();
  109. //}
  110. //_trigExhaustPressureOK.CLK = !IsExhaustPressureOK;
  111. //if (_trigExhaustPressureOK.Q)
  112. //{
  113. // PumpExhaustPressureNotOK.Set();
  114. //}
  115. }
  116. catch (Exception ex)
  117. {
  118. LOG.Write(ex);
  119. }
  120. }
  121. public void Reset()
  122. {
  123. }
  124. }
  125. }