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 cannulaVolume;
public int refillAmount;
public byte[] userOptionsFrompump;
public double initialBolusAmount;
// Bolus settings
public int bolusCalculationOption;

View file

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

View file

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