Extract BaseCommand.

This commit is contained in:
Johannes Mockenhaupt 2017-08-23 12:08:03 +02:00
parent 1d3411ba56
commit 04a03dedc3
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
8 changed files with 22 additions and 7 deletions

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;

View file

@ -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");

View file

@ -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;

View file

@ -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;