setUserOptions cleanup
This commit is contained in:
parent
d051e081e2
commit
ecdbe2ac37
|
@ -382,6 +382,6 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserOptions() {
|
public PumpEnactResult setUserOptions() {
|
||||||
return null;
|
return sExecutionService.setUserOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR.activities;
|
package info.nightscout.androidaps.plugins.PumpDanaR.activities;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
@ -20,13 +19,10 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,19 +93,6 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
+ "\npumpUnits:" + pump.units
|
+ "\npumpUnits:" + pump.units
|
||||||
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
||||||
log.debug("isV2:"+isv2);
|
log.debug("isV2:"+isv2);
|
||||||
if(isv2 && pump.lowReservoirRate < 10){
|
|
||||||
log.debug("No user settings loaded forcing reload!");
|
|
||||||
DanaRv2Plugin.getPlugin().getUserOptions();
|
|
||||||
log.debug("UserOptionsLoaded:" + (System.currentTimeMillis() - pump.lastConnection) / 1000 + " s ago"
|
|
||||||
+ "\ntimeDisplayType:" + pump.timeDisplayType
|
|
||||||
+ "\nbuttonScroll:" + pump.buttonScrollOnOff
|
|
||||||
+ "\ntimeDisplayType:" + pump.timeDisplayType
|
|
||||||
+ "\nlcdOnTimeSec:" + pump.lcdOnTimeSec
|
|
||||||
+ "\nbacklight:" + pump.backlightOnTimeSec
|
|
||||||
+ "\npumpUnits:" + pump.units
|
|
||||||
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false);
|
screenTimeout.setParams((double) pump.lcdOnTimeSec, 5d, 240d, 5d, new DecimalFormat("1"), false);
|
||||||
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false);
|
backlightTimeout.setParams((double) pump.backlightOnTimeSec, 1d, 60d, 1d, new DecimalFormat("1"), false);
|
||||||
|
@ -164,9 +147,6 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
//exit if pump is not DanaRS, Dana!, or DanaR with upgraded firmware
|
//exit if pump is not DanaRS, Dana!, or DanaR with upgraded firmware
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDanaRv2) {
|
|
||||||
DanaRv2Plugin.getPlugin().getUserOptions();
|
|
||||||
}
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
|
||||||
if (timeFormat.isChecked())
|
if (timeFormat.isChecked())
|
||||||
|
@ -209,7 +189,7 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
DanaRv2Plugin.getPlugin().setUserOptions();
|
DanaRv2Plugin.getPlugin().setUserOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainApp.getConfigBuilder().getCommandQueue().setUserSettings(null);
|
MainApp.getConfigBuilder().getCommandQueue().setUserOptions(null);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,11 +56,11 @@ public class MessageHashTable {
|
||||||
put(new MsgSettingGlucose()); // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
|
put(new MsgSettingGlucose()); // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
|
||||||
put(new MsgSettingPumpTime()); // 0x320A CMD_SETTING_V_TIME_I
|
put(new MsgSettingPumpTime()); // 0x320A CMD_SETTING_V_TIME_I
|
||||||
put(new MsgSettingUserOptions()); // 0x320B CMD_SETTING_V_USER_OPTIONS
|
put(new MsgSettingUserOptions()); // 0x320B CMD_SETTING_V_USER_OPTIONS
|
||||||
put(new MsgGetUserOptions()); // 0x320B CMD_SETTING_V_USER_OPTIONS - trying to get uptions
|
|
||||||
put(new MsgSettingActiveProfile()); // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
put(new MsgSettingActiveProfile()); // 0x320C CMD_SETTING_V_PROFILE_NUMBER
|
||||||
put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
||||||
put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S
|
put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||||
put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
||||||
|
put(new MsgSetUserOptions()); // 0x330B CMD_SETTING_USER_OPTIONS_S
|
||||||
put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
||||||
put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE
|
put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE
|
||||||
put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL
|
put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen Georgiev on 6/11/2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
public MsgGetUserOptions() {
|
|
||||||
SetCommand(0x320B);
|
|
||||||
}
|
|
||||||
|
|
||||||
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]);
|
|
||||||
}
|
|
||||||
pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; // 1 -> 24h 0 -> 12h
|
|
||||||
pump.buttonScrollOnOff = bytes[1] == (byte) 1 ? 1 : 0; // 1 -> ON, 0-> OFF
|
|
||||||
pump.beepAndAlarm = bytes[2]; // 1 -> Sound on alarm 2-> Vibrate on alarm 3-> Both on alarm 5-> Sound + beep 6-> vibrate + beep 7-> both + beep Beep adds 4
|
|
||||||
pump.lcdOnTimeSec = bytes[3] & 255;
|
|
||||||
pump.backlightOnTimeSec = bytes[4] & 255;
|
|
||||||
pump.selectedLanguage = bytes[5]; // on DanaRv2 is that needed ?
|
|
||||||
pump.units = bytes[8];
|
|
||||||
pump.shutdownHour = bytes[9];
|
|
||||||
pump.lowReservoirRate = bytes[32] & 255;
|
|
||||||
/* int selectableLanguage1 = bytes[10];
|
|
||||||
int selectableLanguage2 = bytes[11];
|
|
||||||
int selectableLanguage3 = bytes[12];
|
|
||||||
int selectableLanguage4 = bytes[13];
|
|
||||||
int selectableLanguage5 = bytes[14];
|
|
||||||
*/
|
|
||||||
|
|
||||||
// if (Config.logDanaMessageDetail) {
|
|
||||||
|
|
||||||
log.debug("timeDisplayType: " + pump.timeDisplayType);
|
|
||||||
log.debug("Button scroll: " + pump.buttonScrollOnOff);
|
|
||||||
log.debug("BeepAndAlarm: " + pump.beepAndAlarm);
|
|
||||||
log.debug("screen timeout: " + pump.lcdOnTimeSec);
|
|
||||||
log.debug("Backlight: " + pump.backlightOnTimeSec);
|
|
||||||
log.debug("Selected language: " + pump.selectedLanguage);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
byte[] ret = new byte[len];
|
|
||||||
System.arraycopy(bytes, start + 6, ret, 0, len);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Config;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 05.07.2016.
|
||||||
|
*/
|
||||||
|
public class MsgSetUserOptions extends MessageBase {
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
log.debug("Setting user options: " + result + " FAILED!!!");
|
||||||
|
} else {
|
||||||
|
if (Config.logDanaMessageDetail)
|
||||||
|
log.debug("Setting user options: " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,80 +3,61 @@ package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.07.2016.
|
* Created by Rumen Georgiev on 6/11/2018.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class MsgSettingUserOptions extends MessageBase {
|
public class MsgSettingUserOptions extends MessageBase {
|
||||||
|
|
||||||
private int backlightOnTimeSec;
|
|
||||||
private int beepAndAlarm;
|
|
||||||
private int buttonScrollOnOff;
|
|
||||||
private int cannulaVolume;
|
|
||||||
private int error;
|
|
||||||
private int glucoseUnit;
|
|
||||||
private int lcdOnTimeSec;
|
|
||||||
private int lowReservoirRate;
|
|
||||||
private int refillRate;
|
|
||||||
private int selectedLanguage;
|
|
||||||
private int shutdownHour;
|
|
||||||
private int timeDisplayType;
|
|
||||||
|
|
||||||
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) {
|
|
||||||
this();
|
|
||||||
log.debug(" initializing MsgSetUserOptions");
|
|
||||||
log.debug("timeDisplayType: " + (byte) timeDisplayType);
|
|
||||||
log.debug("Button scroll: " + (byte) buttonScrollOnOff);
|
|
||||||
log.debug("BeepAndAlarm: " + (byte) beepAndAlarm);
|
|
||||||
log.debug("screen timeout: " + (byte) lcdOnTimeSec);
|
|
||||||
log.debug("Backlight: " + (byte) backlightOnTimeSec);
|
|
||||||
log.debug("Selected language: " + (byte) selectedLanguage);
|
|
||||||
log.debug("Units: " + (byte) glucoseUnit);
|
|
||||||
log.debug("Shutdown: " + (byte) shutdownHour);
|
|
||||||
log.debug("Low reservoir: " + (byte) lowReservoirRate);
|
|
||||||
this.timeDisplayType = timeDisplayType;
|
|
||||||
this.buttonScrollOnOff = buttonScrollOnOff;
|
|
||||||
this.beepAndAlarm = beepAndAlarm;
|
|
||||||
this.lcdOnTimeSec = lcdOnTimeSec;
|
|
||||||
this.backlightOnTimeSec = backlightOnTimeSec;
|
|
||||||
this.selectedLanguage = selectedLanguage;
|
|
||||||
this.glucoseUnit = glucoseUnit;
|
|
||||||
this.shutdownHour = shutdownHour;
|
|
||||||
this.lowReservoirRate = lowReservoirRate;
|
|
||||||
this.cannulaVolume = cannulaVolume;
|
|
||||||
this.refillRate = refillRate;
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class);
|
private static Logger log = LoggerFactory.getLogger(MsgSettingUserOptions.class);
|
||||||
|
|
||||||
public MsgSettingUserOptions() {
|
public MsgSettingUserOptions() {
|
||||||
SetCommand(0x320B);
|
SetCommand(0x320B);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
public void handleMessage(byte[] packet) {
|
||||||
log.debug("Entering handleMessage ");
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
byte[] bytes = getDataBytes(packet, 0, packet.length - 10);
|
||||||
if (result != 1) {
|
for(int pos=0; pos < bytes.length; pos++) {
|
||||||
failed = true;
|
log.debug("[" + pos + "]" + bytes[pos]);
|
||||||
log.debug("Setting user options: " + result + " FAILED!!!");
|
|
||||||
} else {
|
|
||||||
if (Config.logDanaMessageDetail)
|
|
||||||
log.debug("Setting user options: " + result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1; // 1 -> 24h 0 -> 12h
|
||||||
|
pump.buttonScrollOnOff = bytes[1] == (byte) 1 ? 1 : 0; // 1 -> ON, 0-> OFF
|
||||||
|
pump.beepAndAlarm = bytes[2]; // 1 -> Sound on alarm 2-> Vibrate on alarm 3-> Both on alarm 5-> Sound + beep 6-> vibrate + beep 7-> both + beep Beep adds 4
|
||||||
|
pump.lcdOnTimeSec = bytes[3] & 255;
|
||||||
|
pump.backlightOnTimeSec = bytes[4] & 255;
|
||||||
|
pump.selectedLanguage = bytes[5]; // on DanaRv2 is that needed ?
|
||||||
|
pump.units = bytes[8];
|
||||||
|
pump.shutdownHour = bytes[9];
|
||||||
|
pump.lowReservoirRate = bytes[32] & 255;
|
||||||
|
/* int selectableLanguage1 = bytes[10];
|
||||||
|
int selectableLanguage2 = bytes[11];
|
||||||
|
int selectableLanguage3 = bytes[12];
|
||||||
|
int selectableLanguage4 = bytes[13];
|
||||||
|
int selectableLanguage5 = bytes[14];
|
||||||
|
*/
|
||||||
|
|
||||||
|
// if (Config.logDanaMessageDetail) {
|
||||||
|
|
||||||
|
log.debug("timeDisplayType: " + pump.timeDisplayType);
|
||||||
|
log.debug("Button scroll: " + pump.buttonScrollOnOff);
|
||||||
|
log.debug("BeepAndAlarm: " + pump.beepAndAlarm);
|
||||||
|
log.debug("screen timeout: " + pump.lcdOnTimeSec);
|
||||||
|
log.debug("Backlight: " + pump.backlightOnTimeSec);
|
||||||
|
log.debug("Selected language: " + pump.selectedLanguage);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
byte[] ret = new byte[len];
|
||||||
|
System.arraycopy(bytes, start + 6, ret, 0, len);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ public abstract class AbstractDanaRExecutionService extends Service {
|
||||||
|
|
||||||
public abstract boolean extendedBolusStop();
|
public abstract boolean extendedBolusStop();
|
||||||
|
|
||||||
|
public abstract PumpEnactResult setUserOptions();
|
||||||
|
|
||||||
protected BroadcastReceiver receiver = new BroadcastReceiver() {
|
protected BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -18,8 +18,8 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgGetUserOptions;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetUserOptions;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
|
@ -64,7 +64,6 @@ import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.ToastUtils;
|
|
||||||
|
|
||||||
public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
||||||
|
|
||||||
|
@ -179,6 +178,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
long timeDiff = (mDanaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
@ -384,30 +384,6 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult getUserOptions() {
|
|
||||||
if (!isConnected())
|
|
||||||
return new PumpEnactResult().success(false);
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
|
||||||
MsgGetUserOptions msg = new MsgGetUserOptions();
|
|
||||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
|
||||||
return new PumpEnactResult().success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PumpEnactResult updateUserOptions() {
|
|
||||||
if (!isConnected())
|
|
||||||
return new PumpEnactResult().success(false);
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
|
||||||
MsgSettingUserOptions msg = new MsgSettingUserOptions(pump.timeDisplayType, pump.buttonScrollOnOff, pump.beepAndAlarm, pump.lcdOnTimeSec, pump.backlightOnTimeSec, pump.selectedLanguage, pump.units, pump.shutdownHour, pump.lowReservoirRate, 0, 0);
|
|
||||||
|
|
||||||
mSerialIOThread.sendMessage(msg);
|
|
||||||
while (!msg.done && mRfcommSocket.isConnected()) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
}
|
|
||||||
SystemClock.sleep(200);
|
|
||||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
|
||||||
return new PumpEnactResult().success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(EventAppExit event) {
|
public void onStatusEvent(EventAppExit event) {
|
||||||
if (Config.logFunctionCalls)
|
if (Config.logFunctionCalls)
|
||||||
|
@ -423,4 +399,13 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
||||||
log.debug("EventAppExit finished");
|
log.debug("EventAppExit finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PumpEnactResult setUserOptions() {
|
||||||
|
if (!isConnected())
|
||||||
|
return new PumpEnactResult().success(false);
|
||||||
|
SystemClock.sleep(300);
|
||||||
|
MsgSetUserOptions msg = new MsgSetUserOptions();
|
||||||
|
mSerialIOThread.sendMessage(msg);
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
return new PumpEnactResult().success(!msg.failed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,4 +327,9 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PumpEnactResult setUserOptions() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,15 +391,6 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserOptions() {
|
public PumpEnactResult setUserOptions() {
|
||||||
DanaRv2ExecutionService service = new DanaRv2ExecutionService();
|
return sExecutionService.setUserOptions();
|
||||||
log.debug("MsgSetUserOptions executed!");
|
|
||||||
return service.setUserOptions();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult getUserOptions() {
|
|
||||||
DanaRv2ExecutionService service = new DanaRv2ExecutionService();
|
|
||||||
log.debug("MsgGetUserOptions executed!");
|
|
||||||
return service.getUserOptions();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class MessageHashTable_v2 {
|
||||||
put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
put(new MsgSettingProfileRatiosAll()); // 0x320D CMD_SETTING_V_CIR_CF_VALUE
|
||||||
put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S
|
put(new MsgSetSingleBasalProfile()); // 0x3302 CMD_SETTING_BASAL_INS_S
|
||||||
put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
put(new MsgSetBasalProfile()); // 0x3306 CMD_SETTING_BASAL_PROFILE_S
|
||||||
|
put(new MsgSetUserOptions()); // 0x330B CMD_SETTING_USER_OPTIONS_S
|
||||||
put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
put(new MsgSetActivateBasalProfile()); // 0x330C CMD_SETTING_PROFILE_NUMBER_S
|
||||||
put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE
|
put(new MsgHistoryAllDone()); // 0x41F1 CMD_HISTORY_ALL_DONE
|
||||||
put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL
|
put(new MsgHistoryAll()); // 0x41F2 CMD_HISTORY_ALL
|
||||||
|
|
|
@ -18,8 +18,8 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgGetUserOptions;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSettingUserOptions;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgSetUserOptions;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
|
@ -70,7 +70,6 @@ import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.T;
|
import info.nightscout.utils.T;
|
||||||
import info.nightscout.utils.ToastUtils;
|
|
||||||
|
|
||||||
public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
|
|
||||||
|
@ -201,8 +200,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
//added by Roumen for testing
|
mSerialIOThread.sendMessage(new MsgSettingUserOptions());
|
||||||
mSerialIOThread.sendMessage(new MsgGetUserOptions());
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumptime)));
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
@ -477,38 +475,13 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult setUserOptions() {
|
public PumpEnactResult setUserOptions() {
|
||||||
if (!isConnected()) {
|
if (!isConnected())
|
||||||
log.debug("MsgSetUserOptions - service is not connected");
|
return new PumpEnactResult().success(false);
|
||||||
// return new PumpEnactResult().success(false);
|
|
||||||
connect();
|
|
||||||
}
|
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(300);
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
MsgSetUserOptions msg = new MsgSetUserOptions();
|
||||||
MsgSettingUserOptions msg = new MsgSettingUserOptions(pump.timeDisplayType, pump.buttonScrollOnOff, pump.beepAndAlarm, pump.lcdOnTimeSec, pump.backlightOnTimeSec, pump.selectedLanguage, pump.units, pump.shutdownHour, pump.lowReservoirRate, 0, 0);
|
|
||||||
if (mSerialIOThread != null) {
|
|
||||||
mSerialIOThread.disconnect("MsgSetUserOptions - Recreate SerialIOThread");
|
|
||||||
}
|
|
||||||
mSerialIOThread = new SerialIOThread(mRfcommSocket);
|
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTED, 0));
|
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
while (!msg.done && mRfcommSocket.isConnected()) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
}
|
|
||||||
SystemClock.sleep(200);
|
SystemClock.sleep(200);
|
||||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
return new PumpEnactResult().success(!msg.failed);
|
||||||
return new PumpEnactResult().success(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult getUserOptions() {
|
|
||||||
if (!isConnected()) {
|
|
||||||
log.debug("MsgGetUserOptions fails - disconnected!");
|
|
||||||
connect();
|
|
||||||
// return new PumpEnactResult().success(false);
|
|
||||||
}
|
|
||||||
MsgGetUserOptions msg = new MsgGetUserOptions();
|
|
||||||
// mSerialIOThread.sendMessage(msg); // == null
|
|
||||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
|
||||||
log.debug("MsgGetUserOptions executed!");
|
|
||||||
return new PumpEnactResult().success(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ public class CommandQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if command is queued
|
// returns true if command is queued
|
||||||
public boolean setUserSettings(Callback callback) {
|
public boolean setUserOptions(Callback callback) {
|
||||||
if (isRunning(Command.CommandType.SETUSERSETTINGS)) {
|
if (isRunning(Command.CommandType.SETUSERSETTINGS)) {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(executingNowError()).run();
|
callback.result(executingNowError()).run();
|
||||||
|
|
Loading…
Reference in a new issue