medtronic-2.5.1.1

- DetailedBolusInfo.add is used when Bolus delivered
- fixed some logging problems with Gson for core objects
- when bolus is given, date is changed to when it was actually delivered (in case contacting pump takes longer than exprected)
This commit is contained in:
Andy Rozman 2019-11-04 12:21:29 +00:00
parent 7371ae3315
commit 220bd20f1f
5 changed files with 27 additions and 9 deletions

View file

@ -109,7 +109,7 @@ android {
targetSdkVersion 28
multiDexEnabled true
versionCode 1500
version "2.5.1"
version "medtronic-2.5.1.1"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'

View file

@ -867,6 +867,11 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
}).start();
}
long now = System.currentTimeMillis();
detailedBolusInfo.date = now;
detailedBolusInfo.deliverAt = now; // not sure about that one
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true);
DetailedBolusInfoStorage.INSTANCE.add(detailedBolusInfo);
@ -879,7 +884,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
// calculate time for bolus and set driver to busy for that time
int bolusTime = (int) (detailedBolusInfo.insulin * 42.0d);
long time = System.currentTimeMillis() + (bolusTime * 1000);
long time = now + (bolusTime * 1000);
this.busyTimestamps.add(time);
setEnableCustomAction(MedtronicCustomActionType.ClearBolusBlock, true);

View file

@ -77,6 +77,7 @@ public class MedtronicHistoryData {
private boolean isInit = false;
private Gson gson;
private Gson gsonCore;
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
private ClockDTO pumpTime;
@ -94,10 +95,15 @@ public class MedtronicHistoryData {
public MedtronicHistoryData() {
this.allHistory = new ArrayList<>();
this.gson = MedtronicUtil.gsonInstance;
this.gsonCore = MedtronicUtil.getGsonInstanceCore();
if (this.gson == null) {
this.gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
}
if (this.gsonCore == null) {
this.gsonCore = new GsonBuilder().create();
}
}
@ -597,7 +603,7 @@ public class MedtronicHistoryData {
if (doubleBolusDebug)
LOG.debug("DoubleBolusDebug: List (before filter): {}, FromDb={}", gson.toJson(entryList),
gson.toJson(entriesFromHistory));
gsonCore.toJson(entriesFromHistory));
filterOutAlreadyAddedEntries(entryList, entriesFromHistory);
@ -862,6 +868,7 @@ public class MedtronicHistoryData {
return;
List<DbObjectBase> removeTreatmentsFromHistory = new ArrayList<>();
List<PumpHistoryEntry> removeTreatmentsFromPH = new ArrayList<>();
for (DbObjectBase treatment : treatmentsFromHistory) {
@ -879,11 +886,17 @@ public class MedtronicHistoryData {
if (selectedBolus != null) {
entryList.remove(selectedBolus);
removeTreatmentsFromPH.add(selectedBolus);
removeTreatmentsFromHistory.add(treatment);
}
}
}
if (doubleBolusDebug)
LOG.debug("DoubleBolusDebug: filterOutAlreadyAddedEntries: PumpHistory={}, Treatments={}",
gson.toJson(removeTreatmentsFromPH),
gsonCore.toJson(removeTreatmentsFromHistory));
treatmentsFromHistory.removeAll(removeTreatmentsFromHistory);
}

View file

@ -61,8 +61,7 @@ public class MedtronicUtil extends RileyLinkUtil {
private static int doneBit = 1 << 7;
private static ClockDTO pumpTime;
public static Gson gsonInstance = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
public static Gson gsonInstancePretty = new GsonBuilder().excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting().create();
public static Gson gsonInstanceCore = new GsonBuilder().create();
private static BatteryType batteryType = BatteryType.None;
@ -70,8 +69,9 @@ public class MedtronicUtil extends RileyLinkUtil {
return gsonInstance;
}
public static Gson getGsonInstancePretty() {
return gsonInstancePretty;
public static Gson getGsonInstanceCore() {
return gsonInstanceCore;
}

View file

@ -349,7 +349,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
long time = System.currentTimeMillis();
synchronized (treatments) {
if (MedtronicHistoryData.doubleBolusDebug)
log.debug("DoubleBolusDebug: AllTreatmentsInDb: {}", MedtronicUtil.getGsonInstance().toJson(treatments));
log.debug("DoubleBolusDebug: AllTreatmentsInDb: {}", MedtronicUtil.getGsonInstanceCore().toJson(treatments));
for (Treatment t : treatments) {
if (t.date <= time && t.date >= fromTimestamp)
@ -357,7 +357,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
if (MedtronicHistoryData.doubleBolusDebug)
log.debug("DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={}", fromTimestamp, MedtronicUtil.getGsonInstance().toJson(in5minback));
log.debug("DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={}", fromTimestamp, MedtronicUtil.getGsonInstanceCore().toJson(in5minback));
return in5minback;
}