using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms.VisualStyles; using System.Xml; using IntelligentControlForsx.Service.AGC.Domain; using IntelligentControlForsx.Service.WindturbineInfo; using log4net; using WisdomClient; using WisdomClient.data; namespace IntelligentControlForsx.Service.AGC { public class AgcInfoSvc { #region 单例 private AgcInfoSvc() { } public static AgcInfoSvc Instance { get { return SingletonCreator.instance; } } class SingletonCreator { internal static readonly AgcInfoSvc instance = new AgcInfoSvc(); } #endregion private static ILog logger = LogManager.GetLogger("AppInfoLog"); //agc测点集合 public static IList pointTagNameList = new List(); //agc测点值集合 public static IList agcDataList = new List(); //agc曲线数据--实发有功 public static IList powerActualList = new List(); //agc曲线数据--有功设定 public static IList powerSetList = new List(); public static DateTime? lastUpdateTime_Wind = null; public static DateTime? lastUpdateTime_Sun = null; /// /// 获取agc相关测点,并保存至缓存pointTagNameList /// public static void GetTagName() { IList list = new List(); string path = Environment.CurrentDirectory; string filePath = path + "\\conf\\AgcTagName.xml"; XmlDocument xdoc = new XmlDocument(); xdoc.Load(filePath); //加载xml文档 XmlNodeList rootList = xdoc.SelectNodes("/root"); if (rootList != null && rootList.Count > 0) { XmlNodeList stationNodeList = rootList[0].ChildNodes; foreach (XmlNode stationNode in stationNodeList) { string stationName = ""; string type = ""; if (stationNode.Attributes["name"] != null) stationName = stationNode.Attributes["name"].Value; if (stationNode.Attributes["type"] != null) type = stationNode.Attributes["type"].Value; XmlNodeList partNodeList = stationNode.ChildNodes; AgcPoint data = new AgcPoint(); if (!string.IsNullOrEmpty(stationName)) data.StationName = stationName; if (!string.IsNullOrEmpty(type)) data.PowerType = type; foreach (XmlNode partNode in partNodeList) { try { string xmlName = ""; String xmlValue = ""; if (partNode.Attributes["name"] != null) xmlName = partNode.Attributes["name"].Value; if (partNode.Attributes["value"] != null) xmlValue = partNode.Attributes["value"].Value; if (xmlName == "有功设定限值") data.PowerSetTagName = xmlValue; if (xmlName == "AGC可调上限") data.AgcUpTagName = xmlValue; if (xmlName == "AGC可调下限") data.AgcLowerTagName = xmlValue; if (xmlName == "实发有功") data.ActualPowerTagName = xmlValue; if (xmlName == "理论功率") data.TheoryPowerTagName = xmlValue; if (xmlName == "AGC投入") data.AgcInTagName = xmlValue; if (xmlName == "AGC远方") data.AgcFarTagName = xmlValue; if (xmlName == "有功增闭锁") data.SumLockTagName = xmlValue; if (xmlName == "有功减闭锁") data.SubLockTagName = xmlValue; if (xmlName == "理论功率资源法") data.TheoryPowerResourcesTagName = xmlValue; if (xmlName == "理论功率样板机法") data.TheoryPowerExampleTagName = xmlValue; if (xmlName == "状态") data.StatusTagName = xmlValue; if (xmlName == "预测功率") data.ForecastPowerTagName = xmlValue; } catch (Exception ex) { logger.Info("xml配置读取错误:" + ex.Message); } } list.Add(data); } pointTagNameList = list; } } /// /// 获取AGC实时数据 /// /// 是否为风电 public static void GetLatestAgcDataInfo(object isWind) { if (pointTagNameList.Count <= 0) GetTagName(); IList pointList = new List(); if ((bool)isWind) pointList = pointTagNameList.Where(s => s.PowerType == "wind").ToList(); else pointList = pointTagNameList.Where(s => s.PowerType == "sun").ToList(); for (int i = 0; i < pointList.Count; i++) { string[] tagArr = new string[] { pointList[i].PowerSetTagName, pointList[i].AgcUpTagName, pointList[i].AgcLowerTagName, pointList[i].ActualPowerTagName, pointList[i].TheoryPowerTagName, pointList[i].ForecastPowerTagName, pointList[i].AgcInTagName, pointList[i].AgcFarTagName, pointList[i].SumLockTagName, pointList[i].SubLockTagName, pointList[i].TheoryPowerResourcesTagName, pointList[i].TheoryPowerExampleTagName, pointList[i].StatusTagName }; Dictionary dic = RestfulClient.findLatestByTagNames(tagArr); AgcEntity entity = agcDataList.Where(s => s.StationName == pointList[i].StationName).FirstOrDefault(); if (entity == null) { entity = new AgcEntity(); entity.StationName = pointList[i].StationName; agcDataList.Add(entity); } foreach (var tsData in dic) { if (tsData.Key == pointList[i].PowerSetTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.PowerSetValue = pointValue; } if (tsData.Key == pointList[i].AgcUpTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.AgcUp = pointValue; } if (tsData.Key == pointList[i].AgcLowerTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.AgcLower = pointValue; } if (tsData.Key == pointList[i].ActualPowerTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.ActualPowerValue = pointValue; } if (tsData.Key == pointList[i].TheoryPowerTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.TheoryPower = pointValue; } if (tsData.Key == pointList[i].ForecastPowerTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.ForecastPower = pointValue; } if (tsData.Key == pointList[i].AgcInTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.AgcIn = pointValue == 1; } if (tsData.Key == pointList[i].AgcFarTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.AgcFar = pointValue == 1; } if (tsData.Key == pointList[i].SumLockTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.SumLock = pointValue == 1; } if (tsData.Key == pointList[i].SubLockTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.SubLock = pointValue == 1; } if (tsData.Key == pointList[i].TheoryPowerResourcesTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.TheoryPowerResources = pointValue; } if (tsData.Key == pointList[i].TheoryPowerExampleTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.TheoryPowerExample = pointValue; } if (tsData.Key == pointList[i].StatusTagName) { double pointValue; bool isNum = IsNum(tsData.Value.getValue(), out pointValue); entity.Status = pointValue == 1; } } } } /// /// 获取有功设定和实发历史值 /// /// 起始时间 /// 结束时间 /// 是否为风电 public static void GetHistoryLineData(object isWind) { if (pointTagNameList.Count <= 0) GetTagName(); IList pointList = pointTagNameList; #region 获取各个场站有功设定和实发有功 //麻黄山2有功设定 string powerSetMHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName; //麻黄山2实发有功 string powerActualMHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName; //牛首山2有功设定 string powerSetNSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName; //牛首山2实发有功 string powerActualNSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName; //麻黄山6有功设定 string powerSetMHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName; //麻黄山6实发有功 string powerActualMHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName; //星能6有功设定 string powerSetXN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName; //星能6实发有功 string powerActualXN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName; //牛首山5有功设定 string powerSetNSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName; //牛首山5实发有功 string powerActualNSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName; //香山5有功设定 string powerSetXS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName; //香山5实发有功 string powerActualXS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName; //石嘴山5有功设定 string powerSetSZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName; //石嘴山5实发有功 string powerActualSZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName; //平罗35有功设定 string powerSetPL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName; //平罗5实发有功 string powerActualPL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName; //中卫2有功设定 string powerSetZW2 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName; //中卫2实发有功 string powerActualZW2 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName; #endregion var powerSet_MHS6 = powerSetList.Where(s => s.StationName == "MHS6").FirstOrDefault(); var actualPower_MHS6 = powerActualList.Where(s => s.StationName == "MHS6").FirstOrDefault(); if (powerSet_MHS6 == null) { powerSet_MHS6 = new PowerSet(); powerSet_MHS6.StationName = "MHS6"; powerSet_MHS6.TsDataList = new List(); powerSetList.Add(powerSet_MHS6); } if (actualPower_MHS6 == null) { actualPower_MHS6 = new PowerActual(); actualPower_MHS6.StationName = "MHS6"; actualPower_MHS6.TsDataList = new List(); powerActualList.Add(actualPower_MHS6); } var powerSet_NSS2 = powerSetList.Where(s => s.StationName == "NSS2").FirstOrDefault(); var actualPower_NSS2 = powerActualList.Where(s => s.StationName == "NSS2").FirstOrDefault(); if (powerSet_NSS2 == null) { powerSet_NSS2 = new PowerSet(); powerSet_NSS2.StationName = "NSS2"; powerSet_NSS2.TsDataList = new List(); powerSetList.Add(powerSet_NSS2); } if (actualPower_NSS2 == null) { actualPower_NSS2 = new PowerActual(); actualPower_NSS2.StationName = "NSS2"; actualPower_NSS2.TsDataList = new List(); powerActualList.Add(actualPower_NSS2); } var powerSet_MHS2 = powerSetList.Where(s => s.StationName == "MHS2").FirstOrDefault(); var actualPower_MHS2 = powerActualList.Where(s => s.StationName == "MHS2").FirstOrDefault(); if (powerSet_MHS2 == null) { powerSet_MHS2 = new PowerSet(); powerSet_MHS2.StationName = "MHS2"; powerSet_MHS2.TsDataList = new List(); powerSetList.Add(powerSet_MHS2); } if (actualPower_MHS2 == null) { actualPower_MHS2 = new PowerActual(); actualPower_MHS2.StationName = "MHS2"; actualPower_MHS2.TsDataList = new List(); powerActualList.Add(actualPower_MHS2); } var powerSet_XN6 = powerSetList.Where(s => s.StationName == "XN6").FirstOrDefault(); var actualPower_XN6 = powerActualList.Where(s => s.StationName == "XN6").FirstOrDefault(); if (powerSet_XN6 == null) { powerSet_XN6 = new PowerSet(); powerSet_XN6.StationName = "XN6"; powerSet_XN6.TsDataList = new List(); powerSetList.Add(powerSet_XN6); } if (actualPower_XN6 == null) { actualPower_XN6 = new PowerActual(); actualPower_XN6.StationName = "XN6"; actualPower_XN6.TsDataList = new List(); powerActualList.Add(actualPower_XN6); } var powerSet_NSS5 = powerSetList.Where(s => s.StationName == "NSS5").FirstOrDefault(); var actualPower_NSS5 = powerActualList.Where(s => s.StationName == "NSS5").FirstOrDefault(); if (powerSet_NSS5 == null) { powerSet_NSS5 = new PowerSet(); powerSet_NSS5.StationName = "NSS5"; powerSet_NSS5.TsDataList = new List(); powerSetList.Add(powerSet_NSS5); } if (actualPower_NSS5 == null) { actualPower_NSS5 = new PowerActual(); actualPower_NSS5.StationName = "NSS5"; actualPower_NSS5.TsDataList = new List(); powerActualList.Add(actualPower_NSS5); } var powerSet_XS5 = powerSetList.Where(s => s.StationName == "XS5").FirstOrDefault(); var actualPower_XS5 = powerActualList.Where(s => s.StationName == "XS5").FirstOrDefault(); if (powerSet_XS5 == null) { powerSet_XS5 = new PowerSet(); powerSet_XS5.StationName = "XS5"; powerSet_XS5.TsDataList = new List(); powerSetList.Add(powerSet_XS5); } if (actualPower_XS5 == null) { actualPower_XS5 = new PowerActual(); actualPower_XS5.StationName = "XS5"; actualPower_XS5.TsDataList = new List(); powerActualList.Add(actualPower_XS5); } var powerSet_SZS5 = powerSetList.Where(s => s.StationName == "SZS5").FirstOrDefault(); var actualPower_SZS5 = powerActualList.Where(s => s.StationName == "SZS5").FirstOrDefault(); if (powerSet_SZS5 == null) { powerSet_SZS5 = new PowerSet(); powerSet_SZS5.StationName = "SZS5"; powerSet_SZS5.TsDataList = new List(); powerSetList.Add(powerSet_SZS5); } if (actualPower_SZS5 == null) { actualPower_SZS5 = new PowerActual(); actualPower_SZS5.StationName = "SZS5"; actualPower_SZS5.TsDataList = new List(); powerActualList.Add(actualPower_SZS5); } var powerSet_PL3 = powerSetList.Where(s => s.StationName == "PL3").FirstOrDefault(); var actualPower_PL3 = powerActualList.Where(s => s.StationName == "PL3").FirstOrDefault(); if (powerSet_PL3 == null) { powerSet_PL3 = new PowerSet(); powerSet_PL3.StationName = "PL3"; powerSet_PL3.TsDataList = new List(); powerSetList.Add(powerSet_PL3); } if (actualPower_PL3 == null) { actualPower_PL3 = new PowerActual(); actualPower_PL3.StationName = "PL3"; actualPower_PL3.TsDataList = new List(); powerActualList.Add(actualPower_PL3); } var powerSet_ZW6 = powerSetList.Where(s => s.StationName == "ZW6").FirstOrDefault(); var actualPower_ZW6 = powerActualList.Where(s => s.StationName == "ZW6").FirstOrDefault(); if (powerSet_ZW6 == null) { powerSet_ZW6 = new PowerSet(); powerSet_ZW6.StationName = "ZW6"; powerSet_ZW6.TsDataList = new List(); powerSetList.Add(powerSet_ZW6); } if (actualPower_ZW6 == null) { actualPower_ZW6 = new PowerActual(); actualPower_ZW6.StationName = "ZW6"; actualPower_ZW6.TsDataList = new List(); powerActualList.Add(actualPower_ZW6); } if ((bool)isWind) { DateTime? startTime = null; if (lastUpdateTime_Wind.HasValue) { startTime = lastUpdateTime_Wind.Value; lastUpdateTime_Wind = DateTime.Now; } else { startTime = DateTime.Now.AddHours(-8); lastUpdateTime_Wind = DateTime.Now; } DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); TimeSpan sTime = startTime.Value.Subtract(dtStart); TimeSpan eTime = DateTime.Now.Subtract(dtStart); long startTimeLong = long.Parse(sTime.Ticks.ToString().Substring(0, sTime.Ticks.ToString().Length - 4)); long endTimeLong = long.Parse(eTime.Ticks.ToString().Substring(0, eTime.Ticks.ToString().Length - 4)); logger.Info("风场AGC曲线查询开始========================"); logger.Info("查询开始时间戳"+startTimeLong+"========================"); logger.Info("查询结束时间戳" + endTimeLong + "========================"); TimeSpan sp = DateTime.Now.AddHours(-8).Subtract(dtStart); //获取有效数据最小时间戳 long minTime = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4)); List powerSetList_MHS6 = RestfulClient.findHistorySnapByTagName(powerSetMHS6, startTimeLong, endTimeLong,60); List actualPowe_MHS6 = RestfulClient.findHistorySnapByTagName(powerActualMHS6, startTimeLong, endTimeLong, 60); IList pm6 = powerSet_MHS6.TsDataList.Union(powerSetList_MHS6).Where(s => s.ts > minTime).ToList(); IList am6 = actualPower_MHS6.TsDataList.Union(actualPowe_MHS6).Where(s => s.ts > minTime).ToList(); powerSet_MHS6.TsDataList = pm6.Distinct(new DataCompare()).ToList(); actualPower_MHS6.TsDataList = am6.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_MHS6:" + powerSet_MHS6.TsDataList.Count); logger.Info("actualPower_MHS6:" + actualPower_MHS6.TsDataList.Count); List powerSetList_MHS2 = RestfulClient.findHistorySnapByTagName(powerSetMHS2, startTimeLong, endTimeLong,60); List actualPowe_MHS2 = RestfulClient.findHistorySnapByTagName(powerActualMHS2, startTimeLong, endTimeLong, 60); IList pm2 = powerSet_MHS2.TsDataList.Union(powerSetList_MHS2).Where(s => s.ts > minTime).ToList(); IList am2 = actualPower_MHS2.TsDataList.Union(actualPowe_MHS2).Where(s => s.ts > minTime).ToList(); powerSet_MHS2.TsDataList = pm2.Distinct(new DataCompare()).ToList(); actualPower_MHS2.TsDataList = am2.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_MHS2:" + powerSet_MHS2.TsDataList.Count); logger.Info("actualPower_MHS6:" + actualPower_MHS6.TsDataList.Count); List powerSetList_NSS2 = RestfulClient.findHistorySnapByTagName(powerSetNSS2, startTimeLong, endTimeLong, 60); List actualPowe_NSS2 = RestfulClient.findHistorySnapByTagName(powerActualNSS2, startTimeLong, endTimeLong, 60); IList pn2 = powerSet_NSS2.TsDataList.Union(powerSetList_NSS2).Where(s => s.ts > minTime).ToList(); IList an2 = actualPower_NSS2.TsDataList.Union(actualPowe_NSS2).Where(s => s.ts > minTime).ToList(); powerSet_NSS2.TsDataList = pn2.Distinct(new DataCompare()).ToList(); actualPower_NSS2.TsDataList = an2.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_NSS2:" + powerSet_NSS2.TsDataList.Count); logger.Info("actualPower_NSS2:" + actualPower_NSS2.TsDataList.Count); List powerSetList_XN6 = RestfulClient.findHistorySnapByTagName(powerSetXN6, startTimeLong, endTimeLong, 60); List actualPowe_XN6 = RestfulClient.findHistorySnapByTagName(powerActualXN6, startTimeLong, endTimeLong, 60); IList px6 = powerSet_XN6.TsDataList.Union(powerSetList_XN6).Where(s => s.ts > minTime).ToList(); IList ax6 = actualPower_XN6.TsDataList.Union(actualPowe_XN6).Where(s => s.ts > minTime).ToList(); powerSet_XN6.TsDataList = px6.Distinct(new DataCompare()).ToList(); actualPower_XN6.TsDataList = ax6.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_XN6:" + powerSet_XN6.TsDataList.Count); logger.Info("actualPower_XN6:" + actualPower_XN6.TsDataList.Count); List powerSetList_NSS5 = RestfulClient.findHistorySnapByTagName(powerSetNSS5, startTimeLong, endTimeLong, 60); List actualPowe_NSS5 = RestfulClient.findHistorySnapByTagName(powerActualNSS5, startTimeLong, endTimeLong, 60); List pn5 = powerSet_NSS5.TsDataList.Union(powerSetList_NSS5).Where(s => s.ts > minTime).ToList(); List an5 = actualPower_NSS5.TsDataList.Union(actualPowe_NSS5).Where(s => s.ts > minTime).ToList(); powerSet_NSS5.TsDataList = pn5.Distinct(new DataCompare()).ToList(); actualPower_NSS5.TsDataList = an5.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_NSS5:" + powerSet_NSS5.TsDataList.Count); logger.Info("actualPower_NSS5:" + actualPower_NSS5.TsDataList.Count); List powerSetList_XS5 = RestfulClient.findHistorySnapByTagName(powerSetXS5, startTimeLong, endTimeLong, 60); List actualPowe_XS5 = RestfulClient.findHistorySnapByTagName(powerActualXS5, startTimeLong, endTimeLong, 60); List px5 = powerSet_XS5.TsDataList.Union(powerSetList_XS5).Where(s => s.ts > minTime).ToList(); List ax5 = actualPower_XS5.TsDataList.Union(actualPowe_XS5).Where(s => s.ts > minTime).ToList(); powerSet_XS5.TsDataList = px5.Distinct(new DataCompare()).ToList(); actualPower_XS5.TsDataList = ax5.Distinct(new DataCompare()).ToList(); logger.Info("powerSet_XS5:" + powerSet_XS5.TsDataList.Count); logger.Info("actualPower_XS5:" + actualPower_XS5.TsDataList.Count); logger.Info("风场AGC曲线查询结束========================"); } else { DateTime? startTime = null; if (lastUpdateTime_Sun.HasValue) startTime = lastUpdateTime_Sun.Value; else { startTime = DateTime.Now.AddHours(-8); lastUpdateTime_Sun = DateTime.Now; } DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); TimeSpan sTime = startTime.Value.Subtract(dtStart); TimeSpan eTime = DateTime.Now.Subtract(dtStart); long startTimeLong = long.Parse(sTime.Ticks.ToString().Substring(0, sTime.Ticks.ToString().Length - 4)); long endTimeLong = long.Parse(eTime.Ticks.ToString().Substring(0, eTime.Ticks.ToString().Length - 4)); TimeSpan sp = DateTime.Now.AddHours(-8).Subtract(dtStart); //获取有效数据最小时间戳 long minTime = long.Parse(sp.Ticks.ToString().Substring(0, sp.Ticks.ToString().Length - 4)); List powerSetList_SZS5 = RestfulClient.findHistoryRawByTagName(powerSetSZS5, startTimeLong, endTimeLong); List actualPowe_SZS5 = RestfulClient.findHistoryRawByTagName(powerActualSZS5, startTimeLong, endTimeLong); powerSet_SZS5.TsDataList = powerSet_SZS5.TsDataList.Union(powerSetList_SZS5).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); actualPower_SZS5.TsDataList = actualPower_SZS5.TsDataList.Union(actualPowe_SZS5).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); List powerSetList_PL3 = RestfulClient.findHistoryRawByTagName(powerSetPL3, startTimeLong, endTimeLong); List actualPowe_PL3 = RestfulClient.findHistoryRawByTagName(powerActualPL3, startTimeLong, endTimeLong); powerSet_PL3.TsDataList = powerSet_PL3.TsDataList.Union(powerSetList_PL3).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); actualPower_PL3.TsDataList = actualPower_PL3.TsDataList.Union(actualPowe_PL3).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); List powerSetList_ZW2 = RestfulClient.findHistoryRawByTagName(powerSetZW2, startTimeLong, endTimeLong); List actualPowe_ZW2 = RestfulClient.findHistoryRawByTagName(powerActualZW2, startTimeLong, endTimeLong); powerSet_ZW6.TsDataList = powerSet_ZW6.TsDataList.Union(powerSetList_ZW2).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); actualPower_ZW6.TsDataList = actualPower_ZW6.TsDataList.Union(actualPowe_ZW2).Where(s => s.ts > minTime).ToList().Distinct(new DataCompare()).ToList(); } } //首次页面加载执行 查询当前时间前8小时历史快照 public static void GetHistoryLineDataFirst() { if (pointTagNameList.Count <= 0) GetTagName(); IList pointList = pointTagNameList; #region 获取各个场站有功设定和实发有功测点 //麻黄山2有功设定 string powerSet_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName; //麻黄山2实发有功 string powerActual_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName; //牛首山2有功设定 string powerSet_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName; //牛首山2实发有功 string powerActual_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName; //麻黄山6有功设定 string powerSet_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName; //麻黄山6实发有功 string powerActual_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName; //星能6有功设定 string powerSet_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName; //星能6实发有功 string powerActual_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName; //牛首山5有功设定 string powerSet_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName; //牛首山5实发有功 string powerActual_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName; //香山5有功设定 string powerSet_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName; //香山5实发有功 string powerActual_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName; //石嘴山5有功设定 string powerSet_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName; //石嘴山5实发有功 string powerActual_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName; //平罗35有功设定 string powerSet_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName; //平罗5实发有功 string powerActual_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName; //中卫6有功设定 string powerSet_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName; //中卫6实发有功 string powerActual_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName; #endregion powerSetList = new List(); powerActualList = new List(); long startTimeStep = (DateTime.Now.AddHours(-8).ToUniversalTime().Ticks - 621355968000000000) / 10000; long endTimeStep = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; #region 麻黄山6 PowerSet powerSet_MHS6 = new PowerSet(); powerSet_MHS6.StationName = "MHS6"; powerSet_MHS6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_MHS6, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_MHS6); PowerActual actualPower_MHS6 = new PowerActual(); actualPower_MHS6.StationName = "MHS6"; actualPower_MHS6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_MHS6, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_MHS6); #endregion #region 牛首山2 PowerSet powerSet_NSS2 = new PowerSet(); powerSet_NSS2.StationName = "NSS2"; powerSet_NSS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_NSS2, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_NSS2); PowerActual actualPower_NSS2 = new PowerActual(); actualPower_NSS2.StationName = "NSS2"; actualPower_NSS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_NSS2, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_NSS2); #endregion #region 麻黄山2 PowerSet powerSet_MHS2 = new PowerSet(); powerSet_MHS2.StationName = "MHS2"; powerSet_MHS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_MHS2, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_MHS2); PowerActual actualPower_MHS2 = new PowerActual(); actualPower_MHS2.StationName = "MHS2"; actualPower_MHS2.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_MHS2, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_MHS2); #endregion #region 星能6 PowerSet powerSet_XN6 = new PowerSet(); powerSet_XN6.StationName = "XN6"; powerSet_XN6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_XN6, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_XN6); PowerActual actualPower_XN6 = new PowerActual(); actualPower_XN6.StationName = "XN6"; actualPower_XN6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_XN6, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_XN6); #endregion #region 牛首山5 PowerSet powerSet_NSS5 = new PowerSet(); powerSet_NSS5.StationName = "NSS5"; powerSet_NSS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_NSS5, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_NSS5); PowerActual actualPower_NSS5 = new PowerActual(); actualPower_NSS5.StationName = "NSS5"; actualPower_NSS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_NSS5, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_NSS5); #endregion #region 香山5 PowerSet powerSet_XS5 = new PowerSet(); powerSet_XS5.StationName = "XS5"; powerSet_XS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_XS5, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_XS5); PowerActual actualPower_XS5 = new PowerActual(); actualPower_XS5.StationName = "XS5"; actualPower_XS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_XS5, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_XS5); #endregion #region 石嘴山5 PowerSet powerSet_SZS5 = new PowerSet(); powerSet_SZS5.StationName = "SZS5"; powerSet_SZS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_SZS5, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_SZS5); PowerActual actualPower_SZS5 = new PowerActual(); actualPower_SZS5.StationName = "SZS5"; actualPower_SZS5.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_SZS5, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_SZS5); #endregion #region 平罗3 PowerSet powerSet_PL3 = new PowerSet(); powerSet_PL3.StationName = "PL3"; powerSet_PL3.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_PL3, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_PL3); PowerActual actualPower_PL3 = new PowerActual(); actualPower_PL3.StationName = "PL3"; actualPower_PL3.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_PL3, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_PL3); #endregion #region 中卫6 PowerSet powerSet_ZW6 = new PowerSet(); powerSet_ZW6.StationName = "ZW6"; powerSet_ZW6.TsDataList = RestfulClient.findHistorySnapByTagName(powerSet_TagName_ZW6, startTimeStep, endTimeStep, 60); powerSetList.Add(powerSet_ZW6); PowerActual actualPower_ZW6 = new PowerActual(); actualPower_ZW6.StationName = "ZW6"; actualPower_ZW6.TsDataList = RestfulClient.findHistorySnapByTagName(powerActual_TagName_ZW6, startTimeStep, endTimeStep, 60); powerActualList.Add(actualPower_ZW6); #endregion } public static void UpdateHistoryLineData(object isWind) { if (pointTagNameList.Count <= 0) GetTagName(); IList pointList = pointTagNameList; #region 获取各个场站有功设定和实发有功测点 //麻黄山2有功设定 string powerSet_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().PowerSetTagName; //麻黄山2实发有功 string powerActual_TagName_MHS2 = pointList.Where(s => s.StationName == "MHS2").First().ActualPowerTagName; //牛首山2有功设定 string powerSet_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().PowerSetTagName; //牛首山2实发有功 string powerActual_TagName_NSS2 = pointList.Where(s => s.StationName == "NSS2").First().ActualPowerTagName; //麻黄山6有功设定 string powerSet_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().PowerSetTagName; //麻黄山6实发有功 string powerActual_TagName_MHS6 = pointList.Where(s => s.StationName == "MHS6").First().ActualPowerTagName; //星能6有功设定 string powerSet_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().PowerSetTagName; //星能6实发有功 string powerActual_TagName_XN6 = pointList.Where(s => s.StationName == "XN6").First().ActualPowerTagName; //牛首山5有功设定 string powerSet_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().PowerSetTagName; //牛首山5实发有功 string powerActual_TagName_NSS5 = pointList.Where(s => s.StationName == "NSS5").First().ActualPowerTagName; //香山5有功设定 string powerSet_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().PowerSetTagName; //香山5实发有功 string powerActual_TagName_XS5 = pointList.Where(s => s.StationName == "XS5").First().ActualPowerTagName; //石嘴山5有功设定 string powerSet_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().PowerSetTagName; //石嘴山5实发有功 string powerActual_TagName_SZS5 = pointList.Where(s => s.StationName == "SZS5").First().ActualPowerTagName; //平罗35有功设定 string powerSet_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().PowerSetTagName; //平罗5实发有功 string powerActual_TagName_PL3 = pointList.Where(s => s.StationName == "PL3").First().ActualPowerTagName; //中卫6有功设定 string powerSet_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().PowerSetTagName; //中卫6实发有功 string powerActual_TagName_ZW6 = pointList.Where(s => s.StationName == "ZW6").First().ActualPowerTagName; #endregion //获取当前时间戳 long nowTimeStep = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000; //获取有效数据最小时间戳(当前时间减去8小时) long minTimeStep = (DateTime.Now.AddHours(-8).ToUniversalTime().Ticks - 621355968000000000) / 10000; var powerSet_MHS6 = powerSetList.Where(s => s.StationName == "MHS6").FirstOrDefault(); var actualPower_MHS6 = powerActualList.Where(s => s.StationName == "MHS6").FirstOrDefault(); var powerSet_NSS2 = powerSetList.Where(s => s.StationName == "NSS2").FirstOrDefault(); var actualPower_NSS2 = powerActualList.Where(s => s.StationName == "NSS2").FirstOrDefault(); var powerSet_MHS2 = powerSetList.Where(s => s.StationName == "MHS2").FirstOrDefault(); var actualPower_MHS2 = powerActualList.Where(s => s.StationName == "MHS2").FirstOrDefault(); var powerSet_XN6 = powerSetList.Where(s => s.StationName == "XN6").FirstOrDefault(); var actualPower_XN6 = powerActualList.Where(s => s.StationName == "XN6").FirstOrDefault(); var powerSet_NSS5 = powerSetList.Where(s => s.StationName == "NSS5").FirstOrDefault(); var actualPower_NSS5 = powerActualList.Where(s => s.StationName == "NSS5").FirstOrDefault(); var powerSet_XS5 = powerSetList.Where(s => s.StationName == "XS5").FirstOrDefault(); var actualPower_XS5 = powerActualList.Where(s => s.StationName == "XS5").FirstOrDefault(); var powerSet_SZS5 = powerSetList.Where(s => s.StationName == "SZS5").FirstOrDefault(); var actualPower_SZS5 = powerActualList.Where(s => s.StationName == "SZS5").FirstOrDefault(); var powerSet_PL3 = powerSetList.Where(s => s.StationName == "PL3").FirstOrDefault(); var actualPower_PL3 = powerActualList.Where(s => s.StationName == "PL3").FirstOrDefault(); var powerSet_ZW6 = powerSetList.Where(s => s.StationName == "ZW6").FirstOrDefault(); var actualPower_ZW6 = powerActualList.Where(s => s.StationName == "ZW6").FirstOrDefault(); if ((bool)isWind) { #region MHS6 Dictionary powerSetList_MHS6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS6 }); Dictionary actualPowe_MHS6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_MHS6 }); TsData powerSetTsData_MHS6 = null; TsData actualTsData_MHS6 = null; if (powerSetList_MHS6 != null && powerSetList_MHS6.Count > 0) { var data = powerSetList_MHS6.FirstOrDefault().Value; if (data != null) { powerSetTsData_MHS6 = data; powerSetTsData_MHS6.ts = nowTimeStep; } } if (actualPowe_MHS6 != null && actualPowe_MHS6.Count > 0) { var data = actualPowe_MHS6.FirstOrDefault().Value; if (data != null) { actualTsData_MHS6 = data; actualTsData_MHS6.ts = nowTimeStep; } } if (powerSetTsData_MHS6 != null && powerSet_MHS6.TsDataList != null) powerSet_MHS6.TsDataList.Add(powerSetTsData_MHS6); if (actualTsData_MHS6 != null && actualPower_MHS6.TsDataList != null) actualPower_MHS6.TsDataList.Add(actualTsData_MHS6); IList pm6 = powerSet_MHS6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList am6 = actualPower_MHS6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_MHS6.TsDataList = pm6.Distinct(new DataCompare()).ToList(); actualPower_MHS6.TsDataList = am6.Distinct(new DataCompare()).ToList(); #endregion #region NSS2 Dictionary powerSetList_NSS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS2 }); Dictionary actualPowe_NSS2 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_NSS2 }); TsData powerSetTsData_NSS2 = null; TsData actualTsData_NSS2 = null; if (powerSetList_NSS2 != null && powerSetList_NSS2.Count > 0) { var data = powerSetList_NSS2.FirstOrDefault().Value; if (data != null) { powerSetTsData_NSS2 = data; powerSetTsData_NSS2.ts = nowTimeStep; } } if (actualPowe_NSS2 != null && actualPowe_NSS2.Count > 0) { var data = actualPowe_NSS2.FirstOrDefault().Value; if (data != null) { actualTsData_NSS2 = data; actualTsData_NSS2.ts = nowTimeStep; } } if (powerSetTsData_NSS2 != null && powerSet_NSS2.TsDataList != null) powerSet_NSS2.TsDataList.Add(powerSetTsData_NSS2); if (actualTsData_NSS2 != null && actualPower_NSS2.TsDataList != null) actualPower_NSS2.TsDataList.Add(actualTsData_NSS2); IList pn2 = powerSet_NSS2.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList an2 = actualPower_NSS2.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_NSS2.TsDataList = pn2.Distinct(new DataCompare()).ToList(); actualPower_NSS2.TsDataList = an2.Distinct(new DataCompare()).ToList(); #endregion #region MHS2 Dictionary powerSetList_MHS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS2 }); Dictionary actualPowe_MHS2 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_MHS2 }); TsData powerSetTsData_MHS2 = null; TsData actualTsData_MHS2 = null; if (powerSetList_MHS2 != null && powerSetList_MHS2.Count > 0) { var data = powerSetList_MHS2.FirstOrDefault().Value; if (data != null) { powerSetTsData_MHS2 = data; powerSetTsData_MHS2.ts = nowTimeStep; } } if (actualPowe_MHS2 != null && actualPowe_MHS2.Count > 0) { var data = actualPowe_MHS2.FirstOrDefault().Value; if (data != null) { actualTsData_MHS2 = data; actualTsData_MHS2.ts = nowTimeStep; } } if (powerSetTsData_MHS2 != null && powerSet_MHS2.TsDataList != null) powerSet_MHS2.TsDataList.Add(powerSetTsData_MHS2); if (actualTsData_MHS2 != null && actualPower_MHS2.TsDataList != null) actualPower_MHS2.TsDataList.Add(actualTsData_MHS2); IList pm2 = powerSet_MHS2.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList am2 = actualPower_MHS2.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_MHS2.TsDataList = pm2.Distinct(new DataCompare()).ToList(); actualPower_MHS2.TsDataList = am2.Distinct(new DataCompare()).ToList(); #endregion #region XN6 Dictionary powerSetList_XN6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XN6 }); Dictionary actualPowe_XN6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_XN6 }); TsData powerSetTsData_XN6 = null; TsData actualTsData_XN6 = null; if (powerSetList_XN6 != null && powerSetList_XN6.Count > 0) { var data = powerSetList_XN6.FirstOrDefault().Value; if (data != null) { powerSetTsData_XN6 = data; powerSetTsData_XN6.ts = nowTimeStep; } } if (actualPowe_XN6 != null && actualPowe_XN6.Count > 0) { var data = actualPowe_XN6.FirstOrDefault().Value; if (data != null) { actualTsData_XN6 = data; actualTsData_XN6.ts = nowTimeStep; } } if (powerSetTsData_XN6 != null && powerSet_XN6.TsDataList != null) powerSet_XN6.TsDataList.Add(powerSetTsData_XN6); if (actualTsData_XN6 != null && actualPower_XN6.TsDataList != null) actualPower_XN6.TsDataList.Add(actualTsData_XN6); IList px6 = powerSet_XN6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList ax6 = actualPower_XN6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_XN6.TsDataList = px6.Distinct(new DataCompare()).ToList(); actualPower_XN6.TsDataList = ax6.Distinct(new DataCompare()).ToList(); #endregion #region NSS5 Dictionary powerSetList_NSS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS5 }); Dictionary actualPowe_NSS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_NSS5 }); TsData powerSetTsData_NSS5 = null; TsData actualTsData_NSS5 = null; if (powerSetList_NSS5 != null && powerSetList_NSS5.Count > 0) { var data = powerSetList_NSS5.FirstOrDefault().Value; if (data != null) { powerSetTsData_NSS5 = data; powerSetTsData_NSS5.ts = nowTimeStep; } } if (actualPowe_NSS5 != null && actualPowe_NSS5.Count > 0) { var data = actualPowe_NSS5.FirstOrDefault().Value; if (data != null) { actualTsData_NSS5 = data; actualTsData_NSS5.ts = nowTimeStep; } } if (powerSetTsData_NSS5 != null && powerSet_NSS5.TsDataList != null) powerSet_NSS5.TsDataList.Add(powerSetTsData_NSS5); if (actualTsData_NSS5 != null && actualPower_NSS5.TsDataList != null) actualPower_NSS5.TsDataList.Add(actualTsData_NSS5); IList pn5 = powerSet_NSS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList an5 = actualPower_NSS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_NSS5.TsDataList = pn5.Distinct(new DataCompare()).ToList(); actualPower_NSS5.TsDataList = an5.Distinct(new DataCompare()).ToList(); #endregion #region XS5 Dictionary powerSetList_XS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XS5 }); Dictionary actualPowe_XS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_XS5 }); TsData powerSetTsData_XS5 = null; TsData actualTsData_XS5 = null; if (powerSetList_XS5 != null && powerSetList_XS5.Count > 0) { var data = powerSetList_XS5.FirstOrDefault().Value; if (data != null) { powerSetTsData_XS5 = data; powerSetTsData_XS5.ts = nowTimeStep; } } if (actualPowe_XS5 != null && actualPowe_XS5.Count > 0) { var data = actualPowe_XS5.FirstOrDefault().Value; if (data != null) { actualTsData_XS5 = data; actualTsData_XS5.ts = nowTimeStep; } } if (powerSetTsData_XS5 != null && powerSet_XS5.TsDataList != null) powerSet_XS5.TsDataList.Add(powerSetTsData_XS5); if (actualTsData_XS5 != null && actualPower_XS5.TsDataList != null) actualPower_XS5.TsDataList.Add(actualTsData_XS5); IList px5 = powerSet_XS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList ax5 = actualPower_XS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_XS5.TsDataList = px5.Distinct(new DataCompare()).ToList(); actualPower_XS5.TsDataList = ax5.Distinct(new DataCompare()).ToList(); #endregion } else { #region SZS5 Dictionary powerSetList_SZS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_SZS5 }); Dictionary actualPowe_SZS5 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_SZS5 }); TsData powerSetTsData_SZS5 = null; TsData actualTsData_SZS5 = null; if (powerSetList_SZS5 != null && powerSetList_SZS5.Count > 0) { var data = powerSetList_SZS5.FirstOrDefault().Value; if (data != null) { powerSetTsData_SZS5 = data; powerSetTsData_SZS5.ts = nowTimeStep; } } if (actualPowe_SZS5 != null && actualPowe_SZS5.Count > 0) { var data = actualPowe_SZS5.FirstOrDefault().Value; if (data != null) { actualTsData_SZS5 = data; actualTsData_SZS5.ts = nowTimeStep; } } if (powerSetTsData_SZS5 != null && powerSet_SZS5.TsDataList != null) powerSet_SZS5.TsDataList.Add(powerSetTsData_SZS5); if (actualTsData_SZS5 != null && actualPower_SZS5.TsDataList != null) actualPower_SZS5.TsDataList.Add(actualTsData_SZS5); IList ps5 = powerSet_SZS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList as5 = actualPower_SZS5.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_SZS5.TsDataList = ps5.Distinct(new DataCompare()).ToList(); actualPower_SZS5.TsDataList = as5.Distinct(new DataCompare()).ToList(); #endregion #region PL3 Dictionary powerSetList_PL3 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_PL3 }); Dictionary actualPowe_PL3 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_PL3 }); TsData powerSetTsData_PL3 = null; TsData actualTsData_PL3 = null; if (powerSetList_PL3 != null && powerSetList_PL3.Count > 0) { var data = powerSetList_PL3.FirstOrDefault().Value; if (data != null) powerSetTsData_PL3 = data; } if (actualPowe_PL3 != null && actualPowe_PL3.Count > 0) { var data = actualPowe_PL3.FirstOrDefault().Value; if (data != null) actualTsData_PL3 = data; } if (powerSetTsData_PL3 != null && powerSet_PL3.TsDataList != null) powerSet_PL3.TsDataList.Add(powerSetTsData_PL3); if (actualTsData_PL3 != null && actualPower_PL3.TsDataList != null) actualPower_PL3.TsDataList.Add(actualTsData_PL3); IList pp3 = powerSet_PL3.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList ap3 = actualPower_PL3.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_PL3.TsDataList = pp3.Distinct(new DataCompare()).ToList(); actualPower_PL3.TsDataList = ap3.Distinct(new DataCompare()).ToList(); #endregion #region ZW6 Dictionary powerSetList_ZW6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_ZW6 }); Dictionary actualPowe_ZW6 = RestfulClient.findLatestByTagNames(new string[] { powerActual_TagName_ZW6 }); TsData powerSetTsData_ZW6 = null; TsData actualTsData_ZW6 = null; if (powerSetList_ZW6 != null && powerSetList_ZW6.Count > 0) { var data = powerSetList_ZW6.FirstOrDefault().Value; if (data != null) powerSetTsData_ZW6 = data; } if (actualPowe_ZW6 != null && actualPowe_ZW6.Count > 0) { var data = actualPowe_ZW6.FirstOrDefault().Value; if (data != null) actualTsData_ZW6 = data; } if (powerSetTsData_ZW6 != null && powerSet_ZW6.TsDataList != null) powerSet_ZW6.TsDataList.Add(powerSetTsData_ZW6); if (actualTsData_ZW6 != null && actualPower_ZW6.TsDataList != null) actualPower_ZW6.TsDataList.Add(actualTsData_ZW6); IList pw6 = powerSet_ZW6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); IList aw6 = actualPower_ZW6.TsDataList.Where(s => s.ts > minTimeStep).ToList(); powerSet_ZW6.TsDataList = pw6.Distinct(new DataCompare()).ToList(); actualPower_ZW6.TsDataList = aw6.Distinct(new DataCompare()).ToList(); #endregion } } private static bool IsNum(string s, out double num) { try { if (s == "True" || s == "true") num = 1; else if (s == "false" || s == "False") num = 0; else { num = Convert.ToDouble(s); } return true; } catch (Exception) { num = 0.0; return false; } } } }