Ejemplo n.º 1
0
        //---------------------------------------------------------------------
        /// <summary>
        /// A filter that performs swinging door compression.
        /// </summary>
        /// <param name="data">Input data</param>
        /// <param name="compressionDeviation">
        /// (Absolut) Compression deviation applied to the y values to calculate the
        /// min and max slopes.
        /// </param>
        /// <param name="maxDeltaX">
        /// Length of x before for sure a value gets recoreded. See <see cref="SwingingDoorCompression.MaxDeltaX" />.
        /// </param>
        /// <param name="minDeltaX">
        /// Length of x/time within no value gets recorded (after the last archived value).
        /// See <see cref="SwingingDoorCompression.MinDeltaX" />.
        /// </param>
        /// <returns>swinging door compressed / filtered data.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="data" /> is <c>null</c>
        /// </exception>
        public static DataPointIterator SwingingDoorCompression(this IEnumerable <DataPoint> data, double compressionDeviation, double?maxDeltaX = null, double?minDeltaX = null)
        {
            if (data == null)
            {
                ThrowHelper.ThrowArgumentNull(ThrowHelper.ExceptionArgument.data);
            }

            var compression = new SwingingDoorCompression(compressionDeviation, maxDeltaX, minDeltaX);

            return(compression.Process(data));
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------
        /// <summary>
        /// A filter that performs swinging door compression.
        /// </summary>
        /// <param name="data">Input data</param>
        /// <param name="compressionDeviation">
        /// (Absolut) Compression deviation applied to the y values to calculate the
        /// min and max slopes.
        /// </param>
        /// <param name="maxTime">Length of time before for sure a value gets recoreded</param>
        /// <param name="minTime">Length of time within no value gets recorded (after the last archived value)</param>
        /// <returns>swinging door compressed / filtered data.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="data" /> is <c>null</c>
        /// </exception>
        public static DataPointIterator SwingingDoorCompressionAsync(this IAsyncEnumerable <DataPoint>?data, double compressionDeviation, TimeSpan maxTime, TimeSpan?minTime = null)
        {
            if (data is null)
            {
                ThrowHelper.ThrowArgumentNull(ThrowHelper.ExceptionArgument.data);
            }

            var compression = new SwingingDoorCompression(compressionDeviation, maxTime, minTime);

            return(compression.ProcessAsync(data));
        }