IoPumpCtrl.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 Aitex.Core.RT.SCCore;
  12. namespace VirgoRT.Devices.IODevices
  13. {
  14. class IoPumpCtrl : BaseDevice, IDevice
  15. {
  16. private DOAccessor _doPumpRun;
  17. private DOAccessor _doPumpStop;
  18. private DIAccessor _diDryPumpRunning;
  19. private DIAccessor _diPumpAlarm;
  20. private DIAccessor _diPumpRemoteStatus;
  21. private AOAccessor _aoPumpIOCTRLEnable;
  22. private bool _bAlarmReported = false;
  23. private readonly int _StartTimeout = 5000;
  24. private readonly DeviceTimer _timerStart = new DeviceTimer();
  25. private readonly DeviceTimer _timerStop = new DeviceTimer();
  26. public bool IsRunning => _diDryPumpRunning.Value;
  27. public bool IsError => _diPumpAlarm.Value;
  28. public IoPumpCtrl(string module, XmlElement node, string ioModule = "")
  29. {
  30. base.Module = module;
  31. base.Name = node.GetAttribute("id");
  32. base.Display = node.GetAttribute("display");
  33. base.DeviceID = node.GetAttribute("schematicId");
  34. _doPumpRun = ParseDoNode("doPumpRun", node, ioModule);
  35. _doPumpStop = ParseDoNode("doPumpStop", node, ioModule);
  36. _diDryPumpRunning = ParseDiNode("diDryPumpRunning", node, ioModule);
  37. _diPumpAlarm = ParseDiNode("diPumpAlarm", node, ioModule);
  38. _diPumpRemoteStatus = ParseDiNode("diPumpRemoteStatus", node, ioModule);
  39. _aoPumpIOCTRLEnable = ParseAoNode("aoPumpIOCTRLEnable", node, ioModule);
  40. _SetRealFloat(_aoPumpIOCTRLEnable, (SC.GetValue<int>($"{Module}.DryPump.MFG") == (int)DryPumpMFG.Kashiyama) ? 1 : 0);
  41. EV.PostInfoLog(Module, $"泵控制模式(AO26)设置为:{_aoPumpIOCTRLEnable.Value}");
  42. }
  43. public bool Initialize()
  44. {
  45. return true;
  46. }
  47. public void Monitor()
  48. {
  49. if (SC.GetValue<int>($"{Module}.DryPump.MFG") != (int)DryPumpMFG.Kashiyama)
  50. return;
  51. if(_diPumpAlarm.Value)
  52. {
  53. if(_bAlarmReported == false)
  54. {
  55. EV.PostAlarmLog(Module, "Kashiyama 干泵状态错误");
  56. _bAlarmReported = true;
  57. }
  58. return;
  59. }
  60. if(_timerStart.IsTimeout())
  61. {
  62. _timerStart.Stop();
  63. _doPumpRun.Value = false;
  64. EV.PostAlarmLog(Module, "启动 Kashiyama 干泵超时");
  65. }
  66. else if(!_timerStart.IsIdle())
  67. {
  68. if (_diDryPumpRunning.Value)
  69. {
  70. _timerStart.Stop();
  71. _doPumpRun.Value = false;
  72. }
  73. }
  74. if (_timerStop.IsTimeout() || (!_timerStop.IsIdle() && !_diDryPumpRunning.Value))
  75. {
  76. _timerStop.Stop();
  77. _doPumpStop.Value = false;
  78. }
  79. }
  80. public void StartPump()
  81. {
  82. if(_diPumpRemoteStatus.Value == false)
  83. {
  84. EV.PostAlarmLog(Module, "启动干泵失败, Kashiyama 干泵不是远程控制模式");
  85. return;
  86. }
  87. if (_diPumpAlarm.Value)
  88. {
  89. EV.PostAlarmLog(Module, "启动干泵失败, Kashiyama 状态错误");
  90. return;
  91. }
  92. LOG.Info($"[{Module}] Switch on Kashiyama Pump");
  93. _doPumpRun.Value = true;
  94. _bAlarmReported = false;
  95. _timerStart.Start(_StartTimeout);
  96. }
  97. public void StopPump()
  98. {
  99. LOG.Info($"[{Module}] Switch off Kashiyama Pump");
  100. _doPumpStop.Value = true;
  101. _timerStop.Start(_StartTimeout);
  102. }
  103. public void Terminate()
  104. {
  105. }
  106. public void Reset()
  107. {
  108. _bAlarmReported = false;
  109. }
  110. }
  111. }