Extract BaseCommand.
This commit is contained in:
parent
1d3411ba56
commit
04a03dedc3
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import java.util.Locale;
|
||||||
import de.jotomo.ruffyscripter.PumpState;
|
import de.jotomo.ruffyscripter.PumpState;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
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 static final Logger log = LoggerFactory.getLogger(BolusCommand.class);
|
||||||
|
|
||||||
private final double bolus;
|
private final double bolus;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
// TODO robustness: can a TBR run out, whilst we're trying to cancel it?
|
// 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
|
// 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).
|
// 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);
|
private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -19,7 +19,7 @@ import de.jotomo.ruffyscripter.PumpState;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
import de.jotomo.ruffyscripter.RuffyScripter;
|
||||||
|
|
||||||
|
|
||||||
public class DetermineCapabilitiesCommand implements Command {
|
public class DetermineCapabilitiesCommand extends BaseCommand {
|
||||||
private static final Logger log = LoggerFactory.getLogger(DetermineCapabilitiesCommand.class);
|
private static final Logger log = LoggerFactory.getLogger(DetermineCapabilitiesCommand.class);
|
||||||
public static final int UP_STEPS = 75;
|
public static final int UP_STEPS = 75;
|
||||||
public static final int RETRIES = 5;
|
public static final int RETRIES = 5;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||||
import de.jotomo.ruffyscripter.PumpState;
|
import de.jotomo.ruffyscripter.PumpState;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
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 static final Logger log = LoggerFactory.getLogger(GetBasalCommand.class);
|
||||||
|
|
||||||
private RuffyScripter scripter;
|
private RuffyScripter scripter;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
||||||
import de.jotomo.ruffyscripter.PumpState;
|
import de.jotomo.ruffyscripter.PumpState;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
import de.jotomo.ruffyscripter.RuffyScripter;
|
||||||
|
|
||||||
public class ReadPumpStateCommand implements Command {
|
public class ReadPumpStateCommand extends BaseCommand {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(RuffyScripter ruffyScripter, PumpState initialPumpState) {
|
public CommandResult execute(RuffyScripter ruffyScripter, PumpState initialPumpState) {
|
||||||
return new CommandResult().success(true).enacted(false).message("Returning pump state only");
|
return new CommandResult().success(true).enacted(false).message("Returning pump state only");
|
||||||
|
|
|
@ -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.TBR_SET;
|
||||||
import static org.monkey.d.ruffy.ruffy.driver.display.MenuType.WARNING_OR_ERROR;
|
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 static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class);
|
||||||
|
|
||||||
private final long percentage;
|
private final long percentage;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Locale;
|
||||||
import de.jotomo.ruffyscripter.PumpState;
|
import de.jotomo.ruffyscripter.PumpState;
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
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 static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class);
|
||||||
|
|
||||||
private final long percentage;
|
private final long percentage;
|
||||||
|
|
Loading…
Reference in a new issue