visualize min carbs absorption
This commit is contained in:
parent
11b88c7947
commit
e1dc69cd4d
5 changed files with 103 additions and 41 deletions
|
@ -195,8 +195,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSize() {
|
public float getSize() {
|
||||||
boolean isTablet = MainApp.sResources.getBoolean(R.bool.isTablet);
|
return 1;
|
||||||
return isTablet ? 8 : 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,18 +11,20 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 25.04.2017.
|
* Created by mike on 25.04.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AutosensData {
|
public class AutosensData implements DataPointWithLabelInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(AutosensData.class);
|
private static Logger log = LoggerFactory.getLogger(AutosensData.class);
|
||||||
|
|
||||||
static class CarbsInPast {
|
static class CarbsInPast {
|
||||||
|
@ -66,7 +68,7 @@ public class AutosensData {
|
||||||
public double slopeFromMaxDeviation = 0;
|
public double slopeFromMaxDeviation = 0;
|
||||||
public double slopeFromMinDeviation = 999;
|
public double slopeFromMinDeviation = 999;
|
||||||
public double usedMinCarbsImpact = 0d;
|
public double usedMinCarbsImpact = 0d;
|
||||||
|
public boolean failoverToMinAbsorbtionRate = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -108,4 +110,51 @@ public class AutosensData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------- DataPointWithLabelInterface ------
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getX() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getY() {
|
||||||
|
return cob;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setY(double y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDuration() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PointsWithLabelGraphSeries.Shape getShape() {
|
||||||
|
return PointsWithLabelGraphSeries.Shape.COBFAILOVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getSize() {
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColor() {
|
||||||
|
return MainApp.gc(R.color.cob);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSecondColor() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,13 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.Event;
|
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
@ -218,6 +218,8 @@ public class IobCobThread extends Thread {
|
||||||
// figure out how many carbs that represents
|
// figure out how many carbs that represents
|
||||||
// but always assume at least 3mg/dL/5m (default) absorption per active treatment
|
// but always assume at least 3mg/dL/5m (default) absorption per active treatment
|
||||||
double ci = Math.max(deviation, totalMinCarbsImpact);
|
double ci = Math.max(deviation, totalMinCarbsImpact);
|
||||||
|
if (ci != deviation)
|
||||||
|
autosensData.failoverToMinAbsorbtionRate = true;
|
||||||
autosensData.absorbed = ci * profile.getIc(bgTime) / sens;
|
autosensData.absorbed = ci * profile.getIc(bgTime) / sens;
|
||||||
// and add that to the running total carbsAbsorbed
|
// and add that to the running total carbsAbsorbed
|
||||||
autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d);
|
autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d);
|
||||||
|
|
|
@ -365,6 +365,7 @@ public class GraphData {
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
public void addCob(long fromTime, long toTime, boolean useForScale, double scale) {
|
public void addCob(long fromTime, long toTime, boolean useForScale, double scale) {
|
||||||
|
List<DataPointWithLabelInterface> minFailoverActiveList = new ArrayList<>();
|
||||||
FixedLineGraphSeries<ScaledDataPoint> cobSeries;
|
FixedLineGraphSeries<ScaledDataPoint> cobSeries;
|
||||||
List<ScaledDataPoint> cobArray = new ArrayList<>();
|
List<ScaledDataPoint> cobArray = new ArrayList<>();
|
||||||
Double maxCobValueFound = 0d;
|
Double maxCobValueFound = 0d;
|
||||||
|
@ -382,6 +383,8 @@ public class GraphData {
|
||||||
maxCobValueFound = Math.max(maxCobValueFound, cob);
|
maxCobValueFound = Math.max(maxCobValueFound, cob);
|
||||||
lastCob = cob;
|
lastCob = cob;
|
||||||
}
|
}
|
||||||
|
if (autosensData.failoverToMinAbsorbtionRate)
|
||||||
|
minFailoverActiveList.add(autosensData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,6 +403,10 @@ public class GraphData {
|
||||||
cobScale.setMultiplier(maxY * scale / maxCobValueFound);
|
cobScale.setMultiplier(maxY * scale / maxCobValueFound);
|
||||||
|
|
||||||
addSeries(cobSeries);
|
addSeries(cobSeries);
|
||||||
|
|
||||||
|
DataPointWithLabelInterface[] minFailover = new DataPointWithLabelInterface[minFailoverActiveList.size()];
|
||||||
|
minFailover = minFailoverActiveList.toArray(minFailover);
|
||||||
|
addSeries(new PointsWithLabelGraphSeries<>(minFailover));
|
||||||
}
|
}
|
||||||
|
|
||||||
// scale in % of vertical size (like 0.3)
|
// scale in % of vertical size (like 0.3)
|
||||||
|
|
|
@ -3,42 +3,46 @@ package info.nightscout.androidaps.plugins.Overview.graphExtensions;
|
||||||
/**
|
/**
|
||||||
* GraphView
|
* GraphView
|
||||||
* Copyright (C) 2014 Jonas Gehring
|
* Copyright (C) 2014 Jonas Gehring
|
||||||
*
|
* <p>
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License,
|
* the Free Software Foundation; either version 2 of the License,
|
||||||
* with the "Linking Exception", which can be found at the license.txt
|
* with the "Linking Exception", which can be found at the license.txt
|
||||||
* file in this program.
|
* file in this program.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* with the "Linking Exception" along with this program; if not,
|
* with the "Linking Exception" along with this program; if not,
|
||||||
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
|
* write to the author Jonas Gehring <g.jjoe64@gmail.com>.
|
||||||
|
* <p>
|
||||||
|
* Added by mike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Added by mike
|
* Added by mike
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.util.TypedValue;
|
|
||||||
// Added by Rumen for scalable text
|
|
||||||
import android.content.Context;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.jjoe64.graphview.series.BaseSeries;
|
import com.jjoe64.graphview.series.BaseSeries;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
|
||||||
|
// Added by Rumen for scalable text
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Series that plots the data as points.
|
* Series that plots the data as points.
|
||||||
* The points can be different shapes or a
|
* The points can be different shapes or a
|
||||||
|
@ -74,7 +78,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
OPENAPSOFFLINE,
|
OPENAPSOFFLINE,
|
||||||
EXERCISE,
|
EXERCISE,
|
||||||
GENERAL,
|
GENERAL,
|
||||||
GENERALWITHDURATION
|
GENERALWITHDURATION,
|
||||||
|
COBFAILOVER
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,10 +202,10 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
|
|
||||||
// draw data point
|
// draw data point
|
||||||
if (!overdraw) {
|
if (!overdraw) {
|
||||||
if (value.getShape() == Shape.BG) {
|
if (value.getShape() == Shape.BG || value.getShape() == Shape.COBFAILOVER) {
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
|
||||||
} else if (value.getShape() == Shape.PREDICTION) {
|
} else if (value.getShape() == Shape.PREDICTION) {
|
||||||
mPaint.setColor(value.getColor());
|
mPaint.setColor(value.getColor());
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
|
|
Loading…
Reference in a new issue