ControlLine.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  11. using Gyee_Control.Svc.Cache;
  12. namespace IntelligentControlForsx.MyControls
  13. {
  14. public partial class ControlLine : UserControl
  15. {
  16. public ControlLine()
  17. {
  18. InitializeComponent();
  19. }
  20. #region 风机编号
  21. private string windturbineId;
  22. public string WindturbineId
  23. {
  24. set
  25. {
  26. windturbineId = value;
  27. txtWindturbine.Text = value;
  28. }
  29. get { return windturbineId; }
  30. }
  31. #endregion
  32. #region 风速
  33. private string windSpeed;
  34. public string WindSpeed
  35. {
  36. set
  37. {
  38. windSpeed = value;
  39. txtWindSpeed.Text = value;
  40. }
  41. get { return windSpeed; }
  42. }
  43. #endregion
  44. #region 功率
  45. private string power;
  46. public string Power
  47. {
  48. set
  49. {
  50. power = value;
  51. txtPower.Text = value;
  52. }
  53. get { return power; }
  54. }
  55. #endregion
  56. #region 状态
  57. private string status;
  58. public string Status
  59. {
  60. set
  61. {
  62. status = value;
  63. txtStatus.Text = value;
  64. }
  65. get { return status; }
  66. }
  67. #endregion
  68. #region 发电机转速
  69. private string alternatorSpeed;
  70. public string AlternatorSpeed
  71. {
  72. set
  73. {
  74. alternatorSpeed = value;
  75. txtAlternatorSpeed.Text = value;
  76. }
  77. get { return alternatorSpeed; }
  78. }
  79. #endregion
  80. #region 叶轮转速
  81. private string laminaSpeed;
  82. public string LaminaSpeed
  83. {
  84. set
  85. {
  86. laminaSpeed = value;
  87. txtLaminaSpeed.Text = value;
  88. }
  89. get { return laminaSpeed; }
  90. }
  91. #endregion
  92. #region 限速值
  93. private string limitSpeed;
  94. public string LimitSpeed
  95. {
  96. set
  97. {
  98. limitSpeed = value;
  99. txtLimitSpeed.Text = value;
  100. }
  101. get { return limitSpeed; }
  102. }
  103. #endregion
  104. #region 桨叶角度1
  105. private string laminaAngle1;
  106. public string LaminaAngle1
  107. {
  108. set
  109. {
  110. laminaAngle1 = value;
  111. txtLaminaAngle1.Text = value;
  112. }
  113. get { return laminaAngle1; }
  114. }
  115. #endregion
  116. #region 桨叶角度2
  117. private string laminaAngle2;
  118. public string LaminaAngle2
  119. {
  120. set
  121. {
  122. laminaAngle2 = value;
  123. txtLaminaAngle2.Text = value;
  124. }
  125. get { return laminaAngle2; }
  126. }
  127. #endregion
  128. #region 桨叶角度3
  129. private string laminaAngle3;
  130. public string LaminaAngle3
  131. {
  132. set
  133. {
  134. laminaAngle3 = value;
  135. txtLaminaAngle3.Text = value;
  136. }
  137. get { return laminaAngle3; }
  138. }
  139. #endregion
  140. #region 对风角
  141. private string windAngle;
  142. public string WindAngle
  143. {
  144. set
  145. {
  146. windAngle = value;
  147. txtWindAngle.Text = value;
  148. }
  149. get { return windAngle; }
  150. }
  151. #endregion
  152. #region 偏航位置
  153. private string yawPosition;
  154. public string YawPosition
  155. {
  156. set
  157. {
  158. yawPosition = value;
  159. txtYawPosition.Text = value;
  160. }
  161. get { return yawPosition; }
  162. }
  163. #endregion
  164. private bool isCheck;
  165. public bool IsCheck
  166. {
  167. set
  168. {
  169. isCheck = value;
  170. ckbWindturbine.Checked = value;
  171. }
  172. get { return isCheck; }
  173. }
  174. /// <summary>
  175. /// 绑定数据方法
  176. /// </summary>
  177. /// <param name="data">信息</param>
  178. /// <param name="row">所属行</param>
  179. /// <param name="isHead">是否为表头</param>
  180. public void BindData(WindturbinePointData data, int row, bool isHead)
  181. {
  182. if (isHead)
  183. {
  184. WindturbineId = "风机编号";
  185. WindSpeed = "实时风速";
  186. Power = "功率";
  187. Status = "状态";
  188. AlternatorSpeed = "发电机转速";
  189. LaminaSpeed = "叶轮转速";
  190. LimitSpeed = "限速值";
  191. LaminaAngle1 = "桨叶1角度";
  192. LaminaAngle2 = "桨叶2角度";
  193. LaminaAngle3 = "桨叶2角度";
  194. WindAngle = "对风角";
  195. YawPosition = "偏航位置";
  196. panel1.BackColor = Color.FromArgb(26, 71, 94);
  197. panel3.BackColor = Color.FromArgb(26, 71, 94);
  198. ckbWindturbine.Visible = false;
  199. panel1.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  200. panel3.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  201. ckbWindturbine.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  202. txtWindturbine.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  203. txtWindAngle.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  204. txtLaminaAngle3.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  205. txtLaminaAngle2.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  206. txtLaminaAngle1.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  207. txtLimitSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  208. txtLaminaSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  209. txtAlternatorSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  210. txtStatus.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  211. txtPower.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  212. txtWindSpeed.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  213. txtYawPosition.Font = new Font("微软雅黑", (float)11.25, FontStyle.Bold);
  214. }
  215. else
  216. {
  217. if (data.IsSelect)
  218. {
  219. panel1.BackColor = Color.FromArgb(51, 144, 255);
  220. panel3.BackColor = Color.FromArgb(51, 144, 255);
  221. ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  222. txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  223. txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
  224. txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
  225. txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
  226. txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
  227. txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
  228. txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
  229. txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
  230. txtStatus.BackColor = Color.FromArgb(51, 144, 255);
  231. txtPower.BackColor = Color.FromArgb(51, 144, 255);
  232. txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
  233. txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
  234. }
  235. else
  236. {
  237. if (row % 2 == 0)
  238. {
  239. panel1.BackColor = Color.FromArgb(0, 52, 73);
  240. panel3.BackColor = Color.FromArgb(0, 52, 73);
  241. ckbWindturbine.BackColor = Color.FromArgb(0, 52, 73);
  242. txtWindturbine.BackColor = Color.FromArgb(0, 52, 73);
  243. txtWindAngle.BackColor = Color.FromArgb(0, 52, 73);
  244. txtLaminaAngle3.BackColor = Color.FromArgb(0, 52, 73);
  245. txtLaminaAngle2.BackColor = Color.FromArgb(0, 52, 73);
  246. txtLaminaAngle1.BackColor = Color.FromArgb(0, 52, 73);
  247. txtLimitSpeed.BackColor = Color.FromArgb(0, 52, 73);
  248. txtLaminaSpeed.BackColor = Color.FromArgb(0, 52, 73);
  249. txtAlternatorSpeed.BackColor = Color.FromArgb(0, 52, 73);
  250. txtStatus.BackColor = Color.FromArgb(0, 52, 73);
  251. txtPower.BackColor = Color.FromArgb(0, 52, 73);
  252. txtWindSpeed.BackColor = Color.FromArgb(0, 52, 73);
  253. txtYawPosition.BackColor = Color.FromArgb(0, 52, 73);
  254. }
  255. else
  256. {
  257. panel1.BackColor = Color.FromArgb(26, 71, 94);
  258. panel3.BackColor = Color.FromArgb(26, 71, 94);
  259. ckbWindturbine.BackColor = Color.FromArgb(26, 71, 94);
  260. txtWindturbine.BackColor = Color.FromArgb(26, 71, 94);
  261. txtWindAngle.BackColor = Color.FromArgb(26, 71, 94);
  262. txtLaminaAngle3.BackColor = Color.FromArgb(26, 71, 94);
  263. txtLaminaAngle2.BackColor = Color.FromArgb(26, 71, 94);
  264. txtLaminaAngle1.BackColor = Color.FromArgb(26, 71, 94);
  265. txtLimitSpeed.BackColor = Color.FromArgb(26, 71, 94);
  266. txtLaminaSpeed.BackColor = Color.FromArgb(26, 71, 94);
  267. txtAlternatorSpeed.BackColor = Color.FromArgb(26, 71, 94);
  268. txtStatus.BackColor = Color.FromArgb(26, 71, 94);
  269. txtPower.BackColor = Color.FromArgb(26, 71, 94);
  270. txtWindSpeed.BackColor = Color.FromArgb(26, 71, 94);
  271. txtYawPosition.BackColor = Color.FromArgb(26, 71, 94);
  272. }
  273. }
  274. WindturbineId = data.WindturbineName;
  275. WindSpeed = data.WindSpeed.ToString("f2") + "m/s";
  276. Power = data.Power.ToString("f2") + "kW";
  277. switch (data.Status)
  278. {
  279. case WindturbineStatus.Standby:
  280. Status = "待机";
  281. break;
  282. case WindturbineStatus.OnPower:
  283. Status = "上电";
  284. break;
  285. case WindturbineStatus.Maintain:
  286. Status = "维护";
  287. break;
  288. case WindturbineStatus.Fault:
  289. Status = "故障";
  290. break;
  291. case WindturbineStatus.Start:
  292. Status = "启动";
  293. break;
  294. case WindturbineStatus.Online:
  295. Status = "并网";
  296. break;
  297. case WindturbineStatus.Stop:
  298. Status = "停机";
  299. break;
  300. case WindturbineStatus.Offline:
  301. Status = "离线";
  302. break;
  303. }
  304. AlternatorSpeed = data.AlternatorSpeed.ToString("f2") + " rpm";
  305. LaminaSpeed = data.LimitSpeed.ToString("f2") + " rpm"; ;
  306. LimitSpeed = "17 rpm";
  307. LaminaAngle1 = data.LaminaAngle1.ToString("f2") + "°";
  308. LaminaAngle2 = data.LaminaAngle2.ToString("f2") + "°";
  309. LaminaAngle3 = data.LaminaAngle3.ToString("f2") + "°";
  310. WindAngle = data.WindAngle.ToString("f2") + "°";
  311. YawPosition = data.YawPosition.ToString("f2") + "°";
  312. panel1.BackColor = Color.FromArgb(26, 71, 94);
  313. panel3.BackColor = Color.FromArgb(26, 71, 94);
  314. }
  315. }
  316. private void ckbWindturbine_CheckedChanged(object sender, EventArgs e)
  317. {
  318. string windturbineName = this.Name;
  319. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  320. {
  321. if (CacheInfo.CacheWindturbineDataList[i].WindturbineName == windturbineName)
  322. {
  323. if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
  324. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  325. else
  326. CacheInfo.CacheWindturbineDataList[i].IsCheck = true;
  327. }
  328. }
  329. IsCheck = ckbWindturbine.Checked;
  330. }
  331. private void ControlLine_Click(object sender, EventArgs e)
  332. {
  333. panel1.BackColor = Color.FromArgb(51, 144, 255);
  334. panel3.BackColor = Color.FromArgb(51, 144, 255);
  335. ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  336. txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  337. txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
  338. txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
  339. txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
  340. txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
  341. txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
  342. txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
  343. txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
  344. txtStatus.BackColor = Color.FromArgb(51, 144, 255);
  345. txtPower.BackColor = Color.FromArgb(51, 144, 255);
  346. txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
  347. txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
  348. }
  349. public event EventHandler MyClick;
  350. private void textBox_Click(object sender, EventArgs e)
  351. {
  352. panel1.BackColor = Color.FromArgb(51, 144, 255);
  353. panel3.BackColor = Color.FromArgb(51, 144, 255);
  354. ckbWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  355. txtWindturbine.BackColor = Color.FromArgb(51, 144, 255);
  356. txtWindAngle.BackColor = Color.FromArgb(51, 144, 255);
  357. txtLaminaAngle3.BackColor = Color.FromArgb(51, 144, 255);
  358. txtLaminaAngle2.BackColor = Color.FromArgb(51, 144, 255);
  359. txtLaminaAngle1.BackColor = Color.FromArgb(51, 144, 255);
  360. txtLimitSpeed.BackColor = Color.FromArgb(51, 144, 255);
  361. txtLaminaSpeed.BackColor = Color.FromArgb(51, 144, 255);
  362. txtAlternatorSpeed.BackColor = Color.FromArgb(51, 144, 255);
  363. txtStatus.BackColor = Color.FromArgb(51, 144, 255);
  364. txtPower.BackColor = Color.FromArgb(51, 144, 255);
  365. txtWindSpeed.BackColor = Color.FromArgb(51, 144, 255);
  366. txtYawPosition.BackColor = Color.FromArgb(51, 144, 255);
  367. MyClick(this.WindturbineId, e);
  368. }
  369. }
  370. }