/// <summary> /// 读取某时间段内的所有bool值 /// </summary> /// <param name="file"></param> /// <param name="tid"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <param name="result"></param> public static void ReadAllValue <T>(this HisDataFileInfo file, int tid, DateTime startTime, DateTime endTime, HisQueryResult <T> result) { //long ltmp = 0, ltmp1 = 0; //Stopwatch sw = new Stopwatch(); //sw.Start(); var offset = file.GetFileOffsets(startTime, endTime); var vff = file.GetFileSeriser(); //ltmp = sw.ElapsedMilliseconds; foreach (var vv in offset) { DateTime stime = vv.Key > startTime ? vv.Key : startTime; DateTime etime = vv.Key + vv.Value.Item1 > endTime ? endTime : vv.Key + vv.Value.Item1; ReadAllValue(vff, vv.Value.Item2, tid, stime, etime, result); } //ltmp1 = sw.ElapsedMilliseconds; //vff.Close(); Task.Run(() => { vff.Dispose(); }); //sw.Stop(); //Debug.WriteLine("ReadAllValue:" + ltmp + " ," + (ltmp1 - ltmp) + "," + (sw.ElapsedMilliseconds - ltmp1)); }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="file"></param> /// <param name="tid"></param> /// <param name="time"></param> /// <param name="type"></param> /// <returns></returns> public static object Read <T>(this HisDataFileInfo file, int tid, DateTime time, QueryValueMatchType type) { using (var vff = file.GetFileSeriser()) { var offset = file.GetFileOffsets(time); return(Read <T>(vff, offset, tid, time, type)); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="file"></param> /// <param name="tid"></param> /// <param name="times"></param> /// <param name="type"></param> /// <param name="result"></param> public static void Read <T>(this HisDataFileInfo file, int tid, List <DateTime> times, QueryValueMatchType type, HisQueryResult <T> result) { using (var vff = file.GetFileSeriser()) { Dictionary <long, List <DateTime> > moffs = new Dictionary <long, List <DateTime> >(); foreach (var vv in times) { var ff = file.GetFileOffsets(vv); if (moffs.ContainsKey(ff)) { moffs[ff].Add(vv); } else { moffs.Add(ff, new List <DateTime>() { vv }); } } foreach (var vf in moffs) { if (vf.Key > -1) { Read <T>(vff, vf.Key, tid, vf.Value, type, result); } else { foreach (var vv in vf.Value) { result.Add(default(T), vv, (byte)QualityConst.Null); } } } } }