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 MECF.Framework.Common.Event; using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.Pumps; namespace FurnaceRT.Equipments.Systems { public class IoPump3 : BaseDevice, IDevice { private DIAccessor _diPowerOn; private DOAccessor _doPowerOn; public IoPump3(string module, XmlElement node, string ioModule = "") { var attrModule = node.GetAttribute("module"); base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule; base.Name = node.GetAttribute("id"); base.Display = node.GetAttribute("display"); base.DeviceID = node.GetAttribute("schematicId"); _diPowerOn = ParseDiNode("diPowerOn", node, ioModule); _doPowerOn = ParseDoNode("doPowerOn", node, ioModule); } public bool Initialize() { DATA.Subscribe($"{Module}.{Name}.IsPumpRunning", () => _diPowerOn.Value); OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.SetOnOff}" , SetPumpOnOff); OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOn}", SetPumpOn); OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOff}", SetPumpOff); return true; } private bool SetPumpOn(out string reason, int time, object[] param) { return SetPump(out reason, time, true); } private bool SetPumpOff(out string reason, int time, object[] param) { return SetPump(out reason, time, false); } private bool SetPumpOnOff(out string reason, int time, object[] param) { return SetPump(out reason, time, Convert.ToBoolean((string)param[0])); } public bool SetPump(out string reason, int time, bool isOn) { reason = ""; if (isOn) { } _doPowerOn.Value = isOn; return true; } public bool SetMainPowerOnOff(bool isOn, out string reason) { reason = string.Empty; return true; } public void Terminate() { } public void Monitor() { try { //_trigWarning.CLK = IsWarning; //if (_trigWarning.Q) //{ // PumpWarning.Set(); //} //_trigError.CLK = IsError; //if (_trigError.Q) //{ // PumpError.Set(); // if (_doPowerOn != null && _doPowerOn.Value) // { // _doPowerOn.Value = false; // EV.PostInfoLog(Module, $"set {Name} power off"); // } // if (_doStart != null && _doStart.Value) // { // _doStart.Value = false; // EV.PostInfoLog(Module, $"set {Name} off"); // } //} //_trigOverload.CLK = IsPumpOverloadAlarm; //if (_trigOverload.Q) //{ // PumpOverload.Set(); // if (_doPowerOn != null && _doPowerOn.Value) // { // _doPowerOn.Value = false; // EV.PostInfoLog(Module, $"set {Name} power off"); // } // if (_doStart != null && _doStart.Value) // { // _doStart.Value = false; // EV.PostInfoLog(Module, $"set {Name} off"); // } //} //_trigN2OK.CLK = !IsN2OK; //if (_trigN2OK.Q) //{ // PumpN2NotOK.Set(); //} //_trigExhaustPressureOK.CLK = !IsExhaustPressureOK; //if (_trigExhaustPressureOK.Q) //{ // PumpExhaustPressureNotOK.Set(); //} } catch (Exception ex) { LOG.Write(ex); } } public void Reset() { } } }