Fix carb only treatment.
This commit is contained in:
parent
d0dabf34da
commit
364123c261
1 changed files with 6 additions and 5 deletions
|
@ -254,12 +254,11 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return basal;
|
return basal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rewrite this crap into something comprehensible
|
// what a mess: pump integration code reading carb info from Detailed**Bolus**Info,
|
||||||
|
// writing carb treatments to the history table. What's PumpEnactResult for again?
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
log.debug("deliver treatment called with dbi: " + detailedBolusInfo);
|
log.debug("deliver treatment called with dbi: " + detailedBolusInfo);
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
|
||||||
detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin);
|
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (detailedBolusInfo.insulin > 0) {
|
if (detailedBolusInfo.insulin > 0) {
|
||||||
|
@ -269,6 +268,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
// TODO if no error occurred, the requested bolus is what the pump delievered,
|
// TODO if no error occurred, the requested bolus is what the pump delievered,
|
||||||
// that has been checked. If an error occurred, we should check how much insulin
|
// that has been checked. If an error occurred, we should check how much insulin
|
||||||
// was delivered, e.g. when the cartridge went empty mid-bolus
|
// was delivered, e.g. when the cartridge went empty mid-bolus
|
||||||
|
// For the first iteration, the alert the pump raises must suffice
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
result.comment = bolusCmdResult.message;
|
result.comment = bolusCmdResult.message;
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,11 +277,11 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
// info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog.scheduleDismiss()
|
// info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog.scheduleDismiss()
|
||||||
SystemClock.sleep(6000);
|
SystemClock.sleep(6000);
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = false;
|
result.enacted = true;
|
||||||
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
}
|
}
|
||||||
if (result.enacted) {
|
if (result.enacted) {
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||||
detailedBolusInfo.date = new Date().getTime();
|
detailedBolusInfo.date = new Date().getTime();
|
||||||
|
@ -291,6 +291,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = false;
|
result.success = false;
|
||||||
|
result.enacted = false;
|
||||||
result.bolusDelivered = 0d;
|
result.bolusDelivered = 0d;
|
||||||
result.carbsDelivered = 0d;
|
result.carbsDelivered = 0d;
|
||||||
result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
|
result.comment = MainApp.instance().getString(R.string.danar_invalidinput);
|
||||||
|
|
Loading…
Reference in a new issue