using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using EntityDataSet; using IntelligentControlForsx.Service.WindturbineControl.Domain; using WisdomClient; using WisdomClient.data; namespace IntelligentControlForsx.Service.WindturbineInfo { public class WindturbineStatusSvc { private static Dictionary statusDic = new Dictionary(); private WindturbineStatusSvc() { } class SingletonCreator { internal static readonly WindturbineStatusSvc instance = new WindturbineStatusSvc(); } public static WindturbineStatusSvc Instance { get { return SingletonCreator.instance; } } public static void RefreshStatusSvc(object windturbineListObj) { IList windturbineList = (List)windturbineListObj; Dictionary dic = new Dictionary(); using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { IList list = ctx.view_tspoint.Where( s => s.uniform_code == "FJZT8" && s.thing_type == "windturbine" && windturbineList.Contains(s.thing_id)) .ToList(); Dictionary restultDic = RestfulClient.findLatestByTagNames(list.Select(s => s.id).ToList().ToArray()); foreach (var item in restultDic) { view_tspoint data = list.Where(s => s.id == item.Key).ToList().FirstOrDefault(); if (data != null) { if (!dic.ContainsKey(data.thing_id)) { //风机状态判定 八种状态 统一编码为FJZT8 // 0-停机 //1-上电 //2-待机 //3-启动 //4-并网 //5-故障 //6-维护 //7-离线 //八种状态统计 //TJTS-停机台数 //SDTS-上电台数 //DJTS-待机台数 //QDTS-启动台数 //BWTS-并网台数 //GZTS-故障台数 //WHTS-维护台数 //LXTS-离线台数 int statusValue = Convert.ToInt32(item.Value.getValue()); switch (statusValue) { case 0: { WindturbineStatus status = WindturbineStatus.Stop; dic.Add(data.thing_id, status); } break; case 1: { WindturbineStatus status = WindturbineStatus.OnPower; dic.Add(data.thing_id, status); } break; case 2: { WindturbineStatus status = WindturbineStatus.Standby; dic.Add(data.thing_id, status); } break; case 3: { WindturbineStatus status = WindturbineStatus.Start; dic.Add(data.thing_id, status); } break; case 4: { WindturbineStatus status = WindturbineStatus.Online; dic.Add(data.thing_id, status); } break; case 5: { WindturbineStatus status = WindturbineStatus.Fault; dic.Add(data.thing_id, status); } break; case 6: { WindturbineStatus status = WindturbineStatus.Maintain; dic.Add(data.thing_id, status); } break; case 7: { WindturbineStatus status = WindturbineStatus.Offline; dic.Add(data.thing_id, status); } break; } } } } } statusDic = dic; } public static Dictionary GetStatus() { return statusDic; } } }