Exemple #1
0
        /// <summary>
        /// Sample stream by interval with an interpolator.
        /// </summary>
        /// <typeparam name="T">Type of source/output messages.</typeparam>
        /// <param name="source">Source stream.</param>
        /// <param name="samplingInterval">Interval at which to sample.</param>
        /// <param name="interpolator">Interpolator with which to sample.</param>
        /// <param name="deliveryPolicy">An optional delivery policy.</param>
        /// <returns>Output stream.</returns>
        public static IProducer <T> Sample <T>(
            this IProducer <T> source,
            TimeSpan samplingInterval,
            Match.Interpolator <T> interpolator,
            DeliveryPolicy deliveryPolicy = null)
        {
            var sampler = new Sampler <T>(source.Out.Pipeline, interpolator, samplingInterval);

            return(PipeTo(source, sampler, deliveryPolicy));
        }
Exemple #2
0
        /// <summary>
        /// Sample stream by interval with an interpolator.
        /// </summary>
        /// <typeparam name="T">Type of source/output messages.</typeparam>
        /// <param name="source">Source stream.</param>
        /// <param name="samplingInterval">Interval at which to sample.</param>
        /// <param name="interpolator">Interpolator with which to sample.</param>
        /// <param name="policy">Delivery policy.</param>
        /// <returns>Output stream.</returns>
        public static IProducer <T> Sample <T>(
            this IProducer <T> source,
            TimeSpan samplingInterval,
            Match.Interpolator <T> interpolator,
            DeliveryPolicy policy = null)
        {
            policy = policy ?? DeliveryPolicy.Immediate;
            var sampler = new Sampler <T>(source.Out.Pipeline, interpolator, samplingInterval);

            source.PipeTo(sampler);
            return(sampler);
        }
Exemple #3
0
        /// <summary>
        /// Sample stream by clock signal with an interpolator.
        /// </summary>
        /// <typeparam name="T">Type of source/output messages.</typeparam>
        /// <typeparam name="TClock">Type of clock signal messages.</typeparam>
        /// <param name="source">Source stream.</param>
        /// <param name="clock">Clock signal stream.</param>
        /// <param name="interpolator">Interpolator with which to sample.</param>
        /// <param name="sourceDeliveryPolicy">An optional delivery policy for the source.</param>
        /// <param name="clockDeliveryPolicy">An optional delivery policy for the clock.</param>
        /// <returns>Output stream.</returns>
        public static IProducer <T> Sample <T, TClock>(
            this IProducer <T> source,
            IProducer <TClock> clock,
            Match.Interpolator <T> interpolator,
            DeliveryPolicy sourceDeliveryPolicy = null,
            DeliveryPolicy clockDeliveryPolicy  = null)
        {
            var join = new Join <TClock, T, T>(source.Out.Pipeline, interpolator, (clk, data) => data[0]);

            clock.PipeTo(join.InPrimary, clockDeliveryPolicy);
            source.PipeTo(join.InSecondaries[0], sourceDeliveryPolicy);
            return(join);
        }