Semi-fix bolusing not logging a treatment when there was an error.
This commit is contained in:
parent
e29ef5ffce
commit
f34fed1f05
1 changed files with 14 additions and 8 deletions
|
@ -244,6 +244,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
return 0.5d;
|
return 0.5d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO rewrite this crap into something comprehensible
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||||
|
@ -254,6 +255,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
CommandResult bolusCmdResult = runCommand(new BolusCommand(detailedBolusInfo.insulin));
|
CommandResult bolusCmdResult = runCommand(new BolusCommand(detailedBolusInfo.insulin));
|
||||||
result.success = bolusCmdResult.success;
|
result.success = bolusCmdResult.success;
|
||||||
result.enacted = bolusCmdResult.enacted;
|
result.enacted = bolusCmdResult.enacted;
|
||||||
|
// 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
|
||||||
|
// was delivered, e.g. when the cartridge went empty mid-bolus
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
result.comment = bolusCmdResult.message;
|
result.comment = bolusCmdResult.message;
|
||||||
} else {
|
} else {
|
||||||
|
@ -264,12 +268,14 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
}
|
}
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
if (result.enacted) {
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||||
if (Config.logPumpActions)
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
if (Config.logPumpActions)
|
||||||
detailedBolusInfo.date = new Date().getTime();
|
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
detailedBolusInfo.date = new Date().getTime();
|
||||||
|
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -346,8 +352,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.stoppingtempbasal)));
|
||||||
CommandResult commandResult = runCommand(new CancelTbrCommand());
|
CommandResult commandResult = runCommand(new CancelTbrCommand());
|
||||||
if(commandResult.enacted) {
|
if(commandResult.enacted) {
|
||||||
TemporaryBasal tempStop = new TemporaryBasal(new Date().getTime());
|
TemporaryBasal tempStop = new TemporaryBasal(System.currentTimeMillis());
|
||||||
tempStop.durationInMinutes = 0; // == ending temp basal
|
tempStop.durationInMinutes = 0; // ending temp basal
|
||||||
tempStop.source = Source.USER;
|
tempStop.source = Source.USER;
|
||||||
ConfigBuilderPlugin treatmentsInterface = MainApp.getConfigBuilder();
|
ConfigBuilderPlugin treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
||||||
|
|
Loading…
Reference in a new issue