fix wrong error dialog when only carbs are delivered (R,KoreanR)
This commit is contained in:
parent
7e2fb305c6
commit
c15a4b5efe
5 changed files with 96 additions and 91 deletions
|
@ -72,7 +72,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
|
|
||||||
pumpDescription.storesCarbInfo = true;
|
pumpDescription.storesCarbInfo = false;
|
||||||
|
|
||||||
pumpDescription.supportsTDDs = true;
|
pumpDescription.supportsTDDs = true;
|
||||||
pumpDescription.needsManualTDDLoad = true;
|
pumpDescription.needsManualTDDLoad = true;
|
||||||
|
|
|
@ -264,80 +264,82 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
|
||||||
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
if (amount > 0) {
|
||||||
long bolusStart = System.currentTimeMillis();
|
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
||||||
|
long bolusStart = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!stop.stopped) {
|
if (!stop.stopped) {
|
||||||
mSerialIOThread.sendMessage(start);
|
mSerialIOThread.sendMessage(start);
|
||||||
} else {
|
} else {
|
||||||
t.insulin = 0d;
|
t.insulin = 0d;
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
while (!stop.stopped && !start.failed) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
|
||||||
stop.stopped = true;
|
|
||||||
stop.forced = true;
|
|
||||||
log.debug("Communication stopped");
|
|
||||||
}
|
}
|
||||||
}
|
while (!stop.stopped && !start.failed) {
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(100);
|
||||||
|
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
stop.stopped = true;
|
||||||
bolusingEvent.t = t;
|
stop.forced = true;
|
||||||
bolusingEvent.percent = 99;
|
log.debug("Communication stopped");
|
||||||
|
|
||||||
mBolusingTreatment = null;
|
|
||||||
|
|
||||||
int speed = 12;
|
|
||||||
switch (preferencesSpeed) {
|
|
||||||
case 0:
|
|
||||||
speed = 12;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
speed = 30;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
speed = 60;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// try to find real amount if bolusing was interrupted or comm failed
|
|
||||||
if (t.insulin != amount) {
|
|
||||||
disconnect("bolusingInterrupted");
|
|
||||||
long bolusDurationInMSec = (long) (amount * speed * 1000);
|
|
||||||
long expectedEnd = bolusStart + bolusDurationInMSec + 3000;
|
|
||||||
|
|
||||||
while (System.currentTimeMillis() < expectedEnd) {
|
|
||||||
long waitTime = expectedEnd - System.currentTimeMillis();
|
|
||||||
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
|
|
||||||
MainApp.bus().post(bolusingEvent);
|
|
||||||
SystemClock.sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
final Object o = new Object();
|
|
||||||
synchronized(o) {
|
|
||||||
ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
|
||||||
t.insulin = mDanaRPump.lastBolusAmount;
|
|
||||||
log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
|
|
||||||
} else {
|
|
||||||
log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
|
|
||||||
}
|
|
||||||
synchronized (o) {
|
|
||||||
o.notify();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
o.wait();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
SystemClock.sleep(300);
|
||||||
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
|
||||||
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
|
bolusingEvent.t = t;
|
||||||
|
bolusingEvent.percent = 99;
|
||||||
|
|
||||||
|
mBolusingTreatment = null;
|
||||||
|
|
||||||
|
int speed = 12;
|
||||||
|
switch (preferencesSpeed) {
|
||||||
|
case 0:
|
||||||
|
speed = 12;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
speed = 30;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
speed = 60;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// try to find real amount if bolusing was interrupted or comm failed
|
||||||
|
if (t.insulin != amount) {
|
||||||
|
disconnect("bolusingInterrupted");
|
||||||
|
long bolusDurationInMSec = (long) (amount * speed * 1000);
|
||||||
|
long expectedEnd = bolusStart + bolusDurationInMSec + 3000;
|
||||||
|
|
||||||
|
while (System.currentTimeMillis() < expectedEnd) {
|
||||||
|
long waitTime = expectedEnd - System.currentTimeMillis();
|
||||||
|
bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000);
|
||||||
|
MainApp.bus().post(bolusingEvent);
|
||||||
|
SystemClock.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Object o = new Object();
|
||||||
|
synchronized (o) {
|
||||||
|
ConfigBuilderPlugin.getCommandQueue().independentConnect("bolusingInterrupted", new Callback() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (mDanaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old
|
||||||
|
t.insulin = mDanaRPump.lastBolusAmount;
|
||||||
|
log.debug("Used bolus amount from history: " + mDanaRPump.lastBolusAmount);
|
||||||
|
} else {
|
||||||
|
log.debug("Bolus amount in history too old: " + mDanaRPump.lastBolusTime.toLocaleString());
|
||||||
|
}
|
||||||
|
synchronized (o) {
|
||||||
|
o.notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
o.wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return !start.failed;
|
return !start.failed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
pumpDescription.isRefillingCapable = true;
|
pumpDescription.isRefillingCapable = true;
|
||||||
|
|
||||||
pumpDescription.storesCarbInfo = true;
|
pumpDescription.storesCarbInfo = false;
|
||||||
|
|
||||||
pumpDescription.supportsTDDs = true;
|
pumpDescription.supportsTDDs = true;
|
||||||
pumpDescription.needsManualTDDLoad = true;
|
pumpDescription.needsManualTDDLoad = true;
|
||||||
|
|
|
@ -264,27 +264,29 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
||||||
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
mSerialIOThread.sendMessage(new MsgSetCarbsEntry(carbtime, carbs));
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
if (amount > 0) {
|
||||||
long bolusStart = System.currentTimeMillis();
|
MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables
|
||||||
|
long bolusStart = System.currentTimeMillis();
|
||||||
|
|
||||||
if (!stop.stopped) {
|
if (!stop.stopped) {
|
||||||
mSerialIOThread.sendMessage(start);
|
mSerialIOThread.sendMessage(start);
|
||||||
} else {
|
} else {
|
||||||
t.insulin = 0d;
|
t.insulin = 0d;
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
while (!stop.stopped && !start.failed) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
|
||||||
stop.stopped = true;
|
|
||||||
stop.forced = true;
|
|
||||||
log.debug("Communication stopped");
|
|
||||||
}
|
}
|
||||||
}
|
while (!stop.stopped && !start.failed) {
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(100);
|
||||||
|
if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 15 sec expecting broken comm
|
||||||
|
stop.stopped = true;
|
||||||
|
stop.forced = true;
|
||||||
|
log.debug("Communication stopped");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SystemClock.sleep(300);
|
||||||
|
|
||||||
mBolusingTreatment = null;
|
mBolusingTreatment = null;
|
||||||
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
|
||||||
|
}
|
||||||
|
|
||||||
return !start.failed;
|
return !start.failed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class CommandBolus extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String status() {
|
public String status() {
|
||||||
return "BOLUS " + DecimalFormatter.to1Decimal(detailedBolusInfo.insulin) + "U";
|
return (detailedBolusInfo.insulin > 0 ? "BOLUS " + DecimalFormatter.to1Decimal(detailedBolusInfo.insulin) + "U " : "") +
|
||||||
|
(detailedBolusInfo.carbs > 0 ? "CARBS " + DecimalFormatter.to0Decimal(detailedBolusInfo.carbs) + "g" : "" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue