cpp-watch first roundtrip
This commit is contained in:
parent
85d028abff
commit
26f3362ffc
|
@ -165,20 +165,24 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
|
|
||||||
String msg = "";
|
String msg = "";
|
||||||
|
|
||||||
|
if (!fragmentEnabled){
|
||||||
|
msg+= "NO CPP!" + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
//check for validity
|
//check for validity
|
||||||
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
|
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
|
||||||
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
|
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
|
||||||
}
|
}
|
||||||
if (timeshift < 0 || percentage > 23) {
|
if (timeshift < 0 || timeshift > 23) {
|
||||||
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||||
}
|
}
|
||||||
if(SP.getBoolean("syncprofiletopump", false)){
|
if(!SP.getBoolean("syncprofiletopump", false)){
|
||||||
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
||||||
}
|
}
|
||||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
if (pump != null && profile != null && profile.getBasal() != null){
|
if (pump == null || profile == null || profile.getBasal() == null){
|
||||||
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
||||||
}
|
}
|
||||||
if(!"".equals(msg)) {
|
if(!"".equals(msg)) {
|
||||||
|
@ -201,14 +205,17 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
|
msg += "syctopump";
|
||||||
|
} else {
|
||||||
|
msg += "SP.getBoolean(\"syncprofiletopump\", false): " + SP.getBoolean("syncprofiletopump", false) + " \n";
|
||||||
|
msg += "pump.isThisProfileSet(profile): " + pump.isThisProfileSet(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return formatted string
|
//return formatted string
|
||||||
msg += "%: " + this.percentage + " h: +" + this.timeshift;
|
/*msg += "%: " + this.percentage + " h: +" + this.timeshift;
|
||||||
msg += "\n";
|
msg += "\n";
|
||||||
msg += "\nBasal:\n" + basalString() + "\n";
|
msg += "\nBasal:\n" + basalString() + "\n";
|
||||||
msg += "\nISF:\n" + isfString() + "\n";
|
msg += "\nISF:\n" + isfString() + "\n";
|
||||||
msg += "\nIC:\n" + isfString() + "\n";
|
msg += "\nIC:\n" + isfString() + "\n";*/
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,14 +227,12 @@ public class ActionStringHandler {
|
||||||
lastBolusWizard = bolusWizard;
|
lastBolusWizard = bolusWizard;
|
||||||
|
|
||||||
} else if("opencpp".equals(act[0])){
|
} else if("opencpp".equals(act[0])){
|
||||||
//TODO ADRIAN open cpp
|
|
||||||
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
rTitle = "STATUS";
|
sendError("CPP not activated!");
|
||||||
rAction = "statusmessage";
|
return;
|
||||||
rMessage = "CPP not activated";
|
|
||||||
} else {
|
} else {
|
||||||
// read CPP values
|
// read CPP values
|
||||||
rTitle = "opencpp";
|
rTitle = "opencpp";
|
||||||
|
@ -242,7 +240,23 @@ public class ActionStringHandler {
|
||||||
rAction = "opencpp" + " " + cpp.getPercentage() + " " + cpp.getTimeshift();
|
rAction = "opencpp" + " " + cpp.getPercentage() + " " + cpp.getTimeshift();
|
||||||
}
|
}
|
||||||
|
|
||||||
}else return;
|
} else if("cppset".equals(act[0])){
|
||||||
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
|
sendError("CPP not activated!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// read CPP values
|
||||||
|
rMessage = "CPP:" + "\n\n"+
|
||||||
|
"Percentage: " + act[1] + "%\n" +
|
||||||
|
"Timeshift: " + act[2];
|
||||||
|
rAction = actionstring;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else return;
|
||||||
|
|
||||||
|
|
||||||
// send result
|
// send result
|
||||||
|
@ -397,10 +411,26 @@ public class ActionStringHandler {
|
||||||
double insulin = SafeParse.stringToDouble(act[1]);
|
double insulin = SafeParse.stringToDouble(act[1]);
|
||||||
int carbs = SafeParse.stringToInt(act[2]);
|
int carbs = SafeParse.stringToInt(act[2]);
|
||||||
doBolus(insulin, carbs);
|
doBolus(insulin, carbs);
|
||||||
|
} else if ("cppset".equals(act[0])) {
|
||||||
|
int timeshift = SafeParse.stringToInt(act[1]);
|
||||||
|
int percentage = SafeParse.stringToInt(act[2]);
|
||||||
|
setCPP(percentage, timeshift);
|
||||||
}
|
}
|
||||||
lastBolusWizard = null;
|
lastBolusWizard = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setCPP(int percentage, int timeshift) {
|
||||||
|
Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||||
|
CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class);
|
||||||
|
|
||||||
|
if(cpp == null || activeProfile==null || cpp != activeProfile){
|
||||||
|
sendError("CPP not activated!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String msg = cpp.externallySetParameters(timeshift, percentage);
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance(), msg);
|
||||||
|
}
|
||||||
|
|
||||||
private static void generateTempTarget(int duration, double low, double high) {
|
private static void generateTempTarget(int duration, double low, double high) {
|
||||||
TempTarget tempTarget = new TempTarget();
|
TempTarget tempTarget = new TempTarget();
|
||||||
tempTarget.date = System.currentTimeMillis();
|
tempTarget.date = System.currentTimeMillis();
|
||||||
|
|
Loading…
Reference in a new issue