89 lines
2.7 KiB
C#
89 lines
2.7 KiB
C#
using Aitex.Core.RT.Event;
|
||
using Aitex.Core.RT.IOCore;
|
||
using Aitex.Core.RT.SCCore;
|
||
using Aitex.Core.Util;
|
||
using System.Collections.Generic;
|
||
using System.Xml;
|
||
|
||
namespace Aitex.Core.RT.Device.Devices
|
||
{
|
||
public class IoGasBoxTemp : BaseDevice, IDevice
|
||
{
|
||
//配置中标记的AI名称
|
||
protected readonly List<string> _aiGasBoxTempName = new List<string>()
|
||
{
|
||
"aiHeatTMA",
|
||
"aiHeatTCSPanel",
|
||
"aiHeatinsidePanel",
|
||
"aiHeatoutsidePanel",
|
||
"aiHeatoutsideSH",
|
||
"aiHeatLeakBypass"
|
||
};
|
||
|
||
protected readonly List<AIAccessor> _aiGasBoxTemp;
|
||
|
||
protected readonly DOAccessor _doLineHeaterEnable;
|
||
|
||
protected readonly string _scNameAlarmHigh;
|
||
|
||
protected double _alarmHigh;
|
||
|
||
protected readonly R_TRIG _trigIsAlarm = new R_TRIG();
|
||
|
||
protected int _alarmCount;
|
||
|
||
public IoGasBoxTemp(string module, XmlElement node, string ioModule = "") : base(module, node, ioModule)
|
||
{
|
||
_aiGasBoxTemp = new List<AIAccessor>();
|
||
foreach (var aiName in _aiGasBoxTempName)
|
||
{
|
||
_aiGasBoxTemp.Add(ParseAiNode(aiName, node, ioModule));
|
||
}
|
||
|
||
_doLineHeaterEnable = ParseDoNode("doLineHeaterEnable", node, ioModule);
|
||
|
||
_scNameAlarmHigh = $"PM.{module}.Heater.{node.GetAttribute("scItemName")}";
|
||
}
|
||
|
||
protected override void HandleMonitor()
|
||
{
|
||
string alarmMeg = "";
|
||
foreach (var ai in _aiGasBoxTemp)
|
||
{
|
||
if (ai is not null && ai.FloatValue >= _alarmHigh)
|
||
alarmMeg += $"{ai.Name} = {ai.FloatValue} ; ";
|
||
}
|
||
if (_alarmCount != alarmMeg.Length)// 报警数量发生变化才复位trig,防止未复位时产生新的报警不提示问题
|
||
_trigIsAlarm.RST = true;
|
||
|
||
if (alarmMeg.Length > 0)//有报警
|
||
{
|
||
_trigIsAlarm.CLK = true;
|
||
if (_trigIsAlarm.Q)
|
||
{
|
||
_doLineHeaterEnable?.SetValue(false, out _);
|
||
EV.PostWarningLog(Module, $"{alarmMeg} over temperature {_alarmHigh}\r\n{Module}.{_doLineHeaterEnable.Name} force off");
|
||
}
|
||
}
|
||
|
||
_alarmCount = alarmMeg.Length;
|
||
}
|
||
|
||
public bool Initialize()
|
||
{
|
||
_alarmHigh = SC.SafeGetValue(_scNameAlarmHigh, double.PositiveInfinity);
|
||
SC.RegisterValueChangedCallback(_scNameAlarmHigh, v => _alarmHigh = (double)v);
|
||
|
||
return true;
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
_trigIsAlarm.RST = true;
|
||
}
|
||
|
||
public void Terminate()
|
||
{
|
||
}
|
||
}
|
||
} |