PredictService.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.Model;
  8. using IntelligentControlForsx.Common;
  9. using WisdomClient.data;
  10. using WisdomClient;
  11. using log4net;
  12. namespace IntelligentControlForsx.Service
  13. {
  14. public class PredictService
  15. {
  16. //private ILog logger = LogManager.GetLogger("AppInfoLog");
  17. public static Random random = new Random();
  18. public static StationPredict GetStationPredict(String stationId)
  19. {
  20. StationPredict sp = new StationPredict(stationId);
  21. try
  22. {
  23. StationStatus ss = CacheService.Instance.StationStatusDictionary[stationId];
  24. ss.RefreshBasicWindturbineStatus();
  25. var wsDict = ss.WindturbineStatusDictionary;
  26. foreach(var ws in wsDict.Values)
  27. {
  28. //限电5》运行1》待机0》维护4》故障2》离线3
  29. // case 0: //停机状态
  30. // return Color.FromArgb(176, 151, 63);
  31. //case 1: //上电状态
  32. // return Color.FromArgb(177, 14, 126);
  33. //case 2: //待机状态
  34. // return Color.FromArgb(15, 141, 106);
  35. //case 3: //启动状态
  36. // return Color.FromArgb(14, 72, 91);
  37. //case 4: //并网状态
  38. // return Color.FromArgb(15, 135, 170);
  39. //case 5: //故障状态
  40. // return Color.FromArgb(170, 15, 59);
  41. //case 6: //维护状态
  42. // return Color.FromArgb(204, 83, 51);
  43. //case 7: //离线状态
  44. // return Color.FromArgb(134, 150, 165);
  45. if (ws.GetStatus() == 4 || ws.GetStatus() == 3)
  46. {
  47. if (sp.StopList.Count < 10)
  48. {
  49. sp.StopList.Add(ws);
  50. }
  51. } else if (ws.GetStatus() == 2)
  52. {
  53. if (sp.StartupList.Count < 10)
  54. {
  55. sp.StartupList.Add(ws);
  56. }
  57. if (sp.MaintainList.Count < 10)
  58. {
  59. sp.MaintainList.Add(ws);
  60. }
  61. } else if (ws.GetStatus() == 5) {
  62. sp.ResetList.Add(ws);
  63. } else if (ws.GetStatus() == 6)
  64. {
  65. if (sp.CancelMaintainList.Count < 10)
  66. {
  67. sp.CancelMaintainList.Add(ws);
  68. }
  69. }
  70. else
  71. {
  72. }
  73. }
  74. } catch (Exception ex)
  75. {
  76. Console.WriteLine(ex.Message);
  77. //logger.Error(ex);
  78. }
  79. return sp;
  80. }
  81. public static IList<WindturbineStatus> GetWindturbineStatus(IList<string> wtIds, string stationId)
  82. {
  83. IList<WindturbineStatus> result = new List<WindturbineStatus>();
  84. try
  85. {
  86. StationStatus ss = CacheService.Instance.StationStatusDictionary[stationId];
  87. ss.RefreshBasicWindturbineStatus();
  88. var wsDict = ss.WindturbineStatusDictionary;
  89. foreach (var ws in wsDict.Values)
  90. {
  91. if (wtIds.Contains(ws.WindturbineId))
  92. {
  93. result.Add(ws);
  94. }
  95. }
  96. }
  97. catch (Exception ex)
  98. {
  99. Console.WriteLine(ex.Message);
  100. }
  101. return result;
  102. }
  103. }
  104. }