ParamsForm.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using IntelligentControlForsx.Service;
  2. using IntelligentControlForsx.Service.Control.FormInfo;
  3. using IntelligentControlForsx.Template;
  4. using System;
  5. using System.ComponentModel;
  6. using System.Threading;
  7. using StatInfo = IntelligentControlForsx.Service.Control.FormInfo.StatInfo;
  8. namespace IntelligentControlForsx.ChildForms
  9. {
  10. public partial class ParamsForm : TemplateForm
  11. {
  12. public ParamsForm()
  13. {
  14. InitializeComponent();
  15. }
  16. public override void Active()
  17. {
  18. this.Show();
  19. this.windturbineParams1.Active();
  20. //timer1.Enabled = true;
  21. Thread ayscThread = new Thread(LoadData);
  22. ayscThread.IsBackground = true;
  23. ayscThread.Start();
  24. timer1.Start();
  25. }
  26. public override void DeActive()
  27. {
  28. this.Hide();
  29. this.windturbineParams1.DeActive();
  30. timer1.Stop();
  31. }
  32. private void ParamsForm_Load(object sender, EventArgs e)
  33. {
  34. StationId = "SBQ_FDC";
  35. }
  36. private string stationId;
  37. private string stationName;
  38. [Browsable(true), Category("Data")]
  39. public String StationId
  40. {
  41. get
  42. {
  43. return stationId;
  44. }
  45. set
  46. {
  47. if (value != this.stationId && value.EndsWith("_FDC"))
  48. {
  49. stationId = value;
  50. stationName = CacheService.Instance.getStationName(stationId);
  51. if (isLoadding == true)
  52. return;
  53. Thread ayscThread = new Thread(LoadData);
  54. ayscThread.IsBackground = true;
  55. ayscThread.Start();
  56. windturbineParams1.StationId = stationId;
  57. }
  58. }
  59. }
  60. public override void SelectedStationChanged(string stationId)
  61. {
  62. this.StationId = stationId;
  63. //Active();
  64. }
  65. #region 加载数据
  66. private void timer1_Tick(object sender, EventArgs e)
  67. {
  68. if (isLoadding == true)
  69. return;
  70. Thread ayscThread = new Thread(LoadData);
  71. ayscThread.IsBackground = true;
  72. ayscThread.Start();
  73. }
  74. private bool isLoadding = false;
  75. private void LoadData()
  76. {
  77. if (isLoadding == true)
  78. return;
  79. isLoadding = true;
  80. try
  81. {
  82. StatInfo info = StatInfoSvc.Instance.GetStatInfoByStation(stationId);
  83. info.StationName = stationName;
  84. lock (this)
  85. {
  86. this.BeginInvoke(
  87. (Action)delegate
  88. {
  89. prTop.BindData(info);
  90. });
  91. }
  92. }
  93. catch (Exception ex)
  94. {
  95. //logger.Info("绑定数据失败!ex=" + ex.Message);
  96. }
  97. finally
  98. {
  99. isLoadding = false;
  100. }
  101. }
  102. #endregion
  103. }
  104. }