Ejemplo 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
        }
Ejemplo n.º 2
0
 public void Build(StartAndEndPair[] startsAndEnds)
 {
     using (var builder = new TimeSeriesBuilder(FixedStep))
     {
         builder.Build(startsAndEnds, out _timestamps, out _values, out _highwater);
     }
 }
Ejemplo n.º 3
0
        public void BuildSortedStartsAndEnds(StartAndEndPair[] startsAndEnds, out DateTime[] starts, out DateTime[] ends)
        {
            starts = new DateTime[startsAndEnds.Length];
            ends = new DateTime[startsAndEnds.Length];

            int count = 0;
            foreach(var pair in startsAndEnds)
            {
                starts[count] = pair.Start;
                ends[count] = pair.End;
                count++;
            }

            Array.Sort(starts);
            Array.Sort(ends);
        }
Ejemplo n.º 4
0
        public void TimeSeriesBuilder_BuildsStartAndEndLists()
        {
            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"))
                                    };

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

            DateTime[] starts;
            DateTime[] ends;

            t.BuildSortedStartsAndEnds(startsAndEnds, out starts, out ends);

            Assert.AreEqual(2, starts.Length);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:05:34.222"), starts[0]);
            Assert.AreEqual(2, ends.Length);
            Assert.AreEqual(DateTime.Parse("22-08-2011 17:06:34.222"), ends[0]);
        }
Ejemplo n.º 5
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]);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public void Build(StartAndEndPair[] startsAndEnds, out DateTime[] timestamps, out double[] values, out double[] highwater)
        {
            DateTime[] starts;
            DateTime[] ends;
            BuildSortedStartsAndEnds(startsAndEnds, out starts, out ends);

            BuildVariableStepTimeSeries(starts, ends);

            BuildFixedStepTimeSeries(out timestamps, out values, out highwater);
        }