Merge pull request #1099 from PoweRGbg/dev
getting userOptions from v2 works
This commit is contained in:
commit
b5eff7baab
12 changed files with 165 additions and 37 deletions
|
@ -9,5 +9,5 @@ import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
public interface DanaRInterface {
|
public interface DanaRInterface {
|
||||||
PumpEnactResult loadHistory(byte type); // for history browser
|
PumpEnactResult loadHistory(byte type); // for history browser
|
||||||
PumpEnactResult loadEvents(); // events history to build treatments from
|
PumpEnactResult loadEvents(); // events history to build treatments from
|
||||||
PumpEnactResult setUserSettings(); // like AnyDana does
|
PumpEnactResult setUserOptions(); // like AnyDana does
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserSettings() {
|
public PumpEnactResult setUserOptions() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,11 @@ 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.Overview.Dialogs.ErrorHelperActivity;
|
||||||
|
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.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.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
|
|
||||||
|
@ -81,8 +83,7 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
|
|
||||||
saveToPumpButton.setOnClickListener(v -> onSaveClick());
|
saveToPumpButton.setOnClickListener(v -> onSaveClick());
|
||||||
|
|
||||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
|
boolean isv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||||
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
|
|
||||||
|
|
||||||
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
@ -95,13 +96,42 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
+ "\nbacklight:" + pump.backlightOnTimeSec
|
+ "\nbacklight:" + pump.backlightOnTimeSec
|
||||||
+ "\npumpUnits:" + pump.units
|
+ "\npumpUnits:" + pump.units
|
||||||
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
+ "\nlowReservoir:" + pump.lowReservoirRate);
|
||||||
|
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);
|
||||||
shutdown.setParams((double) pump.shutdownHour, 0d, 24d, 1d, new DecimalFormat("1"), true);
|
shutdown.setParams((double) pump.shutdownHour, 0d, 24d, 1d, new DecimalFormat("1"), true);
|
||||||
lowReservoir.setParams((double) pump.lowReservoirRate, 10d, 60d, 10d, new DecimalFormat("10"), false);
|
lowReservoir.setParams((double) pump.lowReservoirRate, 10d, 60d, 10d, new DecimalFormat("10"), false);
|
||||||
|
switch (pump.beepAndAlarm) {
|
||||||
|
case 1: pumpAlarmSound.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 2: pumpAlarmVibrate.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 3: pumpAlarmBoth.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 5: pumpAlarmSound.setChecked(true);
|
||||||
|
beep.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 6: pumpAlarmVibrate.setChecked(true);
|
||||||
|
beep.setChecked(true);
|
||||||
|
break;
|
||||||
|
case 7: pumpAlarmBoth.setChecked(true);
|
||||||
|
beep.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (pump.lastSettingsRead == 0)
|
if (pump.lastSettingsRead == 0)
|
||||||
log.debug("No settings loaded from pump!");
|
log.debug("No settings loaded from pump!");
|
||||||
else
|
else
|
||||||
|
@ -111,9 +141,9 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
public void setData() {
|
public void setData() {
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
|
||||||
timeFormat.setChecked(pump.timeDisplayType == 0);
|
timeFormat.setChecked(pump.timeDisplayType != 0);
|
||||||
buttonScroll.setChecked(pump.buttonScrollOnOff != 0);
|
buttonScroll.setChecked(pump.buttonScrollOnOff != 0);
|
||||||
beep.setChecked(pump.beepAndAlarm != 0);
|
beep.setChecked(pump.beepAndAlarm > 4);
|
||||||
screenTimeout.setValue((double) pump.lcdOnTimeSec);
|
screenTimeout.setValue((double) pump.lcdOnTimeSec);
|
||||||
backlightTimeout.setValue((double) pump.backlightOnTimeSec);
|
backlightTimeout.setValue((double) pump.backlightOnTimeSec);
|
||||||
pumpUnits.setChecked(pump.getUnits() != null && pump.getUnits().equals(Constants.MMOL));
|
pumpUnits.setChecked(pump.getUnits() != null && pump.getUnits().equals(Constants.MMOL));
|
||||||
|
@ -128,10 +158,15 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
|
|
||||||
public void onSaveClick() {
|
public void onSaveClick() {
|
||||||
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
|
boolean isRS = MainApp.getSpecificPlugin(DanaRSPlugin.class) != null && MainApp.getSpecificPlugin(DanaRSPlugin.class).isEnabled(PluginType.PUMP);
|
||||||
if (!isRS) {
|
boolean isDanaR = MainApp.getSpecificPlugin(DanaRPlugin.class) != null && MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginType.PUMP);
|
||||||
//exit if pump is not DanaRS
|
boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||||
|
if (!isRS && !isDanaR && !isDanaRv2) {
|
||||||
|
//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())
|
||||||
|
@ -143,13 +178,13 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
else
|
else
|
||||||
pump.buttonScrollOnOff = 0;
|
pump.buttonScrollOnOff = 0;
|
||||||
// step is 5 seconds
|
// step is 5 seconds
|
||||||
int screenTimeoutValue = (Integer.parseInt(screenTimeout.getText().toString()) / 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) {
|
||||||
pump.lcdOnTimeSec = screenTimeoutValue;
|
pump.lcdOnTimeSec = screenTimeoutValue;
|
||||||
} else {
|
} else {
|
||||||
pump.lcdOnTimeSec = 5;
|
pump.lcdOnTimeSec = 5;
|
||||||
}
|
}
|
||||||
int backlightTimeoutValue = Integer.parseInt(backlightTimeout.getText().toString());
|
int backlightTimeoutValue = !backlightTimeout.getText().isEmpty() ? Integer.parseInt(backlightTimeout.getText().toString()): 1;
|
||||||
if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
|
if (backlightTimeoutValue > 0 && backlightTimeoutValue < 61) {
|
||||||
pump.backlightOnTimeSec = backlightTimeoutValue;
|
pump.backlightOnTimeSec = backlightTimeoutValue;
|
||||||
}
|
}
|
||||||
|
@ -158,18 +193,22 @@ public class DanaRUserOptionsActivity extends Activity {
|
||||||
} else {
|
} else {
|
||||||
pump.units = 0;
|
pump.units = 0;
|
||||||
}
|
}
|
||||||
int shutDownValue = Integer.parseInt(shutdown.getText().toString());
|
int shutDownValue = !shutdown.getText().isEmpty() ? Integer.parseInt(shutdown.getText().toString()) : 0;
|
||||||
if (shutDownValue > -1 && shutDownValue < 25) {
|
if (shutDownValue > -1 && shutDownValue < 25) {
|
||||||
pump.shutdownHour = shutDownValue;
|
pump.shutdownHour = shutDownValue;
|
||||||
} else {
|
} else {
|
||||||
pump.shutdownHour = 0;
|
pump.shutdownHour = 0;
|
||||||
}
|
}
|
||||||
int lowReservoirValue = (Integer.parseInt(lowReservoir.getText().toString()) * 10) / 10;
|
int lowReservoirValue = !lowReservoir.getText().isEmpty() ? (Integer.parseInt(lowReservoir.getText().toString()) * 10) / 10 : 10;
|
||||||
if (lowReservoirValue > 9 && lowReservoirValue < 51) {
|
if (lowReservoirValue > 9 && lowReservoirValue < 51) {
|
||||||
pump.lowReservoirRate = lowReservoirValue;
|
pump.lowReservoirRate = lowReservoirValue;
|
||||||
} else
|
} else
|
||||||
pump.lowReservoirRate = 10;
|
pump.lowReservoirRate = 10;
|
||||||
|
|
||||||
|
if (isDanaRv2) {
|
||||||
|
DanaRv2Plugin.getPlugin().setUserOptions();
|
||||||
|
}
|
||||||
|
|
||||||
MainApp.getConfigBuilder().getCommandQueue().setUserSettings(null);
|
MainApp.getConfigBuilder().getCommandQueue().setUserSettings(null);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ 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
|
||||||
|
|
|
@ -34,16 +34,20 @@ public class MsgGetUserOptions extends MessageBase {
|
||||||
SetCommand(0x320B);
|
SetCommand(0x320B);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
public void handleMessage(byte[] packet) {
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1;
|
byte[] bytes = getDataBytes(packet, 0, packet.length - 10);
|
||||||
pump.buttonScrollOnOff = bytes[1];
|
for(int pos=0; pos < bytes.length; pos++) {
|
||||||
pump.beepAndAlarm = bytes[2];
|
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.lcdOnTimeSec = bytes[3] & 255;
|
||||||
pump.backlightOnTimeSec = bytes[4] & 255;
|
pump.backlightOnTimeSec = bytes[4] & 255;
|
||||||
pump.selectedLanguage = bytes[5];
|
pump.selectedLanguage = bytes[5]; // on DanaRv2 is that needed ?
|
||||||
pump.units = bytes[8];
|
pump.units = bytes[8];
|
||||||
pump.shutdownHour = bytes[9] & 255;
|
pump.shutdownHour = bytes[9];
|
||||||
pump.lowReservoirRate = bytes[32] & 255;
|
pump.lowReservoirRate = bytes[32] & 255;
|
||||||
/* int selectableLanguage1 = bytes[10];
|
/* int selectableLanguage1 = bytes[10];
|
||||||
int selectableLanguage2 = bytes[11];
|
int selectableLanguage2 = bytes[11];
|
||||||
|
@ -52,7 +56,8 @@ public class MsgGetUserOptions 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);
|
||||||
log.debug("BeepAndAlarm: " + pump.beepAndAlarm);
|
log.debug("BeepAndAlarm: " + pump.beepAndAlarm);
|
||||||
|
@ -62,6 +67,14 @@ public class MsgGetUserOptions 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) {
|
||||||
|
if (bytes == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
byte[] ret = new byte[len];
|
||||||
|
System.arraycopy(bytes, start + 6, ret, 0, len);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.07.2016.
|
* Created by mike on 05.07.2016.
|
||||||
|
@ -32,6 +27,16 @@ public class MsgSettingUserOptions extends MessageBase {
|
||||||
|
|
||||||
public MsgSettingUserOptions(int timeDisplayType, int buttonScrollOnOff, int beepAndAlarm, int lcdOnTimeSec, int backlightOnTimeSec, int selectedLanguage, int glucoseUnit, int shutdownHour, int lowReservoirRate, int cannulaVolume, int refillRate) {
|
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();
|
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.timeDisplayType = timeDisplayType;
|
||||||
this.buttonScrollOnOff = buttonScrollOnOff;
|
this.buttonScrollOnOff = buttonScrollOnOff;
|
||||||
this.beepAndAlarm = beepAndAlarm;
|
this.beepAndAlarm = beepAndAlarm;
|
||||||
|
@ -43,7 +48,8 @@ public class MsgSettingUserOptions extends MessageBase {
|
||||||
this.lowReservoirRate = lowReservoirRate;
|
this.lowReservoirRate = lowReservoirRate;
|
||||||
this.cannulaVolume = cannulaVolume;
|
this.cannulaVolume = cannulaVolume;
|
||||||
this.refillRate = refillRate;
|
this.refillRate = refillRate;
|
||||||
|
// need to organize here
|
||||||
|
// glucoseunit is at pos 8 and lowReservoirRate is at pos 27
|
||||||
AddParamByte((byte) timeDisplayType);
|
AddParamByte((byte) timeDisplayType);
|
||||||
AddParamByte((byte) buttonScrollOnOff);
|
AddParamByte((byte) buttonScrollOnOff);
|
||||||
AddParamByte((byte) beepAndAlarm);
|
AddParamByte((byte) beepAndAlarm);
|
||||||
|
@ -62,6 +68,7 @@ public class MsgSettingUserOptions extends MessageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -18,6 +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.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;
|
||||||
|
@ -382,6 +384,30 @@ 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)
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserSettings() {
|
public PumpEnactResult setUserOptions() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserSettings() {
|
public PumpEnactResult setUserOptions() {
|
||||||
return danaRSService.setUserSettings();
|
return danaRSService.setUserSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,8 +390,16 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setUserSettings() {
|
public PumpEnactResult setUserOptions() {
|
||||||
return null;
|
DanaRv2ExecutionService service = new DanaRv2ExecutionService();
|
||||||
|
log.debug("MsgSetUserOptions executed!");
|
||||||
|
return service.setUserOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PumpEnactResult getUserOptions() {
|
||||||
|
DanaRv2ExecutionService service = new DanaRv2ExecutionService();
|
||||||
|
log.debug("MsgGetUserOptions executed!");
|
||||||
|
return service.getUserOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ 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.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
|
@ -200,6 +201,8 @@ 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 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());
|
||||||
|
@ -473,12 +476,20 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PumpEnactResult updateUserSettings() {
|
public PumpEnactResult setUserOptions() {
|
||||||
if (!isConnected())
|
if (!isConnected()) {
|
||||||
return new PumpEnactResult().success(false);
|
log.debug("MsgSetUserOptions - service is not connected");
|
||||||
|
// return new PumpEnactResult().success(false);
|
||||||
|
connect();
|
||||||
|
}
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(300);
|
||||||
MsgSettingUserOptions msg;
|
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);
|
||||||
|
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()) {
|
while (!msg.done && mRfcommSocket.isConnected()) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
|
@ -487,4 +498,17 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
mDanaRPump.lastConnection = System.currentTimeMillis();
|
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||||
return new PumpEnactResult().success(true);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
package info.nightscout.androidaps.queue.commands;
|
package info.nightscout.androidaps.queue.commands;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
import info.nightscout.androidaps.interfaces.DanaRInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,7 +17,7 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CommandSetUserSettings extends Command {
|
public class CommandSetUserSettings extends Command {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(CommandSetUserSettings.class);
|
||||||
public CommandSetUserSettings(Callback callback) {
|
public CommandSetUserSettings(Callback callback) {
|
||||||
commandType = CommandType.SETUSERSETTINGS;
|
commandType = CommandType.SETUSERSETTINGS;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
@ -22,7 +28,11 @@ public class CommandSetUserSettings extends Command {
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||||
if (pump instanceof DanaRInterface) {
|
if (pump instanceof DanaRInterface) {
|
||||||
DanaRInterface danaPump = (DanaRInterface) pump;
|
DanaRInterface danaPump = (DanaRInterface) pump;
|
||||||
PumpEnactResult r = danaPump.setUserSettings();
|
boolean isDanaRv2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class) != null && MainApp.getSpecificPlugin(DanaRv2Plugin.class).isEnabled(PluginType.PUMP);
|
||||||
|
if(isDanaRv2){
|
||||||
|
log.debug("MsgSetUserOptions detected for DanaRv2");
|
||||||
|
}
|
||||||
|
PumpEnactResult r = danaPump.setUserOptions();
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.result(r).run();
|
callback.result(r).run();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue