Merge pull request #1101 from PoweRGbg/dev

setting user options on DanaR
This commit is contained in:
Milos Kozak 2018-06-13 18:22:56 +02:00 committed by GitHub
commit c568ff61e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 29 deletions

View file

@ -161,7 +161,7 @@ public class DanaRPump {
public int lowReservoirRate; public int lowReservoirRate;
public int cannulaVolume; public int cannulaVolume;
public int refillAmount; public int refillAmount;
public byte[] userOptionsFrompump;
public double initialBolusAmount; public double initialBolusAmount;
// Bolus settings // Bolus settings
public int bolusCalculationOption; public int bolusCalculationOption;

View file

@ -153,6 +153,14 @@ public class DanaRUserOptionsActivity extends Activity {
pump.buttonScrollOnOff = 1; pump.buttonScrollOnOff = 1;
else else
pump.buttonScrollOnOff = 0; pump.buttonScrollOnOff = 0;
pump.beepAndAlarm = 1; // default
if (pumpAlarmSound.isChecked()) pump.beepAndAlarm = 1;
else if (pumpAlarmVibrate.isChecked()) pump.beepAndAlarm = 2;
else if (pumpAlarmBoth.isChecked()) pump.beepAndAlarm = 3;
if (beep.isChecked()) pump.beepAndAlarm += 4;
// step is 5 seconds // step is 5 seconds
int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5: 5; int screenTimeoutValue = !screenTimeout.getText().isEmpty() ? (Integer.parseInt(screenTimeout.getText().toString()) / 5) * 5: 5;
if (screenTimeoutValue > 4 && screenTimeoutValue < 241) { if (screenTimeoutValue > 4 && screenTimeoutValue < 241) {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import android.support.v4.internal.view.SupportMenu;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
@ -11,40 +12,33 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
*/ */
public class MsgSetUserOptions extends MessageBase { public class MsgSetUserOptions extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgSetUserOptions.class);
public boolean done; public boolean done;
public MsgSetUserOptions() { public MsgSetUserOptions() {
SetCommand(0x330B); SetCommand(0x330B);
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
if (pump.userOptionsFrompump == null) {
log.debug(" initializing MsgSetUserOptions"); // No options set -> Exitting
log.debug("timeDisplayType: " + (byte) pump.timeDisplayType); log.debug("NO USER OPTIONS LOADED EXITTING!");
log.debug("Button scroll: " + (byte) pump.buttonScrollOnOff); return;
log.debug("BeepAndAlarm: " + (byte) pump.beepAndAlarm); }
log.debug("screen timeout: " + (byte) pump.lcdOnTimeSec); pump.userOptionsFrompump[0] = (byte) (pump.timeDisplayType == 1 ? 0 : 1);
log.debug("Backlight: " + (byte) pump.backlightOnTimeSec); pump.userOptionsFrompump[1] = (byte) pump.buttonScrollOnOff;
log.debug("Selected language: " + (byte) pump.selectedLanguage); pump.userOptionsFrompump[2] = (byte) pump.beepAndAlarm;
log.debug("Units: " + (byte) pump.units); pump.userOptionsFrompump[3] = (byte) pump.lcdOnTimeSec;
log.debug("Shutdown: " + (byte) pump.shutdownHour); pump.userOptionsFrompump[4] = (byte) pump.backlightOnTimeSec;
log.debug("Low reservoir: " + (byte) pump.lowReservoirRate); pump.userOptionsFrompump[5] = (byte) pump.selectedLanguage;
// need to organize here pump.userOptionsFrompump[8] = (byte) pump.units;
// glucoseunit is at pos 8 and lowReservoirRate is at pos 27 pump.userOptionsFrompump[9] = (byte) pump.shutdownHour;
AddParamByte((byte) pump.timeDisplayType); pump.userOptionsFrompump[27] = (byte) pump.lowReservoirRate;
AddParamByte((byte) pump.buttonScrollOnOff); for(int i=0; i<pump.userOptionsFrompump.length; i++){
AddParamByte((byte) pump.beepAndAlarm); AddParamByte(pump.userOptionsFrompump[i]);
AddParamByte((byte) pump.lcdOnTimeSec); }
AddParamByte((byte) pump.backlightOnTimeSec);
AddParamByte((byte) pump.selectedLanguage);
AddParamByte((byte) pump.units);
AddParamByte((byte) pump.shutdownHour);
AddParamByte((byte) pump.lowReservoirRate);
} }
private static Logger log = LoggerFactory.getLogger(MsgSetUserOptions.class);
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
log.debug("Entering handleMessage ");
int result = intFromBuff(bytes, 0, 1); int result = intFromBuff(bytes, 0, 1);
if (result != 1) { if (result != 1) {
failed = true; failed = true;

View file

@ -3,6 +3,9 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays;
import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
/** /**
@ -20,6 +23,7 @@ public class MsgSettingUserOptions extends MessageBase {
public void handleMessage(byte[] packet) { public void handleMessage(byte[] packet) {
DanaRPump pump = DanaRPump.getInstance(); DanaRPump pump = DanaRPump.getInstance();
byte[] bytes = getDataBytes(packet, 0, packet.length - 10); byte[] bytes = getDataBytes(packet, 0, packet.length - 10);
pump.userOptionsFrompump = Arrays.copyOf(bytes, bytes.length);// saving pumpDataBytes to use it in MsgSetUserOptions
for(int pos=0; pos < bytes.length; pos++) { for(int pos=0; pos < bytes.length; pos++) {
log.debug("[" + pos + "]" + bytes[pos]); log.debug("[" + pos + "]" + bytes[pos]);
} }
@ -39,7 +43,7 @@ public class MsgSettingUserOptions extends MessageBase {
int selectableLanguage5 = bytes[14]; int selectableLanguage5 = bytes[14];
*/ */
// if (Config.logDanaMessageDetail) { if (Config.logDanaMessageDetail) {
log.debug("timeDisplayType: " + pump.timeDisplayType); log.debug("timeDisplayType: " + pump.timeDisplayType);
log.debug("Button scroll: " + pump.buttonScrollOnOff); log.debug("Button scroll: " + pump.buttonScrollOnOff);
@ -50,8 +54,9 @@ public class MsgSettingUserOptions extends MessageBase {
log.debug("Units: " + pump.getUnits()); log.debug("Units: " + pump.getUnits());
log.debug("Shutdown: " + pump.shutdownHour); log.debug("Shutdown: " + pump.shutdownHour);
log.debug("Low reservoir: " + pump.lowReservoirRate); log.debug("Low reservoir: " + pump.lowReservoirRate);
// }
} }
}
public static byte[] getDataBytes(byte[] bytes, int start, int len) { public static byte[] getDataBytes(byte[] bytes, int start, int len) {
if (bytes == null) { if (bytes == null) {
return null; return null;