123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using IntelligentControlForsx.Code;
- using IntelligentControlForsx.Service.AGC;
- using IntelligentControlForsx.Service.AGC.Domain;
- using WisdomClient.data;
- namespace IntelligentControlForsx.MyControls.agc
- {
- public partial class SunAGC : UserControl
- {
- private bool isUpdateDataOver = true;
- private bool isBindFormOver = true;
- private bool isUpdateLineDataOver = true;
- private bool isBindLineFormOver = true;
- public SunAGC()
- {
- InitializeComponent();
- }
- public void DeActive()
- {
- timer1.Stop();
- timer2.Stop();
- }
- public void Active()
- {
- this.Show();
- timer1.Start();
- timer2.Start();
- }
-
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (isBindFormOver)//绑定form
- {
- isBindFormOver = false;
- Thread bindDataThread = new Thread(BindFormInvoke);
- bindDataThread.Start();
- }
- if (isUpdateDataOver)//更新数据
- {
- Thread ayscThread = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetLatestAgcDataInfo));
- ayscThread.IsBackground = true;
- ayscThread.Start(false);
- }
- }
- public delegate void UpdateFormInfoDelegate();
- public void BindFormInvoke()
- {
- UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(FormDataBind);
- if (this.InvokeRequired)
- {
- this.BeginInvoke(del, new object[] { });
- }
- else
- {
- FormDataBind();
- }
- }
- public void FormDataBind()
- {
- string path = UserTools.Path;
- string green_img_path = path + @"\images\green.png";
- string red_img_path = path + @"\images\red.png";
- #region 石嘴山5
- AgcEntity szs5 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "SZS5").FirstOrDefault();
- if (szs5 != null)
- {
- lblPowerSet_SZS5.LableText = szs5.PowerSetValue.ToString("f2");
- lblActualPower_SZS5.LableText = szs5.ActualPowerValue.ToString("f2");
- lblAgcUp_SZS5.LableText = szs5.AgcUp .ToString("f2");
- lblAgcLower_SZS5.LableText = szs5.AgcLower.ToString("f2");
- lblForecastPower_SZS5.LableText = szs5.ForecastPower.ToString("f2");
- if (szs5.AgcIn)
- picAgcOut_SZS5.Image = Image.FromFile(red_img_path);
- else
- picAgcOut_SZS5.Image = Image.FromFile(green_img_path);
- if (szs5.AgcFar)
- picAgcFar_SZS5.Image = Image.FromFile(red_img_path);
- else
- picAgcFar_SZS5.Image = Image.FromFile(green_img_path);
-
- }
- #endregion
- #region 平罗3
- AgcEntity pl3 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "PL3").FirstOrDefault();
- if (pl3 != null)
- {
- lblPowerSet_PL3.LableText = pl3.PowerSetValue .ToString("f2");
- lblActualPower_PL3.LableText = pl3.ActualPowerValue.ToString("f2");
- lblAgcUp_PL3.LableText = pl3.AgcUp .ToString("f2");
- lblAgcLower_PL3.LableText = pl3.AgcLower .ToString("f2");
- lblForecastPower_PL3.LableText = pl3.ForecastPower.ToString("f2");
- if (pl3.AgcIn)
- picAgcOut_PL3.Image = Image.FromFile(red_img_path);
- else
- picAgcOut_PL3.Image = Image.FromFile(green_img_path);
- if (pl3.AgcFar)
- picAgcFar_PL3.Image = Image.FromFile(red_img_path);
- else
- picAgcFar_PL3.Image = Image.FromFile(green_img_path);
- }
- #endregion
- #region 中卫6
- AgcEntity zw6 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "ZW6").FirstOrDefault();
- if (zw6 != null)
- {
- lblPowerSet_ZW6.LableText = zw6.PowerSetValue .ToString("f2");
- lblActualPower_ZW6.LableText = zw6.ActualPowerValue.ToString("f2");
- lblAgcUp_ZW6.LableText = zw6.AgcUp .ToString("f2");
- lblAgcLower_ZW6.LableText = zw6.AgcLower .ToString("f2");
- lblForecastPower_ZW6.LableText = zw6.ForecastPower.ToString("f2");
- if (zw6.AgcIn)
- picAgcOut_ZW6.Image = Image.FromFile(red_img_path);
- else
- picAgcOut_ZW6.Image = Image.FromFile(green_img_path);
- if (zw6.AgcFar)
- picAgcFar_ZW6.Image = Image.FromFile(red_img_path);
- else
- picAgcFar_ZW6.Image = Image.FromFile(green_img_path);
- }
- #endregion
-
- isBindFormOver = true;
- }
- private void timer2_Tick(object sender, EventArgs e)
- {
- if (isBindLineFormOver)//绑定form
- {
- isBindLineFormOver = false;
- Thread bindDataThread = new Thread(BindFormLineInvoke);
- bindDataThread.Start();
- }
- if (isUpdateLineDataOver)//更新数据
- {
- Thread ayscThread = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetHistoryLineData));
- ayscThread.IsBackground = true;
- ayscThread.Start(false);
- }
- }
- public void BindFormLineInvoke()
- {
- UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(FormLineDataBind);
- if (this.InvokeRequired)
- {
- this.BeginInvoke(del, new object[] { });
- }
- else
- {
- FormLineDataBind();
- }
- }
- public void FormLineDataBind()
- {
-
- PowerActual powerActual_szs5 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "SZS5").FirstOrDefault();
- PowerSet powerSet_szs5 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "SZS5").FirstOrDefault();
- if (powerActual_szs5 != null && powerSet_szs5 != null)
- {
- IList<TsData> pstList = new List<TsData>();
- IList<TsData> actlList = new List<TsData>();
- for (int i = 0; i < powerSet_szs5.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerSet_szs5.TsDataList[i].ts;
- double tValue = powerSet_szs5.TsDataList[i].doubleValue.HasValue
- ? powerSet_szs5.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- pstList.Add(tsData);
- }
- for (int i = 0; i < powerActual_szs5.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerActual_szs5.TsDataList[i].ts;
- double tValue = powerActual_szs5.TsDataList[i].doubleValue.HasValue
- ? powerActual_szs5.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- actlList.Add(tsData);
- }
- lineChar_SZS5.DataBind(actlList, pstList);
- }
- PowerActual powerActual_pl3 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "PL3").FirstOrDefault();
- PowerSet powerSet_pl3 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "PL3").FirstOrDefault();
- if (powerActual_pl3 != null && powerSet_pl3 != null)
- {
- IList<TsData> pstList = new List<TsData>();
- IList<TsData> actlList = new List<TsData>();
- for (int i = 0; i < powerSet_pl3.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerSet_pl3.TsDataList[i].ts;
- double tValue = powerSet_pl3.TsDataList[i].doubleValue.HasValue
- ? powerSet_pl3.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- pstList.Add(tsData);
- }
- for (int i = 0; i < powerActual_pl3.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerActual_pl3.TsDataList[i].ts;
- double tValue = powerActual_pl3.TsDataList[i].doubleValue.HasValue
- ? powerActual_pl3.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- actlList.Add(tsData);
- }
- lineChar_PL3.DataBind(actlList, pstList);
- }
- PowerActual powerActual_zw6 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "ZW6").FirstOrDefault();
- PowerSet powerSet_zw6 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "ZW6").FirstOrDefault();
- if (powerActual_zw6 != null && powerSet_zw6 != null)
- {
- IList<TsData> pstList = new List<TsData>();
- IList<TsData> actlList = new List<TsData>();
- for (int i = 0; i < powerSet_zw6.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerSet_zw6.TsDataList[i].ts;
- double tValue = powerSet_zw6.TsDataList[i].doubleValue.HasValue
- ? powerSet_zw6.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- pstList.Add(tsData);
- }
- for (int i = 0; i < powerActual_zw6.TsDataList.Count; i++)
- {
- TsData tsData = new TsData();
- tsData.ts = powerActual_zw6.TsDataList[i].ts;
- double tValue = powerActual_zw6.TsDataList[i].doubleValue.HasValue
- ? powerActual_zw6.TsDataList[i].doubleValue.Value
- : 0.0;
- tsData.doubleValue = tValue;
- actlList.Add(tsData);
- }
- lineChar_ZW6.DataBind(actlList, pstList);
- }
-
- isBindLineFormOver = true;
- }
- private void SunAGC_Load(object sender, EventArgs e)
- {
- Thread ayscThread1 = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetLatestAgcDataInfo));
- ayscThread1.IsBackground = true;
- ayscThread1.Start(true);
- Thread ayscThread2 = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetHistoryLineData));
- ayscThread2.IsBackground = true;
- ayscThread2.Start(true);
- }
-
- }
- }
|