getMax... constraints functions
This commit is contained in:
parent
0f531a9954
commit
ad8ff15cdc
13 changed files with 43 additions and 34 deletions
|
@ -13,9 +13,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ConstraintChecker implements ConstraintsInterface {
|
public class ConstraintChecker implements ConstraintsInterface {
|
||||||
|
|
||||||
private MainApp mainApp;
|
private MainApp mainApp;
|
||||||
|
|
||||||
public ConstraintChecker(MainApp mainApp) {
|
public ConstraintChecker(MainApp mainApp) {
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
}
|
}
|
||||||
|
@ -29,22 +29,38 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
return isClosedLoopAllowed(new Constraint<>(true));
|
return isClosedLoopAllowed(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint<Boolean> isAutosensModeEnabled() {
|
public Constraint<Boolean> isAutosensModeEnabled() {
|
||||||
return isAutosensModeEnabled(new Constraint<>(true));
|
return isAutosensModeEnabled(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint<Boolean> isAMAModeEnabled() {
|
public Constraint<Boolean> isAMAModeEnabled() {
|
||||||
return isAMAModeEnabled(new Constraint<>(true));
|
return isAMAModeEnabled(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint<Boolean> isSMBModeEnabled() {
|
public Constraint<Boolean> isSMBModeEnabled() {
|
||||||
return isSMBModeEnabled(new Constraint<>(true));
|
return isSMBModeEnabled(new Constraint<>(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constraint<Double> getMaxBasalAllowed(Profile profile) {
|
public Constraint<Double> getMaxBasalAllowed(Profile profile) {
|
||||||
return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile);
|
return applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Constraint<Integer> getMaxBasalPercentAllowed(Profile profile) {
|
||||||
|
return applyBasalPercentConstraints(new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE), profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Constraint<Double> getMaxBolusAllowed() {
|
||||||
|
return applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Constraint<Integer> getMaxCarbsAllowed() {
|
||||||
|
return applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Constraint<Double> getMaxIOBAllowed() {
|
||||||
|
return applyMaxIOBConstraints(new Constraint<>(Constants.REALLYHIGHIOB));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
|
public Constraint<Boolean> isLoopInvokationAllowed(Constraint<Boolean> value) {
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
|
@ -61,7 +60,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, new DecimalFormat("0.00"), false);
|
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, new DecimalFormat("0.00"), false);
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
@ -44,7 +43,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
|
|
||||||
View view = inflater.inflate(R.layout.overview_newextendedbolus_dialog, container, false);
|
View view = inflater.inflate(R.layout.overview_newextendedbolus_dialog, container, false);
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
|
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
|
||||||
|
|
||||||
|
|
|
@ -272,11 +272,11 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Integer maxCarbs = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS)).value();
|
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false);
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false);
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
|
|
||||||
Integer maxPercent = 200;
|
Integer maxPercent = 200;
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
maxPercent = MainApp.getConstraintChecker().applyBasalPercentConstraints(new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE), profile).value();
|
maxPercent = MainApp.getConstraintChecker().getMaxBasalPercentAllowed(profile).value();
|
||||||
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||||
editPercent.setParams(0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true, percentTextWatcher);
|
editPercent.setParams(0d, 0d, (double) maxPercent, 5d, new DecimalFormat("0"), true, percentTextWatcher);
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Double maxAbsolute = MainApp.getConstraintChecker().applyBasalConstraints(new Constraint<>(Constants.REALLYHIGHBASALRATE), profile).value();
|
Double maxAbsolute = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||||
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, absoluteTextWatcher);
|
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, absoluteTextWatcher);
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
SafetyPlugin.getPlugin().isClosedLoopAllowed(closedLoopEnabled);
|
SafetyPlugin.getPlugin().isClosedLoopAllowed(closedLoopEnabled);
|
||||||
return new RequirementResult(closedLoopEnabled.value(), MainApp.gs(R.string.closedmodeenabled) + ": " + yesOrNo(closedLoopEnabled.value()));
|
return new RequirementResult(closedLoopEnabled.value(), MainApp.gs(R.string.closedmodeenabled) + ": " + yesOrNo(closedLoopEnabled.value()));
|
||||||
case 4:
|
case 4:
|
||||||
double maxIOB = MainApp.getConstraintChecker().applyMaxIOBConstraints(new Constraint<>(Constants.REALLYHIGHIOB)).value();
|
double maxIOB = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
boolean maxIobSet = maxIOB > 0;
|
boolean maxIobSet = maxIOB > 0;
|
||||||
return new RequirementResult(maxIobSet, MainApp.gs(R.string.maxiobset) + ": " + yesOrNo(maxIobSet));
|
return new RequirementResult(maxIobSet, MainApp.gs(R.string.maxiobset) + ": " + yesOrNo(maxIobSet));
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
||||||
Profiler.log(log, "getMealData()", startPart);
|
Profiler.log(log, "getMealData()", startPart);
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().applyMaxIOBConstraints(new Constraint<>(Constants.REALLYHIGHIOB)).value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
|
|
||||||
minBg = HardLimits.verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
minBg = HardLimits.verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
maxBg = HardLimits.verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
maxBg = HardLimits.verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
|
|
|
@ -194,7 +194,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().applyMaxIOBConstraints(new Constraint<>(Constants.REALLYHIGHIOB)).value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
Profiler.log(log, "MA data gathering", start);
|
Profiler.log(log, "MA data gathering", start);
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
|
|
|
@ -197,7 +197,7 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
||||||
Profiler.log(log, "getMealData()", startPart);
|
Profiler.log(log, "getMealData()", startPart);
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().applyMaxIOBConstraints(new Constraint<>(Constants.REALLYHIGHIOB)).value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
maxCarbs = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS)).value();
|
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
|
|
||||||
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
editCarbs = view.findViewById(R.id.newcarb_carbsamount);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
maxInsulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
|
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newinsulin_amount);
|
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newinsulin_amount);
|
||||||
|
|
||||||
|
|
|
@ -96,8 +96,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||||
|
|
||||||
maxCarbs = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS)).value();
|
maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
maxInsulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
|
|
||||||
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount);
|
editCarbs = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_carbsamount);
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||||
|
|
|
@ -237,8 +237,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
|
|
||||||
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
|
superbolusCheckbox.setVisibility(SP.getBoolean(R.string.key_usesuperbolus, false) ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
Integer maxCarbs = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS)).value();
|
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
Double maxCorrection = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS)).value();
|
Double maxCorrection = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
|
|
||||||
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||||
|
|
|
@ -209,8 +209,7 @@ public class ConstraintsCheckerTest {
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting basal rate to 0.00 U/h because of it must be positive value", d.getReasons());
|
Assert.assertEquals("SafetyPlugin: Limiting basal rate to 0.00 U/h because of it must be positive value", d.getReasons());
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
d = new Constraint<>(Constants.REALLYHIGHBASALRATE);
|
d = constraintChecker.getMaxBasalAllowed(profile);
|
||||||
constraintChecker.applyBasalConstraints(d, profile);
|
|
||||||
Assert.assertEquals(0.8d, d.value());
|
Assert.assertEquals(0.8d, d.value());
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
Assert.assertEquals("SafetyPlugin: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
||||||
"SafetyPlugin: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
"SafetyPlugin: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
||||||
|
@ -255,8 +254,7 @@ public class ConstraintsCheckerTest {
|
||||||
"InsightPumpPlugin: Limiting percent rate to 0% because of it must be positive value", i.getReasons());
|
"InsightPumpPlugin: Limiting percent rate to 0% because of it must be positive value", i.getReasons());
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
i = new Constraint<>(Constants.REALLYHIGHPERCENTBASALRATE);
|
i = constraintChecker.getMaxBasalPercentAllowed(profile);
|
||||||
constraintChecker.applyBasalPercentConstraints(i, profile);
|
|
||||||
Assert.assertEquals((Integer)100, i.value());
|
Assert.assertEquals((Integer)100, i.value());
|
||||||
Assert.assertEquals("SafetyPlugin: Percent rate 1111111% recalculated to 11111.11 U/h with current basal 1.00 U/h\n" +
|
Assert.assertEquals("SafetyPlugin: Percent rate 1111111% recalculated to 11111.11 U/h with current basal 1.00 U/h\n" +
|
||||||
"SafetyPlugin: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
"SafetyPlugin: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
||||||
|
@ -296,8 +294,7 @@ public class ConstraintsCheckerTest {
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting bolus to 0.0 U because of it must be positive value", d.getReasons());
|
Assert.assertEquals("SafetyPlugin: Limiting bolus to 0.0 U because of it must be positive value", d.getReasons());
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
d = new Constraint<>(Constants.REALLYHIGHBOLUS);
|
d = constraintChecker.getMaxBolusAllowed();
|
||||||
constraintChecker.applyBolusConstraints(d);
|
|
||||||
Assert.assertEquals(3d, d.value());
|
Assert.assertEquals(3d, d.value());
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting bolus to 3.0 U because of max value in preferences\n" +
|
Assert.assertEquals("SafetyPlugin: Limiting bolus to 3.0 U because of max value in preferences\n" +
|
||||||
"SafetyPlugin: Limiting bolus to 5.0 U because of hard limit\n" +
|
"SafetyPlugin: Limiting bolus to 5.0 U because of hard limit\n" +
|
||||||
|
@ -320,8 +317,7 @@ public class ConstraintsCheckerTest {
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting carbs to 0 g because of it must be positive value", i.getReasons());
|
Assert.assertEquals("SafetyPlugin: Limiting carbs to 0 g because of it must be positive value", i.getReasons());
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
i = new Constraint<>(Constants.REALLYHIGHCARBS);
|
i = constraintChecker.getMaxCarbsAllowed();
|
||||||
constraintChecker.applyCarbsConstraints(i);
|
|
||||||
Assert.assertEquals((Integer) 48, i.value());
|
Assert.assertEquals((Integer) 48, i.value());
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting carbs to 48 g because of max value in preferences", i.getReasons());
|
Assert.assertEquals("SafetyPlugin: Limiting carbs to 48 g because of max value in preferences", i.getReasons());
|
||||||
}
|
}
|
||||||
|
@ -349,8 +345,7 @@ public class ConstraintsCheckerTest {
|
||||||
OpenAPSSMBPlugin.getPlugin().setFragmentEnabled(PluginBase.APS, true);
|
OpenAPSSMBPlugin.getPlugin().setFragmentEnabled(PluginBase.APS, true);
|
||||||
|
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
Constraint<Double> d = new Constraint<>(Constants.REALLYHIGHIOB);
|
Constraint<Double> d = constraintChecker.getMaxIOBAllowed();
|
||||||
constraintChecker.applyMaxIOBConstraints(d);
|
|
||||||
Assert.assertEquals(1.5d, d.value());
|
Assert.assertEquals(1.5d, d.value());
|
||||||
Assert.assertEquals("SafetyPlugin: Limiting IOB to 1.5 U because of max value in preferences\n" +
|
Assert.assertEquals("SafetyPlugin: Limiting IOB to 1.5 U because of max value in preferences\n" +
|
||||||
"SafetyPlugin: Limiting IOB to 7.0 U because of hard limit\n" +
|
"SafetyPlugin: Limiting IOB to 7.0 U because of hard limit\n" +
|
||||||
|
|
Loading…
Reference in a new issue