修复报警文本逻辑
This commit is contained in:
@@ -369,22 +369,23 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
{
|
||||
string limit = string.Empty;
|
||||
string ex = string.Empty;
|
||||
string text = string.Empty;
|
||||
|
||||
AlarmEnum alarmEnum = AlarmEnum.None;
|
||||
|
||||
if (item.DataTypeEnum.GetNetType() == typeof(bool))
|
||||
{
|
||||
|
||||
alarmEnum = AlarmHostServiceHelpers.GetBoolAlarmCode(item, out limit, out ex);
|
||||
alarmEnum = AlarmHostServiceHelpers.GetBoolAlarmCode(item, out limit, out ex,out text);
|
||||
}
|
||||
else
|
||||
{
|
||||
alarmEnum = AlarmHostServiceHelpers.GetDecimalAlarmDegree(item, out limit, out ex);
|
||||
alarmEnum = AlarmHostServiceHelpers.GetDecimalAlarmDegree(item, out limit, out ex, out text);
|
||||
}
|
||||
if (alarmEnum == AlarmEnum.None)
|
||||
{
|
||||
//需恢复报警,如果存在的话
|
||||
AlarmChange(item, null, EventEnum.Finish, alarmEnum);
|
||||
AlarmChange(item, null, text, EventEnum.Finish, alarmEnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -396,19 +397,19 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
AlarmChange(item, limit, EventEnum.Alarm, alarmEnum);
|
||||
AlarmChange(item, limit, text, EventEnum.Alarm, alarmEnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AlarmChange(item, limit, EventEnum.Alarm, alarmEnum);
|
||||
AlarmChange(item, limit, text, EventEnum.Alarm, alarmEnum);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void AlarmChange(CollectVariableRunTime item, object limit, EventEnum eventEnum, AlarmEnum alarmEnum)
|
||||
private void AlarmChange(CollectVariableRunTime item, object limit,string text, EventEnum eventEnum, AlarmEnum alarmEnum)
|
||||
{
|
||||
if (eventEnum == EventEnum.Finish)
|
||||
{
|
||||
@@ -434,6 +435,7 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
item.EventTypeEnum = eventEnum;
|
||||
item.AlarmLimit = limit.ToString();
|
||||
item.AlarmCode = item.Value.ToString();
|
||||
item.AlarmText = text;
|
||||
item.AlarmTime = DateTime.UtcNow;
|
||||
item.EventTime = DateTime.UtcNow;
|
||||
}
|
||||
@@ -444,6 +446,7 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
item.EventTypeEnum = eventEnum;
|
||||
item.AlarmLimit = oldAlarm.AlarmLimit;
|
||||
item.AlarmCode = item.Value.ToString();
|
||||
item.AlarmText = text;
|
||||
item.EventTime = DateTime.UtcNow;
|
||||
}
|
||||
else if (eventEnum == EventEnum.Check)
|
||||
@@ -452,6 +455,7 @@ public class AlarmHostService : BackgroundService, ISingleton
|
||||
item.EventTypeEnum = eventEnum;
|
||||
item.AlarmLimit = limit.ToString();
|
||||
item.AlarmCode = item.Value.ToString();
|
||||
item.AlarmText = text;
|
||||
item.EventTime = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
|
@@ -8,20 +8,23 @@ public static class AlarmHostServiceHelpers
|
||||
/// <summary>
|
||||
/// 获取bool报警类型
|
||||
/// </summary>
|
||||
public static AlarmEnum GetBoolAlarmCode(CollectVariableRunTime tag, out string limit, out string expressions)
|
||||
public static AlarmEnum GetBoolAlarmCode(CollectVariableRunTime tag, out string limit, out string expressions, out string text)
|
||||
{
|
||||
limit = string.Empty;
|
||||
expressions = string.Empty;
|
||||
text = string.Empty;
|
||||
if (tag.BoolCloseAlarmEnable && tag.Value.ToBoolean() == false)
|
||||
{
|
||||
limit = false.ToString();
|
||||
expressions = tag.BoolCloseRestrainExpressions;
|
||||
text = tag.BoolCloseAlarmText;
|
||||
return AlarmEnum.Close;
|
||||
}
|
||||
if (tag.BoolOpenAlarmEnable && tag.Value.ToBoolean() == true)
|
||||
{
|
||||
limit = true.ToString();
|
||||
expressions = tag.BoolOpenRestrainExpressions;
|
||||
text = tag.BoolOpenAlarmText;
|
||||
return AlarmEnum.Open;
|
||||
}
|
||||
return AlarmEnum.None;
|
||||
@@ -30,15 +33,17 @@ public static class AlarmHostServiceHelpers
|
||||
/// <summary>
|
||||
/// 获取value报警类型
|
||||
/// </summary>
|
||||
public static AlarmEnum GetDecimalAlarmDegree(CollectVariableRunTime tag, out string limit, out string expressions)
|
||||
public static AlarmEnum GetDecimalAlarmDegree(CollectVariableRunTime tag, out string limit, out string expressions, out string text)
|
||||
{
|
||||
limit = string.Empty;
|
||||
expressions = string.Empty;
|
||||
text = string.Empty;
|
||||
|
||||
if (tag.HHAlarmEnable && tag.Value.ToDecimal() > tag.HHAlarmCode.ToDecimal())
|
||||
{
|
||||
limit = tag.HHAlarmCode.ToString();
|
||||
expressions = tag.HHRestrainExpressions;
|
||||
text = tag.HHAlarmText;
|
||||
return AlarmEnum.HH;
|
||||
}
|
||||
|
||||
@@ -46,6 +51,7 @@ public static class AlarmHostServiceHelpers
|
||||
{
|
||||
limit = tag.HAlarmCode.ToString();
|
||||
expressions = tag.HRestrainExpressions;
|
||||
text = tag.HAlarmText;
|
||||
return AlarmEnum.H;
|
||||
}
|
||||
|
||||
@@ -53,12 +59,14 @@ public static class AlarmHostServiceHelpers
|
||||
{
|
||||
limit = tag.LAlarmCode.ToString();
|
||||
expressions = tag.LRestrainExpressions;
|
||||
text = tag.LAlarmText;
|
||||
return AlarmEnum.L;
|
||||
}
|
||||
if (tag.LLAlarmEnable && tag.Value.ToDecimal() < tag.LLAlarmCode.ToDecimal())
|
||||
{
|
||||
limit = tag.LLAlarmCode.ToString();
|
||||
expressions = tag.LLRestrainExpressions;
|
||||
text = tag.LLAlarmText;
|
||||
return AlarmEnum.LL;
|
||||
}
|
||||
return AlarmEnum.None;
|
||||
|
Reference in New Issue
Block a user