GridViewDataSvc.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using System.Windows.Forms;
  9. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  10. using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
  11. using Gyee_Control.Svc.Cache;
  12. namespace IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc
  13. {
  14. public class GridViewDataSvc
  15. {
  16. private static GridViewDataSvc gridViewDataSvc = new GridViewDataSvc();
  17. private GridViewDataSvc()
  18. {
  19. }
  20. public static GridViewDataSvc GetGridViewDataSvc()
  21. {
  22. return gridViewDataSvc;
  23. }
  24. public DataTable GetDataTableHeaders()
  25. {
  26. DataTable dataTable = new DataTable();
  27. dataTable.Columns.Add("风机名称");
  28. dataTable.Columns.Add("风速");
  29. dataTable.Columns.Add("功率");
  30. dataTable.Columns.Add("状态");
  31. dataTable.Columns.Add("挂牌");
  32. dataTable.Columns.Add("发电机转速");
  33. dataTable.Columns.Add("叶轮转速");
  34. dataTable.Columns.Add("转速限值");
  35. dataTable.Columns.Add("桨叶角度1");
  36. dataTable.Columns.Add("桨叶角度2");
  37. dataTable.Columns.Add("桨叶角度3");
  38. dataTable.Columns.Add("对风角度");
  39. dataTable.Columns.Add("偏航位置");
  40. return dataTable;
  41. }
  42. public DataTable GetDataTableByTimer(string stationCode, string project)
  43. {
  44. DataTable resultTable = GetDataTableHeaders();
  45. bool isNull = false;
  46. string[] project1 = { "SG01_01", "SG01_02", "SG01_03", "SG01_04", "SG01_05", "SG01_06", "SG01_07", "SG01_08", "SG01_09", "SG01_10", "SG01_11", "SG01_12", "SG01_13", "SG01_14", "SG01_15", "SG01_16", "SG01_17", "SG01_18", "SG01_19", "SG01_20", "SG01_21", "SG01_22", "SG01_23", "SG01_24", "SG01_25", "SG01_26", "SG01_27", "SG01_28", "SG01_29", "SG01_30", "SG01_31", "SG01_32", "SG01_33" };
  47. string[] project2 = { "SG01_34", "SG01_35", "SG01_36", "SG01_37", "SG01_38", "SG01_39", "SG01_40", "SG01_41", "SG01_42", "SG01_43", "SG01_44", "SG01_45", "SG01_46", "SG01_47", "SG01_48", "SG01_49", "SG01_50", "SG01_51", "SG01_52", "SG01_53", "SG01_54", "SG01_55", "SG01_56", "SG01_57", "SG01_58", "SG01_59", "SG01_60", "SG01_61", "SG01_62", "SG01_63", "SG01_64", "SG01_65", "SG01_66" };
  48. string[] project3 = { "SG01_67", "SG01_68", "SG01_69", "SG01_70", "SG01_71", "SG01_72", "SG01_73", "SG01_74", "SG01_75", "SG01_76", "SG01_77", "SG01_78", "SG01_79", "SG01_80", "SG01_81", "SG01_82", "SG01_83", "SG01_84", "SG01_85", "SG01_86", "SG01_87", "SG01_88", "SG01_89", "SG01_90", "SG01_91" };
  49. string[] project4 = { "SG01_100", "SG01_101", "SG01_102", "SG01_103", "SG01_104", "SG01_105", "SG01_106", "SG01_107", "SG01_108", "SG01_109", "SG01_110", "SG01_111", "SG01_112", "SG01_113", "SG01_114", "SG01_115", "SG01_116", "SG01_92", "SG01_93", "SG01_94", "SG01_95", "SG01_96", "SG01_97", "SG01_98", "SG01_99" };
  50. IList<string> projectList = new List<string>();
  51. if (project == "1")
  52. {
  53. projectList = project1.ToList();
  54. }
  55. if (project == "2")
  56. {
  57. projectList = project2.ToList();
  58. }
  59. if (project == "3")
  60. {
  61. projectList = project3.ToList();
  62. }
  63. if (project == "4")
  64. {
  65. projectList = project4.ToList();
  66. }
  67. IList<WindturbinePointData> pointDataList = CacheInfo.CacheWindturbineDataList.Where(s => s.StationId == stationCode && projectList.Contains(s.WindturbineName)).ToList().OrderBy(k => k.WindturbineName).ToList().OrderBy(s => Convert.ToInt32(Regex.Replace(s.WindturbineName, "[a-zA-Z]", "").Replace("_", ""))).ToList();
  68. //根据风机编号进行排序
  69. for (int i = 0; i < pointDataList.Count; i++)
  70. {
  71. if (pointDataList[i] == null)
  72. isNull = true;
  73. }
  74. if (!isNull)
  75. {
  76. for (int i = 0; i < pointDataList.Count; i++)
  77. {
  78. #region 生成GridView信息
  79. DataRow row = resultTable.NewRow();
  80. row["风机名称"] = pointDataList[i].WindturbineName;
  81. row["风速"] = pointDataList[i].WindSpeed.ToString("f2") + "m/s";
  82. row["功率"] = pointDataList[i].Power.ToString("f2") + "kW";
  83. switch (pointDataList[i].Status)
  84. {
  85. case WindturbineStatus.Standby:
  86. row["状态"] = "待机";
  87. break;
  88. case WindturbineStatus.OnPower:
  89. row["状态"] = "上电";
  90. break;
  91. case WindturbineStatus.Maintain:
  92. row["状态"] = "维护";
  93. break;
  94. case WindturbineStatus.Fault:
  95. row["状态"] = "故障";
  96. break;
  97. case WindturbineStatus.Start:
  98. row["状态"] = "启动";
  99. break;
  100. case WindturbineStatus.Online:
  101. row["状态"] = "并网";
  102. break;
  103. case WindturbineStatus.Stop:
  104. row["状态"] = "停机";
  105. break;
  106. case WindturbineStatus.Offline:
  107. row["状态"] = "离线";
  108. break;
  109. }
  110. switch (pointDataList[i].HungType)
  111. {
  112. case HungType.UnLock:
  113. row["挂牌"] = "正常";
  114. break;
  115. case HungType.StationCheckLock:
  116. row["挂牌"] = "场内受累检修";
  117. break;
  118. case HungType.StationFaulLockt:
  119. row["挂牌"] = "场内受累故障";
  120. break;
  121. case HungType.StationPowerLineLock:
  122. row["挂牌"] = "场外受累电网";
  123. break;
  124. case HungType.StationWeatherLock:
  125. row["挂牌"] = "场外受累天气";
  126. break;
  127. case HungType.FaultLock:
  128. row["挂牌"] = "故障检修";
  129. break;
  130. case HungType.CheckLock:
  131. row["挂牌"] = "检修";
  132. break;
  133. }
  134. row["发电机转速"] = pointDataList[i].AlternatorSpeed.ToString("f2") + "rpm";
  135. row["叶轮转速"] = pointDataList[i].LaminaSpeed.ToString("f2") + "rpm";
  136. row["转速限值"] = "17rpm";
  137. row["桨叶角度1"] = pointDataList[i].LaminaAngle1.ToString("f2") + "°";
  138. row["桨叶角度2"] = pointDataList[i].LaminaAngle2.ToString("f2") + "°";
  139. row["桨叶角度3"] = pointDataList[i].LaminaAngle3.ToString("f2") + "°";
  140. row["对风角度"] = pointDataList[i].WindAngle.ToString("f2") + "°";
  141. row["偏航位置"] = pointDataList[i].YawPosition.ToString("f2") + "°";
  142. resultTable.Rows.Add(row);
  143. #endregion
  144. }
  145. }
  146. return resultTable;
  147. }
  148. }
  149. }