/// <summary> /// Initializes a new instance of the <see cref="Sampler{T}"/> class. /// </summary> /// <param name="pipeline">Pipeline to which this component belongs.</param> /// <param name="interpolator">Interpolator used to sample.</param> /// <param name="samplingInterval">Sampling interval.</param> public Sampler(Pipeline pipeline, Match.Interpolator <T> interpolator, TimeSpan samplingInterval) : base(pipeline) { this.In.Unsubscribed += closingOriginatingTime => this.closingOriginatingTime = closingOriginatingTime; this.interpolator = interpolator; this.samplingInterval = samplingInterval; }
/// <summary> /// Initializes a new instance of the <see cref="Join{TPrimary, TSecondary, TOut}"/> class. /// </summary> /// <param name="pipeline">Pipeline to which this component belongs.</param> /// <param name="interpolator">Interpolator with which to join.</param> /// <param name="outputCreator">Mapping function from message pair to output.</param> /// <param name="secondaryCount">Number of secondary streams.</param> /// <param name="secondarySelector">Selector function mapping primary messages to secondary stream indices.</param> public Join( Pipeline pipeline, Match.Interpolator <TSecondary> interpolator, Func <TPrimary, TSecondary[], TOut> outputCreator, int secondaryCount = 1, Func <TPrimary, IEnumerable <int> > secondarySelector = null) : base() { this.pipeline = pipeline; this.Out = pipeline.CreateEmitter <TOut>(this, nameof(this.Out)); this.InPrimary = pipeline.CreateReceiver <TPrimary>(this, this.ReceivePrimary, nameof(this.InPrimary)); this.interpolator = interpolator; this.outputCreator = outputCreator; this.secondarySelector = secondarySelector; this.inSecondaries = new Receiver <TSecondary> [secondaryCount]; this.secondaryQueues = new Queue <Message <TSecondary> > [secondaryCount]; this.lastValues = new TSecondary[secondaryCount]; this.lastResults = new MatchResult <TSecondary> [secondaryCount]; this.defaultSecondarySet = Enumerable.Range(0, secondaryCount); for (int i = 0; i < secondaryCount; i++) { this.secondaryQueues[i] = new Queue <Message <TSecondary> >(); var id = i; // needed to make the closure below byval var receiver = pipeline.CreateReceiver <TSecondary>(this, (d, e) => this.ReceiveSecondary(id, d, e), "InSecondary" + i); this.inSecondaries[i] = receiver; } }
private void AssertInterpolatorProperties <T>(Match.Interpolator <T> interpolator, TimeSpan windowLeft, TimeSpan windowRight, bool requireNextValue, bool orDefault) { Assert.AreEqual(windowLeft, interpolator.Window.Left); Assert.AreEqual(windowRight, interpolator.Window.Right); Assert.AreEqual(requireNextValue, interpolator.RequireNextValue); Assert.AreEqual(orDefault, interpolator.OrDefault); }
/// <summary> /// Initializes a new instance of the <see cref="Sampler{T}"/> class. /// </summary> /// <param name="pipeline">Pipeline to which this component belongs.</param> /// <param name="interpolator">Interpolator used to sample.</param> /// <param name="samplingInterval">Sampling interval.</param> public Sampler(Pipeline pipeline, Match.Interpolator <T> interpolator, TimeSpan samplingInterval) : base() { this.Out = pipeline.CreateEmitter <T>(this, nameof(this.Out)); this.In = pipeline.CreateReceiver <T>(this, this.Receive, nameof(this.In)); this.interpolator = interpolator; this.samplingInterval = samplingInterval; }
/// <summary> /// Operator that crops an image /// </summary> /// <param name="source">Source image to crop</param> /// <param name="region">Producer that generates rectangles to crop the image against</param> /// <param name="interpolator">Interpolator to use for selecting region</param> /// <returns>Returns a producer that generates the cropped images</returns> public static IProducer <Shared <Image> > Crop(this IProducer <Shared <Image> > source, IProducer <Rectangle> region, Match.Interpolator <Rectangle> interpolator) { return(source.Join(region, interpolator).Crop()); }