AlarmManager.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using NEIntelligentControl2.Models.Alarm;
  2. using NEIntelligentControl2.Models.Messages;
  3. using NEIntelligentControl2.Service.WebSocket;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace NEIntelligentControl2.Service.Alarm
  10. {
  11. /// <summary>
  12. /// 报警管理
  13. /// </summary>
  14. public class AlarmManager
  15. {
  16. public Action<List<FaultInfoModel>> OnFaultCount { get; set; }
  17. public Action<List<AlarmInfo>> OnAlarmCount { get; set; }
  18. private MessageBridge _MessageBridge;
  19. private FaultCountBridge _FaultCountBridge;
  20. private AlarmCountBridge _AlarmCountBridge;
  21. public AlarmManager(MessageBridge mb)
  22. {
  23. _MessageBridge = mb;
  24. _FaultCountBridge = new FaultCountBridge() { Messaged = OnFaultCountMessaged };
  25. _AlarmCountBridge = new AlarmCountBridge() { Messaged = OnAlarmCountMessaged };
  26. _MessageBridge.Register(_FaultCountBridge);
  27. _MessageBridge.Register(_AlarmCountBridge);
  28. }
  29. private void OnAlarmCountMessaged(List<AlarmInfo> obj)
  30. {
  31. try
  32. {
  33. OnAlarmCount?.Invoke(obj);
  34. }
  35. catch { }
  36. }
  37. private void OnFaultCountMessaged(List<FaultInfoModel> fims)
  38. {
  39. try
  40. {
  41. OnFaultCount?.Invoke(fims);
  42. }
  43. catch { }
  44. }
  45. }
  46. }