ControlForm2.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Text.RegularExpressions;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. using EntityDataSet;
  13. using IntelligentControlForsx.Service;
  14. using IntelligentControlForsx.Service.Control.FormInfo;
  15. using IntelligentControlForsx.Service.WindturbineControl.Domain;
  16. using IntelligentControlForsx.Service.WindturbineControl.Domain.Cmd;
  17. using IntelligentControlForsx.Service.WindturbineControl.Domain.FormInfo;
  18. using IntelligentControlForsx.Service.WindturbineControl.FormInfoSvc;
  19. using IntelligentControlForsx.Service.WindturbineControl.IntPtrSvc;
  20. using IntelligentControlForsx.Template;
  21. using Gyee_Control.Svc.Cache;
  22. using Gyee_Control.View;
  23. using log4net;
  24. using log4net.Util;
  25. namespace IntelligentControlForsx.ChildForms
  26. {
  27. public partial class ControlForm2 : TemplateForm
  28. {
  29. private ILog logger = LogManager.GetLogger("AppInfoLog");
  30. private string StationId = "SBQ_FDC";
  31. private StatInfo statInfoByStation = null;
  32. private StatInfo statInfoAll = null;
  33. /// <summary>
  34. /// 当前风场风机状态数量是否绑定结束
  35. /// </summary>
  36. private bool IsBindDataOver = true;
  37. /// <summary>
  38. /// 当前风场风机状态数量是否绑定结束
  39. /// </summary>
  40. private bool IsUpdateDataOver = true;
  41. public ControlForm2()
  42. {
  43. InitializeComponent();
  44. sbQ_Control1.Show();
  45. mhS_Control1.Hide();
  46. xS_Control1.Hide();
  47. qS_Control1.Hide();
  48. nsS_Control1.Hide();
  49. sbQ_Control1.Active();
  50. mhS_Control1.DeActive();
  51. xS_Control1.DeActive();
  52. qS_Control1.DeActive();
  53. nsS_Control1.DeActive();
  54. statInfoByStation = StatInfoSvc.Instance.GetStatInfoByStation(StationId);
  55. BindFormStatInfo();
  56. }
  57. public override void Active()
  58. {
  59. string stationId = NavService.Instance.StationId;
  60. if (stationId == "0")
  61. stationId = "SBQ_FDC";
  62. StationId = stationId;
  63. this.Show();
  64. timer1.Enabled = true;
  65. if (stationId == "SBQ_FDC")
  66. {
  67. sbQ_Control1.Show();
  68. mhS_Control1.Hide();
  69. xS_Control1.Hide();
  70. qS_Control1.Hide();
  71. nsS_Control1.Hide();
  72. sbQ_Control1.Active();
  73. mhS_Control1.DeActive();
  74. xS_Control1.DeActive();
  75. qS_Control1.DeActive();
  76. nsS_Control1.DeActive();
  77. }
  78. else if (stationId == "MHS_FDC")
  79. {
  80. sbQ_Control1.Hide();
  81. mhS_Control1.Show();
  82. xS_Control1.Hide();
  83. qS_Control1.Hide();
  84. nsS_Control1.Hide();
  85. sbQ_Control1.DeActive();
  86. mhS_Control1.Active();
  87. xS_Control1.DeActive();
  88. qS_Control1.DeActive();
  89. nsS_Control1.DeActive();
  90. }
  91. else if (stationId == "XS_FDC")
  92. {
  93. sbQ_Control1.Hide();
  94. mhS_Control1.Hide();
  95. xS_Control1.Show();
  96. qS_Control1.Hide();
  97. nsS_Control1.Hide();
  98. sbQ_Control1.DeActive();
  99. mhS_Control1.DeActive();
  100. xS_Control1.Active();
  101. qS_Control1.DeActive();
  102. nsS_Control1.DeActive();
  103. }
  104. else if (stationId == "QS_FDC")
  105. {
  106. sbQ_Control1.Hide();
  107. mhS_Control1.Hide();
  108. xS_Control1.Hide();
  109. qS_Control1.Show();
  110. nsS_Control1.Hide();
  111. sbQ_Control1.DeActive();
  112. mhS_Control1.DeActive();
  113. xS_Control1.DeActive();
  114. qS_Control1.Active();
  115. nsS_Control1.DeActive();
  116. }
  117. else if (stationId == "NSS_FDC")
  118. {
  119. sbQ_Control1.Hide();
  120. mhS_Control1.Hide();
  121. xS_Control1.Hide();
  122. qS_Control1.Hide();
  123. nsS_Control1.Show();
  124. sbQ_Control1.DeActive();
  125. mhS_Control1.DeActive();
  126. xS_Control1.DeActive();
  127. qS_Control1.DeActive();
  128. nsS_Control1.Active();
  129. }
  130. UpdateStatInfo();
  131. BindFormStatInfo();
  132. }
  133. public override void DeActive()
  134. {
  135. this.Hide();
  136. timer1.Enabled = false;
  137. sbQ_Control1.DeActive();
  138. mhS_Control1.DeActive();
  139. xS_Control1.DeActive();
  140. qS_Control1.DeActive();
  141. nsS_Control1.DeActive();
  142. }
  143. public override void SelectedStationChanged(string stationId)
  144. {
  145. if (stationId == "SBQ_FDC")
  146. {
  147. sbQ_Control1.Show();
  148. mhS_Control1.Hide();
  149. xS_Control1.Hide();
  150. qS_Control1.Hide();
  151. nsS_Control1.Hide();
  152. sbQ_Control1.Active();
  153. mhS_Control1.DeActive();
  154. xS_Control1.DeActive();
  155. qS_Control1.DeActive();
  156. nsS_Control1.DeActive();
  157. StationId = "SBQ_FDC";
  158. UpdateStatInfo();
  159. BindFormStatInfo();
  160. }
  161. if (stationId == "MHS_FDC")
  162. {
  163. sbQ_Control1.Hide();
  164. mhS_Control1.Show();
  165. xS_Control1.Hide();
  166. qS_Control1.Hide();
  167. nsS_Control1.Hide();
  168. sbQ_Control1.DeActive();
  169. mhS_Control1.Active();
  170. xS_Control1.DeActive();
  171. qS_Control1.DeActive();
  172. nsS_Control1.DeActive();
  173. StationId = "MHS_FDC";
  174. UpdateStatInfo();
  175. BindFormStatInfo();
  176. }
  177. if (stationId == "XS_FDC")
  178. {
  179. sbQ_Control1.Hide();
  180. mhS_Control1.Hide();
  181. xS_Control1.Show();
  182. qS_Control1.Hide();
  183. nsS_Control1.Hide();
  184. sbQ_Control1.DeActive();
  185. mhS_Control1.DeActive();
  186. xS_Control1.Active();
  187. qS_Control1.DeActive();
  188. nsS_Control1.DeActive();
  189. StationId = "XS_FDC";
  190. UpdateStatInfo();
  191. BindFormStatInfo();
  192. }
  193. if (stationId == "QS_FDC")
  194. {
  195. sbQ_Control1.Hide();
  196. mhS_Control1.Hide();
  197. xS_Control1.Hide();
  198. qS_Control1.Show();
  199. nsS_Control1.Hide();
  200. sbQ_Control1.DeActive();
  201. mhS_Control1.DeActive();
  202. xS_Control1.DeActive();
  203. qS_Control1.Active();
  204. nsS_Control1.DeActive();
  205. StationId = "QS_FDC";
  206. UpdateStatInfo();
  207. BindFormStatInfo();
  208. }
  209. if (stationId == "NSS_FDC")
  210. {
  211. sbQ_Control1.Hide();
  212. mhS_Control1.Hide();
  213. xS_Control1.Hide();
  214. qS_Control1.Hide();
  215. nsS_Control1.Show();
  216. sbQ_Control1.DeActive();
  217. mhS_Control1.DeActive();
  218. xS_Control1.DeActive();
  219. qS_Control1.DeActive();
  220. nsS_Control1.Active();
  221. StationId = "NSS_FDC";
  222. UpdateStatInfo();
  223. BindFormStatInfo();
  224. }
  225. }
  226. private delegate void UpdateGridViewDelegate();
  227. private void timer1_Tick(object sender, EventArgs e)
  228. {
  229. if (StationId == "0")
  230. StationId = "SBQ_FDC";
  231. if (IsBindDataOver)
  232. {
  233. IsBindDataOver = false;
  234. Thread t = new Thread(BingDataThread);
  235. t.IsBackground = true;
  236. t.Start();
  237. }
  238. if (IsUpdateDataOver)
  239. {
  240. IsBindDataOver = false;
  241. Thread t = new Thread(UpdateStatInfo);
  242. t.IsBackground = true;
  243. t.Start();
  244. }
  245. }
  246. public void BingDataThread()
  247. {
  248. UpdateGridViewDelegate del = new UpdateGridViewDelegate(BindFormStatInfo);
  249. if (this.InvokeRequired)
  250. {
  251. this.BeginInvoke(del, new object[] { });
  252. }
  253. else
  254. {
  255. BindFormStatInfo();
  256. }
  257. IsBindDataOver = true;
  258. }
  259. private void BindFormStatInfo()
  260. {
  261. if (statInfoByStation != null && statInfoByStation.StationId == StationId)
  262. {
  263. controlFormTop.BindStationInfo(statInfoByStation);
  264. controlFormTop.BindAllStationInfo(statInfoAll);
  265. }
  266. }
  267. private void UpdateStatInfo()
  268. {
  269. statInfoByStation = StatInfoSvc.Instance.GetStatInfoByStation(StationId);
  270. statInfoAll = StatInfoSvc.Instance.GeStatInfo();
  271. IsBindDataOver = true;
  272. }
  273. }
  274. }