AlternatorInfo.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using IntelligentControlForsx.Service.WindturbineInfo;
  12. using log4net;
  13. using WisdomClient;
  14. using WisdomClient.data;
  15. namespace IntelligentControlForsx.MyControls.windturbine
  16. {
  17. /// <summary>
  18. /// 发电机
  19. /// </summary>
  20. public partial class AlternatorInfo : BaseControl
  21. {
  22. private static ILog logger = LogManager.GetLogger("AppInfoLog");
  23. public AlternatorInfo()
  24. {
  25. InitializeComponent();
  26. }
  27. public override void Active(string stationId, string windturbineId, string modelId)
  28. {
  29. STATIONID = stationId;
  30. WINDTURBINEID = windturbineId;
  31. timer1.Enabled = true;
  32. Refresh();
  33. }
  34. public override void DeActive()
  35. {
  36. timer1.Enabled = false;
  37. }
  38. private void timer1_Tick(object sender, EventArgs e)
  39. {
  40. if (isRefreshOver)
  41. {
  42. isRefreshOver = false;
  43. //刷新数据线程
  44. Thread refreshThread = new Thread(Refresh);
  45. refreshThread.Start();
  46. isRefreshOver = true;
  47. }
  48. //绑定数据线程
  49. Thread bindDataThread = new Thread(BindData);
  50. bindDataThread.Start();
  51. }
  52. //private delegate void UpdateFormInfoDelegate();
  53. //private void BindData()
  54. //{
  55. // UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(PointInfoBind);
  56. // if (this.InvokeRequired)
  57. // {
  58. // this.BeginInvoke(del, new object[] { });
  59. // }
  60. // else
  61. // {
  62. // PointInfoBind();
  63. // }
  64. //}
  65. //private void PointInfoBind()
  66. //{
  67. // IList<UniformCodeInfo> list = WindturbineInfoSvc.Instance.GetPointData();
  68. // foreach (var data in list)
  69. // {
  70. // string controlName = "P" + data.PartIndex.Replace("part", "") + "_PointValue" + data.Index;
  71. // try
  72. // {
  73. // object obj = this.GetType().GetField(controlName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance
  74. // | System.Reflection.BindingFlags.IgnoreCase).GetValue(this);
  75. // if (obj is PointValueAI)
  76. // {
  77. // PointValueAI ai = (PointValueAI)obj;
  78. // ai.BindData(data);
  79. // }
  80. // else if (obj is PointValueDI)
  81. // {
  82. // PointValueDI di = (PointValueDI)obj;
  83. // di.BindData(data);
  84. // }
  85. // }
  86. // catch (Exception ex)
  87. // {
  88. // logger.Error("绑定数据时,找不到控件:" + ex);
  89. // }
  90. // }
  91. //}
  92. //private void Refresh()
  93. //{
  94. // WindturbineInfoSvc infoSvc = WindturbineInfoSvc.Instance;
  95. // infoSvc.RefreshPointValue(STATIONID, WINDTURBINEID, MODELID, this.GetType().Name);
  96. //}
  97. }
  98. }