/// <summary> /// Calculates average of the current input channel over the time span. /// </summary> public double TimeAvg(int timeSpanSec, int maxPointCount, double cnlVal) { TimeAvgItem timeAvgItem = GetOrAddTimeAvgItem(CnlNum, timeSpanSec, maxPointCount); timeAvgItem.Append(cnlVal); return(timeAvgItem.Avg); }
/// <summary> /// Adds a new or gets an existing TimeAvgItem. /// </summary> public TimeAvgItem GetOrAddTimeAvgItem(int cnlNum, int timeSpanSec, int maxPointCount) { MovAvgItem movAvgItem; if (MovAvgItems.TryGetValue(cnlNum, out movAvgItem) && movAvgItem is TimeAvgItem) { return((TimeAvgItem)movAvgItem); } else { TimeAvgItem timeAvgItem = new TimeAvgItem(timeSpanSec, maxPointCount); MovAvgItems[cnlNum] = timeAvgItem; return(timeAvgItem); } }