123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- 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.Service;
- using IntelligentControlForsx.Service.ZM;
- using IntelligentControlForsx.Service.ZM.Domain;
- using log4net;
- namespace IntelligentControlForsx.MyControls.zm.map
- {
- public partial class SBQ_Project3 : MapControl
- {
- private static ILog logger = LogManager.GetLogger("AppInfoLog");
- /// <summary>
- /// 数据访问是否结束
- /// </summary>
- private bool IsRefreshDataOver = true;
- /// <summary>
- /// 绑定页面是否结束
- /// </summary>
- private bool IsBindFormOver = true;
- private NavService navSvc;
- public SBQ_Project3()
- {
- InitializeComponent();
- navSvc = NavService.Instance;
- }
- public override void Active()
- {
- timer1.Enabled = true;
- }
- public override void DeActive()
- {
- timer1.Enabled = false;
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (IsRefreshDataOver)
- {
- IsRefreshDataOver = false;
- Thread t = new Thread(RefreshData);
- t.IsBackground = true;
- t.Start();
- }
- if (IsBindFormOver)
- {
- IsBindFormOver = false;
- Thread t = new Thread(BindFormInvoke);
- t.IsBackground = true;
- t.Start();
- }
- }
- private void RefreshData()
- {
- ZmWindturbineInfoSvc.GetInfo("SBQ_FDC", "SBQ03_GC");
- IsRefreshDataOver = true;
- }
- public delegate void UpdateFormInfoDelegate();
- public void BindFormInvoke()
- {
- SBQ_Project1.UpdateFormInfoDelegate del = new SBQ_Project1.UpdateFormInfoDelegate(FormDataBind);
- if (this.InvokeRequired)
- {
- this.BeginInvoke(del, new object[] { });
- }
- else
- {
- FormDataBind();
- }
- IsBindFormOver = true;
- }
- private void FormDataBind()
- {
- try
- {
- if (!timer1.Enabled)
- {
- return;
- }
- ZmWindturbineInfo[] tmplist = new ZmWindturbineInfo[ZmWindturbineInfoSvc.infoList.Count];
- ZmWindturbineInfoSvc.infoList.CopyTo(tmplist, 0);
- IList<ZmWindturbineInfo> list = tmplist.Where(s => s.ProjectId == "SBQ03_GC" && s.StationId == "SBQ_FDC").ToList();
- for (int i = 0; i < list.Count; i++)
- {
- string controlName = "wf" + list[i].WindturbineId.Replace("SG01_", "");
- Control ct = this.Controls.Find(controlName, true).FirstOrDefault();
- if (ct != null)
- {
- try
- {
- if (ct is WindturbineInfoControl)
- {
- WindturbineInfoControl wc = (WindturbineInfoControl)ct;
- wc.BindData(list[i].Power, list[i].WindSpeed, Convert.ToInt32(list[i].Status));
- }
- }
- catch (Exception ex)
- {
- logger.Info("寻找控件或控件转换失败" + ex.Message);
- }
- }
- }
- }
- catch { }
- }
- private void Windturbine_MyClick(object sender, EventArgs e)
- {
- try
- {
- WindturbineInfoControl icon = (WindturbineInfoControl)sender;
- if (icon != null)
- {
- string windturbineId = "SG01_" + icon.WindturbineName.Replace("号", "").Trim();
- navSvc.NavForWindturbine("pictureBoxParamters", windturbineId,"SBQ_FDC");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
|