AgcInfoSvc.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms.VisualStyles;
  7. using System.Xml;
  8. using IntelligentControlForsx.Service.AGC.Domain;
  9. using IntelligentControlForsx.Service.WindturbineInfo;
  10. using log4net;
  11. using WisdomClient;
  12. using WisdomClient.data;
  13. namespace IntelligentControlForsx.Service.AGC
  14. {
  15. public class AgcInfoSvc
  16. {
  17. #region 单例
  18. private AgcInfoSvc()
  19. {
  20. }
  21. public static AgcInfoSvc Instance
  22. {
  23. get { return SingletonCreator.instance; }
  24. }
  25. class SingletonCreator
  26. {
  27. internal static readonly AgcInfoSvc instance = new AgcInfoSvc();
  28. }
  29. #endregion
  30. private static ILog logger = LogManager.GetLogger("AppInfoLog");
  31. //agc测点集合
  32. public static IList<AgcPoint> pointTagNameList = new List<AgcPoint>();
  33. //agc测点值集合
  34. public static IList<AgcEntity> agcDataList = new List<AgcEntity>();
  35. //agc曲线数据--实发有功
  36. public static IList<PowerActual> powerActualList = new List<PowerActual>();
  37. //agc曲线数据--有功设定
  38. public static IList<PowerSet> powerSetList = new List<PowerSet>();
  39. public static DateTime? lastUpdateTime_Wind = null;
  40. public static DateTime? lastUpdateTime_Sun = null;
  41. /// <summary>
  42. /// 获取agc相关测点,并保存至缓存pointTagNameList
  43. /// </summary>
  44. public static void GetTagName()
  45. {
  46. IList<AgcPoint> list = new List<AgcPoint>();
  47. string path = Environment.CurrentDirectory;
  48. string filePath = path + "\\conf\\AgcTagName.xml";
  49. XmlDocument xdoc = new XmlDocument();
  50. xdoc.Load(filePath); //加载xml文档
  51. XmlNodeList rootList = xdoc.SelectNodes("/root");
  52. if (rootList != null && rootList.Count > 0)
  53. {
  54. XmlNodeList stationNodeList = rootList[0].ChildNodes;
  55. foreach (XmlNode stationNode in stationNodeList)
  56. {
  57. string stationName = "";
  58. string type = "";
  59. if (stationNode.Attributes["name"] != null)
  60. stationName = stationNode.Attributes["name"].Value;
  61. if (stationNode.Attributes["type"] != null)
  62. type = stationNode.Attributes["type"].Value;
  63. XmlNodeList partNodeList = stationNode.ChildNodes;
  64. AgcPoint data = new AgcPoint();
  65. if (!string.IsNullOrEmpty(stationName))
  66. data.StationName = stationName;
  67. if (!string.IsNullOrEmpty(type))
  68. data.PowerType = type;
  69. foreach (XmlNode partNode in partNodeList)
  70. {
  71. try
  72. {
  73. string xmlName = "";
  74. String xmlValue = "";
  75. if (partNode.Attributes["name"] != null)
  76. xmlName = partNode.Attributes["name"].Value;
  77. if (partNode.Attributes["value"] != null)
  78. xmlValue = partNode.Attributes["value"].Value;
  79. if (xmlName == "有功设定限值")
  80. data.PowerSetTagName = xmlValue;
  81. if (xmlName == "AGC可调上限")
  82. data.AgcUpTagName = xmlValue;
  83. if (xmlName == "AGC可调下限")
  84. data.AgcLowerTagName = xmlValue;
  85. if (xmlName == "实发有功")
  86. data.ActualPowerTagName = xmlValue;
  87. if (xmlName == "理论功率")
  88. data.TheoryPowerTagName = xmlValue;
  89. if (xmlName == "AGC投入")
  90. data.AgcInTagName = xmlValue;
  91. if (xmlName == "AGC远方")
  92. data.AgcFarTagName = xmlValue;
  93. if (xmlName == "有功增闭锁")
  94. data.SumLockTagName = xmlValue;
  95. if (xmlName == "有功减闭锁")
  96. data.SubLockTagName = xmlValue;
  97. if (xmlName == "理论功率资源法")
  98. data.TheoryPowerResourcesTagName = xmlValue;
  99. if (xmlName == "理论功率样板机法")
  100. data.TheoryPowerExampleTagName = xmlValue;
  101. if (xmlName == "状态")
  102. data.StatusTagName = xmlValue;
  103. if (xmlName == "预测功率")
  104. data.ForecastPowerTagName = xmlValue;
  105. }
  106. catch (Exception ex)
  107. {
  108. logger.Info("xml配置读取错误:" + ex.Message);
  109. }
  110. }
  111. list.Add(data);
  112. }
  113. pointTagNameList = list;
  114. }
  115. }
  116. /// <summary>
  117. /// 获取AGC实时数据
  118. /// </summary>
  119. /// <param name="isWind">是否为风电</param>
  120. public static void GetLatestAgcDataInfo(object isWind)
  121. {
  122. if (pointTagNameList.Count <= 0)
  123. GetTagName();
  124. IList<AgcPoint> pointList = new List<AgcPoint>();
  125. if ((bool)isWind)
  126. pointList = pointTagNameList.Where(s => s.PowerType == "wind").ToList();
  127. else
  128. pointList = pointTagNameList.Where(s => s.PowerType == "sun").ToList();
  129. for (int i = 0; i < pointList.Count; i++)
  130. {
  131. string[] tagArr = new string[]
  132. {
  133. pointList[i].PowerSetTagName,
  134. pointList[i].AgcUpTagName,
  135. pointList[i].AgcLowerTagName,
  136. pointList[i].ActualPowerTagName,
  137. pointList[i].TheoryPowerTagName,
  138. pointList[i].ForecastPowerTagName,
  139. pointList[i].AgcInTagName,
  140. pointList[i].AgcFarTagName,
  141. pointList[i].SumLockTagName,
  142. pointList[i].SubLockTagName,
  143. pointList[i].TheoryPowerResourcesTagName,
  144. pointList[i].TheoryPowerExampleTagName,
  145. pointList[i].StatusTagName
  146. };
  147. Dictionary<string, TsData> dic = RestfulClient.findLatestByTagNames(tagArr);
  148. AgcEntity entity = agcDataList.Where(s => s.StationName == pointList[i].StationName).FirstOrDefault();
  149. if (entity == null)
  150. {
  151. entity = new AgcEntity();
  152. entity.StationName = pointList[i].StationName;
  153. agcDataList.Add(entity);
  154. }
  155. foreach (var tsData in dic)
  156. {
  157. if (tsData.Key == pointList[i].PowerSetTagName)
  158. {
  159. double pointValue;
  160. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  161. entity.PowerSetValue = pointValue;
  162. }
  163. if (tsData.Key == pointList[i].AgcUpTagName)
  164. {
  165. double pointValue;
  166. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  167. entity.AgcUp = pointValue;
  168. }
  169. if (tsData.Key == pointList[i].AgcLowerTagName)
  170. {
  171. double pointValue;
  172. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  173. entity.AgcLower = pointValue;
  174. }
  175. if (tsData.Key == pointList[i].ActualPowerTagName)
  176. {
  177. double pointValue;
  178. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  179. entity.ActualPowerValue = pointValue;
  180. }
  181. if (tsData.Key == pointList[i].TheoryPowerTagName)
  182. {
  183. double pointValue;
  184. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  185. entity.TheoryPower = pointValue;
  186. }
  187. if (tsData.Key == pointList[i].ForecastPowerTagName)
  188. {
  189. double pointValue;
  190. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  191. entity.ForecastPower = pointValue;
  192. }
  193. if (tsData.Key == pointList[i].AgcInTagName)
  194. {
  195. double pointValue;
  196. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  197. entity.AgcIn = pointValue == 1;
  198. }
  199. if (tsData.Key == pointList[i].AgcFarTagName)
  200. {
  201. double pointValue;
  202. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  203. entity.AgcFar = pointValue == 1;
  204. }
  205. if (tsData.Key == pointList[i].SumLockTagName)
  206. {
  207. double pointValue;
  208. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  209. entity.SumLock = pointValue == 1;
  210. }
  211. if (tsData.Key == pointList[i].SubLockTagName)
  212. {
  213. double pointValue;
  214. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  215. entity.SubLock = pointValue == 1;
  216. }
  217. if (tsData.Key == pointList[i].TheoryPowerResourcesTagName)
  218. {
  219. double pointValue;
  220. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  221. entity.TheoryPowerResources = pointValue;
  222. }
  223. if (tsData.Key == pointList[i].TheoryPowerExampleTagName)
  224. {
  225. double pointValue;
  226. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  227. entity.TheoryPowerExample = pointValue;
  228. }
  229. if (tsData.Key == pointList[i].StatusTagName)
  230. {
  231. double pointValue;
  232. bool isNum = IsNum(tsData.Value.getValue(), out pointValue);
  233. entity.Status = pointValue == 1;
  234. }
  235. }
  236. }
  237. }
  238. /// <summary>
  239. /// 获取有功设定和实发历史值
  240. /// </summary>
  241. /// <param name="startTime">起始时间</param>
  242. /// <param name="endTime">结束时间</param>
  243. /// <param name="isWind">是否为风电</param>
  244. public static void GetHistoryLineData(object isWind)
  245. {
  246. if (pointTagNameList.Count <= 0)
  247. GetTagName();
  248. IList<AgcPoint> pointList = pointTagNameList;
  249. #region 获取各个场站有功设定和实发有功
  250. //麻黄山2有功设定
  251. string powerSetMHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName;
  252. //麻黄山2实发有功
  253. string powerActualMHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName;
  254. //牛首山2有功设定
  255. string powerSetNSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName;
  256. //牛首山2实发有功
  257. string powerActualNSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName;
  258. //麻黄山6有功设定
  259. string powerSetMHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName;
  260. //麻黄山6实发有功
  261. string powerActualMHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName;
  262. //星能6有功设定
  263. string powerSetXN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName;
  264. //星能6实发有功
  265. string powerActualXN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName;
  266. //牛首山5有功设定
  267. string powerSetNSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName;
  268. //牛首山5实发有功
  269. string powerActualNSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName;
  270. //香山5有功设定
  271. string powerSetXS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName;
  272. //香山5实发有功
  273. string powerActualXS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName;
  274. //石嘴山5有功设定
  275. string powerSetSZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName;
  276. //石嘴山5实发有功
  277. string powerActualSZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName;
  278. //平罗35有功设定
  279. string powerSetPL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName;
  280. //平罗5实发有功
  281. string powerActualPL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName;
  282. //中卫2有功设定
  283. string powerSetZW2 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName;
  284. //中卫2实发有功
  285. string powerActualZW2 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName;
  286. #endregion
  287. var powerSet_MHS6 = powerSetList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  288. var actualPower_MHS6 = powerActualList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  289. if (powerSet_MHS6 == null)
  290. {
  291. powerSet_MHS6 = new PowerSet();
  292. powerSet_MHS6.StationName = "MHS6";
  293. powerSet_MHS6.TsDataList = new List<TsData>();
  294. powerSetList.Add(powerSet_MHS6);
  295. }
  296. if (actualPower_MHS6 == null)
  297. {
  298. actualPower_MHS6 = new PowerActual();
  299. actualPower_MHS6.StationName = "MHS6";
  300. actualPower_MHS6.TsDataList = new List<TsData>();
  301. powerActualList.Add(actualPower_MHS6);
  302. }
  303. var powerSet_NSS2 = powerSetList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  304. var actualPower_NSS2 = powerActualList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  305. if (powerSet_NSS2 == null)
  306. {
  307. powerSet_NSS2 = new PowerSet();
  308. powerSet_NSS2.StationName = "NSS2";
  309. powerSet_NSS2.TsDataList = new List<TsData>();
  310. powerSetList.Add(powerSet_NSS2);
  311. }
  312. if (actualPower_NSS2 == null)
  313. {
  314. actualPower_NSS2 = new PowerActual();
  315. actualPower_NSS2.StationName = "NSS2";
  316. actualPower_NSS2.TsDataList = new List<TsData>();
  317. powerActualList.Add(actualPower_NSS2);
  318. }
  319. var powerSet_MHS2 = powerSetList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  320. var actualPower_MHS2 = powerActualList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  321. if (powerSet_MHS2 == null)
  322. {
  323. powerSet_MHS2 = new PowerSet();
  324. powerSet_MHS2.StationName = "MHS2";
  325. powerSet_MHS2.TsDataList = new List<TsData>();
  326. powerSetList.Add(powerSet_MHS2);
  327. }
  328. if (actualPower_MHS2 == null)
  329. {
  330. actualPower_MHS2 = new PowerActual();
  331. actualPower_MHS2.StationName = "MHS2";
  332. actualPower_MHS2.TsDataList = new List<TsData>();
  333. powerActualList.Add(actualPower_MHS2);
  334. }
  335. var powerSet_XN6 = powerSetList.Where(s => s.StationName == "XN6").FirstOrDefault();
  336. var actualPower_XN6 = powerActualList.Where(s => s.StationName == "XN6").FirstOrDefault();
  337. if (powerSet_XN6 == null)
  338. {
  339. powerSet_XN6 = new PowerSet();
  340. powerSet_XN6.StationName = "XN6";
  341. powerSet_XN6.TsDataList = new List<TsData>();
  342. powerSetList.Add(powerSet_XN6);
  343. }
  344. if (actualPower_XN6 == null)
  345. {
  346. actualPower_XN6 = new PowerActual();
  347. actualPower_XN6.StationName = "XN6";
  348. actualPower_XN6.TsDataList = new List<TsData>();
  349. powerActualList.Add(actualPower_XN6);
  350. }
  351. var powerSet_NSS5 = powerSetList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  352. var actualPower_NSS5 = powerActualList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  353. if (powerSet_NSS5 == null)
  354. {
  355. powerSet_NSS5 = new PowerSet();
  356. powerSet_NSS5.StationName = "NSS5";
  357. powerSet_NSS5.TsDataList = new List<TsData>();
  358. powerSetList.Add(powerSet_NSS5);
  359. }
  360. if (actualPower_NSS5 == null)
  361. {
  362. actualPower_NSS5 = new PowerActual();
  363. actualPower_NSS5.StationName = "NSS5";
  364. actualPower_NSS5.TsDataList = new List<TsData>();
  365. powerActualList.Add(actualPower_NSS5);
  366. }
  367. var powerSet_XS5 = powerSetList.Where(s => s.StationName == "XS5").FirstOrDefault();
  368. var actualPower_XS5 = powerActualList.Where(s => s.StationName == "XS5").FirstOrDefault();
  369. if (powerSet_XS5 == null)
  370. {
  371. powerSet_XS5 = new PowerSet();
  372. powerSet_XS5.StationName = "XS5";
  373. powerSet_XS5.TsDataList = new List<TsData>();
  374. powerSetList.Add(powerSet_XS5);
  375. }
  376. if (actualPower_XS5 == null)
  377. {
  378. actualPower_XS5 = new PowerActual();
  379. actualPower_XS5.StationName = "XS5";
  380. actualPower_XS5.TsDataList = new List<TsData>();
  381. powerActualList.Add(actualPower_XS5);
  382. }
  383. var powerSet_SZS5 = powerSetList.Where(s => s.StationName == "SZS5").FirstOrDefault();
  384. var actualPower_SZS5 = powerActualList.Where(s => s.StationName == "SZS5").FirstOrDefault();
  385. if (powerSet_SZS5 == null)
  386. {
  387. powerSet_SZS5 = new PowerSet();
  388. powerSet_SZS5.StationName = "SZS5";
  389. powerSet_SZS5.TsDataList = new List<TsData>();
  390. powerSetList.Add(powerSet_SZS5);
  391. }
  392. if (actualPower_SZS5 == null)
  393. {
  394. actualPower_SZS5 = new PowerActual();
  395. actualPower_SZS5.StationName = "SZS5";
  396. actualPower_SZS5.TsDataList = new List<TsData>();
  397. powerActualList.Add(actualPower_SZS5);
  398. }
  399. var powerSet_PL3 = powerSetList.Where(s => s.StationName == "PL3").FirstOrDefault();
  400. var actualPower_PL3 = powerActualList.Where(s => s.StationName == "PL3").FirstOrDefault();
  401. if (powerSet_PL3 == null)
  402. {
  403. powerSet_PL3 = new PowerSet();
  404. powerSet_PL3.StationName = "PL3";
  405. powerSet_PL3.TsDataList = new List<TsData>();
  406. powerSetList.Add(powerSet_PL3);
  407. }
  408. if (actualPower_PL3 == null)
  409. {
  410. actualPower_PL3 = new PowerActual();
  411. actualPower_PL3.StationName = "PL3";
  412. actualPower_PL3.TsDataList = new List<TsData>();
  413. powerActualList.Add(actualPower_PL3);
  414. }
  415. var powerSet_ZW6 = powerSetList.Where(s => s.StationName == "ZW6").FirstOrDefault();
  416. var actualPower_ZW6 = powerActualList.Where(s => s.StationName == "ZW6").FirstOrDefault();
  417. if (powerSet_ZW6 == null)
  418. {
  419. powerSet_ZW6 = new PowerSet();
  420. powerSet_ZW6.StationName = "ZW6";
  421. powerSet_ZW6.TsDataList = new List<TsData>();
  422. powerSetList.Add(powerSet_ZW6);
  423. }
  424. if (actualPower_ZW6 == null)
  425. {
  426. actualPower_ZW6 = new PowerActual();
  427. actualPower_ZW6.StationName = "ZW6";
  428. actualPower_ZW6.TsDataList = new List<TsData>();
  429. powerActualList.Add(actualPower_ZW6);
  430. }
  431. if ((bool)isWind)
  432. {
  433. DateTime? startTime = null;
  434. if (lastUpdateTime_Wind.HasValue)
  435. {
  436. startTime = lastUpdateTime_Wind.Value;
  437. lastUpdateTime_Wind = DateTime.Now;
  438. }
  439. else
  440. {
  441. startTime = DateTime.Now.AddHours(-8);
  442. lastUpdateTime_Wind = DateTime.Now;
  443. }
  444. DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
  445. TimeSpan sTime = startTime.Value.Subtract(dtStart);
  446. TimeSpan eTime = DateTime.Now.Subtract(dtStart);
  447. long startTimeLong = long.Parse(sTime.Ticks.ToString().Substring(0, sTime.Ticks.ToString().Length - 4));
  448. long endTimeLong = long.Parse(eTime.Ticks.ToString().Substring(0, eTime.Ticks.ToString().Length - 4));
  449. logger.Info("风场AGC曲线查询开始========================");
  450. logger.Info("查询开始时间戳"+startTimeLong+"========================");
  451. logger.Info("查询结束时间戳" + endTimeLong + "========================");
  452. TimeSpan sp = DateTime.Now.AddHours(-8).Subtract(dtStart);
  453. //获取有效数据最小时间戳
  454. long minTime = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4));
  455. List<TsData> powerSetList_MHS6 = RestfulClient.findHistorySnapByTagName(powerSetMHS6, startTimeLong,
  456. endTimeLong,60);
  457. List<TsData> actualPowe_MHS6 = RestfulClient.findHistorySnapByTagName(powerActualMHS6, startTimeLong,
  458. endTimeLong, 60);
  459. IList<TsData> pm6 = powerSet_MHS6.TsDataList.Union(powerSetList_MHS6).Where(s => s.ts > minTime).ToList();
  460. IList<TsData> am6 = actualPower_MHS6.TsDataList.Union(actualPowe_MHS6).Where(s => s.ts > minTime).ToList();
  461. powerSet_MHS6.TsDataList = pm6.Distinct(new DataCompare()).ToList();
  462. actualPower_MHS6.TsDataList = am6.Distinct(new DataCompare()).ToList();
  463. logger.Info("powerSet_MHS6:" + powerSet_MHS6.TsDataList.Count);
  464. logger.Info("actualPower_MHS6:" + actualPower_MHS6.TsDataList.Count);
  465. List<TsData> powerSetList_MHS2 = RestfulClient.findHistorySnapByTagName(powerSetMHS2, startTimeLong,
  466. endTimeLong,60);
  467. List<TsData> actualPowe_MHS2 = RestfulClient.findHistorySnapByTagName(powerActualMHS2, startTimeLong,
  468. endTimeLong, 60);
  469. IList<TsData> pm2 = powerSet_MHS2.TsDataList.Union(powerSetList_MHS2).Where(s => s.ts > minTime).ToList();
  470. IList<TsData> am2 = actualPower_MHS2.TsDataList.Union(actualPowe_MHS2).Where(s => s.ts > minTime).ToList();
  471. powerSet_MHS2.TsDataList = pm2.Distinct(new DataCompare()).ToList();
  472. actualPower_MHS2.TsDataList = am2.Distinct(new DataCompare()).ToList();
  473. logger.Info("powerSet_MHS2:" + powerSet_MHS2.TsDataList.Count);
  474. logger.Info("actualPower_MHS6:" + actualPower_MHS6.TsDataList.Count);
  475. List<TsData> powerSetList_NSS2 = RestfulClient.findHistorySnapByTagName(powerSetNSS2, startTimeLong,
  476. endTimeLong, 60);
  477. List<TsData> actualPowe_NSS2 = RestfulClient.findHistorySnapByTagName(powerActualNSS2, startTimeLong,
  478. endTimeLong, 60);
  479. IList<TsData> pn2 = powerSet_NSS2.TsDataList.Union(powerSetList_NSS2).Where(s => s.ts > minTime).ToList();
  480. IList<TsData> an2 = actualPower_NSS2.TsDataList.Union(actualPowe_NSS2).Where(s => s.ts > minTime).ToList();
  481. powerSet_NSS2.TsDataList = pn2.Distinct(new DataCompare()).ToList();
  482. actualPower_NSS2.TsDataList = an2.Distinct(new DataCompare()).ToList();
  483. logger.Info("powerSet_NSS2:" + powerSet_NSS2.TsDataList.Count);
  484. logger.Info("actualPower_NSS2:" + actualPower_NSS2.TsDataList.Count);
  485. List<TsData> powerSetList_XN6 = RestfulClient.findHistorySnapByTagName(powerSetXN6, startTimeLong,
  486. endTimeLong, 60);
  487. List<TsData> actualPowe_XN6 = RestfulClient.findHistorySnapByTagName(powerActualXN6, startTimeLong,
  488. endTimeLong, 60);
  489. IList<TsData> px6 = powerSet_XN6.TsDataList.Union(powerSetList_XN6).Where(s => s.ts > minTime).ToList();
  490. IList<TsData> ax6 = actualPower_XN6.TsDataList.Union(actualPowe_XN6).Where(s => s.ts > minTime).ToList();
  491. powerSet_XN6.TsDataList = px6.Distinct(new DataCompare()).ToList();
  492. actualPower_XN6.TsDataList = ax6.Distinct(new DataCompare()).ToList();
  493. logger.Info("powerSet_XN6:" + powerSet_XN6.TsDataList.Count);
  494. logger.Info("actualPower_XN6:" + actualPower_XN6.TsDataList.Count);
  495. List<TsData> powerSetList_NSS5 = RestfulClient.findHistorySnapByTagName(powerSetNSS5, startTimeLong,
  496. endTimeLong, 60);
  497. List<TsData> actualPowe_NSS5 = RestfulClient.findHistorySnapByTagName(powerActualNSS5, startTimeLong,
  498. endTimeLong, 60);
  499. List<TsData> pn5 = powerSet_NSS5.TsDataList.Union(powerSetList_NSS5).Where(s => s.ts > minTime).ToList();
  500. List<TsData> an5 = actualPower_NSS5.TsDataList.Union(actualPowe_NSS5).Where(s => s.ts > minTime).ToList();
  501. powerSet_NSS5.TsDataList = pn5.Distinct(new DataCompare()).ToList();
  502. actualPower_NSS5.TsDataList = an5.Distinct(new DataCompare()).ToList();
  503. logger.Info("powerSet_NSS5:" + powerSet_NSS5.TsDataList.Count);
  504. logger.Info("actualPower_NSS5:" + actualPower_NSS5.TsDataList.Count);
  505. List<TsData> powerSetList_XS5 = RestfulClient.findHistorySnapByTagName(powerSetXS5, startTimeLong,
  506. endTimeLong, 60);
  507. List<TsData> actualPowe_XS5 = RestfulClient.findHistorySnapByTagName(powerActualXS5, startTimeLong,
  508. endTimeLong, 60);
  509. List<TsData> px5 = powerSet_XS5.TsDataList.Union(powerSetList_XS5).Where(s => s.ts > minTime).ToList();
  510. List<TsData> ax5 = actualPower_XS5.TsDataList.Union(actualPowe_XS5).Where(s => s.ts > minTime).ToList();
  511. powerSet_XS5.TsDataList = px5.Distinct(new DataCompare()).ToList();
  512. actualPower_XS5.TsDataList = ax5.Distinct(new DataCompare()).ToList();
  513. logger.Info("powerSet_XS5:" + powerSet_XS5.TsDataList.Count);
  514. logger.Info("actualPower_XS5:" + actualPower_XS5.TsDataList.Count);
  515. logger.Info("风场AGC曲线查询结束========================");
  516. }
  517. else
  518. {
  519. DateTime? startTime = null;
  520. if (lastUpdateTime_Sun.HasValue)
  521. startTime = lastUpdateTime_Sun.Value;
  522. else
  523. {
  524. startTime = DateTime.Now.AddHours(-8);
  525. lastUpdateTime_Sun = DateTime.Now;
  526. }
  527. DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
  528. TimeSpan sTime = startTime.Value.Subtract(dtStart);
  529. TimeSpan eTime = DateTime.Now.Subtract(dtStart);
  530. long startTimeLong = long.Parse(sTime.Ticks.ToString().Substring(0, sTime.Ticks.ToString().Length - 4));
  531. long endTimeLong = long.Parse(eTime.Ticks.ToString().Substring(0, eTime.Ticks.ToString().Length - 4));
  532. TimeSpan sp = DateTime.Now.AddHours(-8).Subtract(dtStart);
  533. //获取有效数据最小时间戳
  534. long minTime = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4));
  535. List<TsData> powerSetList_SZS5 = RestfulClient.findHistoryRawByTagName(powerSetSZS5, startTimeLong, endTimeLong);
  536. List<TsData> actualPowe_SZS5 = RestfulClient.findHistoryRawByTagName(powerActualSZS5, startTimeLong, endTimeLong);
  537. powerSet_SZS5.TsDataList = powerSet_SZS5.TsDataList.Union(powerSetList_SZS5).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  538. actualPower_SZS5.TsDataList = actualPower_SZS5.TsDataList.Union(actualPowe_SZS5).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  539. List<TsData> powerSetList_PL3 = RestfulClient.findHistoryRawByTagName(powerSetPL3, startTimeLong, endTimeLong);
  540. List<TsData> actualPowe_PL3 = RestfulClient.findHistoryRawByTagName(powerActualPL3, startTimeLong, endTimeLong);
  541. powerSet_PL3.TsDataList = powerSet_PL3.TsDataList.Union(powerSetList_PL3).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  542. actualPower_PL3.TsDataList = actualPower_PL3.TsDataList.Union(actualPowe_PL3).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  543. List<TsData> powerSetList_ZW2 = RestfulClient.findHistoryRawByTagName(powerSetZW2, startTimeLong, endTimeLong);
  544. List<TsData> actualPowe_ZW2 = RestfulClient.findHistoryRawByTagName(powerActualZW2, startTimeLong, endTimeLong);
  545. powerSet_ZW6.TsDataList = powerSet_ZW6.TsDataList.Union(powerSetList_ZW2).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  546. actualPower_ZW6.TsDataList = actualPower_ZW6.TsDataList.Union(actualPowe_ZW2).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList();
  547. }
  548. }
  549. //首次页面加载执行 查询当前时间前8小时历史快照
  550. public static void GetHistoryLineDataFirst()
  551. {
  552. if (pointTagNameList.Count <= 0)
  553. GetTagName();
  554. IList<AgcPoint> pointList = pointTagNameList;
  555. #region 获取各个场站有功设定和实发有功测点
  556. //麻黄山2有功设定
  557. string powerSet_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName;
  558. //麻黄山2实发有功
  559. string powerActual_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName;
  560. //牛首山2有功设定
  561. string powerSet_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName;
  562. //牛首山2实发有功
  563. string powerActual_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName;
  564. //麻黄山6有功设定
  565. string powerSet_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName;
  566. //麻黄山6实发有功
  567. string powerActual_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName;
  568. //星能6有功设定
  569. string powerSet_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName;
  570. //星能6实发有功
  571. string powerActual_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName;
  572. //牛首山5有功设定
  573. string powerSet_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName;
  574. //牛首山5实发有功
  575. string powerActual_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName;
  576. //香山5有功设定
  577. string powerSet_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName;
  578. //香山5实发有功
  579. string powerActual_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName;
  580. //石嘴山5有功设定
  581. string powerSet_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName;
  582. //石嘴山5实发有功
  583. string powerActual_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName;
  584. //平罗35有功设定
  585. string powerSet_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName;
  586. //平罗5实发有功
  587. string powerActual_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName;
  588. //中卫6有功设定
  589. string powerSet_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName;
  590. //中卫6实发有功
  591. string powerActual_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName;
  592. #endregion
  593. powerSetList = new List<PowerSet>();
  594. powerActualList = new List<PowerActual>();
  595. long startTimeStep = (DateTime.Now.AddHours(-8).ToUniversalTime().Ticks - 621355968000000000) / 10000;
  596. long endTimeStep = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
  597. #region 麻黄山6
  598. PowerSet powerSet_MHS6 = new PowerSet();
  599. powerSet_MHS6.StationName = "MHS6";
  600. powerSet_MHS6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_MHS6, startTimeStep, endTimeStep, 60);
  601. powerSetList.Add(powerSet_MHS6);
  602. PowerActual actualPower_MHS6 = new PowerActual();
  603. actualPower_MHS6.StationName = "MHS6";
  604. actualPower_MHS6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_MHS6, startTimeStep, endTimeStep, 60);
  605. powerActualList.Add(actualPower_MHS6);
  606. #endregion
  607. #region 牛首山2
  608. PowerSet powerSet_NSS2 = new PowerSet();
  609. powerSet_NSS2.StationName = "NSS2";
  610. powerSet_NSS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_NSS2, startTimeStep, endTimeStep, 60);
  611. powerSetList.Add(powerSet_NSS2);
  612. PowerActual actualPower_NSS2 = new PowerActual();
  613. actualPower_NSS2.StationName = "NSS2";
  614. actualPower_NSS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_NSS2, startTimeStep, endTimeStep, 60);
  615. powerActualList.Add(actualPower_NSS2);
  616. #endregion
  617. #region 麻黄山2
  618. PowerSet powerSet_MHS2 = new PowerSet();
  619. powerSet_MHS2.StationName = "MHS2";
  620. powerSet_MHS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_MHS2, startTimeStep, endTimeStep, 60);
  621. powerSetList.Add(powerSet_MHS2);
  622. PowerActual actualPower_MHS2 = new PowerActual();
  623. actualPower_MHS2.StationName = "MHS2";
  624. actualPower_MHS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_MHS2, startTimeStep, endTimeStep, 60);
  625. powerActualList.Add(actualPower_MHS2);
  626. #endregion
  627. #region 星能6
  628. PowerSet powerSet_XN6 = new PowerSet();
  629. powerSet_XN6.StationName = "XN6";
  630. powerSet_XN6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_XN6, startTimeStep, endTimeStep, 60);
  631. powerSetList.Add(powerSet_XN6);
  632. PowerActual actualPower_XN6 = new PowerActual();
  633. actualPower_XN6.StationName = "XN6";
  634. actualPower_XN6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_XN6, startTimeStep, endTimeStep, 60);
  635. powerActualList.Add(actualPower_XN6);
  636. #endregion
  637. #region 牛首山5
  638. PowerSet powerSet_NSS5 = new PowerSet();
  639. powerSet_NSS5.StationName = "NSS5";
  640. powerSet_NSS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_NSS5, startTimeStep, endTimeStep, 60);
  641. powerSetList.Add(powerSet_NSS5);
  642. PowerActual actualPower_NSS5 = new PowerActual();
  643. actualPower_NSS5.StationName = "NSS5";
  644. actualPower_NSS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_NSS5, startTimeStep, endTimeStep, 60);
  645. powerActualList.Add(actualPower_NSS5);
  646. #endregion
  647. #region 香山5
  648. PowerSet powerSet_XS5 = new PowerSet();
  649. powerSet_XS5.StationName = "XS5";
  650. powerSet_XS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_XS5, startTimeStep, endTimeStep, 60);
  651. powerSetList.Add(powerSet_XS5);
  652. PowerActual actualPower_XS5 = new PowerActual();
  653. actualPower_XS5.StationName = "XS5";
  654. actualPower_XS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_XS5, startTimeStep, endTimeStep, 60);
  655. powerActualList.Add(actualPower_XS5);
  656. #endregion
  657. #region 石嘴山5
  658. PowerSet powerSet_SZS5 = new PowerSet();
  659. powerSet_SZS5.StationName = "SZS5";
  660. powerSet_SZS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_SZS5, startTimeStep, endTimeStep, 60);
  661. powerSetList.Add(powerSet_SZS5);
  662. PowerActual actualPower_SZS5 = new PowerActual();
  663. actualPower_SZS5.StationName = "SZS5";
  664. actualPower_SZS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_SZS5, startTimeStep, endTimeStep, 60);
  665. powerActualList.Add(actualPower_SZS5);
  666. #endregion
  667. #region 平罗3
  668. PowerSet powerSet_PL3 = new PowerSet();
  669. powerSet_PL3.StationName = "PL3";
  670. powerSet_PL3.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_PL3, startTimeStep, endTimeStep, 60);
  671. powerSetList.Add(powerSet_PL3);
  672. PowerActual actualPower_PL3 = new PowerActual();
  673. actualPower_PL3.StationName = "PL3";
  674. actualPower_PL3.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_PL3, startTimeStep, endTimeStep, 60);
  675. powerActualList.Add(actualPower_PL3);
  676. #endregion
  677. #region 中卫6
  678. PowerSet powerSet_ZW6 = new PowerSet();
  679. powerSet_ZW6.StationName = "ZW6";
  680. powerSet_ZW6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_ZW6, startTimeStep, endTimeStep, 60);
  681. powerSetList.Add(powerSet_ZW6);
  682. PowerActual actualPower_ZW6 = new PowerActual();
  683. actualPower_ZW6.StationName = "ZW6";
  684. actualPower_ZW6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_ZW6, startTimeStep, endTimeStep, 60);
  685. powerActualList.Add(actualPower_ZW6);
  686. #endregion
  687. }
  688. public static void UpdateHistoryLineData(object isWind)
  689. {
  690. if (pointTagNameList.Count <= 0)
  691. GetTagName();
  692. IList<AgcPoint> pointList = pointTagNameList;
  693. #region 获取各个场站有功设定和实发有功测点
  694. //麻黄山2有功设定
  695. string powerSet_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName;
  696. //麻黄山2实发有功
  697. string powerActual_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName;
  698. //牛首山2有功设定
  699. string powerSet_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName;
  700. //牛首山2实发有功
  701. string powerActual_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName;
  702. //麻黄山6有功设定
  703. string powerSet_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName;
  704. //麻黄山6实发有功
  705. string powerActual_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName;
  706. //星能6有功设定
  707. string powerSet_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName;
  708. //星能6实发有功
  709. string powerActual_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName;
  710. //牛首山5有功设定
  711. string powerSet_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName;
  712. //牛首山5实发有功
  713. string powerActual_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName;
  714. //香山5有功设定
  715. string powerSet_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName;
  716. //香山5实发有功
  717. string powerActual_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName;
  718. //石嘴山5有功设定
  719. string powerSet_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName;
  720. //石嘴山5实发有功
  721. string powerActual_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName;
  722. //平罗35有功设定
  723. string powerSet_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName;
  724. //平罗5实发有功
  725. string powerActual_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName;
  726. //中卫6有功设定
  727. string powerSet_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName;
  728. //中卫6实发有功
  729. string powerActual_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName;
  730. #endregion
  731. //获取当前时间戳
  732. long nowTimeStep = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
  733. //获取有效数据最小时间戳(当前时间减去8小时)
  734. long minTimeStep = (DateTime.Now.AddHours(-8).ToUniversalTime().Ticks - 621355968000000000) / 10000;
  735. var powerSet_MHS6 = powerSetList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  736. var actualPower_MHS6 = powerActualList.Where(s => s.StationName == "MHS6").FirstOrDefault();
  737. var powerSet_NSS2 = powerSetList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  738. var actualPower_NSS2 = powerActualList.Where(s => s.StationName == "NSS2").FirstOrDefault();
  739. var powerSet_MHS2 = powerSetList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  740. var actualPower_MHS2 = powerActualList.Where(s => s.StationName == "MHS2").FirstOrDefault();
  741. var powerSet_XN6 = powerSetList.Where(s => s.StationName == "XN6").FirstOrDefault();
  742. var actualPower_XN6 = powerActualList.Where(s => s.StationName == "XN6").FirstOrDefault();
  743. var powerSet_NSS5 = powerSetList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  744. var actualPower_NSS5 = powerActualList.Where(s => s.StationName == "NSS5").FirstOrDefault();
  745. var powerSet_XS5 = powerSetList.Where(s => s.StationName == "XS5").FirstOrDefault();
  746. var actualPower_XS5 = powerActualList.Where(s => s.StationName == "XS5").FirstOrDefault();
  747. var powerSet_SZS5 = powerSetList.Where(s => s.StationName == "SZS5").FirstOrDefault();
  748. var actualPower_SZS5 = powerActualList.Where(s => s.StationName == "SZS5").FirstOrDefault();
  749. var powerSet_PL3 = powerSetList.Where(s => s.StationName == "PL3").FirstOrDefault();
  750. var actualPower_PL3 = powerActualList.Where(s => s.StationName == "PL3").FirstOrDefault();
  751. var powerSet_ZW6 = powerSetList.Where(s => s.StationName == "ZW6").FirstOrDefault();
  752. var actualPower_ZW6 = powerActualList.Where(s => s.StationName == "ZW6").FirstOrDefault();
  753. if ((bool)isWind)
  754. {
  755. #region MHS6
  756. Dictionary<string, TsData> powerSetList_MHS6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS6 });
  757. Dictionary<string, TsData> actualPowe_MHS6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_MHS6 });
  758. TsData powerSetTsData_MHS6 = null;
  759. TsData actualTsData_MHS6 = null;
  760. if (powerSetList_MHS6 != null && powerSetList_MHS6.Count > 0)
  761. {
  762. var data = powerSetList_MHS6.FirstOrDefault().Value;
  763. if (data != null)
  764. {
  765. powerSetTsData_MHS6 = data;
  766. powerSetTsData_MHS6.ts = nowTimeStep;
  767. }
  768. }
  769. if (actualPowe_MHS6 != null && actualPowe_MHS6.Count > 0)
  770. {
  771. var data = actualPowe_MHS6.FirstOrDefault().Value;
  772. if (data != null)
  773. {
  774. actualTsData_MHS6 = data;
  775. actualTsData_MHS6.ts = nowTimeStep;
  776. }
  777. }
  778. if (powerSetTsData_MHS6 != null && powerSet_MHS6.TsDataList != null)
  779. powerSet_MHS6.TsDataList.Add(powerSetTsData_MHS6);
  780. if (actualTsData_MHS6 != null && actualPower_MHS6.TsDataList != null)
  781. actualPower_MHS6.TsDataList.Add(actualTsData_MHS6);
  782. IList<TsData> pm6 = powerSet_MHS6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  783. IList<TsData> am6 = actualPower_MHS6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  784. powerSet_MHS6.TsDataList = pm6.Distinct(new DataCompare()).ToList();
  785. actualPower_MHS6.TsDataList = am6.Distinct(new DataCompare()).ToList();
  786. #endregion
  787. #region NSS2
  788. Dictionary<string, TsData> powerSetList_NSS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS2 });
  789. Dictionary<string, TsData> actualPowe_NSS2 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_NSS2 });
  790. TsData powerSetTsData_NSS2 = null;
  791. TsData actualTsData_NSS2 = null;
  792. if (powerSetList_NSS2 != null && powerSetList_NSS2.Count > 0)
  793. {
  794. var data = powerSetList_NSS2.FirstOrDefault().Value;
  795. if (data != null)
  796. {
  797. powerSetTsData_NSS2 = data;
  798. powerSetTsData_NSS2.ts = nowTimeStep;
  799. }
  800. }
  801. if (actualPowe_NSS2 != null && actualPowe_NSS2.Count > 0)
  802. {
  803. var data = actualPowe_NSS2.FirstOrDefault().Value;
  804. if (data != null)
  805. {
  806. actualTsData_NSS2 = data;
  807. actualTsData_NSS2.ts = nowTimeStep;
  808. }
  809. }
  810. if (powerSetTsData_NSS2 != null && powerSet_NSS2.TsDataList != null)
  811. powerSet_NSS2.TsDataList.Add(powerSetTsData_NSS2);
  812. if (actualTsData_NSS2 != null && actualPower_NSS2.TsDataList != null)
  813. actualPower_NSS2.TsDataList.Add(actualTsData_NSS2);
  814. IList<TsData> pn2 = powerSet_NSS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  815. IList<TsData> an2 = actualPower_NSS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  816. powerSet_NSS2.TsDataList = pn2.Distinct(new DataCompare()).ToList();
  817. actualPower_NSS2.TsDataList = an2.Distinct(new DataCompare()).ToList();
  818. #endregion
  819. #region MHS2
  820. Dictionary<string, TsData> powerSetList_MHS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS2 });
  821. Dictionary<string, TsData> actualPowe_MHS2 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_MHS2 });
  822. TsData powerSetTsData_MHS2 = null;
  823. TsData actualTsData_MHS2 = null;
  824. if (powerSetList_MHS2 != null && powerSetList_MHS2.Count > 0)
  825. {
  826. var data = powerSetList_MHS2.FirstOrDefault().Value;
  827. if (data != null)
  828. {
  829. powerSetTsData_MHS2 = data;
  830. powerSetTsData_MHS2.ts = nowTimeStep;
  831. }
  832. }
  833. if (actualPowe_MHS2 != null && actualPowe_MHS2.Count > 0)
  834. {
  835. var data = actualPowe_MHS2.FirstOrDefault().Value;
  836. if (data != null)
  837. {
  838. actualTsData_MHS2 = data;
  839. actualTsData_MHS2.ts = nowTimeStep;
  840. }
  841. }
  842. if (powerSetTsData_MHS2 != null && powerSet_MHS2.TsDataList != null)
  843. powerSet_MHS2.TsDataList.Add(powerSetTsData_MHS2);
  844. if (actualTsData_MHS2 != null && actualPower_MHS2.TsDataList != null)
  845. actualPower_MHS2.TsDataList.Add(actualTsData_MHS2);
  846. IList<TsData> pm2 = powerSet_MHS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  847. IList<TsData> am2 = actualPower_MHS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  848. powerSet_MHS2.TsDataList = pm2.Distinct(new DataCompare()).ToList();
  849. actualPower_MHS2.TsDataList = am2.Distinct(new DataCompare()).ToList();
  850. #endregion
  851. #region XN6
  852. Dictionary<string, TsData> powerSetList_XN6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XN6 });
  853. Dictionary<string, TsData> actualPowe_XN6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_XN6 });
  854. TsData powerSetTsData_XN6 = null;
  855. TsData actualTsData_XN6 = null;
  856. if (powerSetList_XN6 != null && powerSetList_XN6.Count > 0)
  857. {
  858. var data = powerSetList_XN6.FirstOrDefault().Value;
  859. if (data != null)
  860. {
  861. powerSetTsData_XN6 = data;
  862. powerSetTsData_XN6.ts = nowTimeStep;
  863. }
  864. }
  865. if (actualPowe_XN6 != null && actualPowe_XN6.Count > 0)
  866. {
  867. var data = actualPowe_XN6.FirstOrDefault().Value;
  868. if (data != null)
  869. {
  870. actualTsData_XN6 = data;
  871. actualTsData_XN6.ts = nowTimeStep;
  872. }
  873. }
  874. if (powerSetTsData_XN6 != null && powerSet_XN6.TsDataList != null)
  875. powerSet_XN6.TsDataList.Add(powerSetTsData_XN6);
  876. if (actualTsData_XN6 != null && actualPower_XN6.TsDataList != null)
  877. actualPower_XN6.TsDataList.Add(actualTsData_XN6);
  878. IList<TsData> px6 = powerSet_XN6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  879. IList<TsData> ax6 = actualPower_XN6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  880. powerSet_XN6.TsDataList = px6.Distinct(new DataCompare()).ToList();
  881. actualPower_XN6.TsDataList = ax6.Distinct(new DataCompare()).ToList();
  882. #endregion
  883. #region NSS5
  884. Dictionary<string, TsData> powerSetList_NSS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS5 });
  885. Dictionary<string, TsData> actualPowe_NSS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_NSS5 });
  886. TsData powerSetTsData_NSS5 = null;
  887. TsData actualTsData_NSS5 = null;
  888. if (powerSetList_NSS5 != null && powerSetList_NSS5.Count > 0)
  889. {
  890. var data = powerSetList_NSS5.FirstOrDefault().Value;
  891. if (data != null)
  892. {
  893. powerSetTsData_NSS5 = data;
  894. powerSetTsData_NSS5.ts = nowTimeStep;
  895. }
  896. }
  897. if (actualPowe_NSS5 != null && actualPowe_NSS5.Count > 0)
  898. {
  899. var data = actualPowe_NSS5.FirstOrDefault().Value;
  900. if (data != null)
  901. {
  902. actualTsData_NSS5 = data;
  903. actualTsData_NSS5.ts = nowTimeStep;
  904. }
  905. }
  906. if (powerSetTsData_NSS5 != null && powerSet_NSS5.TsDataList != null)
  907. powerSet_NSS5.TsDataList.Add(powerSetTsData_NSS5);
  908. if (actualTsData_NSS5 != null && actualPower_NSS5.TsDataList != null)
  909. actualPower_NSS5.TsDataList.Add(actualTsData_NSS5);
  910. IList<TsData> pn5 = powerSet_NSS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  911. IList<TsData> an5 = actualPower_NSS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  912. powerSet_NSS5.TsDataList = pn5.Distinct(new DataCompare()).ToList();
  913. actualPower_NSS5.TsDataList = an5.Distinct(new DataCompare()).ToList();
  914. #endregion
  915. #region XS5
  916. Dictionary<string, TsData> powerSetList_XS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XS5 });
  917. Dictionary<string, TsData> actualPowe_XS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_XS5 });
  918. TsData powerSetTsData_XS5 = null;
  919. TsData actualTsData_XS5 = null;
  920. if (powerSetList_XS5 != null && powerSetList_XS5.Count > 0)
  921. {
  922. var data = powerSetList_XS5.FirstOrDefault().Value;
  923. if (data != null)
  924. {
  925. powerSetTsData_XS5 = data;
  926. powerSetTsData_XS5.ts = nowTimeStep;
  927. }
  928. }
  929. if (actualPowe_XS5 != null && actualPowe_XS5.Count > 0)
  930. {
  931. var data = actualPowe_XS5.FirstOrDefault().Value;
  932. if (data != null)
  933. {
  934. actualTsData_XS5 = data;
  935. actualTsData_XS5.ts = nowTimeStep;
  936. }
  937. }
  938. if (powerSetTsData_XS5 != null && powerSet_XS5.TsDataList != null)
  939. powerSet_XS5.TsDataList.Add(powerSetTsData_XS5);
  940. if (actualTsData_XS5 != null && actualPower_XS5.TsDataList != null)
  941. actualPower_XS5.TsDataList.Add(actualTsData_XS5);
  942. IList<TsData> px5 = powerSet_XS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  943. IList<TsData> ax5 = actualPower_XS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  944. powerSet_XS5.TsDataList = px5.Distinct(new DataCompare()).ToList();
  945. actualPower_XS5.TsDataList = ax5.Distinct(new DataCompare()).ToList();
  946. #endregion
  947. }
  948. else
  949. {
  950. #region SZS5
  951. Dictionary<string, TsData> powerSetList_SZS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_SZS5 });
  952. Dictionary<string, TsData> actualPowe_SZS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_SZS5 });
  953. TsData powerSetTsData_SZS5 = null;
  954. TsData actualTsData_SZS5 = null;
  955. if (powerSetList_SZS5 != null && powerSetList_SZS5.Count > 0)
  956. {
  957. var data = powerSetList_SZS5.FirstOrDefault().Value;
  958. if (data != null)
  959. {
  960. powerSetTsData_SZS5 = data;
  961. powerSetTsData_SZS5.ts = nowTimeStep;
  962. }
  963. }
  964. if (actualPowe_SZS5 != null && actualPowe_SZS5.Count > 0)
  965. {
  966. var data = actualPowe_SZS5.FirstOrDefault().Value;
  967. if (data != null)
  968. {
  969. actualTsData_SZS5 = data;
  970. actualTsData_SZS5.ts = nowTimeStep;
  971. }
  972. }
  973. if (powerSetTsData_SZS5 != null && powerSet_SZS5.TsDataList != null)
  974. powerSet_SZS5.TsDataList.Add(powerSetTsData_SZS5);
  975. if (actualTsData_SZS5 != null && actualPower_SZS5.TsDataList != null)
  976. actualPower_SZS5.TsDataList.Add(actualTsData_SZS5);
  977. IList<TsData> ps5 = powerSet_SZS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  978. IList<TsData> as5 = actualPower_SZS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  979. powerSet_SZS5.TsDataList = ps5.Distinct(new DataCompare()).ToList();
  980. actualPower_SZS5.TsDataList = as5.Distinct(new DataCompare()).ToList();
  981. #endregion
  982. #region PL3
  983. Dictionary<string, TsData> powerSetList_PL3 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_PL3 });
  984. Dictionary<string, TsData> actualPowe_PL3 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_PL3 });
  985. TsData powerSetTsData_PL3 = null;
  986. TsData actualTsData_PL3 = null;
  987. if (powerSetList_PL3 != null && powerSetList_PL3.Count > 0)
  988. {
  989. var data = powerSetList_PL3.FirstOrDefault().Value;
  990. if (data != null)
  991. powerSetTsData_PL3 = data;
  992. }
  993. if (actualPowe_PL3 != null && actualPowe_PL3.Count > 0)
  994. {
  995. var data = actualPowe_PL3.FirstOrDefault().Value;
  996. if (data != null)
  997. actualTsData_PL3 = data;
  998. }
  999. if (powerSetTsData_PL3 != null && powerSet_PL3.TsDataList != null)
  1000. powerSet_PL3.TsDataList.Add(powerSetTsData_PL3);
  1001. if (actualTsData_PL3 != null && actualPower_PL3.TsDataList != null)
  1002. actualPower_PL3.TsDataList.Add(actualTsData_PL3);
  1003. IList<TsData> pp3 = powerSet_PL3.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  1004. IList<TsData> ap3 = actualPower_PL3.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  1005. powerSet_PL3.TsDataList = pp3.Distinct(new DataCompare()).ToList();
  1006. actualPower_PL3.TsDataList = ap3.Distinct(new DataCompare()).ToList();
  1007. #endregion
  1008. #region ZW6
  1009. Dictionary<string, TsData> powerSetList_ZW6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_ZW6 });
  1010. Dictionary<string, TsData> actualPowe_ZW6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_ZW6 });
  1011. TsData powerSetTsData_ZW6 = null;
  1012. TsData actualTsData_ZW6 = null;
  1013. if (powerSetList_ZW6 != null && powerSetList_ZW6.Count > 0)
  1014. {
  1015. var data = powerSetList_ZW6.FirstOrDefault().Value;
  1016. if (data != null)
  1017. powerSetTsData_ZW6 = data;
  1018. }
  1019. if (actualPowe_ZW6 != null && actualPowe_ZW6.Count > 0)
  1020. {
  1021. var data = actualPowe_ZW6.FirstOrDefault().Value;
  1022. if (data != null)
  1023. actualTsData_ZW6 = data;
  1024. }
  1025. if (powerSetTsData_ZW6 != null && powerSet_ZW6.TsDataList != null)
  1026. powerSet_ZW6.TsDataList.Add(powerSetTsData_ZW6);
  1027. if (actualTsData_ZW6 != null && actualPower_ZW6.TsDataList != null)
  1028. actualPower_ZW6.TsDataList.Add(actualTsData_ZW6);
  1029. IList<TsData> pw6 = powerSet_ZW6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  1030. IList<TsData> aw6 = actualPower_ZW6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
  1031. powerSet_ZW6.TsDataList = pw6.Distinct(new DataCompare()).ToList();
  1032. actualPower_ZW6.TsDataList = aw6.Distinct(new DataCompare()).ToList();
  1033. #endregion
  1034. }
  1035. }
  1036. private static bool IsNum(string s, out double num)
  1037. {
  1038. try
  1039. {
  1040. if (s == "True" || s == "true")
  1041. num = 1;
  1042. else if (s == "false" || s == "False")
  1043. num = 0;
  1044. else
  1045. {
  1046. num = Convert.ToDouble(s);
  1047. }
  1048. return true;
  1049. }
  1050. catch (Exception)
  1051. {
  1052. num = 0.0;
  1053. return false;
  1054. }
  1055. }
  1056. }
  1057. }