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.WindturbineInfo; using log4net; namespace IntelligentControlForsx.MyControls.windturbine { public partial class BaseControl : UserControl { /// /// 风场编号 /// public string STATIONID = "SBQ_FDC"; /// /// 风机编号 /// public string WINDTURBINEID = "SG01_01"; /// /// 风机型号 /// public string MODELID = "UP82_2"; /// /// 数据是否刷新完毕 /// public bool isRefreshOver = true; private static ILog logger = LogManager.GetLogger("AppInfoLog"); public BaseControl() { InitializeComponent(); } public virtual void Active(string stationId, string windturbineId, string modelId) { } public virtual void DeActive() { } public delegate void UpdateFormInfoDelegate(); public void BindData() { UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(PointInfoBind); if (this.InvokeRequired) { this.BeginInvoke(del, new object[] { }); } else { PointInfoBind(); } } public void PointInfoBind() { IList list = WindturbineInfoSvc.Instance.GetPointData(); foreach (var data in list) { string controlName = "P" + data.PartIndex.Replace("part", "") + "_PointValue" + data.Index; try { object obj = this.GetType().GetField(controlName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.IgnoreCase).GetValue(this); if (obj is PointValueAI) { PointValueAI ai = (PointValueAI)obj; ai.BindData(data); } else if (obj is PointValueDI) { PointValueDI di = (PointValueDI)obj; di.BindData(data); } } catch (Exception ex) { logger.Error("绑定数据时,找不到控件:" + ex); } } } public void Refresh() { WindturbineInfoSvc infoSvc = WindturbineInfoSvc.Instance; infoSvc.RefreshPointValue(STATIONID, WINDTURBINEID, MODELID, this.GetType().Name); } } }