show correct constraint in loop plugin

This commit is contained in:
Milos Kozak 2020-08-26 18:12:03 +02:00
parent 8619e4156e
commit d7817792ca

View file

@ -392,7 +392,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
} }
// Prepare for pumps using % basals // Prepare for pumps using % basals
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT) { if (pump.getPumpDescription().tempBasalStyle == PumpDescription.PERCENT && allowPercentage()) {
result.usePercent = true; result.usePercent = true;
} }
result.percent = (int) (result.rate / profile.getBasal() * 100); 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) { private void applyTBRRequest(APSResult request, Profile profile, Callback callback) {
boolean allowPercentage = virtualPumpPlugin.isEnabled(PluginType.PUMP);
if (!request.tempBasalRequested) { if (!request.tempBasalRequested) {
if (callback != null) { if (callback != null) {
@ -681,7 +680,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now); TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now);
if (request.usePercent && allowPercentage) { if (request.usePercent && allowPercentage()) {
if (request.percent == 100 && request.duration == 0) { if (request.percent == 100 && request.duration == 0) {
if (activeTemp != null) { if (activeTemp != null) {
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()"); getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
@ -784,6 +783,10 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
commandQueue.bolus(detailedBolusInfo, callback); commandQueue.bolus(detailedBolusInfo, callback);
} }
private boolean allowPercentage() {
return virtualPumpPlugin.isEnabled(PluginType.PUMP);
}
public void disconnectPump(int durationInMinutes, Profile profile) { public void disconnectPump(int durationInMinutes, Profile profile) {
PumpInterface pump = activePlugin.getActivePump(); PumpInterface pump = activePlugin.getActivePump();