123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- 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;
- /// <summary>
- /// 当前风场风机状态数量是否绑定结束
- /// </summary>
- private bool IsBindDataOver = true;
- /// <summary>
- /// 当前风场风机状态数量是否绑定结束
- /// </summary>
- 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;
- }
- }
- }
|