set positive deviations to zero if bg < 80

This commit is contained in:
Milos Kozak 2018-06-22 21:18:59 +02:00
parent c139942981
commit 8a74646b67
7 changed files with 33 additions and 6 deletions

View file

@ -56,7 +56,8 @@ public class AutosensData implements DataPointWithLabelInterface {
}
public long time = 0L;
long chartTime;
public double bg = 0; // mgdl
private long chartTime;
public String pastSensitivity = "";
public double deviation = 0d;
public boolean validDeviation = false;

View file

@ -146,6 +146,7 @@ public class IobCobOref1Thread extends Thread {
log.error("! value < 39");
continue;
}
autosensData.bg = bg;
delta = (bg - bucketed_data.get(i + 1).value);
avgDelta = (bg - bucketed_data.get(i + 3).value) / 3;
@ -327,7 +328,7 @@ public class IobCobOref1Thread extends Thread {
calendar.setTimeInMillis(bgTime);
int min = calendar.get(MINUTE);
int hours = calendar.get(Calendar.HOUR_OF_DAY);
if (min >= 0 && min < 5 && hours %2 == 0)
if (min >= 0 && min < 5 && hours % 2 == 0)
autosensData.extraDeviation.add(0d);
previous = autosensData;

View file

@ -145,6 +145,7 @@ public class IobCobThread extends Thread {
log.error("! value < 39");
continue;
}
autosensData.bg = bg;
delta = (bg - bucketed_data.get(i + 1).value);
avgDelta = (bg - bucketed_data.get(i + 3).value) / 3;

View file

@ -105,8 +105,14 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
pastSensitivity += "(SITECHANGE)";
}
double deviation = autosensData.validDeviation ? autosensData.deviation : 0d;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(autosensData.validDeviation ? autosensData.deviation : 0d);
deviationsArray.add(deviation);
if (deviationsArray.size() > hoursForDetection * 60 / 5)
deviationsArray.remove(0);

View file

@ -106,8 +106,14 @@ public class SensitivityOref0Plugin extends PluginBase implements SensitivityInt
pastSensitivity += "(SITECHANGE)";
}
double deviation = autosensData.validDeviation ? autosensData.deviation : 0d;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(autosensData.validDeviation ? autosensData.deviation : 0d);
deviationsArray.add(deviation);
if (deviationsArray.size() > hoursForDetection * 60 / 5)
deviationsArray.remove(0);

View file

@ -97,7 +97,13 @@ public class SensitivityOref1Plugin extends PluginBase implements SensitivityInt
pastSensitivity += "(SITECHANGE)";
}
deviationsArray.add(autosensData.validDeviation ? autosensData.deviation : 0d);
double deviation = autosensData.validDeviation ? autosensData.deviation : 0d;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
deviationsArray.add(deviation);
for (int i = 0; i < autosensData.extraDeviation.size(); i++)
deviationsArray.add(autosensData.extraDeviation.get(i));

View file

@ -111,9 +111,15 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
pastSensitivity += "(SITECHANGE)";
}
double deviation = autosensData.validDeviation ? autosensData.deviation : 0d;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
//data.append(autosensData.time);
long reverseWeight = (toTime - autosensData.time) / (5 * 60 * 1000L);
data.append(reverseWeight, autosensData.validDeviation ? autosensData.deviation : 0d);
data.append(reverseWeight, deviation);
//weights += reverseWeight;
//weightedsum += reverseWeight * (autosensData.validDeviation ? autosensData.deviation : 0d);