diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java index 09b5f5dd04..89e595dc62 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java @@ -165,20 +165,24 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte String msg = ""; + if (!fragmentEnabled){ + msg+= "NO CPP!" + "\n"; + } + //check for validity if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) { 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"; } - 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"; } final PumpInterface pump = MainApp.getConfigBuilder(); 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"; } if(!"".equals(msg)) { @@ -201,14 +205,17 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte } }); 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 - msg += "%: " + this.percentage + " h: +" + this.timeshift; + /*msg += "%: " + this.percentage + " h: +" + this.timeshift; msg += "\n"; msg += "\nBasal:\n" + basalString() + "\n"; msg += "\nISF:\n" + isfString() + "\n"; - msg += "\nIC:\n" + isfString() + "\n"; + msg += "\nIC:\n" + isfString() + "\n";*/ return msg; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 09298cd7e5..bee3b47451 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -227,14 +227,12 @@ public class ActionStringHandler { lastBolusWizard = bolusWizard; } else if("opencpp".equals(act[0])){ - //TODO ADRIAN open cpp Object activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface(); CircadianPercentageProfilePlugin cpp = (CircadianPercentageProfilePlugin) MainApp.getSpecificPlugin(CircadianPercentageProfilePlugin.class); if(cpp == null || activeProfile==null || cpp != activeProfile){ - rTitle = "STATUS"; - rAction = "statusmessage"; - rMessage = "CPP not activated"; + sendError("CPP not activated!"); + return; } else { // read CPP values rTitle = "opencpp"; @@ -242,7 +240,23 @@ public class ActionStringHandler { 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 @@ -397,10 +411,26 @@ public class ActionStringHandler { double insulin = SafeParse.stringToDouble(act[1]); int carbs = SafeParse.stringToInt(act[2]); 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; } + 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) { TempTarget tempTarget = new TempTarget(); tempTarget.date = System.currentTimeMillis();