From 9349662f8e99cbde2cb21a4d37a0e62d22940f84 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 23 Aug 2017 13:09:09 +0200 Subject: [PATCH] Rename ReadPumpStateCommand -> GetPumpStateCommand. --- .../java/ruffyscripter/RuffyScripterInstrumentedTest.java | 4 ++-- .../main/java/de/jotomo/ruffyscripter/RuffyScripter.java | 8 ++++---- ...ReadPumpStateCommand.java => GetPumpStateCommand.java} | 4 ++-- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) rename app/src/main/java/de/jotomo/ruffyscripter/commands/{ReadPumpStateCommand.java => GetPumpStateCommand.java} (81%) diff --git a/app/src/androidTest/java/ruffyscripter/RuffyScripterInstrumentedTest.java b/app/src/androidTest/java/ruffyscripter/RuffyScripterInstrumentedTest.java index afc17ff868..894eb292b4 100644 --- a/app/src/androidTest/java/ruffyscripter/RuffyScripterInstrumentedTest.java +++ b/app/src/androidTest/java/ruffyscripter/RuffyScripterInstrumentedTest.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; import de.jotomo.ruffyscripter.RuffyScripter; import de.jotomo.ruffyscripter.commands.CommandResult; -import de.jotomo.ruffyscripter.commands.ReadPumpStateCommand; +import de.jotomo.ruffyscripter.commands.GetPumpStateCommand; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; @@ -99,7 +99,7 @@ public class RuffyScripterInstrumentedTest { // TODO now, how to get ruffy fired up in this test? @Test public void readPumpState() throws Exception { - CommandResult commandResult = ruffyScripter.runCommand(new ReadPumpStateCommand()); + CommandResult commandResult = ruffyScripter.runCommand(new GetPumpStateCommand()); assertTrue(commandResult.success); assertFalse(commandResult.enacted); assertNotNull(commandResult.state); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java index de1694f639..54b4094f68 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/RuffyScripter.java @@ -19,7 +19,7 @@ import java.util.List; import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.CommandException; import de.jotomo.ruffyscripter.commands.CommandResult; -import de.jotomo.ruffyscripter.commands.ReadPumpStateCommand; +import de.jotomo.ruffyscripter.commands.GetPumpStateCommand; // 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 @@ -275,7 +275,7 @@ public class RuffyScripter { return; } } - // Except for ReadPumpStateCommand: fail on all requests if the pump is suspended. + // Except for GetPumpStateCommand: fail on all requests if the pump is suspended. // All trickery of not executing but returning success, so that AAPS can non-sensically TBR away when suspended // are dangerous in the current model where commands are dispatched without checking state beforehand, so // the above tactic would result in boluses not being applied and no warning being raised. @@ -285,7 +285,7 @@ public class RuffyScripter { // esp. with AAPS). // So, for v1, just check the pump is not suspended before executing commands and raising an error for all - // but the ReadPumpStateCommand. For v2, we'll have to come up with a better idea how to deal with the pump's + // but the GetPumpStateCommand. For v2, we'll have to come up with a better idea how to deal with the pump's // state. Maybe having read-only commands and write/treatment commands treated differently, or maybe // build an abstraction on top of the commands, so that e.g. a method on RuffyScripter encapsulates checking // pre-condititions, running one or several commands, checking-post conditions and what not. @@ -293,7 +293,7 @@ public class RuffyScripter { // level to handle state and logic. // For now, when changing cartridges and such: tell AAPS to stop the loop, change cartridge and resume the loop. if (currentMenu == null || currentMenu.getType() == MenuType.STOP) { - if (cmd instanceof ReadPumpStateCommand) { + if (cmd instanceof GetPumpStateCommand) { returnable.cmdResult = new CommandResult().success(true).enacted(false); } else { returnable.cmdResult = new CommandResult().success(false).enacted(false).message("Pump is suspended"); diff --git a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetPumpStateCommand.java similarity index 81% rename from app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java rename to app/src/main/java/de/jotomo/ruffyscripter/commands/GetPumpStateCommand.java index 06ae717633..567685e2af 100644 --- a/app/src/main/java/de/jotomo/ruffyscripter/commands/ReadPumpStateCommand.java +++ b/app/src/main/java/de/jotomo/ruffyscripter/commands/GetPumpStateCommand.java @@ -3,7 +3,7 @@ package de.jotomo.ruffyscripter.commands; import java.util.Collections; import java.util.List; -public class ReadPumpStateCommand extends BaseCommand { +public class GetPumpStateCommand extends BaseCommand { @Override public CommandResult execute() { return new CommandResult().success(true).enacted(false).message("Returning pump state only"); @@ -16,6 +16,6 @@ public class ReadPumpStateCommand extends BaseCommand { @Override public String toString() { - return "ReadPumpStateCommand{}"; + return "GetPumpStateCommand{}"; } } 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 2f61f95e80..e46fd67c10 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 @@ -32,7 +32,7 @@ import de.jotomo.ruffyscripter.commands.CancelTbrCommand; import de.jotomo.ruffyscripter.commands.Command; import de.jotomo.ruffyscripter.commands.CommandResult; import de.jotomo.ruffyscripter.commands.DetermineCapabilitiesCommand; -import de.jotomo.ruffyscripter.commands.ReadPumpStateCommand; +import de.jotomo.ruffyscripter.commands.GetPumpStateCommand; import de.jotomo.ruffyscripter.commands.SetTbrCommand; import de.jotomo.ruffyscripter.commands.SetTbrCommandAlt; import info.nightscout.androidaps.BuildConfig; @@ -348,7 +348,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { if (notAUserRequest && wasRunAtLeastOnce && ranWithinTheLastMinute) { log.debug("Not fetching state from pump, since we did already within the last 60 seconds"); } else { - runCommand(new ReadPumpStateCommand()); + runCommand(new GetPumpStateCommand()); } }