2023-08-28 14:44:34 +08:00
|
|
|
|
using Aitex.Core.RT.Event;
|
2023-08-15 17:42:28 +08:00
|
|
|
|
using Aitex.Core.RT.IOCore;
|
|
|
|
|
using Aitex.Core.RT.SCCore;
|
|
|
|
|
using Aitex.Core.Util;
|
|
|
|
|
using System.Collections.Generic;
|
2023-10-13 16:31:59 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
2023-08-15 17:42:28 +08:00
|
|
|
|
using System.Xml;
|
|
|
|
|
|
2023-08-16 13:50:48 +08:00
|
|
|
|
namespace Aitex.Core.RT.Device.Devices
|
2023-08-15 17:42:28 +08:00
|
|
|
|
{
|
|
|
|
|
public class IoGasBoxTemp : BaseDevice, IDevice
|
|
|
|
|
{
|
|
|
|
|
//配置中标记的AI名称
|
2023-08-28 14:44:34 +08:00
|
|
|
|
protected readonly List<string> _aiGasBoxTempName = new List<string>()
|
2023-08-15 17:42:28 +08:00
|
|
|
|
{
|
|
|
|
|
"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();
|
|
|
|
|
|
2023-08-28 14:44:34 +08:00
|
|
|
|
protected int _alarmCount;
|
2023-08-16 13:50:48 +08:00
|
|
|
|
|
2023-08-15 17:42:28 +08:00
|
|
|
|
public IoGasBoxTemp(string module, XmlElement node, string ioModule = "") : base(module, node, ioModule)
|
|
|
|
|
{
|
|
|
|
|
_aiGasBoxTemp = new List<AIAccessor>();
|
|
|
|
|
foreach (var aiName in _aiGasBoxTempName)
|
|
|
|
|
{
|
2023-08-16 13:50:48 +08:00
|
|
|
|
_aiGasBoxTemp.Add(ParseAiNode(aiName, node, ioModule));
|
2023-08-15 17:42:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_doLineHeaterEnable = ParseDoNode("doLineHeaterEnable", node, ioModule);
|
|
|
|
|
|
2023-08-28 14:44:34 +08:00
|
|
|
|
_scNameAlarmHigh = $"PM.{module}.Heater.{node.GetAttribute("scItemName")}";
|
2023-10-13 16:31:59 +08:00
|
|
|
|
|
|
|
|
|
Debug.Assert(_doLineHeaterEnable != null, "doLineHeaterEnable is not defined.");
|
2023-08-15 17:42:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void HandleMonitor()
|
|
|
|
|
{
|
2023-10-13 16:31:59 +08:00
|
|
|
|
var alarmMsg = _aiGasBoxTemp.Where(ai => _alarmHigh > 0 && ai != null && ai.FloatValue >= _alarmHigh)
|
|
|
|
|
.Aggregate("", (current, ai) => current + $"{ai.Name} = {ai.FloatValue} ; ");
|
|
|
|
|
|
|
|
|
|
if (_alarmCount != alarmMsg.Length)// 报警数量发生变化才复位trig,防止未复位时产生新的报警不提示问题
|
2023-08-16 13:50:48 +08:00
|
|
|
|
_trigIsAlarm.RST = true;
|
|
|
|
|
|
2023-10-13 16:31:59 +08:00
|
|
|
|
if (alarmMsg.Length > 0)//有报警
|
2023-08-15 17:42:28 +08:00
|
|
|
|
{
|
|
|
|
|
_trigIsAlarm.CLK = true;
|
2023-08-16 13:50:48 +08:00
|
|
|
|
if (_trigIsAlarm.Q)
|
|
|
|
|
{
|
2023-10-13 16:31:59 +08:00
|
|
|
|
if (_doLineHeaterEnable == null)
|
|
|
|
|
{
|
|
|
|
|
EV.PostWarningLog(Module,
|
|
|
|
|
$"{alarmMsg} over temperature {_alarmHigh} but doLineHeaterEnable can not be off since it's not defined");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_doLineHeaterEnable.SetValue(false, out _);
|
|
|
|
|
EV.PostWarningLog(Module,
|
|
|
|
|
$"{alarmMsg} over temperature {_alarmHigh}\r\n{Module}.{_doLineHeaterEnable.Name} force off");
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-16 13:50:48 +08:00
|
|
|
|
}
|
2023-08-15 17:42:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-13 16:31:59 +08:00
|
|
|
|
_alarmCount = alarmMsg.Length;
|
2023-08-15 17:42:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Initialize()
|
|
|
|
|
{
|
|
|
|
|
_alarmHigh = SC.SafeGetValue(_scNameAlarmHigh, double.PositiveInfinity);
|
|
|
|
|
SC.RegisterValueChangedCallback(_scNameAlarmHigh, v => _alarmHigh = (double)v);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
2023-08-16 13:50:48 +08:00
|
|
|
|
_trigIsAlarm.RST = true;
|
2023-08-15 17:42:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Terminate()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-28 14:44:34 +08:00
|
|
|
|
}
|