send carbs and insulin in one connect

This commit is contained in:
Milos Kozak 2016-08-08 15:49:13 +02:00
parent 267e0220c0
commit 2e72e18c62
2 changed files with 6 additions and 3 deletions

View file

@ -240,8 +240,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (insulin > 0 || carbs > 0) {
Treatment t = new Treatment();
boolean connectionOK = false;
if (carbs > 0) connectionOK = sExecutionService.carbsEntry(carbs);
if (insulin > 0) connectionOK = sExecutionService.bolus(insulin, t);
if (insulin > 0) connectionOK = sExecutionService.bolus(insulin, carbs, t);
PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK;
result.bolusDelivered = t.insulin;

View file

@ -355,7 +355,7 @@ public class ExecutionService extends Service {
return true;
}
public boolean bolus(Double amount, Treatment t) {
public boolean bolus(Double amount, int carbs, Treatment t) {
bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusProgress progress = new MsgBolusProgress(MainApp.bus(), amount, t);
@ -364,6 +364,10 @@ public class ExecutionService extends Service {
connect("bolus");
if (!isConnected()) return false;
if (carbs > 0) {
Calendar time = Calendar.getInstance();
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs));
}
MainApp.bus().post(new EventDanaRBolusStart());
if (!stop.stopped) {