handle if bolus progress is not sent

This commit is contained in:
Milos Kozak 2017-02-19 00:06:29 +01:00
parent e0a9a7ae81
commit a2eb76a8b8
3 changed files with 6 additions and 5 deletions

View file

@ -395,7 +395,6 @@ public class ExecutionService extends Service {
public boolean bolus(Double amount, int carbs, Treatment t) { public boolean bolus(Double amount, int carbs, Treatment t) {
bolusingTreatment = t; bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount); MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
connect("bolus"); connect("bolus");
@ -405,6 +404,7 @@ public class ExecutionService extends Service {
Calendar time = Calendar.getInstance(); Calendar time = Calendar.getInstance();
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs));
} }
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MainApp.bus().post(new EventDanaRBolusStart()); MainApp.bus().post(new EventDanaRBolusStart());
if (!stop.stopped) { if (!stop.stopped) {
@ -415,7 +415,7 @@ public class ExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); waitMsec(100);
if (progress.lastReceive != 0 && (new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm if ((new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm
stop.stopped = true; stop.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");

View file

@ -30,7 +30,7 @@ public class MsgBolusProgress extends MessageBase {
this(); this();
this.amount = amount; this.amount = amount;
this.t = t; this.t = t;
lastReceive = 0; lastReceive = new Date().getTime();
} }
@Override @Override

View file

@ -387,7 +387,6 @@ public class ExecutionService extends Service {
public boolean bolus(Double amount, int carbs, Treatment t) { public boolean bolus(Double amount, int carbs, Treatment t) {
bolusingTreatment = t; bolusingTreatment = t;
MsgBolusStart start = new MsgBolusStart(amount); MsgBolusStart start = new MsgBolusStart(amount);
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MsgBolusStop stop = new MsgBolusStop(amount, t); MsgBolusStop stop = new MsgBolusStop(amount, t);
connect("bolus"); connect("bolus");
@ -397,6 +396,8 @@ public class ExecutionService extends Service {
Calendar time = Calendar.getInstance(); Calendar time = Calendar.getInstance();
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs)); mSerialIOThread.sendMessage(new MsgSetCarbsEntry(time, carbs));
} }
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
MainApp.bus().post(new EventDanaRBolusStart()); MainApp.bus().post(new EventDanaRBolusStart());
if (!stop.stopped) { if (!stop.stopped) {
@ -407,7 +408,7 @@ public class ExecutionService extends Service {
} }
while (!stop.stopped && !start.failed) { while (!stop.stopped && !start.failed) {
waitMsec(100); waitMsec(100);
if (progress.lastReceive != 0 && (new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm if ((new Date().getTime() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm
stop.stopped = true; stop.stopped = true;
stop.forced = true; stop.forced = true;
log.debug("Communication stopped"); log.debug("Communication stopped");