commit
d2339f0a5b
3 changed files with 15 additions and 12 deletions
|
@ -610,12 +610,12 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
PumpState state = commandResult.state;
|
PumpState state = commandResult.state;
|
||||||
if (state.tbrActive && state.tbrPercent == percent
|
if (state.tbrActive && state.tbrPercent == adjustedPercent
|
||||||
&& (state.tbrRemainingDuration == durationInMinutes || state.tbrRemainingDuration == durationInMinutes - 1)) {
|
&& (state.tbrRemainingDuration == durationInMinutes || state.tbrRemainingDuration == durationInMinutes - 1)) {
|
||||||
TemporaryBasal tempStart = new TemporaryBasal();
|
TemporaryBasal tempStart = new TemporaryBasal();
|
||||||
tempStart.date = state.timestamp;
|
tempStart.date = state.timestamp;
|
||||||
tempStart.durationInMinutes = durationInMinutes;
|
tempStart.durationInMinutes = state.tbrRemainingDuration;
|
||||||
tempStart.percentRate = adjustedPercent;
|
tempStart.percentRate = state.tbrPercent;
|
||||||
tempStart.isAbsolute = false;
|
tempStart.isAbsolute = false;
|
||||||
tempStart.source = Source.USER;
|
tempStart.source = Source.USER;
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStart);
|
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();
|
commandResult = commandExecution.execute();
|
||||||
|
|
||||||
if (!commandResult.success && retries > 0) {
|
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
|
// on connection loss try to reconnect, confirm warning alerts caused by
|
||||||
// the disconnected and then return the command as failed (the caller
|
// the disconnected and then return the command as failed (the caller
|
||||||
// can retry if needed).
|
// can retry if needed).
|
||||||
|
log.debug("Connection unusable, aborting command and attempting reconnect ...");
|
||||||
cmdThread.interrupt();
|
cmdThread.interrupt();
|
||||||
activeCmd.getResult().success = false;
|
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--) {
|
for (int attempts = 2; attempts > 0; attempts--) {
|
||||||
boolean reconnected = recoverFromConnectionLoss();
|
boolean reconnected = recoverFromConnectionLoss();
|
||||||
if (reconnected) {
|
if (reconnected) {
|
||||||
|
|
|
@ -61,10 +61,8 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
boolean cancellingTbr = percentage == 100;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (checkAndWaitIfExistingTbrIsAboutToEnd(cancellingTbr)) {
|
if (checkAndWaitIfExistingTbrIsAboutToEnd()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +70,7 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
boolean increasingPercentage = inputTbrPercentage();
|
boolean increasingPercentage = inputTbrPercentage();
|
||||||
verifyDisplayedTbrPercentage(increasingPercentage);
|
verifyDisplayedTbrPercentage(increasingPercentage);
|
||||||
|
|
||||||
if (cancellingTbr) {
|
if (percentage == 100) {
|
||||||
cancelTbrAndConfirmCancellationWarning();
|
cancelTbrAndConfirmCancellationWarning();
|
||||||
} else {
|
} else {
|
||||||
// switch to TBR_DURATION menu by pressing menu key
|
// 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.
|
* @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);
|
scripter.verifyMenuIsDisplayed(MenuType.MAIN_MENU);
|
||||||
long timeout = System.currentTimeMillis() + 65 * 1000;
|
long timeout = System.currentTimeMillis() + 65 * 1000;
|
||||||
PumpState state = scripter.readPumpStateInternal();
|
PumpState state = scripter.readPumpStateInternal();
|
||||||
|
@ -126,8 +124,9 @@ public class SetTbrCommand extends BaseCommand {
|
||||||
scripter.waitForScreenUpdate();
|
scripter.waitForScreenUpdate();
|
||||||
state = scripter.readPumpStateInternal();
|
state = scripter.readPumpStateInternal();
|
||||||
}
|
}
|
||||||
// if we waited above and a cancellation was requested, we already completed the request
|
// if we waited above and a cancellation (fake or hard) was requested,
|
||||||
if (!state.tbrActive && cancellingTbr) {
|
// we already completed the request
|
||||||
|
if (!state.tbrActive && percentage >= 90 && percentage <= 110) {
|
||||||
result.success = true;
|
result.success = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue