Rename ConfigurePod* classes to SetupPod*
This commit is contained in:
parent
836bc62c65
commit
355b833cb2
|
@ -15,7 +15,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAl
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AssignAddressAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AssignAddressAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.BolusAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.CancelDeliveryAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.CancelDeliveryAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.ConfigurePodAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.SetupPodAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.DeactivatePodAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.DeactivatePodAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetPodInfoAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetPodInfoAction;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetStatusAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.GetStatusAction;
|
||||||
|
@ -93,7 +93,7 @@ public class OmnipodManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SetupProgress.ADDRESS_ASSIGNED.equals(podState.getSetupProgress())) {
|
if (SetupProgress.ADDRESS_ASSIGNED.equals(podState.getSetupProgress())) {
|
||||||
communicationService.executeAction(new ConfigurePodAction(podState));
|
communicationService.executeAction(new SetupPodAction(podState));
|
||||||
}
|
}
|
||||||
|
|
||||||
communicationService.executeAction(new PrimeAction(new PrimeService(), podState));
|
communicationService.executeAction(new PrimeAction(new PrimeService(), podState));
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.util.Collections;
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.OmnipodMessage;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.ConfigurePodCommand;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.command.SetupPodCommand;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.VersionResponse;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PacketType;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
|
||||||
|
@ -17,10 +17,10 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalPod
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.exception.IllegalSetupProgressException;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
|
||||||
|
|
||||||
public class ConfigurePodAction implements OmnipodAction<VersionResponse> {
|
public class SetupPodAction implements OmnipodAction<VersionResponse> {
|
||||||
private final PodSessionState podState;
|
private final PodSessionState podState;
|
||||||
|
|
||||||
public ConfigurePodAction(PodSessionState podState) {
|
public SetupPodAction(PodSessionState podState) {
|
||||||
this.podState = podState;
|
this.podState = podState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,13 +31,13 @@ public class ConfigurePodAction implements OmnipodAction<VersionResponse> {
|
||||||
}
|
}
|
||||||
DateTime activationDate = DateTime.now(podState.getTimeZone());
|
DateTime activationDate = DateTime.now(podState.getTimeZone());
|
||||||
|
|
||||||
ConfigurePodCommand configurePodCommand = new ConfigurePodCommand(podState.getAddress(), activationDate,
|
SetupPodCommand setupPodCommand = new SetupPodCommand(podState.getAddress(), activationDate,
|
||||||
podState.getLot(), podState.getTid());
|
podState.getLot(), podState.getTid());
|
||||||
OmnipodMessage message = new OmnipodMessage(OmnipodConst.DEFAULT_ADDRESS,
|
OmnipodMessage message = new OmnipodMessage(OmnipodConst.DEFAULT_ADDRESS,
|
||||||
Collections.singletonList(configurePodCommand), podState.getMessageNumber());
|
Collections.singletonList(setupPodCommand), podState.getMessageNumber());
|
||||||
VersionResponse configurePodResponse;
|
VersionResponse setupPodResponse;
|
||||||
try {
|
try {
|
||||||
configurePodResponse = communicationService.exchangeMessages(VersionResponse.class, podState,
|
setupPodResponse = communicationService.exchangeMessages(VersionResponse.class, podState,
|
||||||
message, OmnipodConst.DEFAULT_ADDRESS, podState.getAddress());
|
message, OmnipodConst.DEFAULT_ADDRESS, podState.getAddress());
|
||||||
} catch (IllegalPacketTypeException ex) {
|
} catch (IllegalPacketTypeException ex) {
|
||||||
if (PacketType.ACK.equals(ex.getActual())) {
|
if (PacketType.ACK.equals(ex.getActual())) {
|
||||||
|
@ -48,12 +48,12 @@ public class ConfigurePodAction implements OmnipodAction<VersionResponse> {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configurePodResponse.getPodProgressStatus() != PodProgressStatus.PAIRING_SUCCESS) {
|
if (setupPodResponse.getPodProgressStatus() != PodProgressStatus.PAIRING_SUCCESS) {
|
||||||
throw new IllegalPodProgressException(PodProgressStatus.PAIRING_SUCCESS, configurePodResponse.getPodProgressStatus());
|
throw new IllegalPodProgressException(PodProgressStatus.PAIRING_SUCCESS, setupPodResponse.getPodProgressStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
podState.setSetupProgress(SetupProgress.POD_CONFIGURED);
|
podState.setSetupProgress(SetupProgress.POD_CONFIGURED);
|
||||||
|
|
||||||
return configurePodResponse;
|
return setupPodResponse;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.MessageBlock;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType;
|
import info.nightscout.androidaps.plugins.pump.omnipod.defs.MessageBlockType;
|
||||||
|
|
||||||
public class ConfigurePodCommand extends MessageBlock {
|
public class SetupPodCommand extends MessageBlock {
|
||||||
|
|
||||||
private static final byte PACKET_TIMEOUT_LIMIT = 0x04;
|
private static final byte PACKET_TIMEOUT_LIMIT = 0x04;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ public class ConfigurePodCommand extends MessageBlock {
|
||||||
private final DateTime date;
|
private final DateTime date;
|
||||||
private final int address;
|
private final int address;
|
||||||
|
|
||||||
public ConfigurePodCommand(int address, DateTime date, int lot, int tid) {
|
public SetupPodCommand(int address, DateTime date, int lot, int tid) {
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.lot = lot;
|
this.lot = lot;
|
||||||
this.tid = tid;
|
this.tid = tid;
|
||||||
|
@ -46,7 +46,7 @@ public class ConfigurePodCommand extends MessageBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "ConfigurePodCommand{" +
|
return "SetupPodCommand{" +
|
||||||
"lot=" + lot +
|
"lot=" + lot +
|
||||||
", tid=" + tid +
|
", tid=" + tid +
|
||||||
", date=" + date +
|
", date=" + date +
|
|
@ -7,10 +7,10 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
|
|
||||||
import static org.junit.Assert.assertArrayEquals;
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
|
||||||
public class ConfigurePodCommandTest {
|
public class SetupPodCommandTest {
|
||||||
@Test
|
@Test
|
||||||
public void testEncoding() {
|
public void testEncoding() {
|
||||||
ConfigurePodCommand configurePodCommand = new ConfigurePodCommand( //
|
SetupPodCommand setupPodCommand = new SetupPodCommand( //
|
||||||
0x1f00ee87, //
|
0x1f00ee87, //
|
||||||
new DateTime(2013, 4, 5, 22, 52, 0), //
|
new DateTime(2013, 4, 5, 22, 52, 0), //
|
||||||
41847, //
|
41847, //
|
||||||
|
@ -18,7 +18,7 @@ public class ConfigurePodCommandTest {
|
||||||
|
|
||||||
assertArrayEquals( //
|
assertArrayEquals( //
|
||||||
ByteUtil.fromHexString("03131f00ee87140404050d16340000a3770003ab37"), // From https://github.com/openaps/openomni/wiki/Command-03-Setup-Pod
|
ByteUtil.fromHexString("03131f00ee87140404050d16340000a3770003ab37"), // From https://github.com/openaps/openomni/wiki/Command-03-Setup-Pod
|
||||||
configurePodCommand.getRawData());
|
setupPodCommand.getRawData());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add tests
|
// TODO add tests
|
Loading…
Reference in a new issue