diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BaseCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BaseCommand.java new file mode 100644 index 0000000000..5f138637f3 --- /dev/null +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BaseCommand.java @@ -0,0 +1,15 @@ +package de.jotomo.ruffyscripter.commands; + +import de.jotomo.ruffyscripter.RuffyScripter; + +public abstract class BaseCommand implements Command { + // RS will inject itself here + protected RuffyScripter scripter; + public void setScripter(RuffyScripter scripter) { this.scripter = scripter; } + + // TODO upcoming + protected volatile boolean cancelRequested = false; + public void requestCancellation() { + cancelRequested = true; + } +} diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java index d5197452e3..aa0e16b7e7 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/BolusCommand.java @@ -14,7 +14,7 @@ import java.util.Locale; import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; -public class BolusCommand implements Command { +public class BolusCommand extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(BolusCommand.class); private final double bolus; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java index 2931f1d9d9..761c8fcd47 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/CancelTbrCommand.java @@ -14,7 +14,7 @@ import info.nightscout.androidaps.MainApp; // TODO robustness: can a TBR run out, whilst we're trying to cancel it? // Hm, we could just ignore TBRs that run out within the next 60s (0:01 or even 0:02 // given we need some time to process the request). -public class CancelTbrCommand implements Command { +public class CancelTbrCommand extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class); @Override diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java index adc740c13e..2f33287507 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/DetermineCapabilitiesCommand.java @@ -19,7 +19,7 @@ import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; -public class DetermineCapabilitiesCommand implements Command { +public class DetermineCapabilitiesCommand extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(DetermineCapabilitiesCommand.class); public static final int UP_STEPS = 75; public static final int RETRIES = 5; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java index 09958f6bf1..a37e4c2be4 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetBasalCommand.java @@ -13,7 +13,7 @@ import java.util.Map; import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; -public class GetBasalCommand implements Command { +public class GetBasalCommand extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(GetBasalCommand.class); private RuffyScripter scripter; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java index 58e52b0a4f..4b4d164133 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java @@ -6,7 +6,7 @@ import java.util.List; import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; -public class ReadPumpStateCommand implements Command { +public class ReadPumpStateCommand extends BaseCommand { @Override public CommandResult execute(RuffyScripter ruffyScripter, PumpState initialPumpState) { return new CommandResult().success(true).enacted(false).message("Returning pump state only"); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java index 8af26863f7..4edbf39e33 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommand.java @@ -21,7 +21,7 @@ import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.TBR_MENU; import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.TBR_SET; import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.WARNING_OR_ERROR; -public class SetTbrCommand implements Command { +public class SetTbrCommand extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class); private final long percentage; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java index 7a9035cfe5..5cc4094403 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/SetTbrCommandAlt.java @@ -15,7 +15,7 @@ import java.util.Locale; import de.jotomo.ruffyscripter.PumpState; import de.jotomo.ruffyscripter.RuffyScripter; -public class SetTbrCommandAlt implements Command { +public class SetTbrCommandAlt extends BaseCommand { private static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class); private final long percentage;