WindturbineStatusSvc.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using EntityDataSet;
  7. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  8. using WisdomClient;
  9. using WisdomClient.data;
  10. namespace IntelligentControlForsx.Service.WindturbineInfo
  11. {
  12. public class WindturbineStatusSvc
  13. {
  14. private static Dictionary<string, WindturbineStatus> statusDic = new Dictionary<string, WindturbineStatus>();
  15. private WindturbineStatusSvc()
  16. {
  17. }
  18. class SingletonCreator
  19. {
  20. internal static readonly WindturbineStatusSvc instance = new WindturbineStatusSvc();
  21. }
  22. public static WindturbineStatusSvc Instance
  23. {
  24. get { return SingletonCreator.instance; }
  25. }
  26. public static void RefreshStatusSvc(object windturbineListObj)
  27. {
  28. IList<string> windturbineList = (List<string>)windturbineListObj;
  29. Dictionary<string, WindturbineStatus> dic = new Dictionary<string, WindturbineStatus>();
  30. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  31. {
  32. IList<view_tspoint> list =
  33. ctx.view_tspoint.Where(
  34. s => s.uniform_code == "FJZT8" && s.thing_type == "windturbine" && windturbineList.Contains(s.thing_id))
  35. .ToList();
  36. Dictionary<string, TsData> restultDic = RestfulClient.findLatestByTagNames(list.Select(s => s.id).ToList().ToArray());
  37. foreach (var item in restultDic)
  38. {
  39. view_tspoint data = list.Where(s => s.id == item.Key).ToList().FirstOrDefault();
  40. if (data != null)
  41. {
  42. if (!dic.ContainsKey(data.thing_id))
  43. {
  44. //风机状态判定 八种状态 统一编码为FJZT8
  45. // 0-停机
  46. //1-上电
  47. //2-待机
  48. //3-启动
  49. //4-并网
  50. //5-故障
  51. //6-维护
  52. //7-离线
  53. //八种状态统计
  54. //TJTS-停机台数
  55. //SDTS-上电台数
  56. //DJTS-待机台数
  57. //QDTS-启动台数
  58. //BWTS-并网台数
  59. //GZTS-故障台数
  60. //WHTS-维护台数
  61. //LXTS-离线台数
  62. int statusValue = Convert.ToInt32(item.Value.getValue());
  63. switch (statusValue)
  64. {
  65. case 0:
  66. {
  67. WindturbineStatus status = WindturbineStatus.Stop;
  68. dic.Add(data.thing_id, status);
  69. }
  70. break;
  71. case 1:
  72. {
  73. WindturbineStatus status = WindturbineStatus.OnPower;
  74. dic.Add(data.thing_id, status);
  75. }
  76. break;
  77. case 2:
  78. {
  79. WindturbineStatus status = WindturbineStatus.Standby;
  80. dic.Add(data.thing_id, status);
  81. }
  82. break;
  83. case 3:
  84. {
  85. WindturbineStatus status = WindturbineStatus.Start;
  86. dic.Add(data.thing_id, status);
  87. }
  88. break;
  89. case 4:
  90. {
  91. WindturbineStatus status = WindturbineStatus.Online;
  92. dic.Add(data.thing_id, status);
  93. }
  94. break;
  95. case 5:
  96. {
  97. WindturbineStatus status = WindturbineStatus.Fault;
  98. dic.Add(data.thing_id, status);
  99. }
  100. break;
  101. case 6:
  102. {
  103. WindturbineStatus status = WindturbineStatus.Maintain;
  104. dic.Add(data.thing_id, status);
  105. }
  106. break;
  107. case 7:
  108. {
  109. WindturbineStatus status = WindturbineStatus.Offline;
  110. dic.Add(data.thing_id, status);
  111. }
  112. break;
  113. }
  114. }
  115. }
  116. }
  117. }
  118. statusDic = dic;
  119. }
  120. public static Dictionary<string, WindturbineStatus> GetStatus()
  121. {
  122. return statusDic;
  123. }
  124. }
  125. }