Remove RuffyCommandsV1Impl.

This commit is contained in:
Johannes Mockenhaupt 2018-01-28 22:14:26 +01:00
parent 10d2b8739f
commit 6c4c662c31
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
31 changed files with 71 additions and 203 deletions

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
import java.util.Arrays; import java.util.Arrays;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
public interface BolusProgressReporter { public interface BolusProgressReporter {
enum State { enum State {

View file

@ -1,12 +1,12 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpHistory; import de.jotomo.ruffyscripter.history.PumpHistory;
public class CommandResult { public class CommandResult {
/** Whether the command was executed successfully. */ /** Whether the command was executed successfully. */

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
public class PumpErrorCodes { public class PumpErrorCodes {
public static final int CARTRIDGE_EMPTY = 1; public static final int CARTRIDGE_EMPTY = 1;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
/** State displayed on the main screen of the pump. */ /** State displayed on the main screen of the pump. */
public class PumpState { public class PumpState {

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
public class PumpWarningCodes { public class PumpWarningCodes {
public static final int CARTRIDGE_LOW = 1; public static final int CARTRIDGE_LOW = 1;

View file

@ -1,6 +1,6 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffyscripter.history.PumpHistoryRequest;
public interface RuffyCommands { public interface RuffyCommands {
/** Issues a bolus issues updates on progress through via {@link BolusProgressReporter}. */ /** Issues a bolus issues updates on progress through via {@link BolusProgressReporter}. */

View file

@ -1,127 +0,0 @@
package de.jotomo.ruffyscripter;
import android.content.Context;
import android.support.annotation.NonNull;
import java.util.Date;
import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.BolusProgressReporter;
import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.RuffyCommands;
import de.jotomo.ruffy.spi.history.PumpHistory;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
public class RuffyCommandsV1Impl implements RuffyCommands {
private static RuffyCommandsV1Impl instance;
private static RuffyCommands delegate;
@NonNull
public static RuffyCommands getInstance(Context context) {
if (instance == null) {
instance = new RuffyCommandsV1Impl();
delegate = new RuffyScripter(context);
}
return instance;
}
private RuffyCommandsV1Impl() {}
/** Not supported by RuffyScripter */
@Override
public CommandResult getDateAndTime() {
return new CommandResult().success(false);
}
@Override
public CommandResult readReservoirLevelAndLastBolus() {
return delegate.readReservoirLevelAndLastBolus();
}
@Override
public CommandResult confirmAlert(int warningCode) {
return delegate.confirmAlert(warningCode);
}
@Override
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
return delegate.deliverBolus(amount, bolusProgressReporter);
}
@Override
public void cancelBolus() {
delegate.cancelBolus();
}
@Override
public CommandResult setTbr(int percent, int duration) {
return delegate.setTbr(percent, duration);
}
@Override
public CommandResult cancelTbr() {
return delegate.cancelTbr();
}
@Override
public boolean isPumpAvailable() {
return delegate.isPumpAvailable();
}
@Override
public boolean isPumpBusy() {
return delegate.isPumpBusy();
}
@Override
public boolean isConnected() {
return delegate.isConnected();
}
@Override
public void disconnect() {
delegate.disconnect();
}
@Override
public CommandResult readPumpState() {
return delegate.readPumpState();
}
@Override
public CommandResult readHistory(PumpHistoryRequest request) {
return delegate.readHistory(request);
}
@Override
public CommandResult readBasalProfile() {
return delegate.readBasalProfile();
}
@Override
public CommandResult setBasalProfile(BasalProfile basalProfile) {
return delegate.setBasalProfile(basalProfile);
}
/** Not supported by RuffyScripter */
@Override
public CommandResult setDateAndTime() {
return new CommandResult().success(false);
}
@Override
public void requestPairing() {
delegate.requestPairing();
}
@Override
public void sendAuthKey(String key) {
delegate.sendAuthKey(key);
}
@Override
public void unpair() {
delegate.unpair();
}
}

View file

@ -28,13 +28,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffyscripter.history.PumpHistoryRequest;
import de.jotomo.ruffy.spi.BolusProgressReporter;
import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.RuffyCommands;
import de.jotomo.ruffy.spi.WarningOrErrorCode;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
import de.jotomo.ruffyscripter.commands.BolusCommand; import de.jotomo.ruffyscripter.commands.BolusCommand;
import de.jotomo.ruffyscripter.commands.CancelTbrCommand; import de.jotomo.ruffyscripter.commands.CancelTbrCommand;
import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.Command;
@ -127,7 +121,7 @@ public class RuffyScripter implements RuffyCommands {
} }
}; };
RuffyScripter(Context context) { public RuffyScripter(Context context) {
boolean boundSucceeded = false; boolean boundSucceeded = false;
try { try {

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi; package de.jotomo.ruffyscripter;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;

View file

@ -3,7 +3,8 @@ package de.jotomo.ruffyscripter.commands;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffyscripter.CommandResult;
import de.jotomo.ruffyscripter.PumpWarningCodes;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
public abstract class BaseCommand implements Command { public abstract class BaseCommand implements Command {
@ -29,7 +30,7 @@ public abstract class BaseCommand implements Command {
/** /**
* A warning id (or null) caused by a disconnect we can safely confirm on reconnect, * A warning id (or null) caused by a disconnect we can safely confirm on reconnect,
* knowing it's not severe as it was caused by this command. * knowing it's not severe as it was caused by this command.
* @see de.jotomo.ruffy.spi.PumpWarningCodes * @see PumpWarningCodes
*/ */
@Override @Override
public Integer getReconnectWarningId() { public Integer getReconnectWarningId() {

View file

@ -11,17 +11,17 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import de.jotomo.ruffy.spi.BolusProgressReporter; import de.jotomo.ruffyscripter.BolusProgressReporter;
import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffyscripter.PumpWarningCodes;
import de.jotomo.ruffy.spi.WarningOrErrorCode; import de.jotomo.ruffyscripter.WarningOrErrorCode;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.DELIVERED; import static de.jotomo.ruffyscripter.BolusProgressReporter.State.DELIVERED;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.DELIVERING; import static de.jotomo.ruffyscripter.BolusProgressReporter.State.DELIVERING;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.PROGRAMMING; import static de.jotomo.ruffyscripter.BolusProgressReporter.State.PROGRAMMING;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.STOPPED; import static de.jotomo.ruffyscripter.BolusProgressReporter.State.STOPPED;
import static de.jotomo.ruffy.spi.BolusProgressReporter.State.STOPPING; import static de.jotomo.ruffyscripter.BolusProgressReporter.State.STOPPING;
public class BolusCommand extends BaseCommand { public class BolusCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(BolusCommand.class); private static final Logger log = LoggerFactory.getLogger(BolusCommand.class);

View file

@ -4,8 +4,8 @@ import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffyscripter.PumpWarningCodes;
public class CancelTbrCommand extends BaseCommand { public class CancelTbrCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class); private static final Logger log = LoggerFactory.getLogger(CancelTbrCommand.class);

View file

@ -3,7 +3,7 @@ package de.jotomo.ruffyscripter.commands;
import java.util.List; import java.util.List;
import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.RuffyScripter;
import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffyscripter.CommandResult;
/** /**
* Interface for all commands to be executed by the pump. * Interface for all commands to be executed by the pump.

View file

@ -9,8 +9,8 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffyscripter.BasalProfile;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
public class ReadBasalProfileCommand extends BaseCommand { public class ReadBasalProfileCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class); private static final Logger log = LoggerFactory.getLogger(ReadBasalProfileCommand.class);

View file

@ -13,12 +13,12 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpAlert; import de.jotomo.ruffyscripter.history.PumpAlert;
import de.jotomo.ruffy.spi.history.PumpHistory; import de.jotomo.ruffyscripter.history.PumpHistory;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffyscripter.history.PumpHistoryRequest;
import de.jotomo.ruffy.spi.history.Tbr; import de.jotomo.ruffyscripter.history.Tbr;
import de.jotomo.ruffy.spi.history.Tdd; import de.jotomo.ruffyscripter.history.Tdd;
// Note: TBRs are added to history only after they've completed running // Note: TBRs are added to history only after they've completed running
// TODO remove duplication // TODO remove duplication

View file

@ -10,7 +10,7 @@ import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
import java.util.Date; import java.util.Date;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
public class ReadReservoirLevelAndLastBolus extends BaseCommand { public class ReadReservoirLevelAndLastBolus extends BaseCommand {
@Override @Override

View file

@ -12,8 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffyscripter.BasalProfile;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
public class SetBasalProfileCommand extends BaseCommand { public class SetBasalProfileCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(SetBasalProfileCommand.class); private static final Logger log = LoggerFactory.getLogger(SetBasalProfileCommand.class);

View file

@ -12,9 +12,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffyscripter.PumpWarningCodes;
import de.jotomo.ruffy.spi.WarningOrErrorCode; import de.jotomo.ruffyscripter.WarningOrErrorCode;
public class SetTbrCommand extends BaseCommand { public class SetTbrCommand extends BaseCommand {
private static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class); private static final Logger log = LoggerFactory.getLogger(SetTbrCommand.class);

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import java.util.Date; import java.util.Date;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
public abstract class HistoryRecord { public abstract class HistoryRecord {
public final long timestamp; public final long timestamp;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import java.util.Date; import java.util.Date;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import java.util.Date; import java.util.Date;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import java.util.Date; import java.util.Date;

View file

@ -1,4 +1,4 @@
package de.jotomo.ruffy.spi.history; package de.jotomo.ruffyscripter.history;
import java.util.Date; import java.util.Date;

View file

@ -10,7 +10,7 @@ import android.widget.TextView;
import java.text.DateFormat; import java.text.DateFormat;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.history.PumpAlert; import de.jotomo.ruffyscripter.history.PumpAlert;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
public class ComboAlertHistoryDialog extends DialogFragment { public class ComboAlertHistoryDialog extends DialogFragment {

View file

@ -14,8 +14,8 @@ import android.widget.TextView;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment; import info.nightscout.androidaps.plugins.Common.SubscriberFragment;

View file

@ -11,18 +11,18 @@ import org.slf4j.LoggerFactory;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffyscripter.BasalProfile;
import de.jotomo.ruffy.spi.BolusProgressReporter; import de.jotomo.ruffyscripter.BolusProgressReporter;
import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffyscripter.CommandResult;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffyscripter.PumpWarningCodes;
import de.jotomo.ruffy.spi.RuffyCommands; import de.jotomo.ruffyscripter.RuffyCommands;
import de.jotomo.ruffy.spi.WarningOrErrorCode; import de.jotomo.ruffyscripter.RuffyScripter;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.WarningOrErrorCode;
import de.jotomo.ruffy.spi.history.PumpHistory; import de.jotomo.ruffyscripter.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffyscripter.history.PumpHistory;
import de.jotomo.ruffy.spi.history.Tbr; import de.jotomo.ruffyscripter.history.PumpHistoryRequest;
import de.jotomo.ruffyscripter.RuffyCommandsV1Impl; import de.jotomo.ruffyscripter.history.Tbr;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
@ -113,7 +113,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
.success(false).enacted(false).comment(MainApp.sResources.getString(R.string.combo_pump_unsupported_operation)); .success(false).enacted(false).comment(MainApp.sResources.getString(R.string.combo_pump_unsupported_operation));
private ComboPlugin() { private ComboPlugin() {
ruffyScripter = RuffyCommandsV1Impl.getInstance(MainApp.instance()); ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
} }
public ComboPump getPump() { public ComboPump getPump() {

View file

@ -6,11 +6,11 @@ import android.support.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffyscripter.BasalProfile;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffyscripter.PumpState;
import de.jotomo.ruffy.spi.history.Bolus; import de.jotomo.ruffyscripter.history.Bolus;
import de.jotomo.ruffy.spi.history.PumpAlert; import de.jotomo.ruffyscripter.history.PumpAlert;
import de.jotomo.ruffy.spi.history.Tdd; import de.jotomo.ruffyscripter.history.Tdd;
class ComboPump { class ComboPump {
boolean initialized = false; boolean initialized = false;

View file

@ -11,7 +11,7 @@ import java.text.DateFormat;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import de.jotomo.ruffy.spi.history.Tdd; import de.jotomo.ruffyscripter.history.Tdd;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
public class ComboTddHistoryDialog extends DialogFragment { public class ComboTddHistoryDialog extends DialogFragment {