using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using EntityDataSet; using IntelligentControlForsx.MyControls.windturbine; using IntelligentControlForsx.Service; using IntelligentControlForsx.Service.WindturbineControl.Domain; using IntelligentControlForsx.Service.WindturbineInfo; using IntelligentControlForsx.Template; using log4net; using log4net.Util; using WisdomClient; using WisdomClient.data; namespace IntelligentControlForsx.ChildForms { public partial class WindturbineForm : TemplateForm { private static ILog logger = LogManager.GetLogger("AppInfoLog"); /// /// 当前风电场 /// private string nowStationId = "SBQ_FDC"; //public string NowStationId //{ // set // { // BindWindturbine(value); // //麻黄山MG01_01,石板泉SG01_01,青山QS01_01,牛首山NG01_01,香山XG01_01 // switch (value) // { // case "SBQ_FDC": // nowWindturbineId = "SG01_01"; // break; // case "MHS_FDC": // nowWindturbineId = "MG01_01"; // break; // case "QS_FDC": // nowWindturbineId = "QS01_01"; // break; // case "NSS_FDC": // nowWindturbineId = "NG01_01"; // break; // case "XS_FDC": // nowWindturbineId = "XG01_01"; // break; // } // nowStationId = value; // } // get { return nowStationId; } //} /// /// 当前风机 /// private static string nowWindturbineId = "SG01_01"; public void SetNowWindturbineId(string windturbineId, string stationId) { nowWindturbineId = windturbineId; string controlName = "lwn" + windturbineId; try { Control control = null; if (stationId == "SBQ_FDC") { control = this.pnlLeft_SBQ.Controls.Find(controlName, true)[0]; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Show(); } if (stationId == "MHS_FDC") { control = this.pnlLeft_MHS.Controls.Find(controlName, true)[0]; pnlLeft_MHS.Show(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } if (stationId == "NSS_FDC") { control = this.pnlLeft_NSS.Controls.Find(controlName, true)[0]; pnlLeft_MHS.Hide(); pnlLeft_NSS.Show(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } if (stationId == "QS_FDC") { control = this.pnlLeft_QS.Controls.Find(controlName, true)[0]; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Show(); pnlLeft_SBQ.Hide(); } if (stationId == "XS_FDC") { control = this.pnlLeft_XS.Controls.Find(controlName, true)[0]; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Show(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } LabelWindturbineName wn = (LabelWindturbineName)control; NowWindturbineControl = wn; lblWindturbineId.Text = windturbineId; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == windturbineId).FirstOrDefault(); if (data != null) { lblWindturbineModel.Text = data.MODELID; modelId = data.MODELID; } } } catch (Exception ex) { logger.Info(ex.Message); } } /// /// 当前风机型号 /// private string modelId = "UP82_2"; /// /// 当前所显示的页面 /// private BaseControl nowControl = null; /// /// 当前风机控件 /// private LabelWindturbineName nowWindturbineControl = null; public LabelWindturbineName NowWindturbineControl { set { if (value != nowWindturbineControl) { nowWindturbineControl.Style_UnFocus(); value.Style_Focus(); } nowWindturbineControl = value; } get { return nowWindturbineControl; } } /// /// 数据是否刷新完毕 /// public bool isRefreshOver = true; /// /// 当前风场的风机编号集合 /// private IList windturbineList = new List(); public WindturbineForm() { InitializeComponent(); defalutLable = new Label(); #region 加载参数种类页 BasicInfo basicInfo = new BasicInfo(); basicInfo.Name = "basicInfo"; basicInfo.Show(); this.plInfo.Controls.Add(basicInfo); AlternatorInfo alternatorInfo = new AlternatorInfo(); alternatorInfo.Name = "alternatorInfo"; alternatorInfo.Hide(); this.plInfo.Controls.Add(alternatorInfo); ChangePaddleInfo changePaddleInfo = new ChangePaddleInfo(); changePaddleInfo.Name = "changePaddleInfo"; changePaddleInfo.Hide(); this.plInfo.Controls.Add(changePaddleInfo); GearBoxInfo gearBoxInfo = new GearBoxInfo(); gearBoxInfo.Name = "gearBoxInfo"; gearBoxInfo.Hide(); this.plInfo.Controls.Add(gearBoxInfo); PressureInfo pressureInfo = new PressureInfo(); pressureInfo.Name = "pressureInfo"; pressureInfo.Hide(); this.plInfo.Controls.Add(pressureInfo); RoomInfo roomInfo = new RoomInfo(); roomInfo.Name = "roomInfo"; roomInfo.Hide(); this.plInfo.Controls.Add(roomInfo); YawInfo yawInfo = new YawInfo(); yawInfo.Name = "yawInfo"; yawInfo.Hide(); this.plInfo.Controls.Add(yawInfo); OutInInfo outInInfo = new OutInInfo(); outInInfo.Name = "outInInfo"; outInInfo.Hide(); this.plInfo.Controls.Add(outInInfo); FaultInfo2 faultInfo = new FaultInfo2(); faultInfo.Name = "faultInfo"; faultInfo.Hide(); this.plInfo.Controls.Add(faultInfo); #endregion BindWindturbine(nowStationId); this.pnlLeft_MHS.Hide(); this.pnlLeft_NSS.Hide(); this.pnlLeft_XS.Hide(); this.pnlLeft_QS.Hide(); nowControl = basicInfo; lblBasic.BackColor = Color.FromArgb(10, 25, 47); lblBasic.Cursor = Cursors.Default; lblBasic.ForeColor = Color.White; defalutLable = lblBasic; lblStationName.Text = "石板泉风电场"; if (nowWindturbineControl != null) nowWindturbineControl.Style_Focus(); } public override void Active() { nowStationId = NavService.Instance.StationId; if (nowStationId == "0") nowStationId = "SBQ_FDC"; if (nowStationId == "SBQ_FDC") { if (!nowWindturbineId.Contains("SG01_")) nowWindturbineId = "SG01_01"; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) modelId = data.MODELID; } lblWindturbineId.Text = nowWindturbineId; lblWindturbineModel.Text = modelId; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Show(); lblStationName.Text = "石板泉风电场"; for (int i = 0; i < this.pnlLeft_SBQ.Controls.Count; i++) { try { if (this.pnlLeft_SBQ.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_SBQ.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } else if (nowStationId == "XS_FDC") { if (!nowWindturbineId.Contains("XG01_")) nowWindturbineId = "XG01_01"; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) modelId = data.MODELID; } lblWindturbineId.Text = nowWindturbineId; lblWindturbineModel.Text = modelId; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Show(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); lblStationName.Text = "香山风电场"; for (int i = 0; i < this.pnlLeft_XS.Controls.Count; i++) { try { if (this.pnlLeft_XS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_XS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } else if (nowStationId == "NSS_FDC") { if (!nowWindturbineId.Contains("NG01_")) nowWindturbineId = "NG01_01"; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) modelId = data.MODELID; } lblWindturbineId.Text = nowWindturbineId; lblWindturbineModel.Text = modelId; pnlLeft_MHS.Hide(); pnlLeft_NSS.Show(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); lblStationName.Text = "牛首山风电场"; for (int i = 0; i < this.pnlLeft_NSS.Controls.Count; i++) { try { if (this.pnlLeft_NSS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_NSS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } else if (nowStationId == "MHS_FDC") { if (!nowWindturbineId.Contains("MG01_")) nowWindturbineId = "MG01_01"; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) modelId = data.MODELID; } lblWindturbineId.Text = nowWindturbineId; lblWindturbineModel.Text = modelId; pnlLeft_MHS.Show(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); lblStationName.Text = "麻黄山风电场"; for (int i = 0; i < this.pnlLeft_MHS.Controls.Count; i++) { try { if (this.pnlLeft_MHS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_MHS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } else if (nowStationId == "QS_FDC") { if (!nowWindturbineId.Contains("QG01_")) nowWindturbineId = "QG01_01"; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbine data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) modelId = data.MODELID; } lblWindturbineId.Text = nowWindturbineId; lblWindturbineModel.Text = modelId; pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Show(); pnlLeft_SBQ.Hide(); lblStationName.Text = "青山风电场"; for (int i = 0; i < this.pnlLeft_QS.Controls.Count; i++) { try { if (this.pnlLeft_QS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_QS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } for (int i = 0; i < this.plInfo.Controls.Count; i++) { BaseControl c = (BaseControl)this.plInfo.Controls[i]; c.WINDTURBINEID = nowWindturbineId; c.MODELID = modelId; c.STATIONID = nowStationId; } this.Show(); timer1.Enabled = true; nowControl.Show(); nowControl.Active(nowStationId, nowWindturbineId, modelId); } public override void DeActive() { //如果当前控件为非活跃状态,则控件中农的其他子控件都为非活动状态 for (int i = 0; i < this.plInfo.Controls.Count; i++) { if (this.plInfo.Controls[i] is BaseControl) { BaseControl c = (BaseControl)this.plInfo.Controls[i]; c.DeActive(); } } timer1.Enabled = false; this.Hide(); } private void lblTitle_Click(object sender, EventArgs e) { Label lable = (Label)sender; // MyClick(lable.Tag, e); DefaultLable = lable; Label l = (Label)sender; string infoName = ""; switch (l.Name) { case "lblBasic": infoName = "basicInfo"; break; case "lblAlternator": infoName = "alternatorInfo"; break; case "lblGearBox": infoName = "gearBoxInfo"; break; case "lblPropeller": infoName = "changePaddleInfo"; break; case "lblPressure": infoName = "pressureInfo"; break; case "lblRoom": infoName = "roomInfo"; break; case "lblYaw": infoName = "yawInfo"; break; case "lblFault": infoName = "faultInfo"; break; case "lblOutIn": infoName = "outInInfo"; break; } for (int i = 0; i < this.plInfo.Controls.Count; i++) { BaseControl c = (BaseControl)this.plInfo.Controls[i]; Console.WriteLine(c.Name); if (c.Name == infoName) { c.Show(); c.Active(nowStationId, nowWindturbineId, modelId); nowControl = c; } else { c.Hide(); c.DeActive(); } } } #region 组态种类动态效果(导航栏)及其事件 Label defalutLable; [Browsable(true), Category("Appearance")] public Label DefaultLable { get { return defalutLable; } set { if (!this.DesignMode) { if (defalutLable.Name != null && defalutLable.Name.Trim() != "") { value.BackColor = Color.FromArgb(10, 25, 47); value.Cursor = Cursors.Default; value.ForeColor = Color.White; defalutLable.BackColor = Color.FromArgb(15, 45, 74); defalutLable.Cursor = System.Windows.Forms.Cursors.Hand; defalutLable.ForeColor = Color.FromArgb(48, 184, 250); } } defalutLable = value; } } private void lbl_MouseEnter(object sender, System.EventArgs e) { if (!this.DesignMode) { Label lable = (Label)sender; if (defalutLable.Name != lable.Name) { lable.BackColor = Color.FromArgb(10, 25, 47); lable.ForeColor = Color.White; } } } private void lbl_MouseLeave(object sender, System.EventArgs e) { if (!this.DesignMode) { Label lable = (Label)sender; if (defalutLable.Name != lable.Name) { lable.BackColor = Color.FromArgb(5, 45, 74); lable.ForeColor = Color.FromArgb(48, 184, 250); } } } #endregion /// /// 绑定风机tree /// /// private void BindWindturbine(string stationCode) { IList windturbineIdList = new List(); using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { IList list = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID.Contains("FDC")).ToList(); IList orderList_SBQ = list.Where(k => k.WINDPOWERSTATIONID == "SBQ_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("SG01_", ""))).ToList(); IList orderList_NSS = list.Where(k => k.WINDPOWERSTATIONID == "NSS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("NG01_", ""))).ToList(); IList orderListMHS = list.Where(k => k.WINDPOWERSTATIONID == "MHS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("MG01_", ""))).ToList(); IList orderListXS = list.Where(k => k.WINDPOWERSTATIONID == "XS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("XG01_", ""))).ToList(); IList orderListQS = list.Where(k => k.WINDPOWERSTATIONID == "QS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("QG01_", ""))).ToList(); for (int i = 0; i < orderList_SBQ.Count; i++) { LabelWindturbineName wn = new LabelWindturbineName(); wn.Name = "lwn" + orderList_SBQ[i].ID; wn.WindturbineName = orderList_SBQ[i].ID; wn.Dock = DockStyle.Top; wn.MyClick += Windturbine_Click; pnlLeft_SBQ.Controls.Add(wn); windturbineIdList.Add(orderList_SBQ[i].ID); //首页加载时默认将石板泉第一台风机控件赋值给当前风机控件 if (orderList_SBQ[i].ID == "SG01_01") nowWindturbineControl = wn; } for (int i = 0; i < orderList_NSS.Count; i++) { LabelWindturbineName wn = new LabelWindturbineName(); wn.Name = "lwn" + orderList_NSS[i].ID; wn.WindturbineName = orderList_NSS[i].ID; wn.Dock = DockStyle.Top; wn.MyClick += Windturbine_Click; pnlLeft_NSS.Controls.Add(wn); windturbineIdList.Add(orderList_NSS[i].ID); } for (int i = 0; i < orderListMHS.Count; i++) { LabelWindturbineName wn = new LabelWindturbineName(); wn.Name = "lwn" + orderListMHS[i].ID; wn.WindturbineName = orderListMHS[i].ID; wn.Dock = DockStyle.Top; wn.MyClick += Windturbine_Click; pnlLeft_MHS.Controls.Add(wn); windturbineIdList.Add(orderListMHS[i].ID); } for (int i = 0; i < orderListQS.Count; i++) { LabelWindturbineName wn = new LabelWindturbineName(); wn.Name = "lwn" + orderListQS[i].ID; wn.WindturbineName = orderListQS[i].ID; wn.Dock = DockStyle.Top; wn.MyClick += Windturbine_Click; pnlLeft_QS.Controls.Add(wn); windturbineIdList.Add(orderListQS[i].ID); } for (int i = 0; i < orderListXS.Count; i++) { LabelWindturbineName wn = new LabelWindturbineName(); wn.Name = "lwn" + orderListXS[i].ID; wn.WindturbineName = orderListXS[i].ID; wn.Dock = DockStyle.Top; wn.MyClick += Windturbine_Click; pnlLeft_XS.Controls.Add(wn); windturbineIdList.Add(orderListXS[i].ID); } } windturbineList = windturbineIdList; } private void Windturbine_Click(object sender, EventArgs e) { LabelWindturbineName lblControl = (LabelWindturbineName)sender; NowWindturbineControl = lblControl; nowWindturbineId = lblControl.WindturbineName; windturbine data = null; using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { data = ctx.windturbine.Where(s => s.ID == nowWindturbineId).FirstOrDefault(); if (data != null) { lblWindturbineId.Text = data.ID; lblWindturbineModel.Text = data.MODELID; } } for (int i = 0; i < this.plInfo.Controls.Count; i++) { BaseControl c = (BaseControl)this.plInfo.Controls[i]; c.WINDTURBINEID = nowWindturbineId; if (data != null) c.MODELID = data.MODELID; } if (nowControl is OutInInfo) { OutInInfo info = (OutInInfo)nowControl; if (data != null) info.LeftBind(data.WINDPOWERSTATIONID, data.ID, data.MODELID); } if (nowControl is FaultInfo2) { FaultInfo2 info = (FaultInfo2)nowControl; if (data != null) info.LeftBind(data.WINDPOWERSTATIONID, data.ID, data.MODELID); } } public override void SelectedStationChanged(string stationId) { nowStationId = stationId; #region if (stationId == "SBQ_FDC") { pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Show(); } if (stationId == "NSS_FDC") { pnlLeft_MHS.Hide(); pnlLeft_NSS.Show(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } if (stationId == "MHS_FDC") { pnlLeft_MHS.Show(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } if (stationId == "QS_FDC") { pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Hide(); pnlLeft_QS.Show(); pnlLeft_SBQ.Hide(); } if (stationId == "XS_FDC") { pnlLeft_MHS.Hide(); pnlLeft_NSS.Hide(); pnlLeft_XS.Show(); pnlLeft_QS.Hide(); pnlLeft_SBQ.Hide(); } #endregion using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windpowerstation station = ctx.windpowerstation.Where(s => s.ID == stationId).FirstOrDefault(); if (station != null) lblStationName.Text = station.NAME; windturbine wb = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == stationId).FirstOrDefault(); if (wb != null) { nowWindturbineId = wb.ID; modelId = wb.MODELID; lblWindturbineId.Text = wb.ID; lblWindturbineModel.Text = wb.MODELID; for (int i = 0; i < this.plInfo.Controls.Count; i++) { BaseControl c = (BaseControl)this.plInfo.Controls[i]; c.WINDTURBINEID = nowWindturbineId; c.MODELID = wb.MODELID; c.STATIONID = stationId; } } } #region 左边风机焦点 if (stationId == "SBQ_FDC") { for (int i = 0; i < this.pnlLeft_SBQ.Controls.Count; i++) { try { if (this.pnlLeft_SBQ.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_SBQ.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } if (stationId == "NSS_FDC") { for (int i = 0; i < this.pnlLeft_NSS.Controls.Count; i++) { try { if (this.pnlLeft_NSS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_NSS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } if (stationId == "MHS_FDC") { for (int i = 0; i < this.pnlLeft_MHS.Controls.Count; i++) { try { if (this.pnlLeft_MHS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_MHS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } if (stationId == "XS_FDC") { for (int i = 0; i < this.pnlLeft_XS.Controls.Count; i++) { try { if (this.pnlLeft_XS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_XS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } if (stationId == "QS_FDC") { for (int i = 0; i < this.pnlLeft_QS.Controls.Count; i++) { try { if (this.pnlLeft_QS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lbl = (LabelWindturbineName)this.pnlLeft_QS.Controls[i]; if (lbl.Name.Replace("lwn", "") == nowWindturbineId) NowWindturbineControl = lbl; } } catch (Exception) { throw; } } } #endregion } //主要为刷新风机状态 private void timer1_Tick(object sender, EventArgs e) { #region 刷新时间 DateTime time = DateTime.Now; string timeString = time.ToString("yyyy-MM-dd HH:mm:ss"); lblTimeNow.Text = timeString; #endregion if (isRefreshOver) { isRefreshOver = false; //刷新数据线程 Thread refreshThread = new Thread(new ParameterizedThreadStart(WindturbineStatusSvc.RefreshStatusSvc)); IList windturbineIdList = new List(); using (wisdom_cs_entity ctx = new wisdom_cs_entity()) { windturbineIdList = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID == nowStationId) .ToList() .Select(s => s.ID) .ToList(); } refreshThread.Start(windturbineIdList); isRefreshOver = true; } //绑定数据线程 Thread bindDataThread = new Thread(BindData); bindDataThread.Start(); } public delegate void UpdateFormInfoDelegate(); private void BindWindturbineStatus() { #region 刷新风机状态 Dictionary dic = WindturbineStatusSvc.GetStatus(); foreach (var item in dic) { try { string nowWindturbineId = lblWindturbineId.Text; if (nowWindturbineId == item.Key) { switch (item.Value) { case WindturbineStatus.Offline: lblStatus.BackColor = Color.FromArgb(134, 150, 165); lblStatus.Text = "离线"; break; case WindturbineStatus.Start: lblStatus.BackColor = Color.FromArgb(14, 72, 91); lblStatus.Text = "启动"; break; case WindturbineStatus.Fault: lblStatus.BackColor = Color.FromArgb(170, 15, 59); lblStatus.Text = "故障"; break; case WindturbineStatus.Maintain: lblStatus.BackColor = Color.FromArgb(204, 83, 51); lblStatus.Text = "维护"; break; case WindturbineStatus.Stop: lblStatus.BackColor = Color.FromArgb(176, 151, 63); lblStatus.Text = "停机"; break; case WindturbineStatus.Online: lblStatus.BackColor = Color.FromArgb(15, 135, 170); lblStatus.Text = "并网"; break; case WindturbineStatus.OnPower: lblStatus.BackColor = Color.FromArgb(177, 14, 126); lblStatus.Text = "上电"; break; case WindturbineStatus.Standby: lblStatus.BackColor = Color.FromArgb(15, 141, 106); lblStatus.Text = "待机"; break; default: break; } } if (nowStationId == "SBQ_FDC") { for (int i = 0; i < pnlLeft_SBQ.Controls.Count; i++) { string cname = "lwn" + item.Key; if (pnlLeft_SBQ.Controls[i] is LabelWindturbineName) { LabelWindturbineName lblwn = (LabelWindturbineName)pnlLeft_SBQ.Controls[i]; if (lblwn.Name == cname) lblwn.Status = item.Value; } } } if (nowStationId == "MHS_FDC") { for (int i = 0; i < pnlLeft_MHS.Controls.Count; i++) { string cname = "lwn" + item.Key; if (pnlLeft_MHS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lblwn = (LabelWindturbineName)pnlLeft_MHS.Controls[i]; if (lblwn.Name == cname) lblwn.Status = item.Value; } } } if (nowStationId == "XS_FDC") { for (int i = 0; i < pnlLeft_XS.Controls.Count; i++) { string cname = "lwn" + item.Key; if (pnlLeft_XS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lblwn = (LabelWindturbineName)pnlLeft_XS.Controls[i]; if (lblwn.Name == cname) lblwn.Status = item.Value; } } } if (nowStationId == "NSS_FDC") { for (int i = 0; i < pnlLeft_NSS.Controls.Count; i++) { string cname = "lwn" + item.Key; if (pnlLeft_NSS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lblwn = (LabelWindturbineName)pnlLeft_NSS.Controls[i]; if (lblwn.Name == cname) lblwn.Status = item.Value; } } } if (nowStationId == "QS_FDC") { for (int i = 0; i < pnlLeft_QS.Controls.Count; i++) { string cname = "lwn" + item.Key; if (pnlLeft_QS.Controls[i] is LabelWindturbineName) { LabelWindturbineName lblwn = (LabelWindturbineName)pnlLeft_QS.Controls[i]; if (lblwn.Name == cname) lblwn.Status = item.Value; } } } } catch (Exception ex) { logger.Info("找不到要绑定的控件:" + ex.Message); } } #endregion } public void BindData() { UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(BindWindturbineStatus); if (this.InvokeRequired) { this.BeginInvoke(del, new object[] { }); } else { BindWindturbineStatus(); } } } }