public void TestHistoryParamBinary() { HistoryParamDbContext context = new HistoryParamDbContext(); Acrel.HisDB.GetData getData = new Acrel.HisDB.GetData(); string circuitID = "000001G0010001"; string circuitPrame = "31000000000711,31000000000700,31000000000701,31000000000702"; string[] prame = circuitPrame.Split(','); List<HistoryBinarys> list = context.GetHistoryBinaryString(circuitID,prame,DateTime.Now); foreach (HistoryBinarys item in list) { Dictionary<DateTime,double> dic = getData.GetContinueBytesOfFive(item.Value,new DateTime(2018,10,25,0,0,0),new DateTime(2018,10,25,13,0,0),5); Console.WriteLine(dic.Count); } Console.WriteLine(list.Count); }
/// <summary> /// 根据仪表ID,获取仪表所有的参数的值 /// </summary> /// <param name="meterID"></param> /// <param name="dateTime"></param> /// <param name="step"></param> /// <returns></returns> public List <HistoryParameterValue> GetParamByMeterIDValue(string meterID, string dateTime, int step) { Acrel.HisDB.GetData getData = new Acrel.HisDB.GetData(); List <HistoryParameterValue> historyValueList = new List <HistoryParameterValue>(); DateTime nowTime = DateTime.Now; DateTime endTime; DateTime startTime = Util.ConvertString2DateTime(dateTime, "yyyy-MM-dd"); //如果查询是的时间是今天,则结束时间为小于当前时间的为5的倍数的时间 if (nowTime.Day == startTime.Day && nowTime.Month == startTime.Month && nowTime.Year == startTime.Year) { endTime = startTime.AddHours(nowTime.Hour).AddMinutes(nowTime.Minute - nowTime.Minute % 5 - 5); } else { //获取某天的23:55:00 endTime = startTime.AddDays(1).AddMinutes(-5); } List <HistoryBinarys> historyBinarys = GetHistoryBinaryStringByMeterID(meterID, startTime); foreach (HistoryBinarys item in historyBinarys) { HistoryParameterValue historyValue = new HistoryParameterValue(); historyValue.ID = item.CircuitID; historyValue.Name = item.CircuitName; historyValue.ParamCode = item.ParamCode; historyValue.ParamName = item.ParamName; historyValue.Values = ConvertDicToList(getData.GetContinueBytesOfFive(item.Value, startTime, endTime, step)); historyValueList.Add(historyValue); } return(historyValueList); }