using IntelligentControlForsx.Service; using IntelligentControlForsx.Service.Control.FormInfo; using IntelligentControlForsx.Template; using System; using System.ComponentModel; using System.Threading; using StatInfo = IntelligentControlForsx.Service.Control.FormInfo.StatInfo; namespace IntelligentControlForsx.ChildForms { public partial class ParamsForm : TemplateForm { public ParamsForm() { InitializeComponent(); } public override void Active() { this.Show(); this.windturbineParams1.Active(); //timer1.Enabled = true; Thread ayscThread = new Thread(LoadData); ayscThread.IsBackground = true; ayscThread.Start(); timer1.Start(); } public override void DeActive() { this.Hide(); this.windturbineParams1.DeActive(); timer1.Stop(); } private void ParamsForm_Load(object sender, EventArgs e) { StationId = "SBQ_FDC"; } private string stationId; private string stationName; [Browsable(true), Category("Data")] public String StationId { get { return stationId; } set { if (value != this.stationId && value.EndsWith("_FDC")) { stationId = value; stationName = CacheService.Instance.getStationName(stationId); if (isLoadding == true) return; Thread ayscThread = new Thread(LoadData); ayscThread.IsBackground = true; ayscThread.Start(); windturbineParams1.StationId = stationId; } } } public override void SelectedStationChanged(string stationId) { this.StationId = stationId; //Active(); } #region 加载数据 private void timer1_Tick(object sender, EventArgs e) { if (isLoadding == true) return; Thread ayscThread = new Thread(LoadData); ayscThread.IsBackground = true; ayscThread.Start(); } private bool isLoadding = false; private void LoadData() { if (isLoadding == true) return; isLoadding = true; try { StatInfo info = StatInfoSvc.Instance.GetStatInfoByStation(stationId); info.StationName = stationName; lock (this) { this.BeginInvoke( (Action)delegate { prTop.BindData(info); }); } } catch (Exception ex) { //logger.Info("绑定数据失败!ex=" + ex.Message); } finally { isLoadding = false; } } #endregion } }