Merge branch 'andyrozman-virtual_pump_bug_1372' into dev
This commit is contained in:
commit
91695614f4
|
@ -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);
|
||||||
|
|
|
@ -200,7 +200,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
scheduleBgChange(null); // trigger refresh
|
scheduleBgChange(null); // trigger refresh
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
scheduleExtendedBolusChange();
|
scheduleExtendedBolusChange();
|
||||||
|
@ -236,7 +236,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
VirtualPumpPlugin.setFakingStatus(false);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(false);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,8 +967,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
||||||
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
if (!VirtualPumpPlugin.getFakingStatus()) {
|
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
updateEarliestDataChange(0);
|
updateEarliestDataChange(0);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
@ -981,8 +981,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = 0;
|
extendedBolus.durationInMinutes = 0;
|
||||||
extendedBolus.insulin = 0;
|
extendedBolus.insulin = 0;
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
if (!VirtualPumpPlugin.getFakingStatus()) {
|
if (!VirtualPumpPlugin.getPlugin().getFakingStatus()) {
|
||||||
VirtualPumpPlugin.setFakingStatus(true);
|
VirtualPumpPlugin.getPlugin().setFakingStatus(true);
|
||||||
updateEarliestDataChange(0);
|
updateEarliestDataChange(0);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,54 +1,62 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 08.12.2016.
|
* Created by mike on 08.12.2016.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PumpDescription {
|
public class PumpDescription {
|
||||||
|
public PumpType pumpType = PumpType.GenericAAPS;
|
||||||
|
|
||||||
|
public PumpDescription () {
|
||||||
|
resetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
public static final int NONE = 0;
|
public static final int NONE = 0;
|
||||||
public static final int PERCENT = 0x01;
|
public static final int PERCENT = 0x01;
|
||||||
public static final int ABSOLUTE = 0x02;
|
public static final int ABSOLUTE = 0x02;
|
||||||
|
|
||||||
public boolean isBolusCapable = true;
|
public boolean isBolusCapable;
|
||||||
public double bolusStep = 0.1d;
|
public double bolusStep;
|
||||||
|
|
||||||
public boolean isExtendedBolusCapable = true;
|
public boolean isExtendedBolusCapable;
|
||||||
public double extendedBolusStep = 0.1d;
|
public double extendedBolusStep;
|
||||||
public double extendedBolusDurationStep = 30;
|
public double extendedBolusDurationStep;
|
||||||
public double extendedBolusMaxDuration = 12 * 60;
|
public double extendedBolusMaxDuration;
|
||||||
|
|
||||||
public boolean isTempBasalCapable = true;
|
public boolean isTempBasalCapable;
|
||||||
public int tempBasalStyle = PERCENT;
|
public int tempBasalStyle;
|
||||||
|
|
||||||
public int maxTempPercent = 200;
|
public int maxTempPercent;
|
||||||
public int tempPercentStep = 10;
|
public int tempPercentStep;
|
||||||
|
|
||||||
public double maxTempAbsolute = 10;
|
public double maxTempAbsolute;
|
||||||
public double tempAbsoluteStep = 0.05d;
|
public double tempAbsoluteStep;
|
||||||
|
|
||||||
public int tempDurationStep = 60;
|
public int tempDurationStep;
|
||||||
public boolean tempDurationStep15mAllowed = false;
|
public boolean tempDurationStep15mAllowed;
|
||||||
public boolean tempDurationStep30mAllowed = false;
|
public boolean tempDurationStep30mAllowed;
|
||||||
public int tempMaxDuration = 12 * 60;
|
public int tempMaxDuration;
|
||||||
|
|
||||||
|
public boolean isSetBasalProfileCapable;
|
||||||
|
public double basalStep;
|
||||||
|
public double basalMinimumRate;
|
||||||
|
public double basalMaximumRate;
|
||||||
|
|
||||||
|
public boolean isRefillingCapable;
|
||||||
|
|
||||||
|
public boolean storesCarbInfo;
|
||||||
|
|
||||||
|
public boolean is30minBasalRatesCapable;
|
||||||
|
|
||||||
|
public boolean supportsTDDs;
|
||||||
|
public boolean needsManualTDDLoad;
|
||||||
|
|
||||||
|
|
||||||
public boolean isSetBasalProfileCapable = true;
|
public void resetSettings() {
|
||||||
public double basalStep = 0.01d;
|
|
||||||
public double basalMinimumRate = 0.04d;
|
|
||||||
public double basalMaximumRate = 25d;
|
|
||||||
|
|
||||||
public boolean isRefillingCapable = false;
|
|
||||||
|
|
||||||
public boolean storesCarbInfo = true;
|
|
||||||
|
|
||||||
public boolean is30minBasalRatesCapable = false;
|
|
||||||
|
|
||||||
public boolean supportsTDDs = false;
|
|
||||||
public boolean needsManualTDDLoad = true;
|
|
||||||
|
|
||||||
|
|
||||||
public void resetSettings()
|
|
||||||
{
|
|
||||||
isBolusCapable = true;
|
isBolusCapable = true;
|
||||||
bolusStep = 0.1d;
|
bolusStep = 0.1d;
|
||||||
|
|
||||||
|
@ -71,6 +79,7 @@ public class PumpDescription {
|
||||||
isSetBasalProfileCapable = true;
|
isSetBasalProfileCapable = true;
|
||||||
basalStep = 0.01d;
|
basalStep = 0.01d;
|
||||||
basalMinimumRate = 0.04d;
|
basalMinimumRate = 0.04d;
|
||||||
|
basalMaximumRate = 25d;
|
||||||
is30minBasalRatesCapable = false;
|
is30minBasalRatesCapable = false;
|
||||||
|
|
||||||
isRefillingCapable = false;
|
isRefillingCapable = false;
|
||||||
|
@ -78,6 +87,53 @@ public class PumpDescription {
|
||||||
|
|
||||||
supportsTDDs = false;
|
supportsTDDs = false;
|
||||||
needsManualTDDLoad = true;
|
needsManualTDDLoad = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPumpDescription(PumpType pumpType) {
|
||||||
|
resetSettings();
|
||||||
|
this.pumpType = pumpType;
|
||||||
|
|
||||||
|
PumpCapability pumpCapability = pumpType.getPumpCapability();
|
||||||
|
|
||||||
|
isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus);
|
||||||
|
bolusStep = pumpType.getBolusSize();
|
||||||
|
|
||||||
|
isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus);
|
||||||
|
extendedBolusStep = pumpType.getExtendedBolusSettings().getStep();
|
||||||
|
extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep();
|
||||||
|
extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration();
|
||||||
|
|
||||||
|
isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal);
|
||||||
|
|
||||||
|
if (pumpType.getPumpTempBasalType() == PumpTempBasalType.Percent) {
|
||||||
|
tempBasalStyle = PERCENT;
|
||||||
|
maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue();
|
||||||
|
tempPercentStep = (int) pumpType.getTbrSettings().getStep();
|
||||||
|
} else {
|
||||||
|
tempBasalStyle = ABSOLUTE;
|
||||||
|
maxTempAbsolute = pumpType.getTbrSettings().getMaxDose();
|
||||||
|
tempAbsoluteStep = pumpType.getTbrSettings().getStep();
|
||||||
|
}
|
||||||
|
|
||||||
|
tempDurationStep = pumpType.getTbrSettings().getDurationStep();
|
||||||
|
tempMaxDuration = pumpType.getTbrSettings().getMaxDuration();
|
||||||
|
|
||||||
|
tempDurationStep15mAllowed = pumpType.getSpecialBasalDurations()
|
||||||
|
.hasCapability(PumpCapability.BasalRate_Duration15minAllowed);
|
||||||
|
tempDurationStep30mAllowed = pumpType.getSpecialBasalDurations()
|
||||||
|
.hasCapability(PumpCapability.BasalRate_Duration30minAllowed);
|
||||||
|
|
||||||
|
isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet);
|
||||||
|
basalStep = pumpType.getBaseBasalStep();
|
||||||
|
basalMinimumRate = pumpType.getBaseBasalMinValue();
|
||||||
|
|
||||||
|
isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
||||||
|
storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
||||||
|
|
||||||
|
supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);
|
||||||
|
needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
|
||||||
|
|
||||||
|
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHi
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -136,7 +135,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.description(R.string.description_pump_combo)
|
.description(R.string.description_pump_combo)
|
||||||
);
|
);
|
||||||
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("Accu-Chek Combo"));
|
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComboPump getPump() {
|
public ComboPump getPump() {
|
||||||
|
|
|
@ -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, null);
|
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;
|
||||||
}
|
}
|
||||||
|
@ -326,4 +326,68 @@ public enum PumpType {
|
||||||
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double determineCorrectBolusSize(double bolusAmount) {
|
||||||
|
if (bolusAmount == 0.0d) {
|
||||||
|
return bolusAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double bolusStepSize;
|
||||||
|
|
||||||
|
if (getSpecialBolusSize() == null) {
|
||||||
|
bolusStepSize = getBolusSize();
|
||||||
|
} else {
|
||||||
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
|
||||||
|
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
||||||
|
if (bolusAmount == 0.0d) {
|
||||||
|
return bolusAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double bolusStepSize;
|
||||||
|
|
||||||
|
if (getExtendedBolusSettings() == null) { // this should be never null
|
||||||
|
return 0.0d;
|
||||||
|
}
|
||||||
|
|
||||||
|
DoseSettings extendedBolusSettings = getExtendedBolusSettings();
|
||||||
|
|
||||||
|
bolusStepSize = extendedBolusSettings.getStep();
|
||||||
|
|
||||||
|
if (bolusAmount > extendedBolusSettings.getMaxDose()) {
|
||||||
|
bolusAmount = extendedBolusSettings.getMaxDose();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double determineCorrectBasalSize(double basalAmount) {
|
||||||
|
if (basalAmount == 0.0d) {
|
||||||
|
return basalAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
double basalStepSize;
|
||||||
|
|
||||||
|
if (getBaseBasalSpecialSteps() == null) {
|
||||||
|
basalStepSize = getBaseBasalStep();
|
||||||
|
} else {
|
||||||
|
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
||||||
|
|
||||||
|
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (basalAmount > getTbrSettings().getMaxDose())
|
||||||
|
basalAmount = getTbrSettings().getMaxDose().doubleValue();
|
||||||
|
|
||||||
|
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon.utils;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by andy on 02/05/2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PumpUtil {
|
|
||||||
|
|
||||||
|
|
||||||
public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType)
|
|
||||||
{
|
|
||||||
// reset
|
|
||||||
pumpDescription.resetSettings();
|
|
||||||
|
|
||||||
PumpCapability pumpCapability = pumpType.getPumpCapability();
|
|
||||||
|
|
||||||
pumpDescription.isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus);
|
|
||||||
pumpDescription.bolusStep = pumpType.getBolusSize();
|
|
||||||
|
|
||||||
pumpDescription.isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus);
|
|
||||||
pumpDescription.extendedBolusStep = pumpType.getExtendedBolusSettings().getStep();
|
|
||||||
pumpDescription.extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep();
|
|
||||||
pumpDescription.extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration();
|
|
||||||
|
|
||||||
pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal);
|
|
||||||
|
|
||||||
if (pumpType.getPumpTempBasalType()==PumpTempBasalType.Percent)
|
|
||||||
{
|
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.PERCENT;
|
|
||||||
pumpDescription.maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue();
|
|
||||||
pumpDescription.tempPercentStep = (int)pumpType.getTbrSettings().getStep();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pumpDescription.tempBasalStyle = PumpDescription.ABSOLUTE;
|
|
||||||
pumpDescription.maxTempAbsolute = pumpType.getTbrSettings().getMaxDose();
|
|
||||||
pumpDescription.tempAbsoluteStep = pumpType.getTbrSettings().getStep();
|
|
||||||
}
|
|
||||||
|
|
||||||
pumpDescription.tempDurationStep = pumpType.getTbrSettings().getDurationStep();
|
|
||||||
pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration();
|
|
||||||
|
|
||||||
pumpDescription.tempDurationStep15mAllowed = pumpType.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration15minAllowed);
|
|
||||||
pumpDescription.tempDurationStep30mAllowed = pumpType.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration30minAllowed);
|
|
||||||
|
|
||||||
pumpDescription.isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet);
|
|
||||||
pumpDescription.basalStep = pumpType.getBaseBasalStep();
|
|
||||||
pumpDescription.basalMinimumRate = pumpType.getBaseBasalMinValue();
|
|
||||||
|
|
||||||
pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
|
|
||||||
pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
|
|
||||||
|
|
||||||
pumpDescription.supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);
|
|
||||||
pumpDescription.needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad);
|
|
||||||
|
|
||||||
pumpDescription.is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -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() {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
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.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||||
|
@ -48,7 +47,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
public DanaRPlugin() {
|
public DanaRPlugin() {
|
||||||
super();
|
super();
|
||||||
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("DanaR"));
|
pumpDescription.setPumpDescription(PumpType.DanaR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
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.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
|
||||||
|
@ -51,7 +50,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_korean);
|
pluginDescription.description(R.string.description_pump_dana_r_korean);
|
||||||
|
|
||||||
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
useExtendedBoluses = SP.getBoolean(R.string.key_danar_useextended, false);
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("DanaR Korean"));
|
pumpDescription.setPumpDescription(PumpType.DanaRKorean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,7 +44,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
|
@ -90,7 +89,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
.description(R.string.description_pump_dana_rs)
|
.description(R.string.description_pump_dana_rs)
|
||||||
);
|
);
|
||||||
|
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("DanaRS"));
|
pumpDescription.setPumpDescription(PumpType.DanaRS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -264,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
|
||||||
|
@ -616,7 +620,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);
|
||||||
|
|
|
@ -22,7 +22,6 @@ 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.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
|
||||||
|
@ -51,7 +50,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_v2);
|
pluginDescription.description(R.string.description_pump_dana_r_v2);
|
||||||
|
|
||||||
useExtendedBoluses = false;
|
useExtendedBoluses = false;
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("DanaRv2"));
|
pumpDescription.setPumpDescription(PumpType.DanaRv2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,7 +39,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusSilentlyTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusSilentlyTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelTBRSilentlyTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelTBRSilentlyTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
||||||
|
@ -122,7 +121,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
.description(R.string.description_pump_insight)
|
.description(R.string.description_pump_insight)
|
||||||
);
|
);
|
||||||
log("InsightPlugin instantiated");
|
log("InsightPlugin instantiated");
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.getByDescription("Accu-Chek Insight"));
|
pumpDescription.setPumpDescription(PumpType.AccuChekInsight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -42,42 +41,15 @@ import info.nightscout.utils.SP;
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(VirtualPumpPlugin.class);
|
|
||||||
|
|
||||||
private static VirtualPumpPlugin plugin = null;
|
|
||||||
|
|
||||||
public static VirtualPumpPlugin getPlugin() {
|
|
||||||
loadFakingStatus();
|
|
||||||
if (plugin == null)
|
|
||||||
plugin = new VirtualPumpPlugin();
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Integer batteryPercent = 50;
|
static Integer batteryPercent = 50;
|
||||||
static Integer reservoirInUnits = 50;
|
static Integer reservoirInUnits = 50;
|
||||||
|
private static Logger log = LoggerFactory.getLogger(VirtualPumpPlugin.class);
|
||||||
private long lastDataTime = 0;
|
private static VirtualPumpPlugin plugin = null;
|
||||||
|
|
||||||
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||||
|
private PumpType pumpType = null;
|
||||||
|
private long lastDataTime = 0;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
PumpType pumpType = null;
|
|
||||||
|
|
||||||
|
|
||||||
private static void loadFakingStatus() {
|
|
||||||
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setFakingStatus(boolean newStatus) {
|
|
||||||
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
|
||||||
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean getFakingStatus() {
|
|
||||||
return fromNSAreCommingFakedExtendedBoluses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VirtualPumpPlugin() {
|
public VirtualPumpPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.PUMP)
|
.mainType(PluginType.PUMP)
|
||||||
|
@ -118,6 +90,26 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
pumpDescription.is30minBasalRatesCapable = true;
|
pumpDescription.is30minBasalRatesCapable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static VirtualPumpPlugin getPlugin() {
|
||||||
|
if (plugin == null)
|
||||||
|
plugin = new VirtualPumpPlugin();
|
||||||
|
plugin.loadFakingStatus();
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadFakingStatus() {
|
||||||
|
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getFakingStatus() {
|
||||||
|
return fromNSAreCommingFakedExtendedBoluses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFakingStatus(boolean newStatus) {
|
||||||
|
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
||||||
|
SP.putBoolean(R.string.key_fromNSAreCommingFakedExtendedBoluses, fromNSAreCommingFakedExtendedBoluses);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
@ -144,8 +136,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult loadTDDs() {
|
public PumpEnactResult loadTDDs() {
|
||||||
//no result, could read DB in the future?
|
//no result, could read DB in the future?
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
return new PumpEnactResult();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -232,8 +223,10 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
return 0d;
|
return 0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
|
@ -267,11 +260,11 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.absolute(absoluteRate)
|
.absolute(absoluteRate)
|
||||||
|
@ -325,6 +318,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
PumpEnactResult result = cancelExtendedBolus();
|
PumpEnactResult result = cancelExtendedBolus();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||||
extendedBolus.date = System.currentTimeMillis();
|
extendedBolus.date = System.currentTimeMillis();
|
||||||
extendedBolus.insulin = insulin;
|
extendedBolus.insulin = insulin;
|
||||||
|
@ -398,7 +392,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", profileName);
|
extended.put("ActiveProfile", profileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
|
@ -459,7 +453,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
if (L.isEnabled(L.PUMP))
|
if (L.isEnabled(L.PUMP))
|
||||||
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType);
|
||||||
|
|
||||||
PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew);
|
pumpDescription.setPumpDescription(pumpTypeNew);
|
||||||
|
|
||||||
this.pumpType = pumpTypeNew;
|
this.pumpType = pumpTypeNew;
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package info.nightscout.androidaps.plugins.PumpCommon.utils;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -13,14 +13,14 @@ import static org.junit.Assert.*;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 5/13/18.
|
* Created by andy on 5/13/18.
|
||||||
*/
|
*/
|
||||||
public class PumpUtilUTest {
|
public class PumpDescritpionTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setPumpDescription() throws Exception {
|
public void setPumpDescription() {
|
||||||
|
|
||||||
PumpDescription pumpDescription = new PumpDescription();
|
PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
PumpUtil.setPumpDescription(pumpDescription, PumpType.AccuChekCombo);
|
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
||||||
|
|
||||||
Assert.assertEquals(pumpDescription.bolusStep, PumpType.AccuChekCombo.getBolusSize(), 0.1d);
|
Assert.assertEquals(pumpDescription.bolusStep, PumpType.AccuChekCombo.getBolusSize(), 0.1d);
|
||||||
Assert.assertEquals(pumpDescription.basalMinimumRate, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d);
|
Assert.assertEquals(pumpDescription.basalMinimumRate, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d);
|
|
@ -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