From d7817792cab8a86bf12bceef8561a7bf5cce67ea Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 26 Aug 2020 18:12:03 +0200 Subject: [PATCH] show correct constraint in loop plugin --- .../androidaps/plugins/aps/loop/LoopPlugin.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java index ba01db465c..0040dbc6fc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/loop/LoopPlugin.java @@ -392,7 +392,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { } // Prepare for pumps using % basals - if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT) { + if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) { result.usePercent = true; } result.percent = (int) (result.rate / profile.getBasal() * 100); @@ -650,7 +650,6 @@ public class LoopPlugin extends PluginBase implements LoopInterface { */ private void applyTBRRequest(APSResult request, Profile profile, Callback callback) { - boolean allowPercentage = virtualPumpPlugin.isEnabled(PluginType.PUMP); if (!request.tempBasalRequested) { if (callback != null) { @@ -681,7 +680,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface { long now = System.currentTimeMillis(); TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now); - if (request.usePercent && allowPercentage) { + if (request.usePercent && allowPercentage()) { if (request.percent == 100 && request.duration == 0) { if (activeTemp != null) { getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); @@ -784,6 +783,10 @@ public class LoopPlugin extends PluginBase implements LoopInterface { commandQueue.bolus(detailedBolusInfo, callback); } + private boolean allowPercentage() { + return virtualPumpPlugin.isEnabled(PluginType.PUMP); + } + public void disconnectPump(int durationInMinutes, Profile profile) { PumpInterface pump = activePlugin.getActivePump();