Exemple #1
0
        public static WaterSensorData Deserialize(string json)
        {
            var settings = Helpers.GetSerializerSettings();

            WaterSensorData obj = JsonConvert.DeserializeObject <WaterSensorData>(json, settings);

            return(obj);
        }
Exemple #2
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);
        }