From d4d1110d686731f73acf361472fe22ae583f354e Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 25 Aug 2019 14:48:00 +0100 Subject: [PATCH 1/2] - added fake method TBR Percent. If pecent is 0, it calls absolute methods with 0, if not, it calculates value, writes log and then starts absolute method --- .../plugins/pump/medtronic/MedtronicPumpPlugin.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index a16178df18..1158990cd6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -1062,6 +1062,19 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter } + @Override + public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, + boolean enforceNew) { + if (percent==0) { + return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew); + } else { + Double absoluteValue = profile.getBasal() * (percent /100.0d); + LOG.warn("setTempBasalPercent [MedtronicPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (%d). This will start setTempBasalAbsolute, with calculated value (%.2f). Result might not be 100% correct.", percent, absoluteValue); + return setTempBasalAbsolute(absoluteValue, durationInMinutes, profile, enforceNew); + } + } + + private void finishAction(String overviewKey) { if (overviewKey != null) From 2569e66bcee120298e97c79e221930cfec333271 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 25 Aug 2019 19:25:36 +0100 Subject: [PATCH 2/2] - minor change. New absoluteValue is now put through pumpType.determineCorreectBasalValue method, so that we get correct value --- .../plugins/pump/medtronic/MedtronicPumpPlugin.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java index 1158990cd6..f8568299d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicPumpPlugin.java @@ -1068,8 +1068,10 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter if (percent==0) { return setTempBasalAbsolute(0.0d, durationInMinutes, profile, enforceNew); } else { - Double absoluteValue = profile.getBasal() * (percent /100.0d); - LOG.warn("setTempBasalPercent [MedtronicPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (%d). This will start setTempBasalAbsolute, with calculated value (%.2f). Result might not be 100% correct.", percent, absoluteValue); + double absoluteValue = profile.getBasal() * (percent /100.0d); + getMDTPumpStatus(); + absoluteValue = pumpStatusLocal.pumpType.determineCorrectBasalSize(absoluteValue); + LOG.warn("setTempBasalPercent [MedtronicPumpPlugin] - You are trying to use setTempBasalPercent with percent other then 0% (%d). This will start setTempBasalAbsolute, with calculated value (%.3f). Result might not be 100% correct.", percent, absoluteValue); return setTempBasalAbsolute(absoluteValue, durationInMinutes, profile, enforceNew); } }