Exemplo n.º 1
0
        public void TimeSeriesTool_BuildsTimeSeriesFromStartsAndEnds()
        {
            var startsAndEnds = new StartAndEndPair[]
                                    {
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:05:34.222"), 
                                            DateTime.Parse("22-08-2011 17:06:34.222")),
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:07:34.222"), 
                                            DateTime.Parse("22-08-2011 17:08:34.222")),
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:09:34.222"), 
                                            DateTime.Parse("22-08-2011 17:15:34.222"))
                                    };

            var t = new TimeSeries(new TimeSpan(0, 5, 0));

            t.Build(startsAndEnds);

            Assert.AreEqual(3, t.Timestamps.Length);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:05:34.222"), t.Timestamps[0]);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:05:34.222").AddMinutes(5), t.Timestamps[1]);

            // ToDo: Asserts around values at those timestamps
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Usage: tseries -file|-f=<data file> [-step|-s=<fixed step size, as dd:hh:mm:ss.] [-tag|-t=<tag, to filter desired rows>]");
                return;
            }

            string step = "00:05:00";
            string file = string.Empty;
            string tag = string.Empty;
            bool matchTags = false;
            int initialCount = 0;
            OptionSet p = new OptionSet()
                .Add("file=|f=", f => file = f)
                .Add("step=|s=", s => step = s)
                .Add("tag=|t=", t => { tag = t; matchTags = true; })
                .Add("initial=|i=", i => initialCount = Convert.ToInt32(i));
            var unparsed = p.Parse(args);

            FileDataLoader loader = null;
            if (matchTags)
            {
                loader = new FileDataLoader(file, tag);
            }
            else
            {
                loader = new FileDataLoader(file);
            }
            var startsAndEnds = loader.Load();
            
            TimeSpan fixedStep = TimeSpan.Parse(step);
            TimeSeries series = new TimeSeries(fixedStep);
            series.Build(startsAndEnds);

            var index = 0;
            foreach(var t in series.Timestamps)
            {
                Console.WriteLine("{0}\t{1}\t{2}", t, series.Values[index] + initialCount, series.Highwater[index]);
                index++;
            }
        }
Exemplo n.º 3
0
        public void TimeSeriesTool_GeneratesSeriesWithCorrectSteps()
        {
            var startsAndEnds = new StartAndEndPair[]
                                    {
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:05:34.222"), 
                                            DateTime.Parse("22-08-2011 17:06:34.222")),
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:07:34.222"), 
                                            DateTime.Parse("22-08-2011 17:08:34.222")),
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:09:34.222"), 
                                            DateTime.Parse("22-08-2011 17:15:34.222"))
                                    };

            var t = new TimeSeries(new TimeSpan(0, 1, 0));

            t.Build(startsAndEnds);

            Assert.AreEqual(11, t.Timestamps.Length);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:06:34.222"), t.Timestamps[1]);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:15:34.222"), t.Timestamps[10]);
        }
Exemplo n.º 4
0
        public void TimeSeriesTool_BuildThrowsIfNotEnoughTasks()
        {
            var startsAndEnds = new StartAndEndPair[]
                                    {
                                        new StartAndEndPair(
                                            DateTime.Parse("22-08-2011 17:05:34.222"), 
                                            DateTime.Parse("22-08-2011 17:06:34.222"))
                                    };

            var t = new TimeSeries(new TimeSpan(0, 5, 0));

            t.Build(startsAndEnds);
        }
Exemplo n.º 5
0
 public void TimeSeriesTool_CanBeInstantiated()
 {
     var t = new TimeSeries(new TimeSpan(0, 5, 0));
 }