Rename ReadPumpStateCommand -> GetPumpStateCommand.
This commit is contained in:
parent
de693c0f76
commit
9349662f8e
4 changed files with 10 additions and 10 deletions
|
@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import de.jotomo.ruffyscripter.RuffyScripter;
|
import de.jotomo.ruffyscripter.RuffyScripter;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandResult;
|
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.assertFalse;
|
||||||
import static junit.framework.Assert.assertNotNull;
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
@ -99,7 +99,7 @@ public class RuffyScripterInstrumentedTest {
|
||||||
// TODO now, how to get ruffy fired up in this test?
|
// TODO now, how to get ruffy fired up in this test?
|
||||||
@Test
|
@Test
|
||||||
public void readPumpState() throws Exception {
|
public void readPumpState() throws Exception {
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(new ReadPumpStateCommand());
|
CommandResult commandResult = ruffyScripter.runCommand(new GetPumpStateCommand());
|
||||||
assertTrue(commandResult.success);
|
assertTrue(commandResult.success);
|
||||||
assertFalse(commandResult.enacted);
|
assertFalse(commandResult.enacted);
|
||||||
assertNotNull(commandResult.state);
|
assertNotNull(commandResult.state);
|
||||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||||
import de.jotomo.ruffyscripter.commands.Command;
|
import de.jotomo.ruffyscripter.commands.Command;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandException;
|
import de.jotomo.ruffyscripter.commands.CommandException;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandResult;
|
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.
|
// 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
|
// Automatically compare against AAPS db, or log all requests in the PumpInterface (maybe Milos
|
||||||
|
@ -275,7 +275,7 @@ public class RuffyScripter {
|
||||||
return;
|
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
|
// 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
|
// 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.
|
// 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).
|
// esp. with AAPS).
|
||||||
|
|
||||||
// So, for v1, just check the pump is not suspended before executing commands and raising an error for all
|
// 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
|
// 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
|
// 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.
|
// 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.
|
// 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.
|
// 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 (currentMenu == null || currentMenu.getType() == MenuType.STOP) {
|
||||||
if (cmd instanceof ReadPumpStateCommand) {
|
if (cmd instanceof GetPumpStateCommand) {
|
||||||
returnable.cmdResult = new CommandResult().success(true).enacted(false);
|
returnable.cmdResult = new CommandResult().success(true).enacted(false);
|
||||||
} else {
|
} else {
|
||||||
returnable.cmdResult = new CommandResult().success(false).enacted(false).message("Pump is suspended");
|
returnable.cmdResult = new CommandResult().success(false).enacted(false).message("Pump is suspended");
|
||||||
|
|
|
@ -3,7 +3,7 @@ package de.jotomo.ruffyscripter.commands;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReadPumpStateCommand extends BaseCommand {
|
public class GetPumpStateCommand extends BaseCommand {
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute() {
|
public CommandResult execute() {
|
||||||
return new CommandResult().success(true).enacted(false).message("Returning pump state only");
|
return new CommandResult().success(true).enacted(false).message("Returning pump state only");
|
||||||
|
@ -16,6 +16,6 @@ public class ReadPumpStateCommand extends BaseCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ReadPumpStateCommand{}";
|
return "GetPumpStateCommand{}";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,7 +32,7 @@ import de.jotomo.ruffyscripter.commands.CancelTbrCommand;
|
||||||
import de.jotomo.ruffyscripter.commands.Command;
|
import de.jotomo.ruffyscripter.commands.Command;
|
||||||
import de.jotomo.ruffyscripter.commands.CommandResult;
|
import de.jotomo.ruffyscripter.commands.CommandResult;
|
||||||
import de.jotomo.ruffyscripter.commands.DetermineCapabilitiesCommand;
|
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.SetTbrCommand;
|
||||||
import de.jotomo.ruffyscripter.commands.SetTbrCommandAlt;
|
import de.jotomo.ruffyscripter.commands.SetTbrCommandAlt;
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
@ -348,7 +348,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
if (notAUserRequest && wasRunAtLeastOnce && ranWithinTheLastMinute) {
|
if (notAUserRequest && wasRunAtLeastOnce && ranWithinTheLastMinute) {
|
||||||
log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
|
log.debug("Not fetching state from pump, since we did already within the last 60 seconds");
|
||||||
} else {
|
} else {
|
||||||
runCommand(new ReadPumpStateCommand());
|
runCommand(new GetPumpStateCommand());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue