Rename ReadPumpStateCommand -> GetPumpStateCommand.

This commit is contained in:
Johannes Mockenhaupt 2017-08-23 13:09:09 +02:00
parent de693c0f76
commit 9349662f8e
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 10 additions and 10 deletions

View file

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

View file

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

View file

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

View file

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