/// <summary> /// Gets the trend interpretation as single line string /// </summary> /// <param name="trend">The trend.</param> /// <returns></returns> public static string GetTrendInline(this measureTrend trend) { string form = "{0} {1,10}:[_{2,15}_ {3,-14}] ({4,11}) _{5,8}_ "; List <string> st = new List <string>(); st.Add(trend.SampleState.GetStateSymbols()); st.Add(trend.name.toWidthMaximum(8, "")); st.Add(trend.MicroMean.ToString(trend.format)); if (trend.sampledPeriod > 0) { form += trend.sampledPeriod.ToString("F2") + " min"; } st.Add(trend.unit); if (trend.SampleState.HasFlag(measureTrendSampleState.macroMean)) { st.Add(trend.MicroTrend.ToString("P2")); } else { st.Add("~~~~"); } st.Add(trend.Direction.GetTrendDirectionSymbols()); return(string.Format(form, st.ToArray()).toWidthExact(75, " ")); }
/// <summary> /// Gets the trend from set of objects /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sampleset">Set of objects to take measure from</param> /// <param name="selector">Expresion that takes the property value from an object in the <c>sampleset</c></param> /// <param name="trendTaker">The trend taker definition</param> /// <param name="span">The time span to recalculate mean values for.</param> /// <returns></returns> public static measureTrend GetTrend <T>(this IEnumerable <T> sampleset, Func <T, double> selector, measureTrendTaker trendTaker, TimeSpan span) { int sC = sampleset.Count(); int sT = Math.Min(sC, trendTaker.MacroSampleSize); var sValues = (from num in sampleset select selector(num)); //sampleset.Take(sT).GetTimeSpan measureTrend trend = new measureTrend(sValues, trendTaker, span); return(trend); }