From 362c3681d5acf615c1087436e7a92e147f36611e Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 16 Jul 2017 15:28:39 +0200 Subject: [PATCH] Clean up commands package. --- .../de/jotomo/ruffyscripter/{commands => }/History.java | 2 +- .../jotomo/ruffyscripter/{commands => }/PumpState.java | 2 +- .../main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 1 - .../de/jotomo/ruffyscripter/commands/CommandResult.java | 3 +++ .../{NoOpCommand.java => ReadPumpStateCommand.java} | 4 ++-- .../androidaps/plugins/PumpCombo/ComboFragment.java | 2 +- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 9 ++++----- 7 files changed, 12 insertions(+), 11 deletions(-) rename app/src/main/java/de/jotomo/ruffyscripter/{commands => }/History.java (62%) rename app/src/main/java/de/jotomo/ruffyscripter/{commands => }/PumpState.java (96%) rename app/src/main/java/de/jotomo/ruffyscripter/commands/{NoOpCommand.java => ReadPumpStateCommand.java} (77%) diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/History.java b/app/src/main/java/de/jotomo/ruffyscripter/History.java similarity index 62% rename from app/src/main/java/de/jotomo/ruffyscripter/commands/History.java rename to app/src/main/java/de/jotomo/ruffyscripter/History.java index ca322f4ac3..49e34d438f 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/History.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/History.java @@ -1,4 +1,4 @@ -package de.jotomo.ruffyscripter.commands; +package de.jotomo.ruffyscripter; /** The history data read from "My data" */ public class History { diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java similarity index 96% rename from app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java rename to app/src/main/java/de/jotomo/ruffyscripter/PumpState.java index c8ff08a130..80a77a952a 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/PumpState.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/PumpState.java @@ -1,4 +1,4 @@ -package de.jotomo.ruffyscripter.commands; +package de.jotomo.ruffyscripter; import java.util.Date; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index 26053fcce7..71be5372fe 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -16,7 +16,6 @@ import org.slf4j.LoggerFactory; import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.CommandException; import de.jotomo.ruffyscripter.commands.CommandResult; -import de.jotomo.ruffyscripter.commands.PumpState; // TODO regularly read "My data" history (boluses, TBR) to double check all commands ran successfully. // Automatically compare against AAPS db, or log all requests in the PumpInterface (maybe Milos diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java index 999eaf36b8..c5125a5d86 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/CommandResult.java @@ -1,5 +1,8 @@ package de.jotomo.ruffyscripter.commands; +import de.jotomo.ruffyscripter.History; +import de.jotomo.ruffyscripter.PumpState; + public class CommandResult { public boolean success; public boolean enacted; diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/NoOpCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java similarity index 77% rename from app/src/main/java/de/jotomo/ruffyscripter/commands/NoOpCommand.java rename to app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java index 9ae5f361c3..abbadd0d83 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/NoOpCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java @@ -2,7 +2,7 @@ package de.jotomo.ruffyscripter.commands; import de.jotomo.ruffyscripter.RuffyScripter; -public class NoOpCommand implements Command { +public class ReadPumpStateCommand implements Command { @Override public CommandResult execute(RuffyScripter ruffyScripter) { return new CommandResult().success(true).enacted(false).message("Returning pump state only"); @@ -10,6 +10,6 @@ public class NoOpCommand implements Command { @Override public String toString() { - return "NoOpCommand{}"; + return "ReadPumpStateCommand{}"; } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index e759b44ba3..cf329ee035 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -16,7 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.jotomo.ruffyscripter.commands.PumpState; +import de.jotomo.ruffyscripter.PumpState; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index ae1328c680..d9534d8ac4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -7,7 +7,6 @@ import android.content.ServiceConnection; import android.os.IBinder; import android.os.SystemClock; import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import com.squareup.otto.Subscribe; @@ -24,9 +23,9 @@ import de.jotomo.ruffyscripter.commands.BolusCommand; import de.jotomo.ruffyscripter.commands.CancelTbrCommand; import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.CommandResult; -import de.jotomo.ruffyscripter.commands.NoOpCommand; +import de.jotomo.ruffyscripter.commands.ReadPumpStateCommand; import de.jotomo.ruffyscripter.commands.SetTbrCommand; -import de.jotomo.ruffyscripter.commands.PumpState; +import de.jotomo.ruffyscripter.PumpState; import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; @@ -104,7 +103,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { @Override public void run() { log.debug("Querying pump for initial state"); - runCommand(new NoOpCommand()); + runCommand(new ReadPumpStateCommand()); } }).start(); } @@ -311,7 +310,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { // TODO if there was some clue as to what refreshDataFromPump would do with the data ... // that method calls NSUpload.uploadDeviceStatus(); in VirtualPump ... void fetchPumpState() { - runCommand(new NoOpCommand()); + runCommand(new ReadPumpStateCommand()); } private CommandResult runCommand(Command command) {