|
@@ -15,6 +15,7 @@ namespace BPASmartClient.Device |
|
|
public List<Alarm> Alarms { get; set; } = new List<Alarm>(); |
|
|
public List<Alarm> Alarms { get; set; } = new List<Alarm>(); |
|
|
public List<Alarm> HistoryAlarms { get; set; } = new List<Alarm>(); |
|
|
public List<Alarm> HistoryAlarms { get; set; } = new List<Alarm>(); |
|
|
ConcurrentDictionary<string, bool> flagbit = new ConcurrentDictionary<string, bool>(); |
|
|
ConcurrentDictionary<string, bool> flagbit = new ConcurrentDictionary<string, bool>(); |
|
|
|
|
|
ConcurrentDictionary<string, Delay> delays = new ConcurrentDictionary<string, Delay>(); |
|
|
public Action<string> AddAction { get; set; } |
|
|
public Action<string> AddAction { get; set; } |
|
|
public Action<string> RemoveAction { get; set; } |
|
|
public Action<string> RemoveAction { get; set; } |
|
|
public Action ChangeAction { get; set; } |
|
|
public Action ChangeAction { get; set; } |
|
@@ -25,20 +26,25 @@ namespace BPASmartClient.Device |
|
|
/// <param name="Trigger">触发变量</param> |
|
|
/// <param name="Trigger">触发变量</param> |
|
|
/// <param name="text">报警信息</param> |
|
|
/// <param name="text">报警信息</param> |
|
|
/// <param name="edgeType">触发类型,上升沿 或 下降沿</param> |
|
|
/// <param name="edgeType">触发类型,上升沿 或 下降沿</param> |
|
|
public void EdgeAlarm(bool Trigger, string text, AlarmLevel alarmLevel = AlarmLevel.一般报警, AlarmTriggerType edgeType = AlarmTriggerType.Rising) |
|
|
|
|
|
|
|
|
public void EdgeAlarm(bool Trigger, string text, int delay = 2, AlarmLevel alarmLevel = AlarmLevel.一般报警, AlarmTriggerType edgeType = AlarmTriggerType.Rising) |
|
|
{ |
|
|
{ |
|
|
if (!flagbit.ContainsKey(text)) flagbit.TryAdd(text, false); |
|
|
if (!flagbit.ContainsKey(text)) flagbit.TryAdd(text, false); |
|
|
if (edgeType == AlarmTriggerType.Rising ? Trigger : !Trigger) |
|
|
|
|
|
|
|
|
if (!delays.ContainsKey(text)) delays.TryAdd(text, Delay.GetInstance(text)); |
|
|
|
|
|
//if (edgeType == AlarmTriggerType.Rising ? Trigger : !Trigger) |
|
|
|
|
|
if (edgeType == AlarmTriggerType.Rising ? delays[text].Start(Trigger, delay) : delays[text].Start(!Trigger, delay)) |
|
|
{ |
|
|
{ |
|
|
if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text]) |
|
|
if (edgeType == AlarmTriggerType.Rising ? !flagbit[text] : flagbit[text]) |
|
|
{ |
|
|
{ |
|
|
AddAlarm(Trigger, text, alarmLevel); |
|
|
|
|
|
|
|
|
//AddAlarm(Trigger, text, alarmLevel); |
|
|
|
|
|
AddAlarm(Trigger, text.Substring(0, text.LastIndexOf("-")), alarmLevel); |
|
|
|
|
|
|
|
|
flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false; |
|
|
flagbit[text] = edgeType == AlarmTriggerType.Rising ? true : false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
RemoveAlarm(text); |
|
|
|
|
|
|
|
|
//RemoveAlarm(text); |
|
|
|
|
|
RemoveAlarm(text.Substring(0, text.LastIndexOf("-"))); |
|
|
} |
|
|
} |
|
|
if (edgeType == AlarmTriggerType.Rising ? flagbit[text] : !flagbit[text]) flagbit[text] = Trigger; |
|
|
if (edgeType == AlarmTriggerType.Rising ? flagbit[text] : !flagbit[text]) flagbit[text] = Trigger; |
|
|
} |
|
|
} |
|
|