From fad10af11b5bad4cd8c3b50f4545a4f1bb349071 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 19 Mar 2018 11:08:58 +0100 Subject: [PATCH] Clean ups around PumpEnactResult, APSResult. --- .../androidaps/data/PumpEnactResult.java | 23 +++++++++++-------- .../ConfigBuilder/ConfigBuilderPlugin.java | 5 +--- .../androidaps/plugins/Loop/APSResult.java | 6 ++--- .../OpenAPSAMA/DetermineBasalResultAMA.java | 10 ++++---- .../plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 6 ++--- .../OpenAPSMA/DetermineBasalResultMA.java | 12 +++++----- .../plugins/OpenAPSMA/OpenAPSMAPlugin.java | 6 ++--- .../OpenAPSSMB/DetermineBasalResultSMB.java | 4 ++-- .../plugins/OpenAPSSMB/OpenAPSSMBPlugin.java | 6 ++--- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java b/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java index 9aa09244aa..a9467caafd 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java +++ b/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java @@ -100,16 +100,19 @@ public class PumpEnactResult { ret += "\n" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; } else if (isTempCancel) { ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment + "\n" + - MainApp.sResources.getString(R.string.canceltemp); + if (!comment.isEmpty()) + ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + ret += MainApp.sResources.getString(R.string.canceltemp); } else if (isPercent) { ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + if (!comment.isEmpty()) + ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; ret += "\n" + MainApp.sResources.getString(R.string.duration) + ": " + duration + " min"; ret += "\n" + MainApp.sResources.getString(R.string.percent) + ": " + percent + "%"; } else { ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + if (!comment.isEmpty()) + ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; ret += "\n" + MainApp.sResources.getString(R.string.duration) + ": " + duration + " min"; ret += "\n" + MainApp.sResources.getString(R.string.absolute) + ": " + absolute + " U/h"; } @@ -126,7 +129,8 @@ public class PumpEnactResult { } else if (enacted) { if (bolusDelivered > 0) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + if (!comment.isEmpty()) + ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; ret += "
" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; } else if (isTempCancel) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; @@ -134,18 +138,17 @@ public class PumpEnactResult { "
" + MainApp.sResources.getString(R.string.canceltemp); } else if (isPercent && percent != -1) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + if (!comment.isEmpty()) + ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; ret += "
" + MainApp.sResources.getString(R.string.duration) + ": " + duration + " min"; ret += "
" + MainApp.sResources.getString(R.string.percent) + ": " + percent + "%"; } else if (absolute != -1) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; - ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + if (!comment.isEmpty()) + ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; ret += "
" + MainApp.sResources.getString(R.string.duration) + ": " + duration + " min"; ret += "
" + MainApp.sResources.getString(R.string.absolute) + ": " + DecimalFormatter.to2Decimal(absolute) + " U/h"; } - if (bolusDelivered > 0) { - ret += "
" + MainApp.sResources.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusDelivered) + " U"; - } } else { ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 783aee258a..2fb7e6efa0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -4,8 +4,6 @@ import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.support.annotation.Nullable; -import org.json.JSONException; -import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,7 +41,6 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; -import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; import info.nightscout.androidaps.queue.Callback; @@ -355,7 +352,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr * expect absolute request and allow both absolute and percent response based on pump capabilities */ public void applyTBRRequest(APSResult request, Profile profile, Callback callback) { - if (!request.tempBasalReqested) { + if (!request.tempBasalRequested) { return; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java index 8050aa7769..7eab0e7722 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java @@ -31,7 +31,7 @@ public class APSResult { public String reason; public double rate; public int duration; - public boolean tempBasalReqested = false; + public boolean tempBasalRequested = false; public boolean bolusRequested = false; public IobTotal iob; public JSONObject json = new JSONObject(); @@ -98,7 +98,7 @@ public class APSResult { newResult.reason = reason; newResult.rate = rate; newResult.duration = duration; - newResult.tempBasalReqested = tempBasalReqested; + newResult.tempBasalRequested = tempBasalRequested; newResult.bolusRequested = bolusRequested; newResult.iob = iob; return newResult; @@ -216,6 +216,6 @@ public class APSResult { } public boolean isChangeRequested() { - return tempBasalReqested || bolusRequested; + return tempBasalRequested || bolusRequested; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java index 50dde42674..cb2b4a0091 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java @@ -22,7 +22,7 @@ public class DetermineBasalResultAMA extends APSResult { json = j; if (result.containsKey("error")) { reason = result.get("error").toString(); - tempBasalReqested = false; + tempBasalRequested = false; rate = -1; duration = -1; } else { @@ -32,17 +32,17 @@ public class DetermineBasalResultAMA extends APSResult { if (result.containsKey("rate")) { rate = (Double) result.get("rate"); if (rate < 0d) rate = 0d; - tempBasalReqested = true; + tempBasalRequested = true; } else { rate = -1; - tempBasalReqested = false; + tempBasalRequested = false; } if (result.containsKey("duration")) { duration = ((Double) result.get("duration")).intValue(); //changeRequested as above } else { duration = -1; - tempBasalReqested = false; + tempBasalRequested = false; } } bolusRequested = false; @@ -58,7 +58,7 @@ public class DetermineBasalResultAMA extends APSResult { newResult.reason = reason; newResult.rate = rate; newResult.duration = duration; - newResult.tempBasalReqested = tempBasalReqested; + newResult.tempBasalRequested = tempBasalRequested; newResult.rate = rate; newResult.duration = duration; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index dfab195125..f2d792d9e9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -246,7 +246,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { Profiler.log(log, "AMA calculation", start); // Fix bug determine basal if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) - determineBasalResultAMA.tempBasalReqested = false; + determineBasalResultAMA.tempBasalRequested = false; // limit requests on openloop mode if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { long now = System.currentTimeMillis(); @@ -254,9 +254,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { if (activeTemp != null && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) { // going to cancel } else if (activeTemp != null && Math.abs(determineBasalResultAMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) { - determineBasalResultAMA.tempBasalReqested = false; + determineBasalResultAMA.tempBasalRequested = false; } else if (activeTemp == null && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1) - determineBasalResultAMA.tempBasalReqested = false; + determineBasalResultAMA.tempBasalRequested = false; } determineBasalResultAMA.iob = iobArray[0]; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java index 3f40c02980..75928f09d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalResultMA.java @@ -20,7 +20,7 @@ public class DetermineBasalResultMA extends APSResult { json = j; if (result.containsKey("error")) { reason = (String) result.get("error"); - tempBasalReqested = false; + tempBasalRequested = false; rate = -1; duration = -1; mealAssist = ""; @@ -31,17 +31,17 @@ public class DetermineBasalResultMA extends APSResult { if (result.containsKey("rate")) { rate = (Double) result.get("rate"); if (rate < 0d) rate = 0d; - tempBasalReqested = true; + tempBasalRequested = true; } else { rate = -1; - tempBasalReqested = false; + tempBasalRequested = false; } if (result.containsKey("duration")) { duration = ((Double) result.get("duration")).intValue(); //changeRequested as above } else { duration = -1; - tempBasalReqested = false; + tempBasalRequested = false; } if (result.containsKey("mealAssist")) { mealAssist = result.get("mealAssist").toString(); @@ -58,10 +58,10 @@ public class DetermineBasalResultMA extends APSResult { newResult.reason = new String(reason); newResult.rate = rate; newResult.duration = duration; - newResult.tempBasalReqested = isChangeRequested(); + newResult.tempBasalRequested = isChangeRequested(); newResult.rate = rate; newResult.duration = duration; - newResult.tempBasalReqested = isChangeRequested(); + newResult.tempBasalRequested = isChangeRequested(); try { newResult.json = new JSONObject(json.toString()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 76df63e752..a8a6628743 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -235,16 +235,16 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke(); // Fix bug determinef basal if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) - determineBasalResultMA.tempBasalReqested = false; + determineBasalResultMA.tempBasalRequested = false; // limit requests on openloop mode if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now); if (activeTemp != null && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) { // going to cancel } else if (activeTemp != null && Math.abs(determineBasalResultMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) { - determineBasalResultMA.tempBasalReqested = false; + determineBasalResultMA.tempBasalRequested = false; } else if (activeTemp == null && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1) - determineBasalResultMA.tempBasalReqested = false; + determineBasalResultMA.tempBasalRequested = false; } determineBasalResultMA.iob = iobTotal; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java index 0320b3633d..59c1dd95e3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalResultSMB.java @@ -35,7 +35,7 @@ public class DetermineBasalResultSMB extends APSResult { if (result.has("carbsReq")) carbsReq = result.getDouble("carbsReq"); if (result.has("rate") && result.has("duration")) { - tempBasalReqested = true; + tempBasalRequested = true; rate = result.getDouble("rate"); if (rate < 0d) rate = 0d; duration = result.getInt("duration"); @@ -74,7 +74,7 @@ public class DetermineBasalResultSMB extends APSResult { newResult.reason = reason; newResult.rate = rate; newResult.duration = duration; - newResult.tempBasalReqested = tempBasalReqested; + newResult.tempBasalRequested = tempBasalRequested; newResult.bolusRequested = bolusRequested; newResult.rate = rate; newResult.duration = duration; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index f10e6cb0be..778b9d5849 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -251,16 +251,16 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface { // TODO still needed with oref1? // Fix bug determine basal if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress()) - determineBasalResultSMB.tempBasalReqested = false; + determineBasalResultSMB.tempBasalRequested = false; // limit requests on openloop mode if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now); if (activeTemp != null && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) { // going to cancel } else if (activeTemp != null && Math.abs(determineBasalResultSMB.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) { - determineBasalResultSMB.tempBasalReqested = false; + determineBasalResultSMB.tempBasalRequested = false; } else if (activeTemp == null && Math.abs(determineBasalResultSMB.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1) - determineBasalResultSMB.tempBasalReqested = false; + determineBasalResultSMB.tempBasalRequested = false; } determineBasalResultSMB.iob = iobArray[0];