invalidate autosens on new profile
This commit is contained in:
parent
09fea02ed2
commit
d781c69b94
|
@ -356,7 +356,7 @@ public class DataService extends IntentService {
|
||||||
String activeProfile = bundles.getString("activeprofile");
|
String activeProfile = bundles.getString("activeprofile");
|
||||||
String profile = bundles.getString("profile");
|
String profile = bundles.getString("profile");
|
||||||
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
NSProfile nsProfile = new NSProfile(new JSONObject(profile), activeProfile);
|
||||||
MainApp.bus().post(new EventNewBasalProfile(nsProfile));
|
MainApp.bus().post(new EventNewBasalProfile(nsProfile, "NSClient"));
|
||||||
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
|
|
|
@ -7,8 +7,10 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
*/
|
*/
|
||||||
public class EventNewBasalProfile {
|
public class EventNewBasalProfile {
|
||||||
public NSProfile newNSProfile = null;
|
public NSProfile newNSProfile = null;
|
||||||
|
public String from = "";
|
||||||
|
|
||||||
public EventNewBasalProfile(NSProfile newProfile) {
|
public EventNewBasalProfile(NSProfile newProfile, String from) {
|
||||||
newNSProfile = newProfile;
|
newNSProfile = newProfile;
|
||||||
|
this.from = from;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -618,7 +618,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
pump.setNewBasalProfile(nsProfile);
|
pump.setNewBasalProfile(nsProfile);
|
||||||
log.debug("Setting new profile: " + profile);
|
log.debug("Setting new profile: " + profile);
|
||||||
MainApp.bus().post(new EventNewBasalProfile(nsProfile));
|
MainApp.bus().post(new EventNewBasalProfile(nsProfile, "NewNSTreatmentDialog"));
|
||||||
} else {
|
} else {
|
||||||
log.error("No active pump selected");
|
log.error("No active pump selected");
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
private void loadBgData() {
|
private void loadBgData() {
|
||||||
//log.debug("Locking loadBgData");
|
//log.debug("Locking loadBgData");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
onNewProfile(new EventNewBasalProfile(null));
|
onNewProfile(new EventNewBasalProfile(null, "IobCobCalculator init"));
|
||||||
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)), false);
|
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime((long) (new Date().getTime() - 60 * 60 * 1000L * (24 + dia)), false);
|
||||||
log.debug("BG data loaded. Size: " + bgReadings.size());
|
log.debug("BG data loaded. Size: " + bgReadings.size());
|
||||||
}
|
}
|
||||||
|
@ -545,6 +545,20 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
dia = profile.getDia();
|
dia = profile.getDia();
|
||||||
}
|
}
|
||||||
|
if (ev.newNSProfile == null) { // on init no need of reset
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (dataLock) {
|
||||||
|
log.debug("Invalidating cached data because of new profile from " + ev.from + ". IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
|
iobTable = new LongSparseArray<>();
|
||||||
|
autosensDataTable = new LongSparseArray<>();
|
||||||
|
}
|
||||||
|
sHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
calculateSensitivityData();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
// When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated
|
||||||
|
|
Loading…
Reference in a new issue