123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- using System;
- using System.Xml;
- using Aitex.Core.Common.DeviceData;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Event;
- using Aitex.Core.RT.IOCore;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.Util;
- using Aitex.Core.RT.SCCore;
- namespace VirgoRT.Devices.IODevices
- {
- class IoPumpCtrl : BaseDevice, IDevice
- {
- private DOAccessor _doPumpRun;
- private DOAccessor _doPumpStop;
- private DIAccessor _diDryPumpRunning;
- private DIAccessor _diPumpAlarm;
- private DIAccessor _diPumpRemoteStatus;
- private AOAccessor _aoPumpIOCTRLEnable;
- private bool _bAlarmReported = false;
- private readonly int _StartTimeout = 5000;
- private readonly DeviceTimer _timerStart = new DeviceTimer();
- private readonly DeviceTimer _timerStop = new DeviceTimer();
- public bool IsRunning => _diDryPumpRunning.Value;
- public bool IsError => _diPumpAlarm.Value;
- public IoPumpCtrl(string module, XmlElement node, string ioModule = "")
- {
- base.Module = module;
- base.Name = node.GetAttribute("id");
- base.Display = node.GetAttribute("display");
- base.DeviceID = node.GetAttribute("schematicId");
- _doPumpRun = ParseDoNode("doPumpRun", node, ioModule);
- _doPumpStop = ParseDoNode("doPumpStop", node, ioModule);
- _diDryPumpRunning = ParseDiNode("diDryPumpRunning", node, ioModule);
- _diPumpAlarm = ParseDiNode("diPumpAlarm", node, ioModule);
- _diPumpRemoteStatus = ParseDiNode("diPumpRemoteStatus", node, ioModule);
- _aoPumpIOCTRLEnable = ParseAoNode("aoPumpIOCTRLEnable", node, ioModule);
- _SetRealFloat(_aoPumpIOCTRLEnable, (SC.GetValue<int>($"{Module}.DryPump.MFG") == (int)DryPumpMFG.Kashiyama) ? 1 : 0);
- EV.PostInfoLog(Module, $"泵控制模式(AO26)设置为:{_aoPumpIOCTRLEnable.Value}");
- }
- public bool Initialize()
- {
- return true;
- }
- public void Monitor()
- {
- if (SC.GetValue<int>($"{Module}.DryPump.MFG") != (int)DryPumpMFG.Kashiyama)
- return;
- if(_diPumpAlarm.Value)
- {
- if(_bAlarmReported == false)
- {
- EV.PostAlarmLog(Module, "Kashiyama 干泵状态错误");
- _bAlarmReported = true;
- }
- return;
- }
- if(_timerStart.IsTimeout())
- {
- _timerStart.Stop();
- _doPumpRun.Value = false;
- EV.PostAlarmLog(Module, "启动 Kashiyama 干泵超时");
- }
- else if(!_timerStart.IsIdle())
- {
- if (_diDryPumpRunning.Value)
- {
- _timerStart.Stop();
- _doPumpRun.Value = false;
- }
- }
- if (_timerStop.IsTimeout() || (!_timerStop.IsIdle() && !_diDryPumpRunning.Value))
- {
- _timerStop.Stop();
- _doPumpStop.Value = false;
- }
- }
- public void StartPump()
- {
- if(_diPumpRemoteStatus.Value == false)
- {
- EV.PostAlarmLog(Module, "启动干泵失败, Kashiyama 干泵不是远程控制模式");
- return;
- }
- if (_diPumpAlarm.Value)
- {
- EV.PostAlarmLog(Module, "启动干泵失败, Kashiyama 状态错误");
- return;
- }
- LOG.Info($"[{Module}] Switch on Kashiyama Pump");
- _doPumpRun.Value = true;
- _bAlarmReported = false;
- _timerStart.Start(_StartTimeout);
- }
- public void StopPump()
- {
- LOG.Info($"[{Module}] Switch off Kashiyama Pump");
- _doPumpStop.Value = true;
- _timerStop.Start(_StartTimeout);
- }
- public void Terminate()
- {
- }
- public void Reset()
- {
- _bAlarmReported = false;
- }
- }
- }
|