reset autosens on site change (AAPS,WA)

This commit is contained in:
Milos Kozak 2018-06-22 20:11:45 +02:00
parent 8237456030
commit c139942981
2 changed files with 19 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.Config;
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.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -80,6 +81,8 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
} }
List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true);
List<Double> deviationsArray = new ArrayList<>(); List<Double> deviationsArray = new ArrayList<>();
String pastSensitivity = ""; String pastSensitivity = "";
int index = 0; int index = 0;
@ -96,6 +99,12 @@ public class SensitivityAAPSPlugin extends PluginBase implements SensitivityInte
continue; continue;
} }
// reset deviations after site change
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
deviationsArray.clear();
pastSensitivity += "(SITECHANGE)";
}
if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L) if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(autosensData.validDeviation ? autosensData.deviation : 0d); deviationsArray.add(autosensData.validDeviation ? autosensData.deviation : 0d);
if (deviationsArray.size() > hoursForDetection * 60 / 5) if (deviationsArray.size() > hoursForDetection * 60 / 5)

View file

@ -6,11 +6,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Date; import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
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.db.CareportalEvent;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -79,6 +81,8 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
return new AutosensResult(); return new AutosensResult();
} }
List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true);
String pastSensitivity = ""; String pastSensitivity = "";
int index = 0; int index = 0;
LongSparseArray<Double> data = new LongSparseArray<>(); LongSparseArray<Double> data = new LongSparseArray<>();
@ -101,6 +105,12 @@ public class SensitivityWeightedAveragePlugin extends PluginBase implements Sens
continue; continue;
} }
// reset deviations after site change
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
data.clear();
pastSensitivity += "(SITECHANGE)";
}
//data.append(autosensData.time); //data.append(autosensData.time);
long reverseWeight = (toTime - autosensData.time) / (5 * 60 * 1000L); long reverseWeight = (toTime - autosensData.time) / (5 * 60 * 1000L);
data.append(reverseWeight, autosensData.validDeviation ? autosensData.deviation : 0d); data.append(reverseWeight, autosensData.validDeviation ? autosensData.deviation : 0d);