From 0e40d1e7ef61045466956b2baba6b6627b4e331f Mon Sep 17 00:00:00 2001 From: PoweRGbg Date: Wed, 13 Jun 2018 09:49:35 +0300 Subject: [PATCH] Revert "Revert "more debugging output"" This reverts commit 209fb79396816b7d0f48e58570cf2d6261deaa98. --- .../PumpDanaR/comm/MsgGetUserOptions.java | 26 +++++------------- .../PumpDanaR/comm/MsgSettingUserOptions.java | 27 ++++++++++--------- .../plugins/PumpDanaRv2/DanaRv2Plugin.java | 1 - .../services/DanaRv2ExecutionService.java | 15 +++-------- 4 files changed, 24 insertions(+), 45 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java index aeffbd66df..2238f5b9c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgGetUserOptions.java @@ -11,25 +11,9 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; */ public class MsgGetUserOptions extends MessageBase { - private int backlightOnTimeSec; - private int beepAndAlarm; - private int buttonScrollOnOff; - private int cannulaVolume; - private int glucoseUnit; - private int lcdOnTimeSec; - private int lowReservoirRate; - private int refillRate; - private int selectableLanguage1; - private int selectableLanguage2; - private int selectableLanguage3; - private int selectableLanguage4; - private int selectableLanguage5; - private int selectedLanguage; - private int shutdownHour; - private int timeDisplayType; private static Logger log = LoggerFactory.getLogger(MsgGetUserOptions.class); - + private byte[] optionsInPump; public MsgGetUserOptions() { SetCommand(0x320B); } @@ -37,8 +21,9 @@ public class MsgGetUserOptions extends MessageBase { public void handleMessage(byte[] packet) { DanaRPump pump = DanaRPump.getInstance(); byte[] bytes = getDataBytes(packet, 0, packet.length - 10); - for(int pos=0; pos < bytes.length; pos++) { - log.debug("[" + pos + "]" + bytes[pos]); + this.optionsInPump = getDataBytes(packet, 0, packet.length - 10); + for(int pos=0; pos < packet.length; pos++) { + log.debug("[" + pos + "]" + packet[pos]); } pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; // 1 -> 24h 0 -> 12h pump.buttonScrollOnOff = bytes[1] == (byte) 1 ? 1 : 0; // 1 -> ON, 0-> OFF @@ -69,6 +54,7 @@ public class MsgGetUserOptions extends MessageBase { log.debug("Low reservoir: " + pump.lowReservoirRate); // } } + public static byte[] getDataBytes(byte[] bytes, int start, int len) { if (bytes == null) { return null; @@ -77,4 +63,6 @@ public class MsgGetUserOptions extends MessageBase { System.arraycopy(bytes, start + 6, ret, 0, len); return ret; } + + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java index d0e7faf678..51c37b1217 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingUserOptions.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import android.support.v4.internal.view.SupportMenu; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; @@ -23,7 +24,7 @@ public class MsgSettingUserOptions extends MessageBase { private int selectedLanguage; private int shutdownHour; private int timeDisplayType; - + byte[] newOptions; public boolean done; public MsgSettingUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) { @@ -49,17 +50,19 @@ public class MsgSettingUserOptions 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 - AddParamByte((byte) timeDisplayType); - AddParamByte((byte) buttonScrollOnOff); - AddParamByte((byte) beepAndAlarm); - AddParamByte((byte) lcdOnTimeSec); - AddParamByte((byte) backlightOnTimeSec); - AddParamByte((byte) selectedLanguage); - AddParamByte((byte) glucoseUnit); - AddParamByte((byte) shutdownHour); - AddParamByte((byte) lowReservoirRate); + // 6 extended bolus on/off + // 10 missed bolus } ======= @@ -75,6 +78,7 @@ public class MsgSettingUserOptions extends MessageBase { <<<<<<< HEAD public void handleMessage(byte[] bytes) { log.debug("Entering handleMessage "); + newOptions = new byte[]{bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[15], bytes[16], bytes[17], bytes[18], bytes[19], bytes[20], bytes[21], bytes[22], bytes[23], bytes[24], bytes[25], bytes[26], bytes[27], bytes[28], bytes[29], bytes[30], bytes[31], bytes[32]}; int result = intFromBuff(bytes, 0, 1); if (result != 1) { failed = true; @@ -129,7 +133,6 @@ public class MsgSettingUserOptions extends MessageBase { } <<<<<<< HEAD -<<<<<<< HEAD public byte[] getCommByte(int cmd, byte[] data) { int len = (data == null ? 0 : data.length) + 3; byte[] btSendData = new byte[(len + 7)]; @@ -177,6 +180,4 @@ public class MsgSettingUserOptions extends MessageBase { ======= >>>>>>> upstream/rsoption -======= ->>>>>>> parent of f1f8bae2d... more debugging output } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index 26692058ff..517fb914c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -393,7 +393,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin { public PumpEnactResult setUserOptions() { <<<<<<< HEAD DanaRv2ExecutionService service = new DanaRv2ExecutionService(); - log.debug("MsgSetUserOptions executed!"); return service.setUserOptions(); ======= return sExecutionService.setUserOptions(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 2f84581393..a76856996b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -200,12 +200,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mSerialIOThread.sendMessage(new MsgSettingGlucose()); mSerialIOThread.sendMessage(new MsgSettingActiveProfile()); mSerialIOThread.sendMessage(new MsgSettingProfileRatios()); -<<<<<<< HEAD <<<<<<< HEAD //added by Roumen for testing and -======= - //added by Roumen for testing ->>>>>>> parent of f1f8bae2d... more debugging output mSerialIOThread.sendMessage(new MsgGetUserOptions()); ======= mSerialIOThread.sendMessage(new MsgSettingUserOptions()); @@ -486,9 +482,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { public PumpEnactResult setUserOptions() { <<<<<<< HEAD if (!isConnected()) { - log.debug("MsgSetUserOptions - service is not connected"); -// return new PumpEnactResult().success(false); - connect(); + return new PumpEnactResult().success(false); } ======= if (!isConnected()) @@ -504,14 +498,11 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { <<<<<<< HEAD public PumpEnactResult getUserOptions() { if (!isConnected()) { - log.debug("MsgGetUserOptions fails - disconnected!"); - connect(); -// return new PumpEnactResult().success(false); + return new PumpEnactResult().success(false); } MsgGetUserOptions msg = new MsgGetUserOptions(); -// mSerialIOThread.sendMessage(msg); // == null + mSerialIOThread.sendMessage(msg); mDanaRPump.lastConnection = System.currentTimeMillis(); - log.debug("MsgGetUserOptions executed!"); return new PumpEnactResult().success(true); } =======