fix bolus step for Dana pumps

This commit is contained in:
Milos Kozak 2018-04-20 22:13:20 +02:00
parent 2f299bc670
commit 870d23c08c
4 changed files with 13 additions and 7 deletions

View file

@ -35,6 +35,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.NumberPicker; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
@ -104,7 +105,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount); editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only); recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only);

View file

@ -304,7 +304,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
@Override @Override
public void getPumpStatus() { public void getPumpStatus() {
if (sExecutionService != null) sExecutionService.getPumpStatus(); if (sExecutionService != null) {
sExecutionService.getPumpStatus();
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
}
} }
@Override @Override

View file

@ -178,8 +178,6 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
final Object o = new Object(); final Object o = new Object();
danaRSService.connect(from, mDeviceAddress, o); danaRSService.connect(from, mDeviceAddress, o);
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
} }
} }
@ -205,8 +203,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override @Override
public void getPumpStatus() { public void getPumpStatus() {
if (danaRSService != null) if (danaRSService != null) {
danaRSService.getPumpStatus(); danaRSService.getPumpStatus();
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
}
} }
// DanaR interface // DanaR interface

View file

@ -46,13 +46,13 @@ public class DecimalFormatter {
} }
public static String toPumpSupportedBolus(double value) { public static String toPumpSupportedBolus(double value) {
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01 return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? to2Decimal(value) ? to2Decimal(value)
: to1Decimal(value); : to1Decimal(value);
} }
public static DecimalFormat pumpSupportedBolusFormat() { public static DecimalFormat pumpSupportedBolusFormat() {
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01 return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? new DecimalFormat("0.00") ? new DecimalFormat("0.00")
: new DecimalFormat("0.0"); : new DecimalFormat("0.0");
} }