Merge branch 'double_bolus_debug_master' of https://github.com/andyrozman/AndroidAPS into double_bolus_debug_master
This commit is contained in:
commit
1d1549105b
|
@ -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() + '"'
|
||||
|
|
|
@ -48,6 +48,7 @@ import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperAc
|
|||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
import info.nightscout.androidaps.plugins.pump.common.PumpPluginAbstract;
|
||||
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
|
@ -386,7 +387,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
RileyLinkServiceState rileyLinkServiceState = MedtronicUtil.getServiceState();
|
||||
|
||||
if (rileyLinkServiceState==null) {
|
||||
if (rileyLinkServiceState == null) {
|
||||
LOG.error("RileyLink unreachable. RileyLinkServiceState is null.");
|
||||
return false;
|
||||
}
|
||||
|
@ -744,13 +745,13 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
ClockDTO clock = MedtronicUtil.getPumpTime();
|
||||
|
||||
if (clock==null) { // retry
|
||||
if (clock == null) { // retry
|
||||
medtronicUIComm.executeCommand(MedtronicCommandType.GetRealTimeClock);
|
||||
|
||||
clock = MedtronicUtil.getPumpTime();
|
||||
}
|
||||
|
||||
if (clock==null)
|
||||
if (clock == null)
|
||||
return;
|
||||
|
||||
int timeDiff = Math.abs(clock.timeDifference);
|
||||
|
@ -866,7 +867,13 @@ 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);
|
||||
|
||||
// we subtract insulin, exact amount will be visible with next remainingInsulin update.
|
||||
getMDTPumpStatus().reservoirRemainingUnits -= detailedBolusInfo.insulin;
|
||||
|
@ -877,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);
|
||||
|
@ -1065,10 +1072,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
@Override
|
||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile,
|
||||
boolean enforceNew) {
|
||||
if (percent==0) {
|
||||
if (percent == 0) {
|
||||
return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew);
|
||||
} else {
|
||||
double absoluteValue = profile.getBasal() * (percent /100.0d);
|
||||
double absoluteValue = profile.getBasal() * (percent / 100.0d);
|
||||
getMDTPumpStatus();
|
||||
absoluteValue = pumpStatusLocal.pumpType.determineCorrectBasalSize(absoluteValue);
|
||||
LOG.warn("setTempBasalPercent [MedtronicPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (%d). This will start setTempBasalAbsolute, with calculated value (%.3f). Result might not be 100% correct.", percent, absoluteValue);
|
||||
|
|
|
@ -78,6 +78,7 @@ public class MedtronicHistoryData {
|
|||
private boolean isInit = false;
|
||||
|
||||
private Gson gson;
|
||||
private Gson gsonCore;
|
||||
|
||||
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
|
||||
private ClockDTO pumpTime;
|
||||
|
@ -95,10 +96,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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -598,7 +604,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);
|
||||
|
||||
|
@ -610,7 +616,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
if (doubleBolusDebug)
|
||||
LOG.debug("DoubleBolusDebug: List (after filter): {}, FromDb={}", gson.toJson(entryList),
|
||||
gson.toJson(entriesFromHistory));
|
||||
gsonCore.toJson(entriesFromHistory));
|
||||
|
||||
if (isCollectionEmpty(entriesFromHistory)) {
|
||||
for (PumpHistoryEntry treatment : entryList) {
|
||||
|
@ -863,6 +869,7 @@ public class MedtronicHistoryData {
|
|||
return;
|
||||
|
||||
List<DbObjectBase> removeTreatmentsFromHistory = new ArrayList<>();
|
||||
List<PumpHistoryEntry> removeTreatmentsFromPH = new ArrayList<>();
|
||||
|
||||
for (DbObjectBase treatment : treatmentsFromHistory) {
|
||||
|
||||
|
@ -880,11 +887,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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue