setting full userOptions
This commit is contained in:
parent
eaffa66946
commit
faab8fbc67
|
@ -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;
|
||||
|
|
|
@ -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<pump.userOptionsFrompump.length; i++){
|
||||
AddParamByte(pump.userOptionsFrompump[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public MsgSetUserOptions() {
|
||||
|
@ -72,7 +79,6 @@ public class MsgSetUserOptions extends MessageBase {
|
|||
|
||||
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;
|
||||
|
|
|
@ -3,6 +3,8 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
|
||||
/**
|
||||
|
@ -20,8 +22,7 @@ public class MsgSettingUserOptions extends MessageBase {
|
|||
public void handleMessage(byte[] packet) {
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
byte[] bytes = getDataBytes(packet, 0, packet.length - 10);
|
||||
// saving pumpDataBytes to use it in MsgSetUserOptions
|
||||
pump.userOptionsFrompump = bytes;
|
||||
pump.userOptionsFrompump = Arrays.copyOf(bytes, bytes.length);// saving pumpDataBytes to use it in MsgSetUserOptions
|
||||
for(int pos=0; pos < bytes.length; pos++) {
|
||||
log.debug("[" + pos + "]" + bytes[pos]);
|
||||
}
|
||||
|
@ -54,6 +55,7 @@ public class MsgSettingUserOptions extends MessageBase {
|
|||
log.debug("Low reservoir: " + pump.lowReservoirRate);
|
||||
// }
|
||||
}
|
||||
|
||||
public static byte[] getDataBytes(byte[] bytes, int start, int len) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
|
|
Loading…
Reference in a new issue