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