| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 | 
							- 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 IoPump : BaseDevice, IDevice, IPump
 
-     {
 
-         public bool IsRunning
 
-         {
 
-             get
 
-             {
 
-                 if (_diRunning != null)
 
-                     return _diRunning.Value;
 
-                 if (_diPowerOn != null)
 
-                     return _diPowerOn.Value;
 
-                 return true; //默认常开
 
-             }
 
-         }
 
-         public bool IsWarning
 
-         {
 
-             get
 
-             {
 
-                 return _diWarning != null && _diWarning.Value;
 
-             }
 
-         }
 
-  
 
-  
 
-         public bool IsError
 
-         {
 
-             get
 
-             {
 
-                 return _diError != null && _diError.Value;
 
-             }
 
-         }
 
-  
 
-         public bool IsPumpOverloadAlarm
 
-         {
 
-             get
 
-             {
 
-                 return _diOverloadAlarm != null && _diOverloadAlarm.Value;
 
-             }
 
-         }
 
-         public bool HasError
 
-         {
 
-             get
 
-             {
 
-                 return IsPumpOverloadAlarm || IsError;
 
-             }
 
-         }
 
-         public bool IsN2OK
 
-         {
 
-             get
 
-             {
 
-                 if (_diN2OK == null)
 
-                     return true;
 
-                 return _diN2OK.Value;
 
-             }
 
-         }
 
-         public bool IsExhaustPressureOK
 
-         {
 
-             get
 
-             {
 
-                 if (_diExhaustPressureOK == null)
 
-                     return true;
 
-                 return _diExhaustPressureOK.Value;
 
-             }
 
-         }
 
-         private AITPumpData DeviceData
 
-         {
 
-             get
 
-             {
 
-                 AITPumpData data = new AITPumpData()
 
-                 {
 
-                     DeviceName = Name,
 
-                     DeviceSchematicId = DeviceID,
 
-                     DisplayName = Display,
 
-                     DeviceModule = Module,
 
-                     Module = Module,
 
-                     IsOn = IsRunning,
 
-                     IsError = IsError,
 
-                     IsOverLoad = IsPumpOverloadAlarm,
 
-                 };
 
-                 return data;
 
-             }
 
-         }
 
-  
 
-         private DIAccessor _diRunning = null;
 
-         private DIAccessor _diOverloadAlarm;
 
-         private DIAccessor _diPowerOn;
 
-         private DIAccessor _diStart;
 
-         private DIAccessor _diStop;
 
-         private DIAccessor _diN2OK;
 
-         private DIAccessor _diExhaustPressureOK;
 
-         private DIAccessor _diError;
 
-         private DIAccessor _diWarning;
 
-         private DOAccessor _doStart;
 
-         private DOAccessor _doPowerOn;
 
-         private R_TRIG _trigWarning = new R_TRIG();
 
-         private R_TRIG _trigError = new R_TRIG();
 
-         private R_TRIG _trigOverload = new R_TRIG();
 
-         private R_TRIG _trigN2OK = new R_TRIG();
 
-         private R_TRIG _trigExhaustPressureOK = new R_TRIG();
 
-         public AlarmEventItem PumpWarning { get; set; }
 
-         public AlarmEventItem PumpError { get; set; }
 
-         public AlarmEventItem PumpOverload { get; set; }
 
-         public AlarmEventItem PumpN2NotOK { get; set; }
 
-         public AlarmEventItem PumpExhaustPressureNotOK { get; set; }
 
-         public IoPump(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");
 
-             _diError = ParseDiNode("diAlarm", node, ioModule);
 
-             _diRunning = ParseDiNode("diRunning", node, ioModule);
 
-             _diWarning = ParseDiNode("diWarning", node, ioModule);
 
-             _diOverloadAlarm = ParseDiNode("diOverloadAlarm", node, ioModule);
 
-             _diPowerOn = ParseDiNode("diPowerOn", node, ioModule);
 
-             _diStart = ParseDiNode("diStart", node, ioModule);
 
-             _diStop = ParseDiNode("diStop", node, ioModule);
 
-             _diN2OK = ParseDiNode("diN2OK", node, ioModule);
 
-             _diExhaustPressureOK = ParseDiNode("diExhaustPressureOK", node, ioModule);
 
-             _doStart = ParseDoNode("doStartStop", node, ioModule);
 
-             _doPowerOn = ParseDoNode("doPowerOn", node, ioModule);
 
-         }
 
-         public bool Initialize()
 
-         {
 
-             DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
 
-             OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.SetOnOff}" , SetPumpOnOff);
 
-             OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOn}", SetPumpOn);
 
-             OP.Subscribe($"{Module}.{Name}.{AITPumpOperation.PumpOff}", SetPumpOff);
 
