コード例 #1
0
        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);
        }