Пример #1
0
        public void AddBug()
        {
            DateTime           t1  = new DateTime(2013, 1, 1);
            var                t2  = t1.AddDays(365);
            var                fn  = FileUtility.GetTempFileNameInDirectory(@"c:\temp\", ".pdb");
            SQLiteServer       svr = new SQLiteServer(fn);
            TimeSeriesDatabase db  = new Reclamation.TimeSeries.TimeSeriesDatabase(svr, false);
            var                s   = new HydrometDailySeries("pal", "af");

            s.Name = "pal_af";
            s.Read(t1, t2);
            db.AddSeries(s);

            var cs = new CalculationSeries("add_test");

            cs.Expression = "pal_af + pal_af";
            db.AddSeries(cs);


            cs = db.GetSeriesFromName("add_test") as CalculationSeries;
            cs.Calculate(t1, t2);


            cs = db.GetSeriesFromName("add_test") as CalculationSeries;
            cs.Read();

            Assert.IsTrue(cs.Count > 0);
        }
Пример #2
0
        public void ConvertToCelcius()
        {
            var    fn = Path.Combine(TestData.DataPath, "CalculationTests.xlsx");
            Series s  = new ExcelDataReaderSeries(fn, "ConvertToCelcius", "Date", "value");

            s.Units = "degrees C";
            s.Name  = "series1";

            CalculationSeries c = new CalculationSeries();

            c.Parser.VariableResolver.Add("series1", s);
            c.Expression = "5/9*(series1-32)";
            c.Read();

            // c.WriteToConsole();
            c.Clear();
            c.Calculate(); //t,t.AddDays(3));
            c.WriteToConsole();
            Assert.AreEqual(0, c[0].Value, 0.01);
            Assert.AreEqual(100, c[1].Value, 0.01);
        }
Пример #3
0
        public void ConvertToCelcius()
        {
            var    fn  = Path.Combine(TestData.DataPath, "calculationtests_convert.csv");
            var    csv = new CsvFile(fn);
            Series s   = new DataTableSeries(csv, TimeInterval.Daily, "Date", "value");

            s.Units = "degrees C";
            s.Name  = "series1";

            CalculationSeries c = new CalculationSeries();

            c.Parser.VariableResolver.Add("series1", s);
            c.Expression = "5/9*(series1-32)";
            c.Read();

            // c.WriteToConsole();
            c.Clear();
            c.Calculate(); //t,t.AddDays(3));
            c.WriteToConsole();
            Assert.AreEqual(0, c[0].Value, 0.01);
            Assert.AreEqual(100, c[1].Value, 0.01);
        }