commit
d2339f0a5b
|
@ -610,12 +610,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
|
||||
PumpState state = commandResult.state;
|
||||
if (state.tbrActive && state.tbrPercent == percent
|
||||
if (state.tbrActive && state.tbrPercent == adjustedPercent
|
||||
&& (state.tbrRemainingDuration == durationInMinutes || state.tbrRemainingDuration == durationInMinutes - 1)) {
|
||||
TemporaryBasal tempStart = new TemporaryBasal();
|
||||
tempStart.date = state.timestamp;
|
||||
tempStart.durationInMinutes = durationInMinutes;
|
||||
tempStart.percentRate = adjustedPercent;
|
||||
tempStart.durationInMinutes = state.tbrRemainingDuration;
|
||||
tempStart.percentRate = state.tbrPercent;
|
||||
tempStart.isAbsolute = false;
|
||||
tempStart.source = Source.USER;
|
||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStart);
|
||||
|
@ -694,8 +694,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
}
|
||||
|
||||
// Pass this to qeueue??
|
||||
// hm, now that each PumpInterface method is basically one RuffyCommand again ....
|
||||
commandResult = commandExecution.execute();
|
||||
|
||||
if (!commandResult.success && retries > 0) {
|
||||
|
|
|
@ -282,8 +282,14 @@ public class RuffyScripter implements RuffyCommands {
|
|||
// on connection loss try to reconnect, confirm warning alerts caused by
|
||||
// the disconnected and then return the command as failed (the caller
|
||||
// can retry if needed).
|
||||
log.debug("Connection unusable, aborting command and attempting reconnect ...");
|
||||
cmdThread.interrupt();
|
||||
activeCmd.getResult().success = false;
|
||||
|
||||
// the BT connection might be still there, but we might not be receiving
|
||||
// menu updates, so force a disconnect before connecting again
|
||||
disconnect();
|
||||
SystemClock.sleep(500);
|
||||
for (int attempts = 2; attempts > 0; attempts--) {
|
||||
boolean reconnected = recoverFromConnectionLoss();
|
||||
if (reconnected) {
|
||||
|
|
|
@ -61,10 +61,8 @@ public class SetTbrCommand extends BaseCommand {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
boolean cancellingTbr = percentage == 100;
|
||||
|
||||
try {
|
||||
if (checkAndWaitIfExistingTbrIsAboutToEnd(cancellingTbr)) {
|
||||
if (checkAndWaitIfExistingTbrIsAboutToEnd()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,7 +70,7 @@ public class SetTbrCommand extends BaseCommand {
|
|||
boolean increasingPercentage = inputTbrPercentage();
|
||||
verifyDisplayedTbrPercentage(increasingPercentage);
|
||||
|
||||
if (cancellingTbr) {
|
||||
if (percentage == 100) {
|
||||
cancelTbrAndConfirmCancellationWarning();
|
||||
} else {
|
||||
// switch to TBR_DURATION menu by pressing menu key
|
||||
|
@ -116,7 +114,7 @@ public class SetTbrCommand extends BaseCommand {
|
|||
*
|
||||
* @return true if we waited till the TBR ended and cancellation was request so all work is done.
|
||||
*/
|
||||
private boolean checkAndWaitIfExistingTbrIsAboutToEnd(boolean cancellingTbr) {
|
||||
private boolean checkAndWaitIfExistingTbrIsAboutToEnd() {
|
||||
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||
long timeout = System.currentTimeMillis() + 65 * 1000;
|
||||
PumpState state = scripter.readPumpStateInternal();
|
||||
|
@ -126,8 +124,9 @@ public class SetTbrCommand extends BaseCommand {
|
|||
scripter.waitForScreenUpdate();
|
||||
state = scripter.readPumpStateInternal();
|
||||
}
|
||||
// if we waited above and a cancellation was requested, we already completed the request
|
||||
if (!state.tbrActive && cancellingTbr) {
|
||||
// if we waited above and a cancellation (fake or hard) was requested,
|
||||
// we already completed the request
|
||||
if (!state.tbrActive && percentage >= 90 && percentage <= 110) {
|
||||
result.success = true;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue