Merge pull request #959 from MilosKozak/cob-status

New COB status for external status and ongoing notifiaction
This commit is contained in:
Milos Kozak 2018-05-02 11:08:49 +02:00 committed by GitHub
commit 6fa3c04db8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 23 deletions

View file

@ -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 = "--g";
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;
}
}

View file

@ -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";

View file

@ -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()) {

View file

@ -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;
}