123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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<string, WindturbineStatus> statusDic = new Dictionary<string, WindturbineStatus>();
- 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<string> windturbineList = (List<string>)windturbineListObj;
- Dictionary<string, WindturbineStatus> dic = new Dictionary<string, WindturbineStatus>();
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- IList<view_tspoint> list =
- ctx.view_tspoint.Where(
- s => s.uniform_code == "FJZT8" && s.thing_type == "windturbine" && windturbineList.Contains(s.thing_id))
- .ToList();
- Dictionary<string, TsData> 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<string, WindturbineStatus> GetStatus()
- {
- return statusDic;
- }
- }
- }
|