示例#1
0
        public void TestGetHourlyLogs()
        {
            var          phHourlyLogs      = WaterSensorController.GetHourlySummaryPHLogs(2);
            List <PHLog> phDailyLogs       = WaterSensorController.GetDailySummaryPhLogs();
            List <PHLog> phHourlyDailyLogs = new List <PHLog>();

            phHourlyDailyLogs.AddRange(phHourlyLogs);
            foreach (var hourlyLog in phHourlyDailyLogs)
            {
                var dailyLog = phDailyLogs.Find(x => x.LogDate.Day == hourlyLog.LogDate.Day);

                if (dailyLog != null)
                {
                    hourlyLog.PhVal = dailyLog.PhVal;
                }
            }
            //foreach (var hourlyLog in phHourlyLogs)
            //{
            //    var dailyLog = phDailyLogs.Find(x => x.LogDate == hourlyLog.LogDate);

            //    if (dailyLog != null)
            //    {
            //        phHourlyDailyLogs.Add(dailyLog);
            //    }
            //    else
            //    {
            //        phHourlyDailyLogs.Add(hourlyLog);
            //    }
            //}
            //var hourlyAvg = WaterSensorController.GetHourlyPhAverage();
            //var dailyAvg = WaterSensorController.GetDailyPh();
        }
示例#2
0
        public void TestPhLogToFile()
        {
            Globals.SaveLogEveryMin = 1;
            var phStart = 5.0;
            var samples = 10;

            for (int i = 0; i < samples; i++)
            {
                string dec   = "1." + i;
                double aDec  = double.Parse(dec);
                var    phVal = phStart * aDec;
                WaterSensorController.Log <PHLog>(phVal);
                Thread.Sleep((int)Globals.SaveLogEveryMin * 60 * 1000 + 500);
            }

            var phLogs = WaterSensorController.GetLogs <PHLog>();

            Assert.IsTrue(phLogs.Count > 0);
        }
示例#3
0
        public void TestPhHourlyDailyLogs()
        {
            var now     = DateTime.Now;
            var phStart = 5.0;
            var samples = 1100;

            for (int i = 0; i < samples; i++)
            {
                string dec      = "1." + i;
                double aDec     = double.Parse(dec);
                var    phVal    = phStart * aDec;
                var    pastDate = DateTime.Now.AddMinutes(Globals.SaveLogEveryMin * i * -1);
                WaterSensorController._rawPHLogs.Add(new PHLog {
                    PhVal = phVal, LogDate = pastDate
                });
            }

            var hourlyAvg = WaterSensorController.GetHourlyPhAverage();
            var dailyAvg  = WaterSensorController.GetDailyPh();
        }
示例#4
0
        public static WaterSensorData Log(string json, bool isROSensor = false, bool hasPHSensor = true)
        {
            WaterSensorData data = Deserialize(json);

            if (!hasPHSensor)
            {
                int readingDurr  = data.readingDur.ConvSecString();
                int readingInter = data.readingInter.ConvSecString();

                double minReadingTime = readingInter * .60; // has been reading tds for 70% of time.
                if (readingDurr >= minReadingTime)
                {
                    //log tds
                    if (data.tds >= 10 && data.tds <= 500)
                    {
                        WaterSensorController.Log <TDSLog>(data.tds, isROSensor);
                    }
                }
            }
            else if (data.reading == "ph")
            {
                //log tds
                if (data.tds >= 10 && data.tds <= 500)
                {
                    WaterSensorController.Log <TDSLog>(data.tds, isROSensor);
                }
            }
            else
            {
                //log ph
                if (data.ph >= 2 && data.ph <= 9.4)
                {
                    WaterSensorController.Log <PHLog>(data.ph, isROSensor);
                }
            }
            return(data);
        }