diff --git a/MECF.Framework.RT.EquipmentLibrary/Devices/IoLineHeater.cs b/MECF.Framework.RT.EquipmentLibrary/Devices/IoLineHeater.cs index 725cdbe..4aecb4d 100644 --- a/MECF.Framework.RT.EquipmentLibrary/Devices/IoLineHeater.cs +++ b/MECF.Framework.RT.EquipmentLibrary/Devices/IoLineHeater.cs @@ -25,11 +25,13 @@ namespace Aitex.Core.RT.Device.Devices protected int _alarmCount; + protected string _scWarningLog; private readonly LineHeaterData _lineHeaterData = new(); + public LineHeaterData lineHeaterData { - get + get { _lineHeaterData.LineHeaterLaber = Display; _lineHeaterData.ScHighTemp = _alarmHigh; @@ -46,6 +48,14 @@ namespace Aitex.Core.RT.Device.Devices _doLineHeaterEnable = ParseDoNode("doLineHeaterEnable", node, ioModule); _scNameAlarmHigh = $"{ScBasePath}.{node.GetAttribute("scAlarmHigh")}"; + + var scWarningLog = node.GetAttribute("scWarningLog"); + _scWarningLog = scWarningLog == "" ? scWarningLog : SC.GetStringValue($"{ScBasePath}.{scWarningLog}"); + + if (scWarningLog != "") + { + SC.RegisterValueChangedCallback($"{ScBasePath}.{scWarningLog}", (obj) => { _scWarningLog = (string)obj; }); + } } protected override void HandleMonitor() @@ -59,19 +69,26 @@ namespace Aitex.Core.RT.Device.Devices { if (_doLineHeaterEnable == null) { - EV.PostWarningLog(Module, - $"{_aiTemp.Name} {_aiTemp.FloatValue} over temperature {_alarmHigh} but doLineHeaterEnable can not be off since it's not defined"); + PostLog($"{_aiTemp.Name} {_aiTemp.FloatValue} over temperature {_alarmHigh}"); } else { _doLineHeaterEnable.SetValue(false, out _); - EV.PostWarningLog(Module, - $"{_aiTemp.Name} {_aiTemp.FloatValue} over temperature {_alarmHigh}\r\n{Module}.{_doLineHeaterEnable.Name} force off"); + PostLog($"{_aiTemp.Name} {_aiTemp.FloatValue} over temperature {_alarmHigh}\r\n{Module}.{_doLineHeaterEnable.Name} force off"); } + } } } + private void PostLog(string log) + { + if (_scWarningLog == "Alarm") + EV.PostAlarmLog(Module, log); + else + EV.PostWarningLog(Module, log); + } + public bool Initialize() { DATA.Subscribe($"{Module}.LineHeater.{Display}", () => _aiTemp.FloatValue);