public MovingAverageTool <TCustomValuesType> AddRecordedValuesToHistory(QpcTimeStamp qpcTimeStamp = default(QpcTimeStamp)) { qpcTimeStamp = qpcTimeStamp.MapDefaultToNow(); HistoryItem queueItem = new HistoryItem() { sampleStartTimeStamp = accumulatorStartTime, sampleEndTimeStamp = qpcTimeStamp, accumulatedValues = accumulator, }; int historyListCount = historyList.Count; if (historyListCount >= maxAveragingHistoryLength && historyListCount > 0) { historyList.RemoveAt(historyListCount - 1); historyList.Insert(0, queueItem); } else { historyList.Insert(0, queueItem); } accumulator = new TCustomValuesType(); accumulatedValueCount = 0; accumulatorStartTime = qpcTimeStamp; hasNewSample = true; _sampleSeqNum = _sampleSeqNum.IncrementSkipZero(); return(this); }
public MovingAverageTool <TCustomValuesType> Service(QpcTimeStamp qpcTimeStamp = default(QpcTimeStamp)) { qpcTimeStamp = qpcTimeStamp.MapDefaultToNow(); if (!rateIntervalTimer.GetIsTriggered(qpcTimeStamp)) { return(this); } return(AddRecordedValuesToHistory(qpcTimeStamp)); }
public MovingAverageTool <TCustomValuesType> Reset(QpcTimeStamp qpcTimeStamp = default(QpcTimeStamp), bool clearTotalizer = true) { qpcTimeStamp = qpcTimeStamp.MapDefaultToNow(); accumulator = new TCustomValuesType(); accumulatedValueCount = 0; accumulatorStartTime = qpcTimeStamp; if (clearTotalizer) { totalAccumulator = new TCustomValuesType(); totalAccumulatorCount = 0; } historyList.Clear(); rateIntervalTimer.Start(qpcTimeStamp); hasNewSample = false; return(this); }
public TCustomValuesType GetAvg(TimeSpan nominalAcceptanceAge, QpcTimeStamp qpcTimeStamp = default(QpcTimeStamp)) { return(GetAvg(qpcTimeStamp.MapDefaultToNow() - nominalAcceptanceAge)); }