Beispiel #1
0
        public void AnnotationPipeline()
        {
            string path = this.path;

            using (var pipeline = Pipeline.Create(this.name))
            {
                var store = AnnotationStore.Create(pipeline, this.name, path, this.definition);
                path = store.Path;
                var timer       = Timers.Timer <double>(pipeline, TimeSpan.FromMilliseconds(10), (dt, ts) => (double)ts.Ticks);
                var sin         = timer.Select(l => Math.Sin(l / 10000000d));
                var annotations = sin
                                  .Select((d, env) => Tuple.Create(d, env.OriginatingTime))
                                  .Window(-1, 0)
                                  .Select((p) => Tuple.Create(p.First(), p.Last(), this.ComputeTransition(p.First().Item1, p.Last().Item1)))
                                  .Where((t) => t.Item3 != Transitions.None)
                                  .Window(-1, 0)
                                  .Process <IEnumerable <Tuple <Tuple <double, DateTime>, Tuple <double, DateTime>, Transitions> >, AnnotatedEvent>((t, env, s) =>
                {
                    var first  = t.First();
                    var second = t.Last();
                    if (first != second)
                    {
                        var annotatedEvent = this.definition.CreateAnnotatedEvent(first.Item2.Item2, second.Item1.Item2);
                        this.SetAnnotation(annotatedEvent, first.Item3);
                        s.Post(annotatedEvent, env.OriginatingTime);
                    }
                })
                                  .Write("Range", store);
                pipeline.Run(TimeSpan.FromSeconds(10));
            }

            // delete store
            DeleteStore(path);
        }