1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303 |
- 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<AgcPoint> pointTagNameList = new List<AgcPoint>();
- //agc测点值集合
- public static IList<AgcEntity> agcDataList = new List<AgcEntity>();
- //agc曲线数据--实发有功
- public static IList<PowerActual> powerActualList = new List<PowerActual>();
- //agc曲线数据--有功设定
- public static IList<PowerSet> powerSetList = new List<PowerSet>();
- public static DateTime? lastUpdateTime_Wind = null;
- public static DateTime? lastUpdateTime_Sun = null;
- /// <summary>
- /// 获取agc相关测点,并保存至缓存pointTagNameList
- /// </summary>
- public static void GetTagName()
- {
- IList<AgcPoint> list = new List<AgcPoint>();
- 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;
- }
- }
- /// <summary>
- /// 获取AGC实时数据
- /// </summary>
- /// <param name="isWind">是否为风电</param>
- public static void GetLatestAgcDataInfo(object isWind)
- {
- if (pointTagNameList.Count <= 0)
- GetTagName();
- IList<AgcPoint> pointList = new List<AgcPoint>();
- 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<string, TsData> 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;
- }
- }
- }
- }
- /// <summary>
- /// 获取有功设定和实发历史值
- /// </summary>
- /// <param name="startTime">起始时间</param>
- /// <param name="endTime">结束时间</param>
- /// <param name="isWind">是否为风电</param>
- public static void GetHistoryLineData(object isWind)
- {
- if (pointTagNameList.Count <= 0)
- GetTagName();
- IList<AgcPoint> 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<TsData>();
- powerSetList.Add(powerSet_MHS6);
- }
- if (actualPower_MHS6 == null)
- {
- actualPower_MHS6 = new PowerActual();
- actualPower_MHS6.StationName = "MHS6";
- actualPower_MHS6.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_NSS2);
- }
- if (actualPower_NSS2 == null)
- {
- actualPower_NSS2 = new PowerActual();
- actualPower_NSS2.StationName = "NSS2";
- actualPower_NSS2.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_MHS2);
- }
- if (actualPower_MHS2 == null)
- {
- actualPower_MHS2 = new PowerActual();
- actualPower_MHS2.StationName = "MHS2";
- actualPower_MHS2.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_XN6);
- }
- if (actualPower_XN6 == null)
- {
- actualPower_XN6 = new PowerActual();
- actualPower_XN6.StationName = "XN6";
- actualPower_XN6.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_NSS5);
- }
- if (actualPower_NSS5 == null)
- {
- actualPower_NSS5 = new PowerActual();
- actualPower_NSS5.StationName = "NSS5";
- actualPower_NSS5.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_XS5);
- }
- if (actualPower_XS5 == null)
- {
- actualPower_XS5 = new PowerActual();
- actualPower_XS5.StationName = "XS5";
- actualPower_XS5.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_SZS5);
- }
- if (actualPower_SZS5 == null)
- {
- actualPower_SZS5 = new PowerActual();
- actualPower_SZS5.StationName = "SZS5";
- actualPower_SZS5.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_PL3);
- }
- if (actualPower_PL3 == null)
- {
- actualPower_PL3 = new PowerActual();
- actualPower_PL3.StationName = "PL3";
- actualPower_PL3.TsDataList = new List<TsData>();
- 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<TsData>();
- powerSetList.Add(powerSet_ZW6);
- }
- if (actualPower_ZW6 == null)
- {
- actualPower_ZW6 = new PowerActual();
- actualPower_ZW6.StationName = "ZW6";
- actualPower_ZW6.TsDataList = new List<TsData>();
- 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<TsData> powerSetList_MHS6 = RestfulClient.findHistorySnapByTagName(powerSetMHS6, startTimeLong,
- endTimeLong,60);
- List<TsData> actualPowe_MHS6 = RestfulClient.findHistorySnapByTagName(powerActualMHS6, startTimeLong,
- endTimeLong, 60);
- IList<TsData> pm6 = powerSet_MHS6.TsDataList.Union(powerSetList_MHS6).Where(s => s.ts > minTime).ToList();
- IList<TsData> 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<TsData> powerSetList_MHS2 = RestfulClient.findHistorySnapByTagName(powerSetMHS2, startTimeLong,
- endTimeLong,60);
- List<TsData> actualPowe_MHS2 = RestfulClient.findHistorySnapByTagName(powerActualMHS2, startTimeLong,
- endTimeLong, 60);
- IList<TsData> pm2 = powerSet_MHS2.TsDataList.Union(powerSetList_MHS2).Where(s => s.ts > minTime).ToList();
- IList<TsData> 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<TsData> powerSetList_NSS2 = RestfulClient.findHistorySnapByTagName(powerSetNSS2, startTimeLong,
- endTimeLong, 60);
- List<TsData> actualPowe_NSS2 = RestfulClient.findHistorySnapByTagName(powerActualNSS2, startTimeLong,
- endTimeLong, 60);
- IList<TsData> pn2 = powerSet_NSS2.TsDataList.Union(powerSetList_NSS2).Where(s => s.ts > minTime).ToList();
- IList<TsData> 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<TsData> powerSetList_XN6 = RestfulClient.findHistorySnapByTagName(powerSetXN6, startTimeLong,
- endTimeLong, 60);
- List<TsData> actualPowe_XN6 = RestfulClient.findHistorySnapByTagName(powerActualXN6, startTimeLong,
- endTimeLong, 60);
- IList<TsData> px6 = powerSet_XN6.TsDataList.Union(powerSetList_XN6).Where(s => s.ts > minTime).ToList();
- IList<TsData> 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<TsData> powerSetList_NSS5 = RestfulClient.findHistorySnapByTagName(powerSetNSS5, startTimeLong,
- endTimeLong, 60);
- List<TsData> actualPowe_NSS5 = RestfulClient.findHistorySnapByTagName(powerActualNSS5, startTimeLong,
- endTimeLong, 60);
- List<TsData> pn5 = powerSet_NSS5.TsDataList.Union(powerSetList_NSS5).Where(s => s.ts > minTime).ToList();
- List<TsData> 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<TsData> powerSetList_XS5 = RestfulClient.findHistorySnapByTagName(powerSetXS5, startTimeLong,
- endTimeLong, 60);
- List<TsData> actualPowe_XS5 = RestfulClient.findHistorySnapByTagName(powerActualXS5, startTimeLong,
- endTimeLong, 60);
- List<TsData> px5 = powerSet_XS5.TsDataList.Union(powerSetList_XS5).Where(s => s.ts > minTime).ToList();
- List<TsData> 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<TsData> powerSetList_SZS5 = RestfulClient.findHistoryRawByTagName(powerSetSZS5, startTimeLong, endTimeLong);
- List<TsData> 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<TsData> powerSetList_PL3 = RestfulClient.findHistoryRawByTagName(powerSetPL3, startTimeLong, endTimeLong);
- List<TsData> 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<TsData> powerSetList_ZW2 = RestfulClient.findHistoryRawByTagName(powerSetZW2, startTimeLong, endTimeLong);
- List<TsData> 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<AgcPoint> 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<PowerSet>();
- powerActualList = new List<PowerActual>();
- 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<AgcPoint> 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<string, TsData> powerSetList_MHS6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS6 });
- Dictionary<string, TsData> 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<TsData> pm6 = powerSet_MHS6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_NSS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS2 });
- Dictionary<string, TsData> 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<TsData> pn2 = powerSet_NSS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_MHS2 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_MHS2 });
- Dictionary<string, TsData> 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<TsData> pm2 = powerSet_MHS2.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_XN6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XN6 });
- Dictionary<string, TsData> 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<TsData> px6 = powerSet_XN6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_NSS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_NSS5 });
- Dictionary<string, TsData> 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<TsData> pn5 = powerSet_NSS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_XS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_XS5 });
- Dictionary<string, TsData> 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<TsData> px5 = powerSet_XS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_SZS5 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_SZS5 });
- Dictionary<string, TsData> 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<TsData> ps5 = powerSet_SZS5.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_PL3 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_PL3 });
- Dictionary<string, TsData> 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<TsData> pp3 = powerSet_PL3.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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<string, TsData> powerSetList_ZW6 = RestfulClient.findLatestByTagNames(new string[] { powerSet_TagName_ZW6 });
- Dictionary<string, TsData> 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<TsData> pw6 = powerSet_ZW6.TsDataList.Where(s => s.ts > minTimeStep).ToList();
- IList<TsData> 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;
- }
- }
- }
- }
|