From faab8fbc67b647c984c1f033eb04cf479a0f76e2 Mon Sep 17 00:00:00 2001 From: PoweRGbg Date: Wed, 13 Jun 2018 11:43:44 +0300 Subject: [PATCH] setting full userOptions --- .../plugins/PumpDanaR/DanaRPump.java | 2 +- .../PumpDanaR/comm/MsgSetUserOptions.java | 34 +++++++++++-------- .../PumpDanaR/comm/MsgSettingUserOptions.java | 6 ++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java index 1e346695e3..d9bc947b84 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java @@ -161,7 +161,7 @@ public class DanaRPump { public int lowReservoirRate; public int cannulaVolume; public int refillAmount; - + public byte[] userOptionsFrompump; public double initialBolusAmount; // Bolus settings public int bolusCalculationOption; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java index 1f2552ef03..2b19936b10 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSetUserOptions.java @@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; import android.support.v4.internal.view.SupportMenu; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; /** * Created by mike on 05.07.2016. @@ -30,6 +31,13 @@ public class MsgSetUserOptions extends MessageBase { public MsgSetUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) { this(); + DanaRPump pump = DanaRPump.getInstance(); + if (pump.userOptionsFrompump.length == 0) { + // No options set -> Exitting + log.debug("NO USER OPTIONS LOADED EXITTING!"); + return; + } + log.debug(" initializing MsgSetUserOptions"); log.debug("timeDisplayType: " + (byte) timeDisplayType); log.debug("Button scroll: " + (byte) buttonScrollOnOff); @@ -51,19 +59,18 @@ public class MsgSetUserOptions extends MessageBase { this.lowReservoirRate = lowReservoirRate; this.cannulaVolume = cannulaVolume; this.refillRate = refillRate; - newOptions[0] = (byte) (timeDisplayType == 1 ? 0 : 1); - newOptions[1] = (byte) buttonScrollOnOff; - newOptions[2] = (byte) beepAndAlarm; - newOptions[3] = (byte) lcdOnTimeSec; - newOptions[4] = (byte) backlightOnTimeSec; - newOptions[5] = (byte) selectedLanguage; - newOptions[8] = (byte) glucoseUnit; - newOptions[9] = (byte) shutdownHour; - newOptions[27] = (byte) lowReservoirRate; - // need to organize here - // glucoseunit is at pos 8 and lowReservoirRate is at pos 27 - // 6 extended bolus on/off - // 10 missed bolus + pump.userOptionsFrompump[0] = (byte) (timeDisplayType == 1 ? 0 : 1); + pump.userOptionsFrompump[1] = (byte) buttonScrollOnOff; + pump.userOptionsFrompump[2] = (byte) beepAndAlarm; + pump.userOptionsFrompump[3] = (byte) lcdOnTimeSec; + pump.userOptionsFrompump[4] = (byte) backlightOnTimeSec; + pump.userOptionsFrompump[5] = (byte) selectedLanguage; + pump.userOptionsFrompump[8] = (byte) glucoseUnit; + pump.userOptionsFrompump[9] = (byte) shutdownHour; + pump.userOptionsFrompump[27] = (byte) lowReservoirRate; + for(int i=0; i