-             PumpWarning = SubscribeAlarm(new AlarmEventItem()
 
-             {
 
-                 EventEnum = $"{Module}.{Name}PumpWarning",
 
-                 Description = $"{Name} warning ",
 
-                 Solution = "No information available. Press[Clear] to delete alarm message.",
 
-                 Explaination = "No information available.",
 
-                 AutoRecovery = false,
 
-                 Level = EventLevel.Warning,
 
-                 Action = EventAction.Clear,
 
-                 Category = "TubeAlarm",
 
-             }, () => { Reset(); return true; });
 
-             PumpError = SubscribeAlarm(new AlarmEventItem()
 
-             {
 
-                 EventEnum = $"{Module}.{Name}PumpError",
 
-                 Description = $"{Name} error ",
 
-                 Solution = "No information available. Press[Clear] to delete alarm message.",
 
-                 Explaination = "No information available.",
 
-                 AutoRecovery = false,
 
-                 Level = EventLevel.Alarm,
 
-                 Action = EventAction.Clear,
 
-                 Category = "TubeAlarm",
 
-             }, () => { Reset(); return true; });
 
-             PumpOverload = SubscribeAlarm(new AlarmEventItem()
 
-             {
 
-                 EventEnum = $"{Module}.{Name}PumpOverload",
 
-                 Description = $"{Name} overload ",
 
-                 Solution = "No information available. Press[Clear] to delete alarm message.",
 
-                 Explaination = "No information available.",
 
-                 AutoRecovery = false,
 
-                 Level = EventLevel.Alarm,
 
-                 Action = EventAction.Clear,
 
-                 Category = "TubeAlarm",
 
-             }, () => { Reset(); return true; });
 
-             PumpN2NotOK = SubscribeAlarm(new AlarmEventItem()
 
-             {
 
-                 EventEnum = $"{Module}.{Name}PumpN2NotOK",
 
-                 Description = $"{Name} N2 not ok ",
 
-                 Solution = "No information available. Press[Clear] to delete alarm message.",
 
-                 Explaination = "No information available.",
 
-                 AutoRecovery = false,
 
-                 Level = EventLevel.Alarm,
 
-                 Action = EventAction.Clear,
 
-                 Category = "TubeAlarm",
 
-             }, () => { Reset(); return true; });
 
-             PumpExhaustPressureNotOK = SubscribeAlarm(new AlarmEventItem()
 
-             {
 
-                 EventEnum = $"{Module}.{Name}PumpExhaustPressureNotOK",
 
-                 Description = $"{Name} exhaust pressure not ok ",
 
-                 Solution = "No information available. Press[Clear] to delete alarm message.",
 
-                 Explaination = "No information available.",
 
-                 AutoRecovery = false,
 
-                 Level = EventLevel.Alarm,
 
-                 Action = EventAction.Clear,
 
-                 Category = "TubeAlarm",
 
-             }, () => { Reset(); return true; });
 
-             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)
 
-         {
 
-             if (isOn)
 
-             {
 
-                 if (IsError)
 
-                 {
 
-                     reason = "Can not set pump on, pump in error";
 
-                     return false;
 
-                 }
 
-                 if (IsPumpOverloadAlarm)
 
-                 {
 
-                     reason = "Can not set pump on, pump is overload";
 
-                     return false;
 
-                 }
 
-                 if (!IsN2OK)
 
-                 {
 
-                     reason = "Can not set pump on, pump N2 is not OK";
 
-                     return false;
 
-                 }
 
-                 if (!IsExhaustPressureOK)
 
-                 {
 
-                     reason = "Can not set pump on, pump exhaust pressure is not OK";
 
-                     return false;
 
-                 }
 
-             }
 
-             reason = string.Empty;
 
-             if (_doStart != null)
 
-             {
 
-                 _doStart.Value = isOn;
 
-             }
 
-             else if (_doPowerOn != null)
 
-             {
 
-                 _doPowerOn.Value = isOn;
 
-             }
 
-             else
 
-             {
 
-                 reason = "Do not support host control";
 
-                 return false;
 
-             }
 
-             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()
 
-         {
 
-             _trigWarning.RST = true;
 
-             _trigError.RST = true;
 
-             _trigOverload.RST = true;
 
-             _trigN2OK.RST = true;
 
-             _trigExhaustPressureOK.RST = true;
 
-             if (PumpWarning != null)
 
-                 PumpWarning.IsAcknowledged = true;
 
-             if (PumpError != null)
 
-                 PumpError.IsAcknowledged = true;
 
-             if (PumpOverload != null)
 
-                 PumpOverload.IsAcknowledged = true;
 
-             if (PumpN2NotOK != null)
 
-                 PumpN2NotOK.IsAcknowledged = true;
 
-             if (PumpExhaustPressureNotOK != null)
 
-                 PumpExhaustPressureNotOK.IsAcknowledged = true;
 
-             //PumpWarning.Reset();
 
-             //PumpError.Reset();
 
-             //PumpOverload.Reset();
 
-             //PumpN2NotOK.Reset();
 
-             //PumpExhaustPressureNotOK.Reset();
 
-         }
 
-     }
 
- }
 
 
  |