ControlForm.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using EntityDataSet;
  13. using IntelligentControlForsx.Service.Control.FormInfo;
  14. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  15. using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
  16. using IntelligentControlForsx.Service.WindturbineControl.Domain.FormInfo;
  17. using IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc;
  18. using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
  19. using IntelligentControlForsx.Template;
  20. using Gyee_Control.Svc.Cache;
  21. using Gyee_Control.View;
  22. using log4net;
  23. using log4net.Util;
  24. namespace IntelligentControlForsx.ChildForms
  25. {
  26. public partial class ControlForm : TemplateForm
  27. {
  28. private ILog logger = LogManager.GetLogger("AppInfoLog");
  29. public bool firstLoad = true;//第一次加载
  30. public bool IsNeedCheckColumn = true;
  31. public static bool isUpdateOverData = true;
  32. private static bool isUpdateOverGv = true;
  33. private static bool isUpdateOverSuccessCheck = true;
  34. private int selectRow = 0;
  35. GridViewDataSvc gvSvc = null;
  36. private WindturbinePointDataSvc pointSvc = null;
  37. private string stationCode = "SBQ_FDC";
  38. //期次
  39. private string project = "SBQ01_GC";
  40. private static BindingList<WindturbineFormData> formDataList = new BindingList<WindturbineFormData>();
  41. private BindingSource formBindingSource = new BindingSource();
  42. private Dictionary<string, WindturbineStatus> statusDic = new Dictionary<string, WindturbineStatus>();
  43. private string changeStatusWindturbineId = "";
  44. private Color backColor;
  45. public ControlForm()
  46. {
  47. InitializeComponent();
  48. WindturbinePointDataSvc.UpdatePointData(stationCode);
  49. }
  50. public override void Active()
  51. {
  52. this.Show();
  53. timer1.Enabled = true;
  54. WindturbinePointDataSvc.UpdatePointData(stationCode);
  55. Console.WriteLine("数据访问完毕");
  56. //InfoRefresh();
  57. Console.WriteLine("数据绑定完毕");
  58. }
  59. public override void DeActive()
  60. {
  61. this.Hide();
  62. timer1.Enabled = false;
  63. }
  64. private delegate void UpdateGridViewDelegate();
  65. private void btnStart_Click(object sender, EventArgs e)
  66. {
  67. string cmdDescribe = null;
  68. cmdDescribe = "正常启动";
  69. IList<WindturbineCmdInfo> cmdInfoList = new List<WindturbineCmdInfo>();
  70. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  71. {
  72. if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
  73. {
  74. WindturbineCmdInfo info = new WindturbineCmdInfo();
  75. info.WindturbineId = CacheInfo.CacheWindturbineDataList[i].WindturbineName;
  76. info.CmdType = CmdType.Start;
  77. cmdInfoList.Add(info);
  78. }
  79. }
  80. Confirm confirm = new Confirm(stationCode, cmdInfoList, cmdDescribe);
  81. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  82. {
  83. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  84. }
  85. confirm.ShowDialog();
  86. ClearCheck();
  87. }
  88. private void btnStop_Click(object sender, EventArgs e)
  89. {
  90. string cmdDescribe = null;
  91. try
  92. {
  93. cmdDescribe = "正常停机";
  94. IList<WindturbineCmdInfo> cmdInfoList = new List<WindturbineCmdInfo>();
  95. IList<WindturbinePointData> list = CacheInfo.CacheWindturbineDataList;
  96. for (int i = 0; i < list.Count; i++)
  97. {
  98. if (list[i].IsCheck)
  99. {
  100. WindturbineCmdInfo info = new WindturbineCmdInfo();
  101. info.WindturbineId = list[i].WindturbineName;
  102. info.CmdType = CmdType.Stop;
  103. cmdInfoList.Add(info);
  104. }
  105. }
  106. Confirm confirm = new Confirm(stationCode, cmdInfoList, cmdDescribe);
  107. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  108. {
  109. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  110. }
  111. confirm.ShowDialog();
  112. ClearCheck();
  113. }
  114. catch (Exception ex)
  115. {
  116. }
  117. }
  118. private void btnRest_Click(object sender, EventArgs e)
  119. {
  120. string cmdDescribe = null;
  121. cmdDescribe = "复位";
  122. IList<WindturbineCmdInfo> cmdInfoList = new List<WindturbineCmdInfo>();
  123. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  124. {
  125. if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
  126. {
  127. WindturbineCmdInfo info = new WindturbineCmdInfo();
  128. info.WindturbineId = CacheInfo.CacheWindturbineDataList[i].WindturbineName;
  129. info.CmdType = CmdType.Reset;
  130. cmdInfoList.Add(info);
  131. }
  132. }
  133. Confirm confirm = new Confirm(stationCode, cmdInfoList, cmdDescribe);
  134. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  135. {
  136. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  137. }
  138. confirm.ShowDialog();
  139. ClearCheck();
  140. }
  141. private void gvWindturbine_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  142. {
  143. if (e.RowIndex != -1)
  144. {
  145. if (e.ColumnIndex == 0)
  146. {
  147. string isCheck = gvWindturbine.Rows[e.RowIndex].Cells["Select"].Value == null ? "0" : gvWindturbine.Rows[e.RowIndex].Cells["Select"].Value.ToString();
  148. if (isCheck == "1")
  149. gvWindturbine.Rows[e.RowIndex].Cells["Select"].Value = 0;
  150. else
  151. gvWindturbine.Rows[e.RowIndex].Cells["Select"].Value = 1;
  152. string windturbineId = this.gvWindturbine.Rows[e.RowIndex].Cells[1].Value.ToString();
  153. int nullCount = CacheInfo.CacheWindturbineDataList.Where(s => s == null).ToList().Count;
  154. if (nullCount == 0)
  155. {
  156. var data = CacheInfo.CacheWindturbineDataList.Where(s => s.WindturbineName == windturbineId).FirstOrDefault();
  157. if (data != null)
  158. {
  159. var newData = data;
  160. if (data.IsCheck)
  161. newData.IsCheck = false;
  162. else
  163. newData.IsCheck = true;
  164. CacheInfo.CacheWindturbineDataList.Remove(data);
  165. CacheInfo.CacheWindturbineDataList.Add(newData);
  166. }
  167. }
  168. }
  169. selectRow = e.RowIndex;
  170. string[] SBQ_UP105 = { "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", "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" };
  171. IList<string> enbleMaintainList = SBQ_UP105.ToList();
  172. IList<string> cacheWindturbineIdList =
  173. CacheInfo.CacheWindturbineDataList.Where(k => k.IsCheck == true).Select(s => s.WindturbineName).ToList();
  174. if (enbleMaintainList.Intersect(cacheWindturbineIdList).ToList().Count > 0)
  175. {
  176. btnMaintain.Enabled = false;
  177. btnRegister.Enabled = false;
  178. btnUnMaintain.Enabled = false;
  179. }
  180. else
  181. {
  182. btnMaintain.Enabled = true;
  183. btnRegister.Enabled = true;
  184. btnUnMaintain.Enabled = true;
  185. }
  186. }
  187. else
  188. {
  189. if (e.ColumnIndex == 0)
  190. {
  191. for (int i = 0; i < gvWindturbine.RowCount; i++)
  192. {
  193. string isCheck = gvWindturbine.Rows[i].Cells["Select"].Value == null
  194. ? "0"
  195. : gvWindturbine.Rows[i].Cells["Select"].Value.ToString();
  196. if (isCheck == "1")
  197. gvWindturbine.Rows[i].Cells["Select"].Value = 0;
  198. else
  199. gvWindturbine.Rows[i].Cells["Select"].Value = 1;
  200. string windturbineId = this.gvWindturbine.Rows[i].Cells[1].Value.ToString();
  201. var data =
  202. CacheInfo.CacheWindturbineDataList.Where(s => s.WindturbineName == windturbineId)
  203. .FirstOrDefault();
  204. if (data != null)
  205. {
  206. var newData = data;
  207. if (data.IsCheck)
  208. newData.IsCheck = false;
  209. else
  210. newData.IsCheck = true;
  211. CacheInfo.CacheWindturbineDataList.Remove(data);
  212. CacheInfo.CacheWindturbineDataList.Add(newData);
  213. }
  214. }
  215. }
  216. }
  217. }
  218. private void ControlForm_Load(object sender, EventArgs e)
  219. {
  220. }
  221. private void timer1_Tick(object sender, EventArgs e)
  222. {
  223. if (firstLoad)
  224. {
  225. firstLoad = false;
  226. using (wisdom_cs_entity ctx = new wisdom_cs_entity())
  227. {
  228. IList<windturbine> windturbineList =
  229. ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == "SBQ_FDC" && s.PROJECTID == project).ToList();
  230. formDataList = new BindingList<WindturbineFormData>();
  231. IList<WindturbinePointData> list = CacheInfo.CacheWindturbineDataList.Where(s => s.StationId == stationCode && s.ProjectId == project).ToList().OrderBy(s => Convert.ToInt32(Regex.Replace(s.WindturbineName, "[a-zA-Z]", "").Replace("_", ""))).ToList();
  232. ;
  233. statusDic.Clear();
  234. for (int i = 0; i < list.Count; i++)
  235. {
  236. string statusString = "";
  237. #region 状态转化字符串
  238. switch (list[i].Status)
  239. {
  240. case WindturbineStatus.Standby:
  241. statusString = "待机";
  242. break;
  243. case WindturbineStatus.OnPower:
  244. statusString = "上电";
  245. break;
  246. case WindturbineStatus.Maintain:
  247. statusString = "维护";
  248. break;
  249. case WindturbineStatus.Fault:
  250. statusString = "故障";
  251. break;
  252. case WindturbineStatus.Start:
  253. statusString = "启动";
  254. break;
  255. case WindturbineStatus.Online:
  256. statusString = "并网";
  257. break;
  258. case WindturbineStatus.Stop:
  259. statusString = "停机";
  260. break;
  261. case WindturbineStatus.Offline:
  262. statusString = "离线";
  263. break;
  264. }
  265. #endregion
  266. string hungTypeString = "";
  267. switch (list[i].HungType)
  268. {
  269. case HungType.UnLock:
  270. hungTypeString = "正常";
  271. break;
  272. case HungType.StationCheckLock:
  273. hungTypeString = "场内受累检修";
  274. break;
  275. case HungType.StationFaulLockt:
  276. hungTypeString = "场内受累故障";
  277. break;
  278. case HungType.StationPowerLineLock:
  279. hungTypeString = "场外受累电网";
  280. break;
  281. case HungType.StationWeatherLock:
  282. hungTypeString = "场外受累天气";
  283. break;
  284. case HungType.FaultLock:
  285. hungTypeString = "故障检修";
  286. break;
  287. case HungType.CheckLock:
  288. hungTypeString = "检修";
  289. break;
  290. }
  291. WindturbineFormData data = new WindturbineFormData(list[i].WindturbineName,
  292. list[i].WindSpeed.ToString("f2"),
  293. list[i].Power.ToString("f2"),
  294. statusString,
  295. hungTypeString,
  296. list[i].AlternatorSpeed.ToString("f2"),
  297. list[i].LaminaSpeed.ToString("f2"),
  298. list[i].LimitSpeed.ToString("f2"),
  299. list[i].LaminaAngle1.ToString("f2"),
  300. list[i].LaminaAngle2.ToString("f2"),
  301. list[i].LaminaAngle3.ToString("f2"),
  302. list[i].WindAngle.ToString("f2"),
  303. list[i].YawPosition.ToString("f2")
  304. );
  305. formDataList.Add(data);
  306. if (!statusDic.ContainsKey(windturbineList[i].ID))
  307. statusDic.Add(windturbineList[i].ID, list[i].Status);
  308. }
  309. formBindingSource.DataSource = formDataList;
  310. this.gvWindturbine.DataSource = formBindingSource;
  311. if (IsNeedCheckColumn)
  312. {
  313. DataGridViewCheckBoxColumn checkColum = new DataGridViewCheckBoxColumn();
  314. checkColum.HeaderText = "";
  315. checkColum.Name = "Select";
  316. checkColum.DataPropertyName = "Select";
  317. checkColum.ReadOnly = false;
  318. checkColum.TrueValue = true;
  319. checkColum.FalseValue = false;
  320. gvWindturbine.Columns.Insert(0, checkColum);
  321. IsNeedCheckColumn = false;
  322. }
  323. gvWindturbine.Columns[0].Width = 50;
  324. gvWindturbine.Columns[1].Width = 110;
  325. }
  326. #region 修改风机状态背景色
  327. for (int i = 0; i < gvWindturbine.RowCount; i++)
  328. {
  329. string statusString = gvWindturbine.Rows[i].Cells[4].Value.ToString();
  330. DataGridViewRow row = gvWindturbine.Rows[i];
  331. switch (statusString)
  332. {
  333. case "待机":
  334. row.Cells[1].Style.BackColor = Color.FromArgb(15, 141, 106);
  335. break;
  336. case "上电":
  337. row.Cells[1].Style.BackColor = Color.FromArgb(177, 14, 126);
  338. break;
  339. case "维护":
  340. row.Cells[1].Style.BackColor = Color.FromArgb(204, 83, 51);
  341. break;
  342. case "故障":
  343. row.Cells[1].Style.BackColor = Color.FromArgb(170, 15, 59);
  344. break;
  345. case "启动":
  346. row.Cells[1].Style.BackColor = Color.FromArgb(14, 72, 91);
  347. break;
  348. case "并网":
  349. row.Cells[1].Style.BackColor = Color.FromArgb(15, 135, 170);
  350. break;
  351. case "停机":
  352. row.Cells[1].Style.BackColor = Color.FromArgb(176, 151, 63);
  353. break;
  354. case "离线":
  355. row.Cells[1].Style.BackColor = Color.FromArgb(134, 150, 165);
  356. break;
  357. }
  358. }
  359. #endregion
  360. #region 修改表头
  361. gvWindturbine.Columns[1].HeaderText = "风机编号";
  362. gvWindturbine.Columns[2].HeaderText = "风速 m/s";
  363. gvWindturbine.Columns[3].HeaderText = "功率 kwh";
  364. gvWindturbine.Columns[4].HeaderText = "状态";
  365. gvWindturbine.Columns[5].HeaderText = "发电机转速";
  366. gvWindturbine.Columns[6].HeaderText = "限速值";
  367. gvWindturbine.Columns[7].HeaderText = "叶轮转速";
  368. gvWindturbine.Columns[8].HeaderText = "桨叶角度1";
  369. gvWindturbine.Columns[9].HeaderText = "桨叶角度2";
  370. gvWindturbine.Columns[10].HeaderText = "桨叶角度3";
  371. gvWindturbine.Columns[11].HeaderText = "对风角度";
  372. gvWindturbine.Columns[12].HeaderText = "偏航位置";
  373. #endregion
  374. }
  375. if (isUpdateOverData)
  376. {
  377. isUpdateOverData = false;
  378. Thread getDataThread = new Thread(new ParameterizedThreadStart(WindturbinePointDataSvc.UpdatePointData));//创建数据更新线程
  379. getDataThread.Start(stationCode);
  380. }
  381. if (isUpdateOverGv)
  382. {
  383. isUpdateOverGv = false;
  384. Thread t = new Thread(ThreadInfo);
  385. t.IsBackground = true;
  386. t.Start();
  387. }
  388. }
  389. public void ThreadInfo()
  390. {
  391. UpdateGridViewDelegate del = new UpdateGridViewDelegate(FormDataBind);
  392. if (gvWindturbine.InvokeRequired)
  393. {
  394. gvWindturbine.BeginInvoke(del, new object[] { });
  395. }
  396. else
  397. {
  398. FormDataBind();
  399. }
  400. }
  401. public void FormDataBind()
  402. {
  403. IList<WindturbinePointData> pointDataList = CacheInfo.CacheWindturbineDataList.Where(s => s.StationId == stationCode && s.ProjectId == project).ToList().OrderBy(k => k.WindturbineName).ToList();
  404. BindingList<WindturbineFormData> dataList = this.formBindingSource.DataSource as BindingList<WindturbineFormData>;
  405. DateTime stime = DateTime.Now;
  406. for (int i = 0; i < pointDataList.Count; i++)
  407. {
  408. var data =
  409. dataList.Where(s => s.WindturbineId == pointDataList[i].WindturbineName).FirstOrDefault();
  410. if (data != null)
  411. {
  412. data.WindSpeed = pointDataList[i].WindSpeed.ToString("f2");
  413. data.Power = pointDataList[i].Power.ToString("f2");
  414. switch (pointDataList[i].Status)
  415. {
  416. case WindturbineStatus.Standby:
  417. data.StatusString = "待机";
  418. break;
  419. case WindturbineStatus.OnPower:
  420. data.StatusString = "上电";
  421. break;
  422. case WindturbineStatus.Maintain:
  423. data.StatusString = "维护";
  424. break;
  425. case WindturbineStatus.Fault:
  426. data.StatusString = "故障";
  427. break;
  428. case WindturbineStatus.Start:
  429. data.StatusString = "启动";
  430. break;
  431. case WindturbineStatus.Online:
  432. data.StatusString = "并网";
  433. break;
  434. case WindturbineStatus.Stop:
  435. data.StatusString = "停机";
  436. break;
  437. case WindturbineStatus.Offline:
  438. data.StatusString = "离线";
  439. break;
  440. }
  441. data.AlternatorSpeed = pointDataList[i].AlternatorSpeed.ToString("f2");
  442. data.LaminaSpeed = pointDataList[i].LaminaSpeed.ToString("f2");
  443. data.LimitSpeed = pointDataList[i].LimitSpeed.ToString("f2");
  444. data.LaminaAngle1 = pointDataList[i].LaminaAngle1.ToString("f2");
  445. data.LaminaAngle2 = pointDataList[i].LaminaAngle2.ToString("f2");
  446. data.LaminaAngle3 = pointDataList[i].LaminaAngle3.ToString("f2");
  447. data.WindAngle = pointDataList[i].WindAngle.ToString("f2");
  448. data.YawPosition = pointDataList[i].YawPosition.ToString("f2");
  449. StatusStyleThread(data.WindturbineId, pointDataList[i].Status);
  450. }
  451. }
  452. UpdateStatInfo("SBQ_FDC");
  453. isUpdateOverGv = true;
  454. DateTime etime = DateTime.Now;
  455. TimeSpan span = etime - stime;
  456. Console.WriteLine("绑定页面时间:" + span.TotalMilliseconds);
  457. }
  458. private void btnRegister_Click(object sender, EventArgs e)
  459. {
  460. MessageBox.Show("管理员验证指纹");
  461. FingerCheck check = new FingerCheck();
  462. check.ShowDialog();
  463. user adminUser = FingerCheck.checkSuccessUser;
  464. if (adminUser != null && adminUser.user_name == "admin")
  465. {
  466. Register register = new Register();
  467. register.ShowDialog();
  468. }
  469. else
  470. {
  471. MessageBox.Show("管理员验证失败");
  472. }
  473. }
  474. private void btnMaintain_Click(object sender, EventArgs e)
  475. {
  476. string cmdDescribe = null;
  477. cmdDescribe = "正常维护";
  478. IList<WindturbineCmdInfo> cmdInfoList = new List<WindturbineCmdInfo>();
  479. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  480. {
  481. if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
  482. {
  483. WindturbineCmdInfo info = new WindturbineCmdInfo();
  484. info.WindturbineId = CacheInfo.CacheWindturbineDataList[i].WindturbineName;
  485. info.CmdType = CmdType.Maintain;
  486. cmdInfoList.Add(info);
  487. }
  488. }
  489. Confirm confirm = new Confirm(stationCode, cmdInfoList, cmdDescribe);
  490. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  491. {
  492. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  493. }
  494. confirm.ShowDialog();
  495. ClearCheck();
  496. }
  497. private void btnUnMaintain_Click(object sender, EventArgs e)
  498. {
  499. string cmdDescribe = null;
  500. cmdDescribe = "正常取消维护";
  501. IList<WindturbineCmdInfo> cmdInfoList = new List<WindturbineCmdInfo>();
  502. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  503. {
  504. if (CacheInfo.CacheWindturbineDataList[i].IsCheck)
  505. {
  506. WindturbineCmdInfo info = new WindturbineCmdInfo();
  507. info.WindturbineId = CacheInfo.CacheWindturbineDataList[i].WindturbineName;
  508. info.CmdType = CmdType.UnMaintain;
  509. cmdInfoList.Add(info);
  510. }
  511. }
  512. Confirm confirm = new Confirm(stationCode, cmdInfoList, cmdDescribe);
  513. for (int i = 0; i < CacheInfo.CacheWindturbineDataList.Count; i++)
  514. {
  515. CacheInfo.CacheWindturbineDataList[i].IsCheck = false;
  516. }
  517. confirm.ShowDialog();
  518. ClearCheck();
  519. }
  520. private void lblProject1_Click(object sender, EventArgs e)
  521. {
  522. project = "SBQ01_GC";
  523. firstLoad = true;
  524. ThreadInfo();
  525. lblProject1.BackColor = Color.FromArgb(15, 141, 106);
  526. lblProject2.BackColor = Color.FromArgb(3, 24, 48);
  527. lblProject3.BackColor = Color.FromArgb(3, 24, 48);
  528. lblProject4.BackColor = Color.FromArgb(3, 24, 48);
  529. btnMaintain.Enabled = true;
  530. btnUnMaintain.Enabled = true;
  531. btnRest.Enabled = true;
  532. }
  533. private void lblProject2_Click(object sender, EventArgs e)
  534. {
  535. project = "SBQ02_GC";
  536. firstLoad = true;
  537. ThreadInfo();
  538. lblProject1.BackColor = Color.FromArgb(3, 24, 48);
  539. lblProject2.BackColor = Color.FromArgb(15, 141, 106);
  540. lblProject3.BackColor = Color.FromArgb(3, 24, 48);
  541. lblProject4.BackColor = Color.FromArgb(3, 24, 48);
  542. btnMaintain.Enabled = true;
  543. btnUnMaintain.Enabled = true;
  544. btnRest.Enabled = true;
  545. }
  546. private void lblProject3_Click(object sender, EventArgs e)
  547. {
  548. project = "SBQ03_GC";
  549. firstLoad = true;
  550. ThreadInfo();
  551. lblProject1.BackColor = Color.FromArgb(3, 24, 48);
  552. lblProject2.BackColor = Color.FromArgb(3, 24, 48);
  553. lblProject3.BackColor = Color.FromArgb(15, 141, 106);
  554. lblProject4.BackColor = Color.FromArgb(3, 24, 48);
  555. btnMaintain.Enabled = false;
  556. btnUnMaintain.Enabled = false;
  557. btnRest.Enabled = false;
  558. }
  559. private void lblProject4_Click(object sender, EventArgs e)
  560. {
  561. project = "SBQ04_GC";
  562. firstLoad = true;
  563. ThreadInfo();
  564. lblProject1.BackColor = Color.FromArgb(3, 24, 48);
  565. lblProject2.BackColor = Color.FromArgb(3, 24, 48);
  566. lblProject3.BackColor = Color.FromArgb(3, 24, 48);
  567. lblProject4.BackColor = Color.FromArgb(15, 141, 106);
  568. btnMaintain.Enabled = false;
  569. btnUnMaintain.Enabled = false;
  570. btnRest.Enabled = false;
  571. }
  572. private void StatusStyleThread(string windturbineId, WindturbineStatus status)
  573. {
  574. WindturbineStatus oldStatus = statusDic[windturbineId];
  575. if (oldStatus != status)
  576. {
  577. statusDic[windturbineId] = status;
  578. switch (status)
  579. {
  580. case WindturbineStatus.Offline:
  581. backColor = Color.FromArgb(134, 150, 165);
  582. break;
  583. case WindturbineStatus.Start:
  584. backColor = Color.FromArgb(14, 72, 91);
  585. break;
  586. case WindturbineStatus.Fault:
  587. backColor = Color.FromArgb(170, 15, 59);
  588. break;
  589. case WindturbineStatus.Maintain:
  590. backColor = Color.FromArgb(204, 83, 51);
  591. break;
  592. case WindturbineStatus.Stop:
  593. backColor = Color.FromArgb(176, 151, 63);
  594. break;
  595. case WindturbineStatus.Online:
  596. backColor = Color.FromArgb(15, 135, 170);
  597. break;
  598. case WindturbineStatus.OnPower:
  599. backColor = Color.FromArgb(177, 14, 126);
  600. break;
  601. case WindturbineStatus.Standby:
  602. backColor = Color.FromArgb(15, 141, 106);
  603. break;
  604. default: break;
  605. }
  606. changeStatusWindturbineId = windturbineId;
  607. UpdateStatus();
  608. }
  609. }
  610. public void UpdateStatus()
  611. {
  612. UpdateGridViewDelegate del = new UpdateGridViewDelegate(BackStyleColor);
  613. if (gvWindturbine.InvokeRequired)
  614. {
  615. gvWindturbine.BeginInvoke(del, new object[] { });
  616. }
  617. else
  618. {
  619. BackStyleColor();
  620. }
  621. }
  622. private void BackStyleColor()
  623. {
  624. for (int i = 0; i < gvWindturbine.RowCount; i++)
  625. {
  626. if (gvWindturbine.Rows[i].Cells[1].Value == changeStatusWindturbineId)
  627. {
  628. gvWindturbine.Rows[i].Cells[1].Style.BackColor = backColor;
  629. }
  630. }
  631. }
  632. private void ClearCheck()
  633. {
  634. for (int i = 0; i < gvWindturbine.RowCount; i++)
  635. {
  636. gvWindturbine.Rows[i].Cells["Select"].Value = 0;
  637. }
  638. }
  639. /// <summary>
  640. /// 更新统计类信息
  641. /// </summary>
  642. private void UpdateStatInfo(string station)
  643. {
  644. if (station == "")
  645. station = "SBQ_FDC";
  646. StatInfo info1 = StatInfoSvc.Instance.GetStatInfoByStation(station);
  647. StatInfo info2 = StatInfoSvc.Instance.GeStatInfo();
  648. controlFormTop.BindStationInfo(info1);
  649. controlFormTop.BindAllStationInfo(info2);
  650. }
  651. public override void SelectedStationChanged(string stationId)
  652. {
  653. MessageBox.Show("风场切换");
  654. }
  655. }
  656. }