using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using EntityDataSet; using IntelligentControlForsx.Service; using IntelligentControlForsx.Service.Control.FormInfo; using IntelligentControlForsx.Service.WindturbineControl.Domain; using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd; using IntelligentControlForsx.Service.WindturbineControl.Domain.FormInfo; using IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc; using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc; using IntelligentControlForsx.Template; using Gyee_Control.Svc.Cache; using Gyee_Control.View; using log4net; using log4net.Util; namespace IntelligentControlForsx.ChildForms { public partial class ControlForm2 : TemplateForm { private ILog logger = LogManager.GetLogger("AppInfoLog"); private string StationId = "SBQ_FDC"; private StatInfo statInfoByStation = null; private StatInfo statInfoAll = null; /// /// 当前风场风机状态数量是否绑定结束 /// private bool IsBindDataOver = true; /// /// 当前风场风机状态数量是否绑定结束 /// private bool IsUpdateDataOver = true; public ControlForm2() { InitializeComponent(); sbQ_Control1.Show(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.Active(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); statInfoByStation = StatInfoSvc.Instance.GetStatInfoByStation(StationId); BindFormStatInfo(); } public override void Active() { string stationId = NavService.Instance.StationId; if (stationId == "0") stationId = "SBQ_FDC"; StationId = stationId; this.Show(); timer1.Enabled = true; if (stationId == "SBQ_FDC") { sbQ_Control1.Show(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.Active(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); } else if (stationId == "MHS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Show(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.Active(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); } else if (stationId == "XS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Show(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.Active(); qS_Control1.DeActive(); nsS_Control1.DeActive(); } else if (stationId == "QS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Show(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.Active(); nsS_Control1.DeActive(); } else if (stationId == "NSS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Show(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.Active(); } UpdateStatInfo(); BindFormStatInfo(); } public override void DeActive() { this.Hide(); timer1.Enabled = false; sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); } public override void SelectedStationChanged(string stationId) { if (stationId == "SBQ_FDC") { sbQ_Control1.Show(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.Active(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); StationId = "SBQ_FDC"; UpdateStatInfo(); BindFormStatInfo(); } if (stationId == "MHS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Show(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.Active(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.DeActive(); StationId = "MHS_FDC"; UpdateStatInfo(); BindFormStatInfo(); } if (stationId == "XS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Show(); qS_Control1.Hide(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.Active(); qS_Control1.DeActive(); nsS_Control1.DeActive(); StationId = "XS_FDC"; UpdateStatInfo(); BindFormStatInfo(); } if (stationId == "QS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Show(); nsS_Control1.Hide(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.Active(); nsS_Control1.DeActive(); StationId = "QS_FDC"; UpdateStatInfo(); BindFormStatInfo(); } if (stationId == "NSS_FDC") { sbQ_Control1.Hide(); mhS_Control1.Hide(); xS_Control1.Hide(); qS_Control1.Hide(); nsS_Control1.Show(); sbQ_Control1.DeActive(); mhS_Control1.DeActive(); xS_Control1.DeActive(); qS_Control1.DeActive(); nsS_Control1.Active(); StationId = "NSS_FDC"; UpdateStatInfo(); BindFormStatInfo(); } } private delegate void UpdateGridViewDelegate(); private void timer1_Tick(object sender, EventArgs e) { if (StationId == "0") StationId = "SBQ_FDC"; if (IsBindDataOver) { IsBindDataOver = false; Thread t = new Thread(BingDataThread); t.IsBackground = true; t.Start(); } if (IsUpdateDataOver) { IsBindDataOver = false; Thread t = new Thread(UpdateStatInfo); t.IsBackground = true; t.Start(); } } public void BingDataThread() { UpdateGridViewDelegate del = new UpdateGridViewDelegate(BindFormStatInfo); if (this.InvokeRequired) { this.BeginInvoke(del, new object[] { }); } else { BindFormStatInfo(); } IsBindDataOver = true; } private void BindFormStatInfo() { if (statInfoByStation != null && statInfoByStation.StationId == StationId) { controlFormTop.BindStationInfo(statInfoByStation); controlFormTop.BindAllStationInfo(statInfoAll); } } private void UpdateStatInfo() { statInfoByStation = StatInfoSvc.Instance.GetStatInfoByStation(StationId); statInfoAll = StatInfoSvc.Instance.GeStatInfo(); IsBindDataOver = true; } } }