12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082 |
- 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");
- /// <summary>
- /// 当前风电场
- /// </summary>
- 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; }
- //}
- /// <summary>
- /// 当前风机
- /// </summary>
- 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);
- }
- }
- /// <summary>
- /// 当前风机型号
- /// </summary>
- private string modelId = "UP82_2";
- /// <summary>
- /// 当前所显示的页面
- /// </summary>
- private BaseControl nowControl = null;
- /// <summary>
- /// 当前风机控件
- /// </summary>
- private LabelWindturbineName nowWindturbineControl = null;
- public LabelWindturbineName NowWindturbineControl
- {
- set
- {
- if (value != nowWindturbineControl)
- {
- nowWindturbineControl.Style_UnFocus();
- value.Style_Focus();
- }
- nowWindturbineControl = value;
- }
- get { return nowWindturbineControl; }
- }
- /// <summary>
- /// 数据是否刷新完毕
- /// </summary>
- public bool isRefreshOver = true;
- /// <summary>
- /// 当前风场的风机编号集合
- /// </summary>
- private IList<string> windturbineList = new List<string>();
- 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
- /// <summary>
- /// 绑定风机tree
- /// </summary>
- /// <param name="stationCode"></param>
- private void BindWindturbine(string stationCode)
- {
- IList<string> windturbineIdList = new List<string>();
- using (wisdom_cs_entity ctx = new wisdom_cs_entity())
- {
- IList<windturbine> list = ctx.windturbine.Where(s => s.WINDPOWERSTATIONID.Contains("FDC")).ToList();
- IList<windturbine> orderList_SBQ = list.Where(k => k.WINDPOWERSTATIONID == "SBQ_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("SG01_", ""))).ToList();
- IList<windturbine> orderList_NSS = list.Where(k => k.WINDPOWERSTATIONID == "NSS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("NG01_", ""))).ToList();
- IList<windturbine> orderListMHS = list.Where(k => k.WINDPOWERSTATIONID == "MHS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("MG01_", ""))).ToList();
- IList<windturbine> orderListXS = list.Where(k => k.WINDPOWERSTATIONID == "XS_FDC").OrderByDescending(s => Convert.ToInt32(s.ID.Replace("XG01_", ""))).ToList();
- IList<windturbine> 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<string> windturbineIdList = new List<string>();
- 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<string, WindturbineStatus> 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();
- }
- }
- }
- }
|