private Dictionary <AggregationUnit, double[]> ApplyAggregationFunction <T>(DatasetInfo dataset, T[] data, byte[] status, List <AggregationUnit> aggregationUnits) where T : unmanaged { var nanLimit = 0.99; var dataset_double = default(double[]); var partialBuffersMap = new Dictionary <AggregationUnit, double[]>(); foreach (var unit in aggregationUnits) { var aggregation = unit.Aggregation; var period = unit.Period; var method = unit.Method; var argument = unit.Argument; var sampleCount = dataset.GetSampleRate(ensureNonZeroIntegerHz: true).SamplesPerSecondAsUInt64 *(ulong)period; switch (unit.Method) { case AggregationMethod.Mean: case AggregationMethod.MeanPolar: case AggregationMethod.Min: case AggregationMethod.Max: case AggregationMethod.Std: case AggregationMethod.Rms: case AggregationMethod.SampleAndHold: case AggregationMethod.Sum: if (dataset_double == null) { dataset_double = BufferUtilities.ApplyDatasetStatus <T>(data, status); } partialBuffersMap[unit] = this.ApplyAggregationFunction(method, argument, (int)sampleCount, dataset_double, nanLimit, _logger); break; case AggregationMethod.MinBitwise: case AggregationMethod.MaxBitwise: partialBuffersMap[unit] = this.ApplyAggregationFunction(method, argument, (int)sampleCount, data, status, nanLimit, _logger); break; default: _logger.LogWarning($"The aggregation method '{unit.Method}' is not known. Skipping period {period}."); continue; } } return(partialBuffersMap); }
public IEnumerable <DataReaderProgressRecord> Read( DatasetInfo dataset, DateTime begin, DateTime end, ulong upperBlockSize, CancellationToken cancellationToken) { #warning This is only a workaround. Should not be necessary when 1 Minute Base limit has been removed and all code is unit tested and rewritten. var fundamentalPeriod = (dataset.GetSampleRate().SamplesPerDay == 144) ? TimeSpan.FromMinutes(10) : TimeSpan.FromMinutes(1); return(this.Read(new List <DatasetInfo>() { dataset }, begin, end, upperBlockSize, fundamentalPeriod, cancellationToken)); }