Exemplo n.º 1
0
 /// <summary>
 /// Samples a stream at interpolation points given by a clock stream, by selecting the nearest
 /// message within a relative time interval to the interpolation point.
 /// </summary>
 /// <typeparam name="T">Type of source and output messages.</typeparam>
 /// <typeparam name="TClock">Type of messages on the clock stream.</typeparam>
 /// <param name="source">Source stream.</param>
 /// <param name="clock">Clock stream that dictates the interpolation points.</param>
 /// <param name="relativeTimeInterval">The relative time interval within which to search for the nearest message.</param>
 /// <param name="sourceDeliveryPolicy">An optional delivery policy for the source stream.</param>
 /// <param name="clockDeliveryPolicy">An optional delivery policy for the clock stream.</param>
 /// <returns>Sampled stream.</returns>
 public static IProducer <T> Sample <T, TClock>(
     this IProducer <T> source,
     IProducer <TClock> clock,
     RelativeTimeInterval relativeTimeInterval,
     DeliveryPolicy sourceDeliveryPolicy = null,
     DeliveryPolicy clockDeliveryPolicy  = null)
 {
     return(source.Interpolate(clock, Reproducible.Nearest <T>(relativeTimeInterval), sourceDeliveryPolicy, clockDeliveryPolicy));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Sample a stream at interpolation points given by a clock stream, by selecting the nearest
 /// message within a given tolerance to the interpolation point.
 /// </summary>
 /// <typeparam name="T">Type of source and output messages.</typeparam>
 /// <typeparam name="TClock">Type of messages on the clock stream.</typeparam>
 /// <param name="source">Source stream.</param>
 /// <param name="clock">Clock stream that dictates the interpolation points.</param>
 /// <param name="tolerance">The tolerance within which to search for the nearest message.</param>
 /// <param name="sourceDeliveryPolicy">An optional delivery policy for the source stream.</param>
 /// <param name="clockDeliveryPolicy">An optional delivery policy for the clock stream.</param>
 /// <returns>Sampled stream.</returns>
 public static IProducer <T> Sample <T, TClock>(
     this IProducer <T> source,
     IProducer <TClock> clock,
     TimeSpan tolerance,
     DeliveryPolicy <T> sourceDeliveryPolicy     = null,
     DeliveryPolicy <TClock> clockDeliveryPolicy = null)
 {
     return(source.Interpolate(clock, Reproducible.Nearest <T>(new RelativeTimeInterval(-tolerance, tolerance)), sourceDeliveryPolicy, clockDeliveryPolicy));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Samples a stream at interpolation points given by a clock stream, by selecting the nearest
 /// message within a relative time interval to the interpolation point.
 /// </summary>
 /// <typeparam name="T">Type of source and output messages.</typeparam>
 /// <typeparam name="TClock">Type of messages on the clock stream.</typeparam>
 /// <param name="source">Source stream.</param>
 /// <param name="clock">Clock stream that dictates the interpolation points.</param>
 /// <param name="relativeTimeInterval">The relative time interval within which to search for the nearest message.
 /// If the parameter is not specified the <see cref="RelativeTimeInterval.Infinite"/>relative time interval is
 /// used,resulting in sampling the nearest point to the clock signal on the source stream.</param>
 /// <param name="sourceDeliveryPolicy">An optional delivery policy for the source stream.</param>
 /// <param name="clockDeliveryPolicy">An optional delivery policy for the clock stream.</param>
 /// <param name="name">An optional name for the stream operator.</param>
 /// <returns>Sampled stream.</returns>
 public static IProducer <T> Sample <T, TClock>(
     this IProducer <T> source,
     IProducer <TClock> clock,
     RelativeTimeInterval relativeTimeInterval   = null,
     DeliveryPolicy <T> sourceDeliveryPolicy     = null,
     DeliveryPolicy <TClock> clockDeliveryPolicy = null,
     string name = nameof(Sample))
 {
     relativeTimeInterval ??= RelativeTimeInterval.Infinite;
     return(source.Interpolate(clock, Reproducible.Nearest <T>(relativeTimeInterval), sourceDeliveryPolicy, clockDeliveryPolicy, name));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sample a stream at a given sampling interval, by selecting the nearest message
 /// within a given tolerance to the interpolation point.
 /// </summary>
 /// <typeparam name="T">Type of source (and output) messages.</typeparam>
 /// <param name="source">Source stream.</param>
 /// <param name="samplingInterval">Interval at which to apply the interpolator.</param>
 /// <param name="tolerance">The tolerance within which to search for the nearest message.</param>
 /// <param name="alignmentDateTime">If non-null, this parameter specifies a time to align the sampling messages with. If the paramater
 /// is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the
 /// specified alignment time.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <returns>Sampled stream.</returns>
 public static IProducer <T> Sample <T>(
     this IProducer <T> source,
     TimeSpan samplingInterval,
     TimeSpan tolerance,
     DateTime?alignmentDateTime    = null,
     DeliveryPolicy deliveryPolicy = null)
 {
     return(source.Interpolate(
                samplingInterval,
                Reproducible.Nearest <T>(new RelativeTimeInterval(-tolerance, tolerance)),
                alignmentDateTime,
                deliveryPolicy));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sample a stream at a given sampling interval, by selecting the nearest message
 /// within a relative time interval to the interpolation point.
 /// </summary>
 /// <typeparam name="T">Type of source (and output) messages.</typeparam>
 /// <param name="source">Source stream.</param>
 /// <param name="samplingInterval">Interval at which to apply the interpolator.</param>
 /// <param name="relativeTimeInterval">The relative time interval within which to search for the nearest message.
 /// If the parameter is not specified the <see cref="RelativeTimeInterval.Infinite"/>relative time interval is
 /// used,resulting in sampling the nearest point to the clock signal on the source stream.</param>
 /// <param name="alignmentDateTime">If non-null, this parameter specifies a time to align the sampling messages with. If the parameter
 /// is non-null, the messages will have originating times that align with (i.e., are an integral number of intervals away from) the
 /// specified alignment time.</param>
 /// <param name="deliveryPolicy">An optional delivery policy.</param>
 /// <returns>Sampled stream.</returns>
 public static IProducer <T> Sample <T>(
     this IProducer <T> source,
     TimeSpan samplingInterval,
     RelativeTimeInterval relativeTimeInterval = null,
     DateTime?alignmentDateTime        = null,
     DeliveryPolicy <T> deliveryPolicy = null)
 {
     relativeTimeInterval ??= RelativeTimeInterval.Infinite;
     return(source.Interpolate(
                samplingInterval,
                Reproducible.Nearest <T>(relativeTimeInterval),
                alignmentDateTime,
                deliveryPolicy));
 }