Merge remote-tracking branch 'remotes/origin/dev' into dev

This commit is contained in:
Tebbe Ubben 2018-02-06 00:13:28 +01:00
commit 515b0d251a

View file

@ -459,18 +459,18 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
log("Base basal rate appears to be zero!"); log("Base basal rate appears to be zero!");
return pumpEnactFailure(); return pumpEnactFailure();
} }
int amount = (int) Math.round(100d / base_basal * absoluteRate); int percent_amount = (int) Math.round(100d / base_basal * absoluteRate);
log("Calculated requested rate: " + absoluteRate + " base rate: " + base_basal + " percentage: " + amount + "%"); log("Calculated requested rate: " + absoluteRate + " base rate: " + base_basal + " percentage: " + percent_amount + "%");
amount = (int) Math.round(((double) amount) / 10d) * 10; percent_amount = (int) Math.round(((double) percent_amount) / 10d) * 10;
log("Calculated final rate: " + amount + "%"); log("Calculated final rate: " + percent_amount + "%");
if (amount == 100) { if (percent_amount == 100) {
return cancelTempBasal(false); return cancelTempBasal(false);
} }
if (amount > 250) amount = 250; if (percent_amount > 250) percent_amount = 250;
final SetTBRTaskRunner task = new SetTBRTaskRunner(connector.getServiceConnector(), amount, durationInMinutes); final SetTBRTaskRunner task = new SetTBRTaskRunner(connector.getServiceConnector(), percent_amount, durationInMinutes);
final UUID cmd = aSyncTaskRunner(task, "Set TBR abs: " + absoluteRate + " " + durationInMinutes + "m"); final UUID cmd = aSyncTaskRunner(task, "Set TBR abs: " + absoluteRate + " " + durationInMinutes + "m");
if (cmd == null) { if (cmd == null) {
@ -480,18 +480,19 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME); Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
log("Got command status: " + ms); log("Got command status: " + ms);
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(false).duration(durationInMinutes); PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(true).duration(durationInMinutes);
pumpEnactResult.absolute = absoluteRate; // TODO get converted value? pumpEnactResult.percent = percent_amount;
pumpEnactResult.success = ms.success(); pumpEnactResult.success = ms.success();
pumpEnactResult.isTempCancel = false; // do we test this here? pumpEnactResult.isTempCancel = percent_amount == 100; // 100% temp basal is a cancellation
pumpEnactResult.comment = ms.getCommandComment(); pumpEnactResult.comment = ms.getCommandComment();
if (pumpEnactResult.success) { if (pumpEnactResult.success) {
// create log entry // create log entry
final TemporaryBasal tempBasal = new TemporaryBasal(); final TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = System.currentTimeMillis(); tempBasal.date = System.currentTimeMillis();
tempBasal.isAbsolute = true; tempBasal.isAbsolute = false;
tempBasal.absoluteRate = base_basal / 100d * ((double) amount); // is this the correct figure to use? tempBasal.percentRate = percent_amount;
tempBasal.durationInMinutes = durationInMinutes; tempBasal.durationInMinutes = durationInMinutes;
tempBasal.source = Source.USER; tempBasal.source = Source.USER;
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal); MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);