WindAGC.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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.Code;
  12. using IntelligentControlForsx.Service.AGC;
  13. using IntelligentControlForsx.Service.AGC.Domain;
  14. using WisdomClient;
  15. using WisdomClient.data;
  16. namespace IntelligentControlForsx.MyControls.agc
  17. {
  18. public partial class WindAGC : UserControl
  19. {
  20. private bool isUpdateDataOver = true;
  21. private bool isBindFormOver = true;
  22. private bool isUpdateLineDataOver = true;
  23. private bool isBindLineFormOver = true;
  24. public WindAGC()
  25. {
  26. InitializeComponent();
  27. //Thread t = new Thread(LineInitThread);
  28. //t.IsBackground = true;
  29. //t.Start();
  30. AgcInfoSvc.GetTagName();
  31. AgcPoint agcMHS2 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  32. AgcPoint agcMHS6 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  33. AgcPoint agcNSS2 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  34. AgcPoint agcNSS5 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  35. AgcPoint agcXN6 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "XN6").FirstOrDefault();
  36. AgcPoint agcXS5 = AgcInfoSvc.pointTagNameList.Where(s => s.StationName == "XS5").FirstOrDefault();
  37. if (agcMHS2 != null)
  38. lineChar_MHS2.BindPointAndTitle(agcMHS2.ActualPowerTagName, agcMHS2.PowerSetTagName, "麻黄山第二风电场");
  39. if (agcMHS6 != null)
  40. lineChar_MHS6.BindPointAndTitle(agcMHS6.ActualPowerTagName, agcMHS6.PowerSetTagName, "麻黄山第六风电场");
  41. if (agcNSS2 != null)
  42. lineChar_NSS2.BindPointAndTitle(agcNSS2.ActualPowerTagName, agcNSS2.PowerSetTagName, "牛首山第二风电场");
  43. if (agcNSS5 != null)
  44. lineChar_NSS5.BindPointAndTitle(agcNSS5.ActualPowerTagName, agcNSS5.PowerSetTagName, "牛首山第五风电场");
  45. if (agcXN6 != null)
  46. lineChar_XN6.BindPointAndTitle(agcXN6.ActualPowerTagName, agcXN6.PowerSetTagName, "星能第六风电场");
  47. if (agcXS5 != null)
  48. lineChar_XS5.BindPointAndTitle(agcXS5.ActualPowerTagName, agcXS5.PowerSetTagName, "香山第五风电场");
  49. //Thread t = new Thread(InitData);
  50. // t.IsBackground = true;
  51. // t.Start();
  52. }
  53. private void InitData()
  54. {
  55. isUpdateLineDataOver = false;
  56. AgcInfoSvc.GetHistoryLineDataFirst();
  57. isUpdateLineDataOver = true;
  58. }
  59. public void DeActive()
  60. {
  61. timer1.Stop();
  62. timer2.Stop();
  63. }
  64. public void Active()
  65. {
  66. this.Show();
  67. timer1.Start();
  68. timer2.Start();
  69. }
  70. private void timer1_Tick(object sender, EventArgs e)
  71. {
  72. if (isBindFormOver)//绑定form
  73. {
  74. isBindFormOver = false;
  75. Thread bindDataThread = new Thread(BindFormInvoke);
  76. bindDataThread.Start();
  77. }
  78. if (isUpdateDataOver)//更新数据
  79. {
  80. Thread ayscThread = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetLatestAgcDataInfo));
  81. ayscThread.IsBackground = true;
  82. ayscThread.Start(true);
  83. }
  84. }
  85. public delegate void UpdateFormInfoDelegate();
  86. public void BindFormInvoke()
  87. {
  88. UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(FormDataBind);
  89. if (this.InvokeRequired)
  90. {
  91. this.BeginInvoke(del, new object[] { });
  92. }
  93. else
  94. {
  95. FormDataBind();
  96. }
  97. }
  98. public void FormDataBind()
  99. {
  100. string path = UserTools.Path;
  101. string green_img_path = path + @"\images\green.png";
  102. string red_img_path = path + @"\images\red.png";
  103. #region 麻黄山2
  104. AgcEntity mhs2 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  105. if (mhs2 != null)
  106. {
  107. lblPowerSet_MHS2.LableText = mhs2.PowerSetValue.ToString("f2");
  108. lblPowerSet_MHS2.BindData(mhs2.PowerSetValue.ToString("f2"), "MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0296", "麻黄山2有功设定限值");
  109. lblActualPower_MHS2.LableText = mhs2.ActualPowerValue.ToString("f2");
  110. lblActualPower_MHS2.BindData(mhs2.ActualPowerValue.ToString("f2"), "MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0029", "麻黄山2实发有功");
  111. lblAgcOn_MHS2.LableText = (mhs2.AgcUp / 10).ToString("f2");
  112. lblAgcOn_MHS2.BindData((mhs2.AgcUp / 10).ToString("f2"), "MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0294", "麻黄山2AGC可调上限");
  113. lblAgcUp_MHS2.LableText = (mhs2.AgcLower / 100).ToString("f2");
  114. lblAgcUp_MHS2.BindData((mhs2.AgcLower / 100).ToString("f2"), "MHSDQ.NX_GD_MHSF_DQ_P1_L1_001_AI0295", "麻黄山2AGC可调下限");
  115. lblTheoryPower_MHS2.LableText = (mhs2.TheoryPower / 1000).ToString("f2");
  116. lblTheoryPower_MHS2.BindData((mhs2.TheoryPower / 1000).ToString("f2"), "MHSFCJSFW.NX_GD_MHSF_XX_XX_XXX_XXX_CI0192", "麻黄山2理论功率");
  117. lblForecastPower_MHS2.LableText = mhs2.ForecastPower.ToString("f2");
  118. lblForecastPower_MHS2.BindData(mhs2.ForecastPower.ToString("f2"), "MHSFGL.NX_GD_MHSF_YC_P1_L1_001_CDQ001", "麻黄山2预测功率");
  119. if (mhs2.AgcIn)
  120. picAgcIn_MHS2.Image = Image.FromFile(red_img_path);
  121. else
  122. picAgcIn_MHS2.Image = Image.FromFile(green_img_path);
  123. if (mhs2.AgcFar)
  124. picAgcFar_MHS2.Image = Image.FromFile(red_img_path);
  125. else
  126. picAgcFar_MHS2.Image = Image.FromFile(green_img_path);
  127. if (mhs2.SumLock)
  128. picSumLock_MHS2.Image = Image.FromFile(red_img_path);
  129. else
  130. picSumLock_MHS2.Image = Image.FromFile(green_img_path);
  131. if (mhs2.SubLock)
  132. picSubLock_MHS2.Image = Image.FromFile(red_img_path);
  133. else
  134. picSubLock_MHS2.Image = Image.FromFile(green_img_path);
  135. }
  136. #endregion
  137. #region 牛首山2
  138. AgcEntity nss2 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  139. if (nss2 != null)
  140. {
  141. lblPowerSet_NSS2.LableText = nss2.PowerSetValue.ToString("f2");
  142. lblPowerSet_NSS2.BindData(nss2.PowerSetValue.ToString("f2"), "NSSDQ.NX_GD_NSSF_DQ_P1_L1_001_AI1019", "牛首山2有功设定限值");
  143. lblActualPower_NSS2.LableText = nss2.ActualPowerValue.ToString("f2");
  144. lblActualPower_NSS2.BindData(nss2.ActualPowerValue.ToString("f2"), "NSSDQ.NX_GD_NSSF_DQ_P1_L1_001_QCYGGL", "牛首山2实发有功");
  145. lblAgcOn_NSS2.LableText = (nss2.AgcUp / 1000).ToString("f2");
  146. lblAgcOn_NSS2.BindData((nss2.AgcUp / 1000).ToString("f2"), "NSSDQ.NX_GD_NSSF_DQ_P1_L1_001_AI1009", "牛首山2AGC可调上限");
  147. lblAgcUp_NSS2.LableText = (nss2.AgcLower / 1000).ToString("f2");
  148. lblAgcUp_NSS2.BindData((nss2.AgcLower / 1000).ToString("f2"), "NSSDQ.NX_GD_NSSF_DQ_P1_L1_001_AI1010", "牛首山2AGC可调下限");
  149. lblTheoryPower_NSS2.LableText = (nss2.TheoryPower / 1000).ToString("f2");
  150. lblTheoryPower_NSS2.BindData((nss2.TheoryPower / 1000).ToString("f2"), "NSSFCJSFW.NX_GD_NSSF_XX_XX_XXX_XXX_CI0192", "牛首山2理论功率");
  151. lblForecastPower_NSS2.LableText = nss2.ForecastPower.ToString("f2");
  152. lblForecastPower_NSS2.BindData(nss2.ForecastPower.ToString("f2"), "NSSFGL.NX_GD_NSSF_YC_P1_L1_001_CDQ001", "牛首山2预测功率");
  153. if (nss2.AgcIn)
  154. picAgcIn_NSS2.Image = Image.FromFile(red_img_path);
  155. else
  156. picAgcIn_NSS2.Image = Image.FromFile(green_img_path);
  157. if (nss2.AgcFar)
  158. picAgcFar_NSS2.Image = Image.FromFile(red_img_path);
  159. else
  160. picAgcFar_NSS2.Image = Image.FromFile(green_img_path);
  161. if (nss2.SumLock)
  162. picSumLock_NSS2.Image = Image.FromFile(red_img_path);
  163. else
  164. picSumLock_NSS2.Image = Image.FromFile(green_img_path);
  165. if (nss2.SubLock)
  166. picSubLock_NSS2.Image = Image.FromFile(red_img_path);
  167. else
  168. picSubLock_NSS2.Image = Image.FromFile(green_img_path);
  169. }
  170. #endregion
  171. #region 麻黄山6
  172. AgcEntity mhs6 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  173. if (mhs6 != null)
  174. {
  175. lblPowerSet_MHS6.LableText = mhs6.PowerSetValue.ToString("f2");
  176. lblPowerSet_MHS6.BindData(mhs6.PowerSetValue.ToString("f2"), "QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI1281", "麻黄山6有功设定限值");
  177. lblActualPower_MHS6.LableText = mhs6.ActualPowerValue.ToString("f2");
  178. lblActualPower_MHS6.BindData(mhs6.ActualPowerValue.ToString("f2"), "QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI1282", "麻黄山6实发有功");
  179. lblAgcOn_MHS6.LableText = mhs6.AgcUp.ToString("f2");
  180. lblAgcOn_MHS6.BindData(mhs6.AgcUp.ToString("f2"), "QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI1284", "麻黄山6AGC可调上限");
  181. lblAgcUp_MHS6.LableText = mhs6.AgcLower.ToString("f2");
  182. lblAgcUp_MHS6.BindData(mhs6.AgcLower.ToString("f2"), "QSDQ.NX_GD_QSF_DQ_P1_L1_001_AI1285", "麻黄山6AGC可调下限");
  183. lblTheoryPower_MHS6.LableText = (mhs6.TheoryPower / 1000).ToString("f2");
  184. lblTheoryPower_MHS6.BindData((mhs6.TheoryPower / 1000).ToString("f2"), "QSFCJSFW.NX_GD_QSF_XX_XX_XXX_XXX_CI0192", "麻黄山6理论功率");
  185. lblForecastPower_MHS6.LableText = mhs6.ForecastPower.ToString("f2");
  186. lblForecastPower_MHS6.BindData(mhs6.ForecastPower.ToString("f2"), "QSFGL.NX_GD_QSF_YC_P1_L1_001_CDQ001", "麻黄山6预测功率");
  187. if (mhs6.AgcIn)
  188. picAgcIn_MHS6.Image = Image.FromFile(red_img_path);
  189. else
  190. picAgcIn_MHS6.Image = Image.FromFile(green_img_path);
  191. if (mhs6.AgcFar)
  192. picAgcFar_MHS6.Image = Image.FromFile(red_img_path);
  193. else
  194. picAgcFar_MHS6.Image = Image.FromFile(green_img_path);
  195. if (mhs6.SumLock)
  196. picSumLock_MHS6.Image = Image.FromFile(red_img_path);
  197. else
  198. picSumLock_MHS6.Image = Image.FromFile(green_img_path);
  199. if (mhs6.SubLock)
  200. picSubLock_MHS6.Image = Image.FromFile(red_img_path);
  201. else
  202. picSubLock_MHS6.Image = Image.FromFile(green_img_path);
  203. }
  204. #endregion
  205. #region 星能6
  206. AgcEntity xn6 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "XN6").FirstOrDefault();
  207. if (xn6 != null)
  208. {
  209. lblPowerSet_XN6.LableText = xn6.PowerSetValue.ToString("f2");
  210. lblPowerSet_XN6.BindData(xn6.PowerSetValue.ToString("f2"), "SBQDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0818", "星能6有功设定限值");
  211. lblActualPower_XN6.LableText = xn6.ActualPowerValue.ToString("f2");
  212. lblActualPower_XN6.BindData(xn6.ActualPowerValue.ToString("f2"), "SBQDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0817", "星能6实发有功");
  213. lblAgcOn_XN6.LableText = (xn6.AgcUp / 10).ToString("f2");
  214. lblAgcOn_XN6.BindData((xn6.AgcUp / 10).ToString("f2"), "SBQDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0819", "星能6AGC可调上限");
  215. lblAgcUp_XN6.LableText = (xn6.AgcLower / 10).ToString("f2");
  216. lblAgcUp_XN6.BindData((xn6.AgcLower / 10).ToString("f2"), "SBQDQ.NX_GD_SBQF_DQ_P1_L1_001_AI0820", "星能6AGC可调下限");
  217. lblTheoryPower_XN6.LableText = (xn6.TheoryPower / 1000).ToString("f2");
  218. lblTheoryPower_XN6.BindData((xn6.TheoryPower / 1000).ToString("f2"), "SBQFCJSFW.NX_GD_SBQF_FJ_P1_XXX_XXX_CI0191", "星能6理论功率");
  219. lblForecastPower_XN6.LableText = xn6.ForecastPower.ToString("f2");
  220. lblForecastPower_XN6.BindData(xn6.ForecastPower.ToString("f2"), "SBQFGL.NX_GD_SBQF_YC_P1_L1_002_CDQ001", "星能6预测功率");
  221. if (xn6.AgcIn)
  222. picAgcIn_XN6.Image = Image.FromFile(red_img_path);
  223. else
  224. picAgcIn_XN6.Image = Image.FromFile(green_img_path);
  225. if (xn6.AgcFar)
  226. picAgcFar_XN6.Image = Image.FromFile(red_img_path);
  227. else
  228. picAgcFar_XN6.Image = Image.FromFile(green_img_path);
  229. if (xn6.SumLock)
  230. picSumLock_XN6.Image = Image.FromFile(red_img_path);
  231. else
  232. picSumLock_XN6.Image = Image.FromFile(green_img_path);
  233. if (xn6.SubLock)
  234. picSubLock_XN6.Image = Image.FromFile(red_img_path);
  235. else
  236. picSubLock_XN6.Image = Image.FromFile(green_img_path);
  237. }
  238. #endregion
  239. #region 牛首山5
  240. AgcEntity nss5 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  241. if (nss5 != null)
  242. {
  243. lblPowerSet_NSS5.LableText = nss5.PowerSetValue.ToString("f2");
  244. lblActualPower_NSS5.LableText = nss5.ActualPowerValue.ToString("f2");
  245. lblAgcOn_NSS5.LableText = nss5.AgcUp.ToString("f2");
  246. lblAgcUp_NSS5.LableText = nss5.AgcLower.ToString("f2");
  247. // SBQFCJSFW.NX_GD_SBQF_FJ_P2_XXX_XXX_CI0191/1000+SBQFCJSFW.NX_GD_SBQF_FJ_P3_XXX_XXX_CI0191/1000+SBQFCJSFW.NX_GD_SBQF_FJ_P4_XXX_XXX_CI0191/1000
  248. string[] arr = new string[]
  249. {
  250. "SBQFCJSFW.NX_GD_SBQF_FJ_P2_XXX_XXX_CI0191",
  251. "SBQFCJSFW.NX_GD_SBQF_FJ_P3_XXX_XXX_CI0191",
  252. "SBQFCJSFW.NX_GD_SBQF_FJ_P4_XXX_XXX_CI0191"
  253. };
  254. Dictionary<string, TsData> dic = RestfulClient.findLatestByTagNames(arr);
  255. double pointValue = 0.0;
  256. foreach (var tsData in dic)
  257. {
  258. double pv = Convert.ToDouble(tsData.Value.getValue());
  259. pointValue = pointValue + pv;
  260. }
  261. lblTheoryPower_NSS5.LableText = (pointValue / 1000).ToString("f2");
  262. lblForecastPower_NSS5.LableText = nss5.ForecastPower.ToString("f2");
  263. if (nss5.AgcIn)
  264. picAgcIn_NSS5.Image = Image.FromFile(red_img_path);
  265. else
  266. picAgcIn_NSS5.Image = Image.FromFile(green_img_path);
  267. if (nss5.AgcFar)
  268. picAgcFar_NSS5.Image = Image.FromFile(red_img_path);
  269. else
  270. picAgcFar_NSS5.Image = Image.FromFile(green_img_path);
  271. if (nss5.SumLock)
  272. picSumLock_NSS5.Image = Image.FromFile(red_img_path);
  273. else
  274. picSumLock_NSS5.Image = Image.FromFile(green_img_path);
  275. if (nss5.SubLock)
  276. picSubLock_NSS5.Image = Image.FromFile(red_img_path);
  277. else
  278. picSubLock_NSS5.Image = Image.FromFile(green_img_path);
  279. }
  280. #endregion
  281. #region 香山5
  282. AgcEntity xs5 = AgcInfoSvc.agcDataList.Where(s => s.StationName == "XS5").FirstOrDefault();
  283. if (xs5 != null)
  284. {
  285. lblPowerSet_XS5.LableText = xs5.PowerSetValue.ToString("f2");
  286. lblPowerSet_XS5.BindData(xs5.PowerSetValue.ToString("f2"), "XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0411", "香山5有功设定限值");
  287. lblActualPower_XS5.LableText = xs5.ActualPowerValue.ToString("f2");
  288. lblActualPower_XS5.BindData(xs5.ActualPowerValue.ToString("f2"), "XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0415", "香山5实发有功");
  289. lblAgcOn_XS5.LableText = xs5.AgcUp.ToString("f2");
  290. lblAgcOn_XS5.BindData(xs5.AgcUp.ToString("f2"), "XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0412", "香山5AGC可调上限");
  291. lblAgcUp_XS5.LableText = xs5.AgcLower.ToString("f2");
  292. lblAgcUp_XS5.BindData(xs5.AgcLower.ToString("f2"), "XSDQ.NX_GD_XSF_DQ_P1_L1_001_AI0413", "香山5AGC可调下限");
  293. lblTheoryPower_XS5.LableText = (xs5.TheoryPower / 1000).ToString("f2");
  294. lblTheoryPower_XS5.BindData((xs5.TheoryPower / 1000).ToString("f2"), "XSFCJSFW.NX_GD_XSF_XX_XX_XXX_XXX_CI0192", "香山5理论功率");
  295. lblForecastPower_XS5.LableText = xs5.ForecastPower.ToString("f2");
  296. lblForecastPower_XS5.BindData(xs5.ForecastPower.ToString("f2"), "XSFGL.NX_GD_XSF_YC_P1_L1_001_CDQ001", "香山5预测功率");
  297. if (xs5.AgcIn)
  298. picAgcIn_XS5.Image = Image.FromFile(red_img_path);
  299. else
  300. picAgcIn_XS5.Image = Image.FromFile(green_img_path);
  301. if (xs5.AgcFar)
  302. picAgcFar_XS5.Image = Image.FromFile(red_img_path);
  303. else
  304. picAgcFar_XS5.Image = Image.FromFile(green_img_path);
  305. if (xs5.SumLock)
  306. picSumLock_XS5.Image = Image.FromFile(red_img_path);
  307. else
  308. picSumLock_XS5.Image = Image.FromFile(green_img_path);
  309. if (xs5.SubLock)
  310. picSubLock_XS5.Image = Image.FromFile(red_img_path);
  311. else
  312. picSubLock_XS5.Image = Image.FromFile(green_img_path);
  313. }
  314. #endregion
  315. isBindFormOver = true;
  316. }
  317. private void timer2_Tick(object sender, EventArgs e)
  318. {
  319. if (isBindLineFormOver)//绑定form
  320. {
  321. isBindLineFormOver = false;
  322. Thread bindDataThread = new Thread(BindFormLineInvoke);
  323. bindDataThread.Start();
  324. }
  325. if (isUpdateLineDataOver)//更新数据
  326. {
  327. isUpdateLineDataOver = false;
  328. Thread ayscThread = new Thread(new ParameterizedThreadStart(UpdateHistoryLineData));
  329. ayscThread.IsBackground = true;
  330. ayscThread.Start(true);
  331. }
  332. }
  333. private void UpdateHistoryLineData(Object isWind)
  334. {
  335. AgcInfoSvc.GetHistoryLineData(isWind);
  336. isUpdateLineDataOver = true;
  337. //AgcInfoSvc.UpdateHistoryLineData(isWind);
  338. //isUpdateLineDataOver = true;
  339. }
  340. public void BindFormLineInvoke()
  341. {
  342. UpdateFormInfoDelegate del = new UpdateFormInfoDelegate(FormLineDataBind);
  343. if (this.InvokeRequired)
  344. {
  345. this.BeginInvoke(del, new object[] { });
  346. }
  347. else
  348. {
  349. FormLineDataBind();
  350. }
  351. }
  352. public void FormLineDataBind()
  353. {
  354. PowerActual powerActual_mhs2 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  355. PowerSet powerSet_mhs2 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  356. if (powerActual_mhs2 != null && powerSet_mhs2 != null)
  357. {
  358. //IList<TsData> pstList=new List<TsData>();
  359. //for (int i = 0; i < powerSet_mhs2.TsDataList.Count; i++)
  360. //{
  361. // TsData tsData=new TsData();
  362. // tsData.ts = powerSet_mhs2.TsDataList[i].ts;
  363. // double tValue = powerSet_mhs2.TsDataList[i].doubleValue.HasValue
  364. // ? powerSet_mhs2.TsDataList[i].doubleValue.Value/10
  365. // : 0.0;
  366. // tsData.doubleValue = tValue;
  367. // pstList.Add(tsData);
  368. //}
  369. lineChar_MHS2.DataBind(powerActual_mhs2.TsDataList, powerSet_mhs2.TsDataList);
  370. }
  371. PowerActual powerActual_nss2 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  372. PowerSet powerSet_nss2 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  373. if (powerActual_nss2 != null && powerSet_nss2 != null)
  374. lineChar_NSS2.DataBind(powerActual_nss2.TsDataList, powerSet_nss2.TsDataList);
  375. PowerActual powerActual_mhs6 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  376. PowerSet powerSet_mhs6 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  377. if (powerActual_mhs6 != null && powerSet_mhs6 != null)
  378. {
  379. IList<TsData> pstList = new List<TsData>();
  380. IList<TsData> actlList = new List<TsData>();
  381. for (int i = 0; i < powerSet_mhs6.TsDataList.Count; i++)
  382. {
  383. TsData tsData = new TsData();
  384. tsData.ts = powerSet_mhs6.TsDataList[i].ts;
  385. double tValue = powerSet_mhs6.TsDataList[i].doubleValue.HasValue
  386. ? powerSet_mhs6.TsDataList[i].doubleValue.Value
  387. : 0.0;
  388. tsData.doubleValue = tValue;
  389. pstList.Add(tsData);
  390. }
  391. for (int i = 0; i < powerActual_mhs6.TsDataList.Count; i++)
  392. {
  393. TsData tsData = new TsData();
  394. tsData.ts = powerActual_mhs6.TsDataList[i].ts;
  395. double tValue = powerActual_mhs6.TsDataList[i].doubleValue.HasValue
  396. ? powerActual_mhs6.TsDataList[i].doubleValue.Value
  397. : 0.0;
  398. tsData.doubleValue = tValue;
  399. actlList.Add(tsData);
  400. }
  401. lineChar_MHS6.DataBind(actlList, pstList);
  402. }
  403. PowerActual powerActual_xn6 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "XN6").FirstOrDefault();
  404. PowerSet powerSet_xn6 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "XN6").FirstOrDefault();
  405. if (powerActual_xn6 != null && powerSet_xn6 != null)
  406. {
  407. IList<TsData> pstList = new List<TsData>();
  408. IList<TsData> actlList = new List<TsData>();
  409. for (int i = 0; i < powerSet_xn6.TsDataList.Count; i++)
  410. {
  411. TsData tsData = new TsData();
  412. tsData.ts = powerSet_xn6.TsDataList[i].ts;
  413. double tValue = powerSet_xn6.TsDataList[i].doubleValue.HasValue
  414. ? powerSet_xn6.TsDataList[i].doubleValue.Value
  415. : 0.0;
  416. tsData.doubleValue = tValue;
  417. pstList.Add(tsData);
  418. }
  419. for (int i = 0; i < powerActual_xn6.TsDataList.Count; i++)
  420. {
  421. TsData tsData = new TsData();
  422. tsData.ts = powerActual_xn6.TsDataList[i].ts;
  423. double tValue = powerActual_xn6.TsDataList[i].doubleValue.HasValue
  424. ? powerActual_xn6.TsDataList[i].doubleValue.Value
  425. : 0.0;
  426. tsData.doubleValue = tValue;
  427. actlList.Add(tsData);
  428. }
  429. lineChar_XN6.DataBind(actlList, pstList);
  430. }
  431. PowerActual powerActual_nss5 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  432. PowerSet powerSet_nss5 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  433. if (powerActual_nss5 != null && powerSet_nss5 != null)
  434. {
  435. IList<TsData> pstList = new List<TsData>();
  436. IList<TsData> actlList = new List<TsData>();
  437. for (int i = 0; i < powerSet_nss5.TsDataList.Count; i++)
  438. {
  439. TsData tsData = new TsData();
  440. tsData.ts = powerSet_nss5.TsDataList[i].ts;
  441. double tValue = powerSet_nss5.TsDataList[i].doubleValue.HasValue
  442. ? powerSet_nss5.TsDataList[i].doubleValue.Value
  443. : 0.0;
  444. tsData.doubleValue = tValue;
  445. pstList.Add(tsData);
  446. }
  447. for (int i = 0; i < powerActual_nss5.TsDataList.Count; i++)
  448. {
  449. TsData tsData = new TsData();
  450. tsData.ts = powerActual_nss5.TsDataList[i].ts;
  451. double tValue = powerActual_nss5.TsDataList[i].doubleValue.HasValue
  452. ? powerActual_nss5.TsDataList[i].doubleValue.Value
  453. : 0.0;
  454. tsData.doubleValue = tValue;
  455. actlList.Add(tsData);
  456. }
  457. lineChar_NSS5.DataBind(actlList, pstList);
  458. }
  459. PowerActual powerActual_xs5 = AgcInfoSvc.powerActualList.Where(s => s.StationName == "XS5").FirstOrDefault();
  460. PowerSet powerSet_xs5 = AgcInfoSvc.powerSetList.Where(s => s.StationName == "XS5").FirstOrDefault();
  461. if (powerSet_xs5 != null && powerActual_xs5 != null)
  462. lineChar_XS5.DataBind(powerActual_xs5.TsDataList, powerSet_xs5.TsDataList);
  463. isBindLineFormOver = true;
  464. }
  465. private void WindAGC_Load(object sender, EventArgs e)
  466. {
  467. Thread ayscThread1 = new Thread(new ParameterizedThreadStart(AgcInfoSvc.GetLatestAgcDataInfo));
  468. ayscThread1.IsBackground = true;
  469. ayscThread1.Start(true);
  470. Thread t = new Thread(FirstFormLoad);
  471. t.IsBackground = true;
  472. t.Start();
  473. }
  474. private void FirstFormLoad()
  475. {
  476. AgcInfoSvc.GetHistoryLineData(true);
  477. BindFormLineInvoke();
  478. }
  479. private void LineInitThread()
  480. {
  481. isUpdateLineDataOver = false;
  482. AgcInfoSvc.GetHistoryLineData(true);
  483. isUpdateLineDataOver = true;
  484. isBindLineFormOver = false;
  485. BindFormLineInvoke();
  486. isBindLineFormOver = true;
  487. }
  488. }
  489. }