Ejemplo n.º 1
0
        private static double calculateSlope(BgReading current, BgReading last)
        {
            if (current.Timestamp == last.Timestamp)
            {
                return(0.0);
            }

            return((last._glucose - current._glucose) / (last.Timestamp - current.Timestamp));
        }
Ejemplo n.º 2
0
        public static string GetGlucoseDirection(BgReading current, BgReading last)
        {
            //converted from:
            //https://github.com/NightscoutFoundation/xDrip/blob/b34e63223573a367105b31536e413d4b83b78dab/app/src/main/java/com/eveningoutpost/dexdrip/Models/BgReading.java#L563

            double sloapPerMinute = calculateSlopeByMinute(current, last);

            String arrow = "Unknown";

            if (sloapPerMinute <= (-3.5))
            {
                arrow = "DoubleDown";
            }
            else if (sloapPerMinute <= (-2))
            {
                arrow = "SingleDown";
            }
            else if (sloapPerMinute <= (-1))
            {
                arrow = "FortyFiveDown";
            }
            else if (sloapPerMinute <= (1))
            {
                arrow = "Flat";
            }
            else if (sloapPerMinute <= (2))
            {
                arrow = "FortyFiveUp";
            }
            else if (sloapPerMinute <= (3.5))
            {
                arrow = "SingleUp";
            }
            else if (sloapPerMinute <= (40))
            {
                arrow = "DoubleUp";
            }
            return(arrow);
        }
Ejemplo n.º 3
0
 public string GetRelativeGlucoseDirection(BgReading otherReading)
 {
     return(GlucoseMath.GetGlucoseDirection(this, otherReading));
 }
Ejemplo n.º 4
0
 private static double calculateSlopeByMinute(BgReading current, BgReading last)
 {
     return(calculateSlope(current, last) * 60000);
 }