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));
|
||||
}
|
||||
|
||||
public Constraint<Double> getMaxExtendedBolusAllowed() {
|
||||
return applyExtendedBolusConstraints(new Constraint<>(Constants.REALLYHIGHBOLUS));
|
||||
}
|
||||
|
||||
public Constraint<Integer> getMaxCarbsAllowed() {
|
||||
return applyCarbsConstraints(new Constraint<>(Constants.REALLYHIGHCARBS));
|
||||
}
|
||||
|
@ -170,6 +174,17 @@ public class ConstraintChecker implements ConstraintsInterface {
|
|||
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
|
||||
public Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||
ArrayList<PluginBase> constraintsPlugins = mainApp.getSpecificPluginsListByInterface(ConstraintsInterface.class);
|
||||
|
|
|
@ -47,6 +47,15 @@ public class Constraint<T extends Comparable> {
|
|||
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) {
|
||||
if (value.compareTo(this.value) < 0) {
|
||||
this.value = value;
|
||||
|
|
|
@ -43,6 +43,10 @@ public interface ConstraintsInterface {
|
|||
return insulin;
|
||||
}
|
||||
|
||||
default Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||
return insulin;
|
||||
}
|
||||
|
||||
default Constraint<Integer> applyCarbsConstraints(Constraint<Integer> carbs) {
|
||||
return carbs;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
|
||||
/**
|
||||
* Created by mike on 09.06.2016.
|
||||
|
@ -168,7 +169,9 @@ public abstract class PluginBase {
|
|||
if (getType() == PluginType.PUMP) {
|
||||
new Thread(() -> {
|
||||
SystemClock.sleep(3000);
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Pump driver changed.", null);
|
||||
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
|
||||
if (commandQueue != null)
|
||||
commandQueue.readStatus("Pump driver changed.", null);
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
|||
*/
|
||||
|
||||
public class PumpDescription {
|
||||
PumpType pumpType = PumpType.GenericAAPS;
|
||||
public PumpType pumpType = PumpType.GenericAAPS;
|
||||
|
||||
public PumpDescription () {
|
||||
resetSettings();
|
||||
|
|
|
@ -44,7 +44,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
|
||||
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.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);
|
||||
|
||||
Double insulinAfterConstraint = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
Double insulinAfterConstraint = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||
confirmMessage += " " + insulinAfterConstraint + " U ";
|
||||
confirmMessage += MainApp.gs(R.string.duration) + " " + durationInMinutes + "min ?";
|
||||
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.PluginDescription;
|
||||
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.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
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(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;
|
||||
}
|
||||
|
||||
|
@ -136,10 +150,14 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
|||
applyBasalConstraints(absoluteConstraint, profile);
|
||||
percentRate.copyReasons(absoluteConstraint);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue();
|
||||
if (pump != null) {
|
||||
if (percentRateAfterConst < 100)
|
||||
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, 10d).intValue();
|
||||
else percentRateAfterConst = Round.floorTo((double) percentRateAfterConst, 10d).intValue();
|
||||
percentRateAfterConst = Round.ceilTo((double) percentRateAfterConst, (double) pump.getPumpDescription().tempPercentStep).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);
|
||||
|
||||
|
@ -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(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,13 +6,13 @@ package info.nightscout.androidaps.plugins.PumpCommon.data;
|
|||
|
||||
public class DoseSettings {
|
||||
|
||||
private float step;
|
||||
private double step;
|
||||
private int durationStep;
|
||||
private int maxDuration;
|
||||
private float minDose;
|
||||
private Float maxDose;
|
||||
private double minDose;
|
||||
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.durationStep = durationStep;
|
||||
|
@ -21,13 +21,13 @@ public class DoseSettings {
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ public class DoseSettings {
|
|||
return maxDuration;
|
||||
}
|
||||
|
||||
public float getMinDose() {
|
||||
public double getMinDose() {
|
||||
return minDose;
|
||||
}
|
||||
|
||||
public Float getMaxDose() {
|
||||
public Double getMaxDose() {
|
||||
return maxDose;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,18 +10,18 @@ public enum DoseStepSize
|
|||
ComboBasal( //
|
||||
new DoseStepSizeEntry(0f, 1f, 0.01f), //
|
||||
new DoseStepSizeEntry(1f, 10f, 0.05f), //
|
||||
new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), //
|
||||
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.1f)), //
|
||||
|
||||
InsightBolus(
|
||||
new DoseStepSizeEntry(0f, 2f, 0.05f), //
|
||||
new DoseStepSizeEntry(2f, 5f, 0.1f), //
|
||||
new DoseStepSizeEntry(5f, 10f, 0.2f), //
|
||||
new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.5f)),
|
||||
new DoseStepSizeEntry(10f, Double.MAX_VALUE, 0.5f)),
|
||||
|
||||
MedtronicVeoBasal( //
|
||||
new DoseStepSizeEntry(0f, 1f, 0.025f), //
|
||||
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) {
|
||||
if (entry.from <= amount && entry.to > amount)
|
||||
|
@ -57,7 +57,7 @@ public enum DoseStepSize
|
|||
sb.append(entry.from);
|
||||
sb.append("-");
|
||||
|
||||
if (entry.to == Float.MAX_VALUE)
|
||||
if (entry.to == Double.MAX_VALUE)
|
||||
{
|
||||
sb.append("~}");
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ public enum DoseStepSize
|
|||
|
||||
static class DoseStepSizeEntry
|
||||
{
|
||||
float from;
|
||||
float to;
|
||||
float value;
|
||||
double from;
|
||||
double to;
|
||||
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]
|
||||
DoseStepSizeEntry(float from, float to, float value)
|
||||
DoseStepSizeEntry(double from, double to, double value)
|
||||
{
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
|
|
|
@ -18,108 +18,108 @@ import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings;
|
|||
|
||||
public enum PumpType {
|
||||
|
||||
GenericAAPS("Generic AAPS", 0.1f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
GenericAAPS("Generic AAPS", 0.1d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10,30, 24*60, 0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01f, 0.01f, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(10,30, 24*60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
// Cellnovo
|
||||
|
||||
Cellnovo1("Cellnovo", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 24*60, 1f, null),
|
||||
Cellnovo1("Cellnovo", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 24*60, 1d, null),
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(5,30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(5,30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
// Accu-Chek
|
||||
|
||||
AccuChekCombo("Accu-Chek Combo", 0.1f, null, //
|
||||
new DoseSettings(0.1f, 15, 12*60, 0.1f), //
|
||||
AccuChekCombo("Accu-Chek Combo", 0.1d, null, //
|
||||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01f, 0.1f, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01d, 0.1d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||
|
||||
AccuChekSpirit("Accu-Chek Spirit", 0.1f, null, //
|
||||
new DoseSettings(0.1f, 15, 12*60, 0.1f), //
|
||||
AccuChekSpirit("Accu-Chek Spirit", 0.1d, null, //
|
||||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01f, 0.1f, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
AccuChekInsight("Accu-Chek Insight", 0.05f, DoseStepSize.InsightBolus, //
|
||||
new DoseSettings(0.05f, 15, 24*60, 0.05f), //
|
||||
AccuChekInsight("Accu-Chek Insight", 0.05d, DoseStepSize.InsightBolus, //
|
||||
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(10, 15, 12*60,0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.02f, 0.1f, null, PumpCapability.InsightCapabilities), //
|
||||
new DoseSettings(10, 15, 12*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.02d, 0.1d, null, PumpCapability.InsightCapabilities), //
|
||||
|
||||
// Animas
|
||||
AnimasVibe("Animas Vibe", 0.05f, null, // AnimasBolus?
|
||||
new DoseSettings(0.05f, 30, 12*60, 0.05f), //
|
||||
AnimasVibe("Animas Vibe", 0.05d, null, // AnimasBolus?
|
||||
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10, 30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025f, 5f, 0f, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(10, 30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
AnimasPing("Animas Ping", AnimasVibe),
|
||||
|
||||
// Dana
|
||||
DanaR("DanaR", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
DanaR("DanaR", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||
0.04f, 0.01f, null, PumpCapability.DanaCapabilities),
|
||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||
|
||||
DanaRKorean("DanaR Korean", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
DanaRKorean("DanaR Korean", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||
0.1f, 0.01f, null, PumpCapability.DanaCapabilities),
|
||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||
|
||||
DanaRS("DanaRS", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
DanaRS("DanaRS", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Percent, //
|
||||
new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.04f, 0.01f, null, PumpCapability.DanaWithHistoryCapabilities),
|
||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
||||
|
||||
DanaRv2("DanaRv2", DanaRS),
|
||||
|
||||
|
||||
// Insulet
|
||||
Insulet_Omnipod("Insulet Omnipod", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
Insulet_Omnipod("Insulet Omnipod", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities),
|
||||
new DoseSettings(0.05d, 30, 12*60, 0d, 5.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||
|
||||
// Medtronic
|
||||
Medtronic_512_712("Medtronic 512/712", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
Medtronic_512_712("Medtronic 512/712", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
||||
|
||||
Medtronic_515_715("Medtronic 515/715", Medtronic_512_712),
|
||||
Medtronic_522_722("Medtronic 522/722", Medtronic_512_712),
|
||||
|
||||
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
||||
|
||||
Medtronic_640G("Medtronic 640G", 0.025f, null, //
|
||||
new DoseSettings(0.05f, 30, 8*60, 0.05f), //
|
||||
Medtronic_640G("Medtronic 640G", 0.025d, null, //
|
||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
||||
PumpTempBasalType.Absolute, //
|
||||
new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||
|
||||
// Tandem
|
||||
TandemTSlim("Tandem t:slim", 0.01f, null, //
|
||||
new DoseSettings(0.01f,15, 8*60, 0.4f),
|
||||
TandemTSlim("Tandem t:slim", 0.01d, null, //
|
||||
new DoseSettings(0.01d,15, 8*60, 0.4d),
|
||||
PumpTempBasalType.Percent,
|
||||
new DoseSettings(1,15, 8*60, 0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.1f, 0.001f, null, PumpCapability.VirtualPumpCapabilities),
|
||||
new DoseSettings(1,15, 8*60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
||||
|
||||
TandemTFlex("Tandem t:flex", TandemTSlim), //
|
||||
TandemTSlimG4("Tandem t:slim G4", TandemTSlim), //
|
||||
|
@ -127,15 +127,15 @@ public enum PumpType {
|
|||
;
|
||||
|
||||
private String description;
|
||||
private float bolusSize;
|
||||
private double bolusSize;
|
||||
private DoseStepSize specialBolusSize;
|
||||
private DoseSettings extendedBolusSettings;
|
||||
private PumpTempBasalType pumpTempBasalType;
|
||||
private DoseSettings tbrSettings;
|
||||
private PumpCapability specialBasalDurations;
|
||||
private float baseBasalMinValue; //
|
||||
private Float baseBasalMaxValue;
|
||||
private float baseBasalStep; //
|
||||
private double baseBasalMinValue; //
|
||||
private Double baseBasalMaxValue;
|
||||
private double baseBasalStep; //
|
||||
private DoseStepSize baseBasalSpecialSteps; //
|
||||
private PumpCapability pumpCapability;
|
||||
|
||||
|
@ -165,18 +165,18 @@ public enum PumpType {
|
|||
this.pumpCapability = pumpCapability;
|
||||
}
|
||||
|
||||
PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, //
|
||||
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||
DoseSettings extendedBolusSettings, //
|
||||
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);
|
||||
}
|
||||
|
||||
PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, //
|
||||
PumpType(String description, double bolusSize, DoseStepSize specialBolusSize, //
|
||||
DoseSettings extendedBolusSettings, //
|
||||
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.bolusSize = bolusSize;
|
||||
|
@ -205,7 +205,7 @@ public enum PumpType {
|
|||
return this.pumpCapability;
|
||||
}
|
||||
|
||||
public float getBolusSize() {
|
||||
public double getBolusSize() {
|
||||
return isParentSet() ? parent.bolusSize : bolusSize;
|
||||
}
|
||||
|
||||
|
@ -230,17 +230,17 @@ public enum PumpType {
|
|||
}
|
||||
|
||||
|
||||
public float getBaseBasalMinValue() {
|
||||
public double getBaseBasalMinValue() {
|
||||
return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue;
|
||||
}
|
||||
|
||||
|
||||
public Float getBaseBasalMaxValue() {
|
||||
public Double getBaseBasalMaxValue() {
|
||||
return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue;
|
||||
}
|
||||
|
||||
|
||||
public float getBaseBasalStep() {
|
||||
public double getBaseBasalStep() {
|
||||
return isParentSet() ? parent.baseBasalStep : baseBasalStep;
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ public enum PumpType {
|
|||
|
||||
private String getBaseBasalRange()
|
||||
{
|
||||
Float maxValue = getBaseBasalMaxValue();
|
||||
Double maxValue = getBaseBasalMaxValue();
|
||||
|
||||
return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public enum PumpType {
|
|||
} else {
|
||||
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||
|
||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((float)bolusAmount);
|
||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
|
||||
}
|
||||
|
||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||
|
@ -381,7 +381,7 @@ public enum PumpType {
|
|||
} else {
|
||||
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
||||
|
||||
basalStepSize = specialBolusSize.getStepSizeForAmount((float) basalAmount);
|
||||
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
|
||||
}
|
||||
|
||||
if (basalAmount > getTbrSettings().getMaxDose())
|
||||
|
|
|
@ -214,7 +214,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
@Override
|
||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
insulin = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||
// needs to be rounded
|
||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||
|
@ -409,6 +409,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
return insulin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||
return applyBolusConstraints(insulin);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ProfileStore getProfile() {
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MsgSetExtendedBolusStart extends MessageBase {
|
|||
// HARDCODED LIMITS
|
||||
if (halfhours < 1) halfhours = 1;
|
||||
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));
|
||||
AddParamByte(halfhours);
|
||||
|
|
|
@ -263,6 +263,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
return insulin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Constraint<Double> applyExtendedBolusConstraints(Constraint<Double> insulin) {
|
||||
return applyBolusConstraints(insulin);
|
||||
}
|
||||
|
||||
// Profile interface
|
||||
|
||||
@Nullable
|
||||
|
@ -600,7 +605,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
@Override
|
||||
public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
insulin = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
insulin = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||
// needs to be rounded
|
||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||
|
|
|
@ -227,8 +227,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
|
||||
detailedBolusInfo.insulin = pumpType.determineCorrectBolusSize(detailedBolusInfo.insulin);
|
||||
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
result.success = true;
|
||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||
|
@ -267,8 +265,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
@Override
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||
|
||||
absoluteRate = pumpType.determineCorrectBasalSize(absoluteRate);
|
||||
|
||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||
.date(System.currentTimeMillis())
|
||||
.absolute(absoluteRate)
|
||||
|
@ -323,8 +319,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
|||
if (!result.success)
|
||||
return result;
|
||||
|
||||
insulin = pumpType.determineCorrectExtendedBolusSize(insulin);
|
||||
|
||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||
extendedBolus.date = System.currentTimeMillis();
|
||||
extendedBolus.insulin = insulin;
|
||||
|
|
|
@ -298,7 +298,7 @@ public class CommandQueue {
|
|||
return false;
|
||||
}
|
||||
|
||||
Double rateAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(insulin)).value();
|
||||
Double rateAfterConstraints = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(insulin)).value();
|
||||
|
||||
// remove all unfinished
|
||||
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.queue;
|
|||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
|
||||
|
@ -34,13 +35,16 @@ public class QueueThread extends Thread {
|
|||
|
||||
private PowerManager.WakeLock mWakeLock;
|
||||
|
||||
public QueueThread(CommandQueue queue) {
|
||||
QueueThread(CommandQueue queue) {
|
||||
super();
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</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="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>
|
||||
|
|
|
@ -156,7 +156,7 @@ public class ConstraintsCheckerTest {
|
|||
// Apply all limits
|
||||
Constraint<Double> d = constraintChecker.getMaxBasalAllowed(AAPSMocker.getValidProfile());
|
||||
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());
|
||||
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class ConstraintsCheckerTest {
|
|||
// Apply all limits
|
||||
Constraint<Integer> i = constraintChecker.getMaxBasalPercentAllowed(AAPSMocker.getValidProfile());
|
||||
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());
|
||||
|
||||
}
|
||||
|
|
|
@ -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" +
|
||||
"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 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());
|
||||
|
||||
}
|
||||
|
@ -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 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 500.00 U/h because of pump limit\n" +
|
||||
"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());
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ public class CommandQueueTest extends CommandQueue {
|
|||
when(MainApp.instance()).thenReturn(mainApp);
|
||||
Constraint<Double> bolusConstraint = new Constraint<>(0d);
|
||||
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(bolusConstraint);
|
||||
when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(bolusConstraint);
|
||||
Constraint<Integer> carbsConstraint = new Constraint<>(0);
|
||||
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(carbsConstraint);
|
||||
Constraint<Double> rateConstraint = new Constraint<>(0d);
|
||||
|
|
Loading…
Reference in a new issue