diff --git a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java index 07ca0fc049..5faa288d77 100644 --- a/app/src/main/java/info/nightscout/androidaps/Services/DataService.java +++ b/app/src/main/java/info/nightscout/androidaps/Services/DataService.java @@ -192,7 +192,7 @@ public class DataService extends IntentService { bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP); bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW); - MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP", xDripEnabled); + MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP"); } private void handleNewDataFromGlimp(Intent intent) { @@ -206,7 +206,7 @@ public class DataService extends IntentService { bgReading.date = bundle.getLong("myTimestamp"); bgReading.raw = 0; - MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP", glimpEnabled); + MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP"); } private void handleNewDataFromDexcomG5(Intent intent) { @@ -229,7 +229,7 @@ public class DataService extends IntentService { bgReading.direction = json.getString("m_trend"); bgReading.date = json.getLong("m_time") * 1000L; bgReading.raw = 0; - boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5", dexcomG5Enabled); + boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "DexcomG5"); if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) { NSUpload.uploadBg(bgReading); } @@ -268,7 +268,7 @@ public class DataService extends IntentService { bgReading.date = json_object.getLong("date"); bgReading.raw = json_object.getDouble("sgv"); - MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g", mm640gEnabled); + MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g"); break; default: log.debug("Unknown entries type: " + type); @@ -425,7 +425,7 @@ public class DataService extends IntentService { JSONObject sgvJson = new JSONObject(sgvstring); NSSgv nsSgv = new NSSgv(sgvJson); BgReading bgReading = new BgReading(nsSgv); - MainApp.getDbHelper().createIfNotExists(bgReading, "NS", nsClientEnabled); + MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); } if (bundles.containsKey("sgvs")) { @@ -435,7 +435,7 @@ public class DataService extends IntentService { JSONObject sgvJson = jsonArray.getJSONObject(i); NSSgv nsSgv = new NSSgv(sgvJson); BgReading bgReading = new BgReading(nsSgv); - MainApp.getDbHelper().createIfNotExists(bgReading, "NS", nsClientEnabled); + MainApp.getDbHelper().createIfNotExists(bgReading, "NS"); } } } catch (Exception e) { 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..264a153c5e 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java +++ b/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java @@ -97,19 +97,23 @@ public class PumpEnactResult { if (bolusDelivered > 0) { ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; - ret += "\n" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; + ret += "\n" + MainApp.sResources.getString(R.string.smb_shortname) + + ": " + bolusDelivered + " " + MainApp.gs(R.string.insulin_unit_shortname); } 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,26 +130,26 @@ 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; - ret += "
" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; + if (!comment.isEmpty()) + ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + ret += "
" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + " " + MainApp.gs(R.string.insulin_unit_shortname); } else if (isTempCancel) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment + "
" + 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/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 041f92ab84..68b506b37a 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -8,6 +8,7 @@ import android.support.annotation.Nullable; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.dao.CloseableIterator; import com.j256.ormlite.dao.Dao; +import com.j256.ormlite.dao.DaoManager; import com.j256.ormlite.stmt.PreparedQuery; import com.j256.ormlite.stmt.QueryBuilder; import com.j256.ormlite.stmt.Where; @@ -240,7 +241,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { log.error("Unhandled exception", e); } VirtualPumpPlugin.setFakingStatus(true); - scheduleBgChange(null, false, false); // trigger refresh + scheduleBgChange(null); // trigger refresh scheduleTemporaryBasalChange(); scheduleTreatmentChange(null); scheduleExtendedBolusChange(); @@ -366,14 +367,14 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } // ------------------- BgReading handling ----------------------- - public boolean createIfNotExists(BgReading bgReading, String from, boolean isFromActiveBgSource) { + public boolean createIfNotExists(BgReading bgReading, String from) { try { bgReading.date = roundDateToSec(bgReading.date); BgReading old = getDaoBgReadings().queryForId(bgReading.date); if (old == null) { getDaoBgReadings().create(bgReading); log.debug("BG: New record from: " + from + " " + bgReading.toString()); - scheduleBgChange(bgReading, true, isFromActiveBgSource); + scheduleBgChange(bgReading); return true; } if (!old.isEqual(bgReading)) { @@ -381,7 +382,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { old.copyFrom(bgReading); getDaoBgReadings().update(old); log.debug("BG: Updating record from: " + from + " New data: " + old.toString()); - scheduleBgChange(bgReading, false, isFromActiveBgSource); + scheduleBgChange(bgReading); return false; } } catch (SQLException e) { @@ -399,11 +400,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { } } - private static void scheduleBgChange(@Nullable final BgReading bgReading, boolean isNew, boolean isFromActiveBgSource) { + private static void scheduleBgChange(@Nullable final BgReading bgReading) { class PostRunnable implements Runnable { public void run() { log.debug("Firing EventNewBg"); - MainApp.bus().post(new EventNewBG(bgReading, isNew, isFromActiveBgSource)); + MainApp.bus().post(new EventNewBG(bgReading)); scheduledBgPost = null; } } diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java index e65c02a58c..dc4d434e0a 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java +++ b/app/src/main/java/info/nightscout/androidaps/events/EventNewBG.java @@ -10,17 +10,8 @@ import info.nightscout.androidaps.db.BgReading; public class EventNewBG extends EventLoop { @Nullable public final BgReading bgReading; - public final boolean isNew; - public final boolean isFromActiveBgSource; - /** Whether the BgReading is current (enough to use for treatment decisions). */ - public boolean isCurrent() { - return bgReading != null && bgReading.date + 9 * 60 * 1000 > System.currentTimeMillis(); - } - - public EventNewBG(@Nullable BgReading bgReading, boolean isNew, boolean isFromActiveBgSource) { + public EventNewBG(BgReading bgReading) { this.bgReading = bgReading; - this.isNew = isNew; - this.isFromActiveBgSource = isFromActiveBgSource; } } 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 351cbc2191..0b886f8332 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 @@ -351,13 +351,15 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface { * 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.tempBasalRequested) { + return; + } + PumpInterface pump = getActivePump(); request.rateConstraint = new Constraint<>(request.rate); request.rate = MainApp.getConstraintChecker().applyBasalConstraints(request.rateConstraint, profile).value(); - long now = System.currentTimeMillis(); - if (!pump.isInitialized()) { log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized)); if (callback != null) { @@ -377,37 +379,55 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface { if (Config.logCongigBuilderActions) log.debug("applyAPSRequest: " + request.toString()); - if (request.tempBasalReqested) { - TemporaryBasal activeTemp = getTempBasalFromHistory(now); - if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) { - if (activeTemp != null) { - if (Config.logCongigBuilderActions) - log.debug("applyAPSRequest: cancelTempBasal()"); - getCommandQueue().cancelTempBasal(false, callback); - } else { - if (Config.logCongigBuilderActions) - log.debug("applyAPSRequest: Basal set correctly"); - if (callback != null) { - callback.result(new PumpEnactResult().absolute(request.rate).duration(0).enacted(false).success(true).comment("Basal set correctly")).run(); - } - } - } else if (activeTemp != null - && activeTemp.getPlannedRemainingMinutes() > 5 - && Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) { + long now = System.currentTimeMillis(); + TemporaryBasal activeTemp = getTempBasalFromHistory(now); + if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) { + if (activeTemp != null) { if (Config.logCongigBuilderActions) - log.debug("applyAPSRequest: Temp basal set correctly"); - if (callback != null) { - callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile)).duration(activeTemp.getPlannedRemainingMinutes()).enacted(false).success(true).comment("Temp basal set correctly")).run(); - } + log.debug("applyAPSRequest: cancelTempBasal()"); + getCommandQueue().cancelTempBasal(false, callback); } else { if (Config.logCongigBuilderActions) - log.debug("applyAPSRequest: setTempBasalAbsolute()"); - getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback); + log.debug("applyAPSRequest: Basal set correctly"); + if (callback != null) { + callback.result(new PumpEnactResult().absolute(request.rate).duration(0) + .enacted(false).success(true).comment(MainApp.gs(R.string.basal_set_correctly))).run(); + } } + } else if (activeTemp != null + && activeTemp.getPlannedRemainingMinutes() > 5 + && request.duration - activeTemp.getPlannedRemainingMinutes() < 30 + && Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) { + if (Config.logCongigBuilderActions) + log.debug("applyAPSRequest: Temp basal set correctly"); + if (callback != null) { + callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile)) + .enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes()) + .comment(MainApp.gs(R.string.let_temp_basal_run))).run(); + } + } else { + if (Config.logCongigBuilderActions) + log.debug("applyAPSRequest: setTempBasalAbsolute()"); + getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback); } } public void applySMBRequest(APSResult request, Callback callback) { + if (!request.bolusRequested) { + return; + } + + long lastBolusTime = getLastBolusTime(); + if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { + log.debug("SMB requested but still in 3 min interval"); + if (callback != null) { + callback.result(new PumpEnactResult() + .comment(MainApp.gs(R.string.smb_frequency_exceeded)) + .enacted(false).success(false)).run(); + } + return; + } + PumpInterface pump = getActivePump(); if (!pump.isInitialized()) { @@ -429,20 +449,16 @@ public class ConfigBuilderPlugin implements PluginBase, TreatmentsInterface { if (Config.logCongigBuilderActions) log.debug("applySMBRequest: " + request.toString()); - if (request.bolusRequested) { - long lastBolusTime = getLastBolusTime(); - if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) { - log.debug("SMB requsted but still in 3 min interval"); - } else { - DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); - detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS; - detailedBolusInfo.insulin = request.smb; - detailedBolusInfo.isSMB = true; - detailedBolusInfo.source = Source.USER; - detailedBolusInfo.deliverAt = request.deliverAt; - getCommandQueue().bolus(detailedBolusInfo, callback); - } - } + // deliver SMB + DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo(); + detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS; + detailedBolusInfo.insulin = request.smb; + detailedBolusInfo.isSMB = true; + detailedBolusInfo.source = Source.USER; + detailedBolusInfo.deliverAt = request.deliverAt; + if (Config.logCongigBuilderActions) + log.debug("applyAPSRequest: bolus()"); + getCommandQueue().bolus(detailedBolusInfo, callback); } // ****** Treatments interface ***** diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 19b8e492d6..c60991253c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -531,8 +531,6 @@ public class IobCobCalculatorPlugin implements PluginBase { @Subscribe public void onEventNewBG(EventNewBG ev) { - if (!ev.isFromActiveBgSource) - return; if (this != getPlugin()) { log.debug("Ignoring event for non default instance"); 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 a1588e859f..958743234d 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 @@ -32,7 +32,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(); @@ -102,7 +102,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; newResult.json = json; @@ -226,6 +226,6 @@ public class APSResult { } public boolean isChangeRequested() { - return tempBasalReqested || bolusRequested; + return tempBasalRequested || bolusRequested; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index c5eee53c80..5879b28b73 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -159,12 +159,8 @@ public class LoopPlugin implements PluginBase { @Subscribe public void onStatusEvent(final EventAutosensCalculationFinished ev) { - if (!(ev.cause instanceof EventNewBG)) - return; - - EventNewBG bgEv = (EventNewBG) ev.cause; - if (bgEv.isNew && bgEv.isFromActiveBgSource && bgEv.isCurrent()) { - invoke("New BG", true); + if (ev.cause instanceof EventNewBG) { + invoke(ev.getClass().getSimpleName() + "(" + ev.cause.getClass().getSimpleName() + ")", true); } } @@ -337,7 +333,10 @@ public class LoopPlugin implements PluginBase { if (result.isChangeRequested()) { final PumpEnactResult waiting = new PumpEnactResult(); waiting.queued = true; - lastRun.tbrSetByPump = waiting; + if (resultAfterConstraints.tempBasalRequested) + lastRun.tbrSetByPump = waiting; + if (resultAfterConstraints.bolusRequested) + lastRun.smbSetByPump = waiting; MainApp.bus().post(new EventLoopUpdateGui()); FabricPrivacy.getInstance().logCustom(new CustomEvent("APSRequest")); MainApp.getConfigBuilder().applyTBRRequest(resultAfterConstraints, profile, new Callback() { 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 178745e3bc..49dcfdbb6e 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.getConstraintChecker().isClosedLoopAllowed().value()) { 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 2f947d3975..9bd5d5189b 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 @@ -234,16 +234,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.getConstraintChecker().isClosedLoopAllowed().value()) { 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 22860f2c27..a16734700b 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.getConstraintChecker().isClosedLoopAllowed().value()) { 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]; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index 09f123909b..eca35fba08 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -142,16 +142,14 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com @Subscribe public void onStatusEvent(final EventNewBG e) { - if (e.isFromActiveBgSource && e.isNew && e.isCurrent()) { - Activity activity = getActivity(); - if (activity != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - calculateInsulin(); - } - }); - } + Activity activity = getActivity(); + if (activity != null) + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + calculateInsulin(); + } + }); } @Subscribe 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 a68864b9c8..26d5851865 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 @@ -255,8 +255,7 @@ public class PersistentNotificationPlugin implements PluginBase { @Subscribe public void onStatusEvent(final EventNewBG ev) { - if (ev.isFromActiveBgSource && ev.isNew && ev.isCurrent()) - updateNotification(); + updateNotification(); } @Subscribe diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index d7c0a4b7c6..9753f35ea4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -233,7 +233,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis // reservoir int reservoirLevel = plugin.getPump().reservoirLevel; if (reservoirLevel != -1) { - reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.treatments_wizard_unit_label)); + reservoirView.setText(reservoirLevel + " " + MainApp.sResources.getString(R.string.insulin_unit_shortname)); } else if (ps.insulinState == PumpState.LOW) { reservoirView.setText(MainApp.gs(R.string.combo_reservoir_low)); } else if (ps.insulinState == PumpState.EMPTY) { @@ -275,7 +275,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis if (bolus != null) { long agoMsc = System.currentTimeMillis() - bolus.timestamp; double bolusMinAgo = agoMsc / 60d / 1000d; - String unit = MainApp.gs(R.string.treatments_wizard_unit_label); + String unit = MainApp.gs(R.string.insulin_unit_shortname); String ago; if ((agoMsc < 60 * 1000)) { ago = MainApp.gs(R.string.combo_pump_connected_now); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 5f3ae270cf..a4eafb3a6f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -347,7 +347,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf private BasalProfile convertProfileToComboProfile(Profile profile) { BasalProfile basalProfile = new BasalProfile(); for (int i = 0; i < 24; i++) { - double rate = profile.getBasal(Integer.valueOf(i * 60 * 60)); + double rate = profile.getBasalTimeFromMidnight(i * 60 * 60); /*The Combo pump does hava a different granularity for basal rate: * 0.01 - if below 1U/h diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index bc44c75911..5f11fc5fda 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -182,8 +182,7 @@ public class WearPlugin implements PluginBase { @Subscribe public void onStatusEvent(final EventNewBG ev) { - if (ev.isFromActiveBgSource) - sendDataToWatch(true, true, true); + sendDataToWatch(true, true, true); } @Subscribe 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 f1fd58c3f9..76e8ac9e4d 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 @@ -235,8 +235,7 @@ public class StatuslinePlugin implements PluginBase { @Subscribe public void onStatusEvent(final EventNewBG ev) { - if (ev.isFromActiveBgSource && ev.isNew && ev.isCurrent()) - sendStatus(); + sendStatus(); } @Subscribe diff --git a/app/src/main/java/info/nightscout/utils/HardLimits.java b/app/src/main/java/info/nightscout/utils/HardLimits.java index 00e42ce535..a277148d11 100644 --- a/app/src/main/java/info/nightscout/utils/HardLimits.java +++ b/app/src/main/java/info/nightscout/utils/HardLimits.java @@ -18,7 +18,7 @@ public class HardLimits { final static int ADULT = 2; final static int RESISTANTADULT = 3; - final static double[] MAXBOLUS = {5d, 10d, 17d, 21d}; + final static double[] MAXBOLUS = {5d, 10d, 17d, 25d}; // Very Hard Limits Ranges // First value is the Lowest and second value is the Highest a Limit can define @@ -40,7 +40,7 @@ public class HardLimits { public static final double MAXISF = 720; // mgdl public static final double[] MAXIOB_AMA = {3, 5, 7, 12}; - public static final double[] MAXIOB_SMB = {3, 7, 12, 22}; + public static final double[] MAXIOB_SMB = {3, 7, 12, 25}; public static final double[] MAXBASAL = {2, 5, 10, 12}; diff --git a/app/src/main/res/layout/overview_wizard_dialog.xml b/app/src/main/res/layout/overview_wizard_dialog.xml index faaae6967d..4fbdfd3614 100644 --- a/app/src/main/res/layout/overview_wizard_dialog.xml +++ b/app/src/main/res/layout/overview_wizard_dialog.xml @@ -108,7 +108,7 @@ android:gravity="left" android:minWidth="45dp" android:paddingLeft="5dp" - android:text="@string/treatments_wizard_unit_label" + android:text="@string/insulin_unit_shortname" android:textAppearance="?android:attr/textAppearanceSmall" /> diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index a8ce006ae4..1c50162d75 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -40,7 +40,7 @@ КЗ ВХ Корекция - Ед + Ед IOB от болуси Старт сега Базова базална стойност diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 9b41207756..a62329ae4b 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -139,7 +139,7 @@ Bolusové IOB Sacharidy Korekce - U + U Maximální povolený bolus [U] Maximální povolené sacharidy [g] Bezpečnost zadání ošetřeni diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 10a2d32c6f..bbe2ed5497 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -84,7 +84,7 @@ Aktives Gesamt-IOB: Gesamt-IOB: Basal-IOB - IE + IE Virtuelle Pumpe Reservoir xDrip @@ -742,4 +742,6 @@ Es wurde keine hohe TBR gesetzt, da nach der Berechnung Boluseinträge in der Pumpenhistorik gefunden wurden. Der letzte Bolus liegt mehr als 24 Stunden zurück oder liegt in der Zukunft. Prüfe bitte das Datum auf der Pumpe. Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe. + Anzahl TBRs + Anzahl Boluse diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 2dbac99d72..1b7fdf8022 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -42,7 +42,7 @@ TT Υδατάνθρακες Διόρθωση - U + U Bolus IOB Έναρξη τώρα ΕΙΚΟΝΙΚΗ ΑΝΤΛΙΑ diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3a3c46cf13..af936ed618 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -36,7 +36,7 @@ Glucosa Hidratos Carbono Corrección - U + U Bolo IOB Ejecutar ahora BOMBA VIRTUAL diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 44550e54dc..67ecda2b0f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -42,7 +42,7 @@ CT Glucides Corr - U + U Bolus IR "Exécuter maintenant " POMPE VIRTUELLE diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9877ee2535..352f802ee6 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -425,7 +425,7 @@ Sicurezza delle prestazioni Valore massimo carbo (g) Bolo massimo (U) - U + U Correzione COB Carboidrati diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index a0994b4e9f..46f1cb3525 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -40,7 +40,7 @@ 혈당 탄수화물 교정 - U + U 식사주입 IOB 지금 실행 가상 펌프 diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index a6bb2f2d34..ca73dcbffa 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -347,7 +347,7 @@ Autoscroll Geen NS API geheim op (min 12 kar.) Max toegestane bolus [E] - E + E Correctie COB Koolhydraten diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index caa88fbe76..aca835b34d 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -42,7 +42,7 @@ BG Carbohidrați Corecție - U + U Bolus IOB Fă acum POMPĂ VIRTUALĂ diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 2ebcf74b46..ddc446b62c 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -482,7 +482,7 @@ углеводы активн углеводы коррекция - ед + ед макс разрешенный болюс макс разрешенные углеводы (г) безопасность назначений diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index d4923abfbb..669f96e4e9 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -303,7 +303,7 @@ Säkerhet vid behandling Max tillåtna KH (g) Max tillåten bolus [E] - E + E Korr COB KH diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2af8624a21..536da84e9d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -42,7 +42,7 @@ TT Carbs Corr - U + U Bolus IOB Run now VIRTUAL PUMP @@ -639,8 +639,8 @@ Cancel Not all profiles loaded! Values not stored! - Accu-Chek Combo - COMBO + Accu-Chek Combo + COMBO Enable broadcasts to other apps (like xDrip). Enable local Broadcasts. ACTIVITY & FEEDBACK @@ -887,7 +887,7 @@ Enable SMB when there is temp target active (eating soon, exercise) Enable SMB with high temp targets Enable SMB when there is high temp target active (exercise) - Let current temp basal run + Let temp basal run Mute Insulin Carbs @@ -976,5 +976,7 @@ max basal multiplier max daily basal multiplier openapsma_max_iob + A bolus was delivered within the last 3 minutes, skipping SMB + Basal set correctly