added SetUserOptions for DanaR
This commit is contained in:
parent
17a0aba2e5
commit
2441214bb8
5 changed files with 149 additions and 8 deletions
|
@ -103,11 +103,14 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
|
||||||
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
|
if(LocalProfilePlugin.LOCAL_PROFILE.equals(name)){
|
||||||
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
|
name = DecimalFormatter.to2Decimal(getProfileObject().percentageBasalSum()) + "U ";
|
||||||
}
|
}
|
||||||
if (isCPP) {
|
//Test if name is already containing percentage or timeshift
|
||||||
name += "(" + percentage + "%";
|
if (!name.endsWith("h)") || !name.endsWith("%)")) {
|
||||||
if (timeshift != 0)
|
if (isCPP) {
|
||||||
name += "," + timeshift + "h";
|
name += "(" + percentage + "%";
|
||||||
name += ")";
|
if (timeshift != 0)
|
||||||
|
name += "," + timeshift + "h";
|
||||||
|
name += ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
//hide user options button if not an RS pump
|
//hide user options button if not an RS pump
|
||||||
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
|
boolean isKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class) != null && MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginType.PUMP);
|
||||||
if(isKorean){
|
if (isKorean ) {
|
||||||
danar_user_options.setVisibility(View.GONE);
|
danar_user_options.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
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[] bytes) {
|
||||||
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
|
pump.timeDisplayType = bytes[0] == (byte) 1 ? 0 : 1;
|
||||||
|
pump.buttonScrollOnOff = bytes[1];
|
||||||
|
pump.beepAndAlarm = bytes[2];
|
||||||
|
pump.lcdOnTimeSec = bytes[3] & 255;
|
||||||
|
pump.backlightOnTimeSec = bytes[4] & 255;
|
||||||
|
pump.selectedLanguage = bytes[5];
|
||||||
|
pump.units = bytes[8];
|
||||||
|
pump.shutdownHour = bytes[9] & 255;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,18 +3,73 @@ 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.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.
|
||||||
*/
|
*/
|
||||||
public class MsgSettingUserOptions extends MessageBase {
|
public class MsgSettingUserOptions extends MessageBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(MsgSettingShippingInfo.class);
|
|
||||||
|
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();
|
||||||
|
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;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
public MsgSettingUserOptions() {
|
public MsgSettingUserOptions() {
|
||||||
SetCommand(0x320B);
|
SetCommand(0x320B);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMessage(byte[] bytes) {
|
public void handleMessage(byte[] bytes) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.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;
|
||||||
|
@ -471,4 +472,19 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
SystemClock.sleep(Math.min(timeToWholeMinute, 100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PumpEnactResult updateUserSettings() {
|
||||||
|
if (!isConnected())
|
||||||
|
return new PumpEnactResult().success(false);
|
||||||
|
SystemClock.sleep(300);
|
||||||
|
MsgSettingUserOptions msg;
|
||||||
|
|
||||||
|
mSerialIOThread.sendMessage(msg);
|
||||||
|
while (!msg.done && mRfcommSocket.isConnected()) {
|
||||||
|
SystemClock.sleep(100);
|
||||||
|
}
|
||||||
|
SystemClock.sleep(200);
|
||||||
|
mDanaRPump.lastConnection = System.currentTimeMillis();
|
||||||
|
return new PumpEnactResult().success(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue