Add Command.getReconnectAlarm() to safely confirm alerts caused by an interrupted command.

This commit is contained in:
Johannes Mockenhaupt 2017-10-25 15:09:50 +02:00
parent 2b8b6828e5
commit e800bd5092
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
5 changed files with 20 additions and 2 deletions

View file

@ -15,4 +15,11 @@ public abstract class BaseCommand implements Command {
public boolean needsRunMode() {
return false;
}
// TODO i18n; can we work with error codes instead of messages? Like W07? that way we're language agnostic
// error message ist still needed to cancel TBR though, let next-gen ruffy take care of that?
/** An alarm (or null) caused by a disconnect we can safely confirm on reconnect,
* knowing it's not severe as it was caused by this command. */
@Override
public String getReconnectAlarm() { return null; }
}

View file

@ -42,6 +42,11 @@ public class BolusCommand extends BaseCommand {
return violations;
}
@Override
public String getReconnectAlarm() {
return "BOLUS CANCELLED";
}
@Override
public CommandResult execute() {
try {
@ -184,7 +189,7 @@ public class BolusCommand extends BaseCommand {
}
// TODO check date so we don't pick a false record if the previous bolus had the same amount;
// also, report back partial bolus. Just call ReadHsstory(timestamp, boluses=true) cmd ...
// also, report back partial bolus. Just call ReadHistory(timestamp, boluses=true) cmd ...
double lastBolusInHistory = (double) scripter.getCurrentMenu().getAttribute(MenuAttribute.BOLUS);
if (Math.abs(bolus - lastBolusInHistory) > 0.05) {
throw new CommandException().success(false).enacted(true)

View file

@ -22,7 +22,7 @@ public class CancelTbrCommand extends BaseCommand {
}
@Override
public String reconnectAlarm() {
public String getReconnectAlarm() {
return "TBR CANCELLED";
}

View file

@ -17,4 +17,5 @@ public interface Command {
List<String> validateArguments();
void setScripter(RuffyScripter scripter);
boolean needsRunMode();
String getReconnectAlarm();
}

View file

@ -52,6 +52,11 @@ public class SetTbrCommand extends BaseCommand {
return violations;
}
@Override
public String getReconnectAlarm() {
return "TBR CANCELLED";
}
@Override
public CommandResult execute() {
try {