apply bolus description settings in constraints
This commit is contained in:
parent
62b111eb64
commit
315c83069d
|
@ -58,6 +58,10 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
return applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS));
|
return applyBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Constraint<Double> getMaxExtendedBolusAllowed() {
|
||||||
|
return applyExtendedBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS));
|
||||||
|
}
|
||||||
|
|
||||||
public Constraint<Integer> getMaxCarbsAllowed() {
|
public Constraint<Integer> getMaxCarbsAllowed() {
|
||||||
return applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS));
|
return applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS));
|
||||||
}
|
}
|
||||||
|
@ -170,6 +174,17 @@ public class ConstraintChecker implements ConstraintsInterface {
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
|
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
|
for (PluginBase p : constraintsPlugins) {
|
||||||
|
ConstraintsInterface constrain = (ConstraintsInterface) p;
|
||||||
|
if (!p.isEnabled(PluginType.CONSTRAINTS)) continue;
|
||||||
|
constrain.applyExtendedBolusConstraints(insulin);
|
||||||
|
}
|
||||||
|
return insulin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||||
|
|
|
@ -47,6 +47,15 @@ public class Constraint<T extends Comparable> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Constraint<T> setIfDifferent(T value, String reason, Object from) {
|
||||||
|
if (!this.value.equals(value)) {
|
||||||
|
this.value = value;
|
||||||
|
addReason(reason, from);
|
||||||
|
addMostLimingReason(reason, from);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Constraint<T> setIfSmaller(T value, String reason, Object from) {
|
public Constraint<T> setIfSmaller(T value, String reason, Object from) {
|
||||||
if (value.compareTo(this.value) < 0) {
|
if (value.compareTo(this.value) < 0) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|
|
@ -43,6 +43,10 @@ public interface ConstraintsInterface {
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
|
return insulin;
|
||||||
|
}
|
||||||
|
|
||||||
default Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
default Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||||
return carbs;
|
return carbs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.06.2016.
|
* Created by mike on 09.06.2016.
|
||||||
|
@ -168,7 +169,9 @@ public abstract class PluginBase {
|
||||||
if (getType() == PluginType.PUMP) {
|
if (getType() == PluginType.PUMP) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
SystemClock.sleep(3000);
|
SystemClock.sleep(3000);
|
||||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Pump driver changed.", null);
|
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
||||||
|
if (commandQueue != null)
|
||||||
|
commandQueue.readStatus("Pump driver changed.", null);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PumpDescription {
|
public class PumpDescription {
|
||||||
PumpType pumpType = PumpType.GenericAAPS;
|
public PumpType pumpType = PumpType.GenericAAPS;
|
||||||
|
|
||||||
public PumpDescription () {
|
public PumpDescription () {
|
||||||
resetSettings();
|
resetSettings();
|
||||||
|
|
|
@ -44,7 +44,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().getMaxBolusAllowed().value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxExtendedBolusAllowed().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);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
||||||
|
|
||||||
String confirmMessage = MainApp.gs(R.string.setextendedbolusquestion);
|
String confirmMessage = MainApp.gs(R.string.setextendedbolusquestion);
|
||||||
|
|
||||||
Double insulinAfterConstraint = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
Double insulinAfterConstraint = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||||
confirmMessage += " " + insulinAfterConstraint + " U ";
|
confirmMessage += " " + insulinAfterConstraint + " U ";
|
||||||
confirmMessage += MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
|
confirmMessage += MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||||
if (insulinAfterConstraint - insulin != 0d)
|
if (insulinAfterConstraint - insulin != 0d)
|
||||||
|
|
|
@ -10,6 +10,8 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
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.OpenAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||||
|
@ -121,6 +123,18 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
absoluteRate.setIfSmaller(maxFromDaily, String.format(MainApp.gs(R.string.limitingbasalratio), maxFromDaily, MainApp.gs(R.string.maxdailybasalmultiplier)), this);
|
absoluteRate.setIfSmaller(maxFromDaily, String.format(MainApp.gs(R.string.limitingbasalratio), maxFromDaily, MainApp.gs(R.string.maxdailybasalmultiplier)), this);
|
||||||
|
|
||||||
absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(MainApp.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), MainApp.gs(R.string.hardlimit)), this);
|
absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(MainApp.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), MainApp.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
// check for pump max
|
||||||
|
if (pump != null) {
|
||||||
|
double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose();
|
||||||
|
absoluteRate.setIfSmaller(pumpLimit, String.format(MainApp.gs(R.string.limitingbasalratio), pumpLimit, MainApp.gs(R.string.pumplimit)), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// do rounding
|
||||||
|
if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
|
absoluteRate.set(Round.roundTo(absoluteRate.value(), pump.getPumpDescription().tempAbsoluteStep));
|
||||||
|
}
|
||||||
return absoluteRate;
|
return absoluteRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +150,14 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
applyBasalConstraints(absoluteConstraint, profile);
|
applyBasalConstraints(absoluteConstraint, profile);
|
||||||
percentRate.copyReasons(absoluteConstraint);
|
percentRate.copyReasons(absoluteConstraint);
|
||||||
|
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
||||||
|
if (pump != null) {
|
||||||
if (percentRateAfterConst < 100)
|
if (percentRateAfterConst < 100)
|
||||||
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, 10d).intValue();
|
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, (double) pump.getPumpDescription().tempPercentStep).intValue();
|
||||||
else percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, 10d).intValue();
|
else
|
||||||
|
percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, (double) pump.getPumpDescription().tempPercentStep).intValue();
|
||||||
|
}
|
||||||
|
|
||||||
percentRate.set(percentRateAfterConst, String.format(MainApp.gs(R.string.limitingpercentrate), percentRateAfterConst, MainApp.gs(R.string.pumplimit)), this);
|
percentRate.set(percentRateAfterConst, String.format(MainApp.gs(R.string.limitingpercentrate), percentRateAfterConst, MainApp.gs(R.string.pumplimit)), this);
|
||||||
|
|
||||||
|
@ -154,6 +172,29 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
insulin.setIfSmaller(maxBolus, String.format(MainApp.gs(R.string.limitingbolus), maxBolus, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
insulin.setIfSmaller(maxBolus, String.format(MainApp.gs(R.string.limitingbolus), maxBolus, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
if (pump != null) {
|
||||||
|
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value()));
|
||||||
|
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||||
|
}
|
||||||
|
return insulin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
|
insulin.setIfGreater(0d, String.format(MainApp.gs(R.string.limitingextendedbolus), 0d, MainApp.gs(R.string.itmustbepositivevalue)), this);
|
||||||
|
|
||||||
|
Double maxBolus = SP.getDouble(R.string.key_treatmentssafety_maxbolus, 3d);
|
||||||
|
insulin.setIfSmaller(maxBolus, String.format(MainApp.gs(R.string.limitingextendedbolus), maxBolus, MainApp.gs(R.string.maxvalueinpreferences)), this);
|
||||||
|
|
||||||
|
insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingextendedbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this);
|
||||||
|
|
||||||
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
|
if (pump != null) {
|
||||||
|
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value()));
|
||||||
|
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||||
|
}
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ package info.nightscout.androidaps.plugins.PumpCommon.data;
|
||||||
|
|
||||||
public class DoseSettings {
|
public class DoseSettings {
|
||||||
|
|
||||||
private float step;
|
private double step;
|
||||||
private int durationStep;
|
private int durationStep;
|
||||||
private int maxDuration;
|
private int maxDuration;
|
||||||
private float minDose;
|
private double minDose;
|
||||||
private Float maxDose;
|
private Double maxDose;
|
||||||
|
|
||||||
public DoseSettings(float step, int durationStep, int maxDuration, float minDose, Float maxDose)
|
public DoseSettings(double step, int durationStep, int maxDuration, double minDose, Double maxDose)
|
||||||
{
|
{
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.durationStep = durationStep;
|
this.durationStep = durationStep;
|
||||||
|
@ -21,13 +21,13 @@ public class DoseSettings {
|
||||||
this.maxDose = maxDose;
|
this.maxDose = maxDose;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoseSettings(float step, int durationStep, int maxDuration, float minDose)
|
public DoseSettings(double step, int durationStep, int maxDuration, double minDose)
|
||||||
{
|
{
|
||||||
this(step, durationStep, maxDuration, minDose, Float.MAX_VALUE);
|
this(step, durationStep, maxDuration, minDose, Double.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getStep() {
|
public double getStep() {
|
||||||
return step;
|
return step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ public class DoseSettings {
|
||||||
return maxDuration;
|
return maxDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMinDose() {
|
public double getMinDose() {
|
||||||
return minDose;
|
return minDose;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getMaxDose() {
|
public Double getMaxDose() {
|
||||||
return maxDose;
|
return maxDose;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,18 @@ public enum DoseStepSize
|
||||||
ComboBasal( //
|
ComboBasal( //
|
||||||
new DoseStepSizeEntry(0f, 1f, 0.01f), //
|
new DoseStepSizeEntry(0f, 1f, 0.01f), //
|
||||||
new DoseStepSizeEntry(1f, 10f, 0.05f), //
|
new DoseStepSizeEntry(1f, 10f, 0.05f), //
|
||||||
new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), //
|
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.1f)), //
|
||||||
|
|
||||||
InsightBolus(
|
InsightBolus(
|
||||||
new DoseStepSizeEntry(0f, 2f, 0.05f), //
|
new DoseStepSizeEntry(0f, 2f, 0.05f), //
|
||||||
new DoseStepSizeEntry(2f, 5f, 0.1f), //
|
new DoseStepSizeEntry(2f, 5f, 0.1f), //
|
||||||
new DoseStepSizeEntry(5f, 10f, 0.2f), //
|
new DoseStepSizeEntry(5f, 10f, 0.2f), //
|
||||||
new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.5f)),
|
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.5f)),
|
||||||
|
|
||||||
MedtronicVeoBasal( //
|
MedtronicVeoBasal( //
|
||||||
new DoseStepSizeEntry(0f, 1f, 0.025f), //
|
new DoseStepSizeEntry(0f, 1f, 0.025f), //
|
||||||
new DoseStepSizeEntry(1f, 10f, 0.05f), //
|
new DoseStepSizeEntry(1f, 10f, 0.05f), //
|
||||||
new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), //
|
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.1f)), //
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ public enum DoseStepSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getStepSizeForAmount(float amount)
|
public double getStepSizeForAmount(double amount)
|
||||||
{
|
{
|
||||||
for (DoseStepSizeEntry entry : entries) {
|
for (DoseStepSizeEntry entry : entries) {
|
||||||
if (entry.from <= amount && entry.to > amount)
|
if (entry.from <= amount && entry.to > amount)
|
||||||
|
@ -57,7 +57,7 @@ public enum DoseStepSize
|
||||||
sb.append(entry.from);
|
sb.append(entry.from);
|
||||||
sb.append("-");
|
sb.append("-");
|
||||||
|
|
||||||
if (entry.to == Float.MAX_VALUE)
|
if (entry.to == Double.MAX_VALUE)
|
||||||
{
|
{
|
||||||
sb.append("~}");
|
sb.append("~}");
|
||||||
}
|
}
|
||||||
|
@ -74,12 +74,12 @@ public enum DoseStepSize
|
||||||
|
|
||||||
static class DoseStepSizeEntry
|
static class DoseStepSizeEntry
|
||||||
{
|
{
|
||||||
float from;
|
double from;
|
||||||
float to;
|
double to;
|
||||||
float value;
|
double value;
|
||||||
|
|
||||||
// to = this value is not included, but would actually mean <, so for rates between 0.025-0.975 u/h, we would have [from=0, to=10]
|
// to = this value is not included, but would actually mean <, so for rates between 0.025-0.975 u/h, we would have [from=0, to=10]
|
||||||
DoseStepSizeEntry(float from, float to, float value)
|
DoseStepSizeEntry(double from, double to, double value)
|
||||||
{
|
{
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
|
|
|
@ -18,108 +18,108 @@ import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings;
|
||||||
|
|
||||||
public enum PumpType {
|
public enum PumpType {
|
||||||
|
|
||||||
GenericAAPS("Generic AAPS", 0.1f, null, //
|
GenericAAPS("Generic AAPS", 0.1d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10,30, 24*60, 0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10,30, 24*60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01f, 0.01f, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Cellnovo
|
// Cellnovo
|
||||||
|
|
||||||
Cellnovo1("Cellnovo", 0.05f, null, //
|
Cellnovo1("Cellnovo", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 24*60, 1f, null),
|
new DoseSettings(0.05d, 30, 24*60, 1d, null),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(5,30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(5,30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), //
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Accu-Chek
|
// Accu-Chek
|
||||||
|
|
||||||
AccuChekCombo("Accu-Chek Combo", 0.1f, null, //
|
AccuChekCombo("Accu-Chek Combo", 0.1d, null, //
|
||||||
new DoseSettings(0.1f, 15, 12*60, 0.1f), //
|
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01f, 0.1f, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
0.01d, 0.1d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||||
|
|
||||||
AccuChekSpirit("Accu-Chek Spirit", 0.1f, null, //
|
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
|
||||||
new DoseSettings(0.1f, 15, 12*60, 0.1f), //
|
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01f, 0.1f, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AccuChekInsight("Accu-Chek Insight", 0.05f, DoseStepSize.InsightBolus, //
|
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
|
||||||
new DoseSettings(0.05f, 15, 24*60, 0.05f), //
|
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12*60,0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.02f, 0.1f, null, PumpCapability.InsightCapabilities), //
|
0.02d, 0.1d, null, PumpCapability.InsightCapabilities), //
|
||||||
|
|
||||||
// Animas
|
// Animas
|
||||||
AnimasVibe("Animas Vibe", 0.05f, null, // AnimasBolus?
|
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
|
||||||
new DoseSettings(0.05f, 30, 12*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10, 30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(10, 30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025f, 5f, 0f, null, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AnimasPing("Animas Ping", AnimasVibe),
|
AnimasPing("Animas Ping", AnimasVibe),
|
||||||
|
|
||||||
// Dana
|
// Dana
|
||||||
DanaR("DanaR", 0.05f, null, //
|
DanaR("DanaR", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.04f, 0.01f, null, PumpCapability.DanaCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRKorean("DanaR Korean", 0.05f, null, //
|
DanaRKorean("DanaR Korean", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.1f, 0.01f, null, PumpCapability.DanaCapabilities),
|
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRS("DanaRS", 0.05f, null, //
|
DanaRS("DanaRS", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.04f, 0.01f, null, PumpCapability.DanaWithHistoryCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
||||||
|
|
||||||
DanaRv2("DanaRv2", DanaRS),
|
DanaRv2("DanaRv2", DanaRS),
|
||||||
|
|
||||||
|
|
||||||
// Insulet
|
// Insulet
|
||||||
Insulet_Omnipod("Insulet Omnipod", 0.05f, null, //
|
Insulet_Omnipod("Insulet Omnipod", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
new DoseSettings(0.05d, 30, 12*60, 0d, 5.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities),
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
// Medtronic
|
// Medtronic
|
||||||
Medtronic_512_712("Medtronic 512/712", 0.05f, null, //
|
Medtronic_512_712("Medtronic 512/712", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
||||||
|
|
||||||
Medtronic_515_715("Medtronic 515/715", Medtronic_512_712),
|
Medtronic_515_715("Medtronic 515/715", Medtronic_512_712),
|
||||||
Medtronic_522_722("Medtronic 522/722", Medtronic_512_712),
|
Medtronic_522_722("Medtronic 522/722", Medtronic_512_712),
|
||||||
|
|
||||||
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05f, null, //
|
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
||||||
|
|
||||||
Medtronic_640G("Medtronic 640G", 0.025f, null, //
|
Medtronic_640G("Medtronic 640G", 0.025d, null, //
|
||||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Tandem
|
// Tandem
|
||||||
TandemTSlim("Tandem t:slim", 0.01f, null, //
|
TandemTSlim("Tandem t:slim", 0.01d, null, //
|
||||||
new DoseSettings(0.01f,15, 8*60, 0.4f),
|
new DoseSettings(0.01d,15, 8*60, 0.4d),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(1,15, 8*60, 0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(1,15, 8*60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.1f, 0.001f, null, PumpCapability.VirtualPumpCapabilities),
|
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
TandemTFlex("Tandem t:flex", TandemTSlim), //
|
TandemTFlex("Tandem t:flex", TandemTSlim), //
|
||||||
TandemTSlimG4("Tandem t:slim G4", TandemTSlim), //
|
TandemTSlimG4("Tandem t:slim G4", TandemTSlim), //
|
||||||
|
@ -127,15 +127,15 @@ public enum PumpType {
|
||||||
;
|
;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
private float bolusSize;
|
private double bolusSize;
|
||||||
private DoseStepSize specialBolusSize;
|
private DoseStepSize specialBolusSize;
|
||||||
private DoseSettings extendedBolusSettings;
|
private DoseSettings extendedBolusSettings;
|
||||||
private PumpTempBasalType pumpTempBasalType;
|
private PumpTempBasalType pumpTempBasalType;
|
||||||
private DoseSettings tbrSettings;
|
private DoseSettings tbrSettings;
|
||||||
private PumpCapability specialBasalDurations;
|
private PumpCapability specialBasalDurations;
|
||||||
private float baseBasalMinValue; //
|
private double baseBasalMinValue; //
|
||||||
private Float baseBasalMaxValue;
|
private Double baseBasalMaxValue;
|
||||||
private float baseBasalStep; //
|
private double baseBasalStep; //
|
||||||
private DoseStepSize baseBasalSpecialSteps; //
|
private DoseStepSize baseBasalSpecialSteps; //
|
||||||
private PumpCapability pumpCapability;
|
private PumpCapability pumpCapability;
|
||||||
|
|
||||||
|
@ -165,18 +165,18 @@ public enum PumpType {
|
||||||
this.pumpCapability = pumpCapability;
|
this.pumpCapability = pumpCapability;
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, //
|
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||||
DoseSettings extendedBolusSettings, //
|
DoseSettings extendedBolusSettings, //
|
||||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||||
float baseBasalMinValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
||||||
{
|
{
|
||||||
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
|
this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability);
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, //
|
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||||
DoseSettings extendedBolusSettings, //
|
DoseSettings extendedBolusSettings, //
|
||||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||||
float baseBasalMinValue, Float baseBasalMaxValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
||||||
{
|
{
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.bolusSize = bolusSize;
|
this.bolusSize = bolusSize;
|
||||||
|
@ -205,7 +205,7 @@ public enum PumpType {
|
||||||
return this.pumpCapability;
|
return this.pumpCapability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getBolusSize() {
|
public double getBolusSize() {
|
||||||
return isParentSet() ? parent.bolusSize : bolusSize;
|
return isParentSet() ? parent.bolusSize : bolusSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,17 +230,17 @@ public enum PumpType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getBaseBasalMinValue() {
|
public double getBaseBasalMinValue() {
|
||||||
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
|
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Float getBaseBasalMaxValue() {
|
public Double getBaseBasalMaxValue() {
|
||||||
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
|
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public float getBaseBasalStep() {
|
public double getBaseBasalStep() {
|
||||||
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
|
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ public enum PumpType {
|
||||||
|
|
||||||
private String getBaseBasalRange()
|
private String getBaseBasalRange()
|
||||||
{
|
{
|
||||||
Float maxValue = getBaseBasalMaxValue();
|
Double maxValue = getBaseBasalMaxValue();
|
||||||
|
|
||||||
return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ public enum PumpType {
|
||||||
} else {
|
} else {
|
||||||
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
|
||||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((float)bolusAmount);
|
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
@ -381,7 +381,7 @@ public enum PumpType {
|
||||||
} else {
|
} else {
|
||||||
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
||||||
|
|
||||||
basalStepSize = specialBolusSize.getStepSizeForAmount((float) basalAmount);
|
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basalAmount > getTbrSettings().getMaxDose())
|
if (basalAmount > getTbrSettings().getMaxDose())
|
||||||
|
|
|
@ -214,7 +214,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
insulin = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||||
// needs to be rounded
|
// needs to be rounded
|
||||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||||
|
@ -409,6 +409,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
|
return applyBolusConstraints(insulin);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public ProfileStore getProfile() {
|
public ProfileStore getProfile() {
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
|
||||||
// HARDCODED LIMITS
|
// HARDCODED LIMITS
|
||||||
if (halfhours < 1) halfhours = 1;
|
if (halfhours < 1) halfhours = 1;
|
||||||
if (halfhours > 16) halfhours = 16;
|
if (halfhours > 16) halfhours = 16;
|
||||||
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
|
amount = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(amount)).value();
|
||||||
|
|
||||||
AddParamInt((int) (amount * 100));
|
AddParamInt((int) (amount * 100));
|
||||||
AddParamByte(halfhours);
|
AddParamByte(halfhours);
|
||||||
|
|
|
@ -263,6 +263,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
return insulin;
|
return insulin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||||
|
return applyBolusConstraints(insulin);
|
||||||
|
}
|
||||||
|
|
||||||
// Profile interface
|
// Profile interface
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -600,7 +605,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
@Override
|
@Override
|
||||||
public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
insulin = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||||
// needs to be rounded
|
// needs to be rounded
|
||||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||||
|
|
|
@ -227,8 +227,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
|
||||||
detailedBolusInfo.insulin = pumpType.determineCorrectBolusSize(detailedBolusInfo.insulin);
|
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
|
@ -267,8 +265,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
|
||||||
absoluteRate = pumpType.determineCorrectBasalSize(absoluteRate);
|
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.absolute(absoluteRate)
|
.absolute(absoluteRate)
|
||||||
|
@ -323,8 +319,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
insulin = pumpType.determineCorrectExtendedBolusSize(insulin);
|
|
||||||
|
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||||
extendedBolus.date = System.currentTimeMillis();
|
extendedBolus.date = System.currentTimeMillis();
|
||||||
extendedBolus.insulin = insulin;
|
extendedBolus.insulin = insulin;
|
||||||
|
|
|
@ -298,7 +298,7 @@ public class CommandQueue {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Double rateAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
Double rateAfterConstraints = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||||
|
|
||||||
// remove all unfinished
|
// remove all unfinished
|
||||||
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.queue;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.ContextWrapper;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
|
@ -34,13 +35,16 @@ public class QueueThread extends Thread {
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
public QueueThread(CommandQueue queue) {
|
QueueThread(CommandQueue queue) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.queue = queue;
|
this.queue = queue;
|
||||||
PowerManager powerManager = (PowerManager) MainApp.instance().getApplicationContext().getSystemService(Context.POWER_SERVICE);
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
|
if (context != null) {
|
||||||
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "QueueThread");
|
mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "QueueThread");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void run() {
|
public final void run() {
|
||||||
|
|
|
@ -1019,6 +1019,7 @@
|
||||||
<string name="limitingpercentrate">Limiting max percent rate to %1$d%% because of %2$s</string>
|
<string name="limitingpercentrate">Limiting max percent rate to %1$d%% because of %2$s</string>
|
||||||
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
|
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
|
||||||
<string name="limitingbolus">Limiting bolus to %1$.1f U because of %2$s</string>
|
<string name="limitingbolus">Limiting bolus to %1$.1f U because of %2$s</string>
|
||||||
|
<string name="limitingextendedbolus">Limiting extended bolus to %1$.1f U because of %2$s</string>
|
||||||
<string name="limitingmaxiob">Limiting max IOB to %1$.1f U because of %2$s</string>
|
<string name="limitingmaxiob">Limiting max IOB to %1$.1f U because of %2$s</string>
|
||||||
<string name="limitingcarbs">Limiting carbs to %1$d g because of %2$s</string>
|
<string name="limitingcarbs">Limiting carbs to %1$d g because of %2$s</string>
|
||||||
<string name="limitingiob">Limiting IOB to %1$.1f U because of %2$s</string>
|
<string name="limitingiob">Limiting IOB to %1$.1f U because of %2$s</string>
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class ConstraintsCheckerTest {
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
Constraint<Double> d = constraintChecker.getMaxBasalAllowed(AAPSMocker.getValidProfile());
|
Constraint<Double> d = constraintChecker.getMaxBasalAllowed(AAPSMocker.getValidProfile());
|
||||||
Assert.assertEquals(0.8d, d.value());
|
Assert.assertEquals(0.8d, d.value());
|
||||||
Assert.assertEquals(true, d.getReasonList().size() == 6);
|
Assert.assertEquals(7, d.getReasonList().size());
|
||||||
Assert.assertEquals("DanaR: Limiting basal rate to 0.80 U/h because of pump limit", d.getMostLimitedReasons());
|
Assert.assertEquals("DanaR: Limiting basal rate to 0.80 U/h because of pump limit", d.getMostLimitedReasons());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class ConstraintsCheckerTest {
|
||||||
// Apply all limits
|
// Apply all limits
|
||||||
Constraint<Integer> i = constraintChecker.getMaxBasalPercentAllowed(AAPSMocker.getValidProfile());
|
Constraint<Integer> i = constraintChecker.getMaxBasalPercentAllowed(AAPSMocker.getValidProfile());
|
||||||
Assert.assertEquals((Integer) 100, i.value());
|
Assert.assertEquals((Integer) 100, i.value());
|
||||||
Assert.assertEquals(true, i.getReasonList().size() == 9); // 6x Safety & RS & R & Insight
|
Assert.assertEquals(10, i.getReasonList().size()); // 7x Safety & RS & R & Insight
|
||||||
Assert.assertEquals("Safety: Limiting percent rate to 100% because of pump limit", i.getMostLimitedReasons());
|
Assert.assertEquals("Safety: Limiting percent rate to 100% because of pump limit", i.getMostLimitedReasons());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,8 @@ public class SafetyPluginTest {
|
||||||
Assert.assertEquals("Safety: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
Assert.assertEquals("Safety: Limiting basal rate to 1.00 U/h because of max value in preferences\n" +
|
||||||
"Safety: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
"Safety: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
||||||
"Safety: Limiting basal rate to 3.00 U/h because of max daily basal multiplier\n" +
|
"Safety: Limiting basal rate to 3.00 U/h because of max daily basal multiplier\n" +
|
||||||
"Safety: Limiting basal rate to 2.00 U/h because of hard limit", c.getReasons());
|
"Safety: Limiting basal rate to 2.00 U/h because of hard limit\n" +
|
||||||
|
"Safety: Limiting basal rate to 500.00 U/h because of pump limit", c.getReasons());
|
||||||
Assert.assertEquals("Safety: Limiting basal rate to 1.00 U/h because of max value in preferences", c.getMostLimitedReasons());
|
Assert.assertEquals("Safety: Limiting basal rate to 1.00 U/h because of max value in preferences", c.getMostLimitedReasons());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -144,6 +145,7 @@ public class SafetyPluginTest {
|
||||||
"Safety: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
"Safety: Limiting basal rate to 4.00 U/h because of max basal multiplier\n" +
|
||||||
"Safety: Limiting basal rate to 3.00 U/h because of max daily basal multiplier\n" +
|
"Safety: Limiting basal rate to 3.00 U/h because of max daily basal multiplier\n" +
|
||||||
"Safety: Limiting basal rate to 2.00 U/h because of hard limit\n" +
|
"Safety: Limiting basal rate to 2.00 U/h because of hard limit\n" +
|
||||||
|
"Safety: Limiting basal rate to 500.00 U/h because of pump limit\n" +
|
||||||
"Safety: Limiting percent rate to 100% because of pump limit", i.getReasons());
|
"Safety: Limiting percent rate to 100% because of pump limit", i.getReasons());
|
||||||
Assert.assertEquals("Safety: Limiting percent rate to 100% because of pump limit", i.getMostLimitedReasons());
|
Assert.assertEquals("Safety: Limiting percent rate to 100% because of pump limit", i.getMostLimitedReasons());
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class CommandQueueTest extends CommandQueue {
|
||||||
when(MainApp.instance()).thenReturn(mainApp);
|
when(MainApp.instance()).thenReturn(mainApp);
|
||||||
Constraint<Double> bolusConstraint = new Constraint<>(0d);
|
Constraint<Double> bolusConstraint = new Constraint<>(0d);
|
||||||
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(bolusConstraint);
|
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(bolusConstraint);
|
||||||
|
when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(bolusConstraint);
|
||||||
Constraint<Integer> carbsConstraint = new Constraint<>(0);
|
Constraint<Integer> carbsConstraint = new Constraint<>(0);
|
||||||
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(carbsConstraint);
|
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(carbsConstraint);
|
||||||
Constraint<Double> rateConstraint = new Constraint<>(0d);
|
Constraint<Double> rateConstraint = new Constraint<>(0d);
|
||||||
|
|
Loading…
Reference in a new issue