WindturbineInfoBridge.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using NEIntelligentControl2.Models.Windturbine;
  2. using NEIntelligentControl2.Service.WebSocket;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace NEIntelligentControl2.Models.Messages
  9. {
  10. /// <summary>
  11. /// 风机信息桥
  12. /// </summary>
  13. class WindturbineInfoBridge : IMessage
  14. {
  15. public List<string> MessageTypes { get; set; } = new List<string>() { "WindturbineInformation".GetConfiguration() };
  16. public Action<Dictionary<string, WindturbineInfo>> Messaged { get; set; }
  17. public async Task OnMessage(object message)
  18. {
  19. try
  20. {
  21. await Task.Run(onmessage);
  22. }
  23. catch (Exception e)
  24. {
  25. Console.WriteLine($"风机信息WebSocket数据解析失败:{e.Message}");
  26. }
  27. void onmessage()
  28. {
  29. var ss = message as Dictionary<string, WindturbineInfo>;
  30. if (ss == null) return;
  31. Messaged?.Invoke(ss);
  32. }
  33. }
  34. }
  35. }