1234567891011121314151617181920212223242526272829303132333435363738 |
- using NEIntelligentControl2.Models.Windturbine;
- using NEIntelligentControl2.Service.WebSocket;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NEIntelligentControl2.Models.Messages
- {
- /// <summary>
- /// 风机信息桥
- /// </summary>
- class WindturbineInfoBridge : IMessage
- {
- public List<string> MessageTypes { get; set; } = new List<string>() { "WindturbineInformation".GetConfiguration() };
- public Action<Dictionary<string, WindturbineInfo>> Messaged { get; set; }
- public async Task OnMessage(object message)
- {
- try
- {
- await Task.Run(onmessage);
- }
- catch (Exception e)
- {
- Console.WriteLine($"风机信息WebSocket数据解析失败:{e.Message}");
- }
- void onmessage()
- {
- var ss = message as Dictionary<string, WindturbineInfo>;
- if (ss == null) return;
- Messaged?.Invoke(ss);
- }
- }
- }
- }
|