From 6ecdd4d7fc21ad9e4016f8c3fa7a58a491a1d5df Mon Sep 17 00:00:00 2001 From: Tim Gunn <2896311+Tornado-Tim@users.noreply.github.com> Date: Sun, 7 Mar 2021 02:53:01 +1300 Subject: [PATCH 1/3] Add appropriate constraint so isLgsAllowed Constraint can be properly checked --- .../plugins/configBuilder/ConstraintChecker.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt index 111dcd5b79..07b4f8f66b 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConstraintChecker.kt @@ -18,6 +18,9 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug fun isClosedLoopAllowed(): Constraint = isClosedLoopAllowed(Constraint(true)) + fun isLgsAllowed(): Constraint = + isLgsAllowed(Constraint(true)) + fun isAutosensModeEnabled(): Constraint = isAutosensModeEnabled(Constraint(true)) @@ -77,6 +80,16 @@ class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlug return value } + override fun isLgsAllowed(value: Constraint): Constraint { + val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java) + for (p in constraintsPlugins) { + val constraint = p as ConstraintsInterface + if (!p.isEnabled(PluginType.CONSTRAINTS)) continue + constraint.isLgsAllowed(value) + } + return value + } + override fun isAutosensModeEnabled(value: Constraint): Constraint { val constraintsPlugins = activePlugin.getSpecificPluginsListByInterface(ConstraintsInterface::class.java) for (p in constraintsPlugins) { From 2738cf7fcecce9eb08810f36e1db3cdace5421ac Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 7 Mar 2021 00:46:53 +0000 Subject: [PATCH 2/3] - TBR was incorrectly interpretted for high TBR values --- .../pump/MedtronicPumpHistoryDecoder.java | 14 ++++++++--- .../medtronic/data/dto/TempBasalPair.java | 25 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java index 124b98f880..682d887ff2 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/history/pump/MedtronicPumpHistoryDecoder.java @@ -106,7 +106,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder> 3) == 0); +// TempBasalPair tbr = new TempBasalPair( +// tbrRate.getHead()[0], +// tbrDuration.getHead()[0], +// (ByteUtil.asUINT8(tbrRate.getDatetime()[4]) >> 3) == 0); + + TempBasalPair tbr = new TempBasalPair( + tbrRate.getHead()[0], + tbrRate.getBody()[0], + tbrDuration.getHead()[0], + (ByteUtil.asUINT8(tbrRate.getDatetime()[4]) >> 3) == 0); // System.out.println("TBR: amount=" + tbr.getInsulinRate() + ", duration=" + tbr.getDurationMinutes() // // + " min. Packed: " + tbr.getValue() diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java index 5fa8f3966e..0a5e78427c 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java @@ -1,5 +1,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; +import android.util.Log; + import androidx.annotation.NonNull; import java.util.ArrayList; @@ -38,6 +40,29 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo } + /** + * This constructor is for use with PumpHistoryDecoder + * + * @param rateByte0 + * @param startTimeByte + * @param isPercent + */ + public TempBasalPair(byte rateByte0, byte rateByte1, int startTimeByte, boolean isPercent) { + // int rateInt = ByteUtil.asUINT8(rateByte0); + + if (isPercent) { + this.insulinRate = rateByte0; + } else { + int rateInt2 = ByteUtil.toInt(rateByte1, rateByte0); + int rateInt3 = (rateByte1 & 0x7) << 8 | rateByte0; + this.insulinRate = rateInt2 * 0.025; + Log.d("ddd", "OldRate=" + this.insulinRate + ", NewRate=" + rateInt2 * 0.025 + ", NewRate2=" + + rateInt2 * 0.1 + ", NNNRate=" + rateInt3 * 0.025); + } + this.durationMinutes = startTimeByte * 30; + this.isPercent = isPercent; + } + public TempBasalPair(AAPSLogger aapsLogger, byte[] response) { super(); From 4232679c06e002494cdf6731188b5f385f4f1ed6 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 7 Mar 2021 00:57:13 +0000 Subject: [PATCH 3/3] - small change (removed unneeded code) --- .../plugins/pump/medtronic/data/dto/TempBasalPair.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java index 0a5e78427c..86e5c9bd36 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/TempBasalPair.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.plugins.pump.medtronic.data.dto; -import android.util.Log; - import androidx.annotation.NonNull; import java.util.ArrayList; @@ -48,16 +46,10 @@ public class TempBasalPair extends info.nightscout.androidaps.plugins.pump.commo * @param isPercent */ public TempBasalPair(byte rateByte0, byte rateByte1, int startTimeByte, boolean isPercent) { - // int rateInt = ByteUtil.asUINT8(rateByte0); - if (isPercent) { this.insulinRate = rateByte0; } else { - int rateInt2 = ByteUtil.toInt(rateByte1, rateByte0); - int rateInt3 = (rateByte1 & 0x7) << 8 | rateByte0; - this.insulinRate = rateInt2 * 0.025; - Log.d("ddd", "OldRate=" + this.insulinRate + ", NewRate=" + rateInt2 * 0.025 + ", NewRate2=" - + rateInt2 * 0.1 + ", NNNRate=" + rateInt3 * 0.025); + this.insulinRate = ByteUtil.toInt(rateByte1, rateByte0) * 0.025; } this.durationMinutes = startTimeByte * 30; this.isPercent = isPercent;