From f75329f5dc7e1a1218eec01b25b51884562538ff Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 2 May 2018 07:51:04 +0200 Subject: [PATCH 1/4] move COB string representation to CobInfo --- .../plugins/IobCobCalculator/CobInfo.java | 18 ++++++++++++++++++ .../wearintegration/WatchUpdaterService.java | 19 +------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java index 90b72132bd..f05d443bba 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java @@ -1,7 +1,10 @@ package info.nightscout.androidaps.plugins.IobCobCalculator; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import info.nightscout.utils.DecimalFormatter; + public class CobInfo { /** All COB up to now, including carbs not yet processed by IobCob calculation. */ @Nullable @@ -12,4 +15,19 @@ public class CobInfo { this.displayCob = displayCob; this.futureCarbs = futureCarbs; } + + @NonNull + public static String generateCOBString() { + + String cobStringResult = "--"; + CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "WatcherUpdaterService"); + if (cobInfo.displayCob != null) { + cobStringResult = DecimalFormatter.to0Decimal(cobInfo.displayCob); + if (cobInfo.futureCarbs > 0) { + cobStringResult += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"; + } + cobStringResult += "g"; + } + return cobStringResult; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 0d809a7bab..e999a9f4b9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -42,8 +42,6 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; -import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; -import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; @@ -592,7 +590,7 @@ public class WatchUpdaterService extends WearableListenerService implements iobSum = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); iobDetail = "(" + DecimalFormatter.to2Decimal(bolusIob.iob) + "|" + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")"; - cobString = generateCOBString(); + cobString = CobInfo.generateCOBString(); currentBasal = generateBasalString(treatmentsInterface); //bgi @@ -715,21 +713,6 @@ public class WatchUpdaterService extends WearableListenerService implements return basalStringResult; } - @NonNull - private String generateCOBString() { - - String cobStringResult = "--"; - CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "WatcherUpdaterService"); - if (cobInfo.displayCob != null) { - cobStringResult = DecimalFormatter.to0Decimal(cobInfo.displayCob); - if (cobInfo.futureCarbs > 0) { - cobStringResult += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"; - } - cobStringResult += "g"; - } - return cobStringResult; - } - @Override public void onDestroy() { if (googleApiClient != null && googleApiClient.isConnected()) { From 915dac8ef3fa1bb365a62325c0bde44baa4dd108 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 2 May 2018 07:55:55 +0200 Subject: [PATCH 2/4] COB in external status --- .../androidaps/plugins/XDripStatusline/StatuslinePlugin.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java index 5ce277e399..0c5cbe5805 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/XDripStatusline/StatuslinePlugin.java @@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DecimalFormatter; @@ -130,7 +131,7 @@ public class StatuslinePlugin extends PluginBase { IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round(); treatmentsInterface.updateTotalIOBTempBasals(); IobTotal basalIob = treatmentsInterface.getLastCalculationTempBasals().round(); - status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob); + status += DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob)+"U"; if (mPrefs.getBoolean("xdripstatus_detailediob", true)) { @@ -146,6 +147,7 @@ public class StatuslinePlugin extends PluginBase { double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf(); status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi); + status += " " + CobInfo.generateCOBString(); return status; } From c445c078e11824fdeb6080a37057c0f51abe5fcd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 2 May 2018 07:57:29 +0200 Subject: [PATCH 3/4] add g to default COB as well --- .../nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java index f05d443bba..c7213b9f51 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/CobInfo.java @@ -19,7 +19,7 @@ public class CobInfo { @NonNull public static String generateCOBString() { - String cobStringResult = "--"; + String cobStringResult = "--g"; CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "WatcherUpdaterService"); if (cobInfo.displayCob != null) { cobStringResult = DecimalFormatter.to0Decimal(cobInfo.displayCob); From 24bd509ec63e8c192c71f6e5998c34dbfdcd9969 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 2 May 2018 08:04:34 +0200 Subject: [PATCH 4/4] COB in ongoing notification --- .../PersistentNotificationPlugin.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index 68ff7cec69..332b308ade 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -35,6 +35,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.IobCobCalculator.CobInfo; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.utils.DecimalFormatter; @@ -125,11 +126,9 @@ public class PersistentNotificationPlugin extends PluginBase { IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round(); IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round(); - String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U (" - + ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U " - + ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)"; - + String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob)+": " + CobInfo.generateCOBString(); + String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h";