public Level1FlightRecord[] ReduceFlightRawDataPoints(string parameterID, ParameterRawData[] points, int secondGap) { //1. 每秒钟取一个点 var wrapped = from one in points select new ParameterRawDataWrap(one); //2. 每secondGap取一个值 List<Level1FlightRecord> records = new List<Level1FlightRecord>(); List<ParameterRawDataWrap> tempList = new List<ParameterRawDataWrap>(); int startSec = 0; int endSec = Math.Min(startSec + secondGap, points[points.Length - 1].Second); foreach (var one in wrapped) { if (one.m_RawData.Second >= startSec && one.m_RawData.Second < endSec) { tempList.Add(one); } else { Level1FlightRecord rec = new Level1FlightRecord() { ParameterID = parameterID, StartSecond = startSec, EndSecond = endSec, Values = (from o in tempList select o.SummaryValue).ToArray() }; records.Add(rec); tempList.Clear(); startSec = endSec; endSec = Math.Min(endSec + secondGap, points[points.Length - 1].Second); } } Level1FlightRecord rec2 = new Level1FlightRecord() { ParameterID = parameterID, StartSecond = startSec, EndSecond = endSec, Values = (from o in tempList select o.SummaryValue).ToArray() }; records.Add(rec2); tempList.Clear(); return records.ToArray(); }
public ParameterRawDataWrap(ParameterRawData rawData) { if (rawData == null) throw new NullReferenceException(); m_RawData = rawData; }
public virtual string OnStepData(int second, ParameterRawData[] datas) { string result = string.Empty; try { result = this.HandleOneStepData(second, datas); } catch (Exception e) { result = e.Message + "\r\n" + e.StackTrace; } finally {//控制DoWorkCore什么时候完成,无论如何都要释放一个 this.m_lastResult = result; //LastResult用于返回最后一个错误,因为释放信号量之后可能比result返回更快完成 try { m_semaphore.Release(); } catch { } } return result; }
public abstract void AssignValue(ModelRawData data, ParameterRawData two);
/// <summary> /// 真正的单步做法,只需要Override这个即可 /// </summary> /// <param name="second"></param> /// <param name="datas"></param> /// <returns></returns> protected abstract string HandleOneStepData(int second, ParameterRawData[] datas);