Automatically update pod state from PodInfoFaultEvent
This commit is contained in:
parent
908c666d5f
commit
ff72b0d474
|
@ -24,7 +24,7 @@ public class DeactivatePodAction implements OmnipodAction<StatusResponse> {
|
|||
|
||||
@Override
|
||||
public StatusResponse execute(OmnipodRileyLinkCommunicationManager communicationService) {
|
||||
if (!podStateManager.isSuspended() && !podStateManager.hasFaultEvent()) {
|
||||
if (!podStateManager.isSuspended() && !podStateManager.isPodFaulted()) {
|
||||
try {
|
||||
communicationService.executeAction(new CancelDeliveryAction(podStateManager,
|
||||
EnumSet.allOf(DeliveryType.class), acknowledgementBeep));
|
||||
|
|
|
@ -30,7 +30,9 @@ public class PrimeAction implements OmnipodAction<StatusResponse> {
|
|||
throw new IllegalPodProgressException(PodProgressStatus.PAIRING_COMPLETED, podStateManager.isPodInitialized() ? podStateManager.getPodProgressStatus() : null);
|
||||
}
|
||||
if (podStateManager.getPodProgressStatus().isBefore(PodProgressStatus.PRIMING)) {
|
||||
service.executeDisableTab5Sub16FaultConfigCommand(communicationService, podStateManager);
|
||||
// FaultConfigCommand sets internal pod variables to effectively disable $6x faults which occur more often with a 0 TBR
|
||||
service.executeDisableTab5Sub16And17FaultConfigCommand(communicationService, podStateManager);
|
||||
|
||||
service.executeFinishSetupReminderAlertCommand(communicationService, podStateManager);
|
||||
return service.executePrimeBolusCommand(communicationService, podStateManager);
|
||||
} else if (podStateManager.getPodProgressStatus().equals(PodProgressStatus.PRIMING)) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.rileylink.OmnipodRileyLin
|
|||
|
||||
public class PrimeService {
|
||||
|
||||
public StatusResponse executeDisableTab5Sub16FaultConfigCommand(OmnipodRileyLinkCommunicationManager communicationService, PodStateManager podStateManager) {
|
||||
public StatusResponse executeDisableTab5Sub16And17FaultConfigCommand(OmnipodRileyLinkCommunicationManager communicationService, PodStateManager podStateManager) {
|
||||
FaultConfigCommand faultConfigCommand = new FaultConfigCommand(podStateManager.getCurrentNonce(), (byte) 0x00, (byte) 0x00);
|
||||
OmnipodMessage faultConfigMessage = new OmnipodMessage(podStateManager.getAddress(),
|
||||
Collections.singletonList(faultConfigCommand), podStateManager.getMessageNumber());
|
||||
|
|
|
@ -13,7 +13,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Message
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodConstants;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
|
||||
|
||||
public class StatusResponse extends MessageBlock {
|
||||
public class StatusResponse extends MessageBlock implements StatusUpdatableResponse {
|
||||
private static final int MESSAGE_LENGTH = 10;
|
||||
|
||||
private final DeliveryStatus deliveryStatus;
|
||||
|
@ -22,9 +22,9 @@ public class StatusResponse extends MessageBlock {
|
|||
private final Double reservoirLevel;
|
||||
private final int ticksDelivered;
|
||||
private final double insulinDelivered;
|
||||
private final double insulinNotDelivered;
|
||||
private final double bolusNotDelivered;
|
||||
private final byte podMessageCounter;
|
||||
private final AlertSet alerts;
|
||||
private final AlertSet unacknowledgedAlerts;
|
||||
|
||||
public StatusResponse(byte[] encodedData) {
|
||||
if (encodedData.length < MESSAGE_LENGTH) {
|
||||
|
@ -45,8 +45,8 @@ public class StatusResponse extends MessageBlock {
|
|||
insulinDelivered = OmnipodConstants.POD_PULSE_SIZE * ticksDelivered;
|
||||
podMessageCounter = (byte) ((encodedData[4] >>> 3) & 0xf);
|
||||
|
||||
insulinNotDelivered = OmnipodConstants.POD_PULSE_SIZE * (((encodedData[4] & 0x03) << 8) | ByteUtil.convertUnsignedByteToInt(encodedData[5]));
|
||||
alerts = new AlertSet((byte) (((encodedData[6] & 0x7f) << 1) | (ByteUtil.convertUnsignedByteToInt(encodedData[7]) >>> 7)));
|
||||
bolusNotDelivered = OmnipodConstants.POD_PULSE_SIZE * (((encodedData[4] & 0x03) << 8) | ByteUtil.convertUnsignedByteToInt(encodedData[5]));
|
||||
unacknowledgedAlerts = new AlertSet((byte) (((encodedData[6] & 0x7f) << 1) | (ByteUtil.convertUnsignedByteToInt(encodedData[7]) >>> 7)));
|
||||
|
||||
double reservoirValue = (((encodedData[8] & 0x3) << 8) + ByteUtil.convertUnsignedByteToInt(encodedData[9])) * OmnipodConstants.POD_PULSE_SIZE;
|
||||
if (reservoirValue > OmnipodConstants.MAX_RESERVOIR_READING) {
|
||||
|
@ -61,40 +61,40 @@ public class StatusResponse extends MessageBlock {
|
|||
return MessageBlockType.STATUS_RESPONSE;
|
||||
}
|
||||
|
||||
public DeliveryStatus getDeliveryStatus() {
|
||||
@Override public DeliveryStatus getDeliveryStatus() {
|
||||
return deliveryStatus;
|
||||
}
|
||||
|
||||
public PodProgressStatus getPodProgressStatus() {
|
||||
@Override public PodProgressStatus getPodProgressStatus() {
|
||||
return podProgressStatus;
|
||||
}
|
||||
|
||||
public Duration getTimeActive() {
|
||||
@Override public Duration getTimeActive() {
|
||||
return timeActive;
|
||||
}
|
||||
|
||||
public Double getReservoirLevel() {
|
||||
@Override public Double getReservoirLevel() {
|
||||
return reservoirLevel;
|
||||
}
|
||||
|
||||
public int getTicksDelivered() {
|
||||
@Override public int getTicksDelivered() {
|
||||
return ticksDelivered;
|
||||
}
|
||||
|
||||
public double getInsulinDelivered() {
|
||||
@Override public double getInsulinDelivered() {
|
||||
return insulinDelivered;
|
||||
}
|
||||
|
||||
public double getInsulinNotDelivered() {
|
||||
return insulinNotDelivered;
|
||||
@Override public double getBolusNotDelivered() {
|
||||
return bolusNotDelivered;
|
||||
}
|
||||
|
||||
public byte getPodMessageCounter() {
|
||||
@Override public byte getPodMessageCounter() {
|
||||
return podMessageCounter;
|
||||
}
|
||||
|
||||
public AlertSet getAlerts() {
|
||||
return alerts;
|
||||
@Override public AlertSet getUnacknowledgedAlerts() {
|
||||
return unacknowledgedAlerts;
|
||||
}
|
||||
|
||||
@Override public byte[] getRawData() {
|
||||
|
@ -109,17 +109,18 @@ public class StatusResponse extends MessageBlock {
|
|||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@Override public String toString() {
|
||||
return "StatusResponse{" +
|
||||
"deliveryStatus=" + deliveryStatus +
|
||||
", podProgressStatus=" + podProgressStatus +
|
||||
", timeActive=" + timeActive +
|
||||
", reservoirLevel=" + reservoirLevel +
|
||||
", ticksDelivered=" + ticksDelivered +
|
||||
", insulinDelivered=" + insulinDelivered +
|
||||
", insulinNotDelivered=" + insulinNotDelivered +
|
||||
", bolusNotDelivered=" + bolusNotDelivered +
|
||||
", podMessageCounter=" + podMessageCounter +
|
||||
", alerts=" + alerts +
|
||||
", unacknowledgedAlerts=" + unacknowledgedAlerts +
|
||||
", encodedData=" + ByteUtil.shortHexStringWithoutSpaces(encodedData) +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response;
|
||||
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
|
||||
|
||||
public interface StatusUpdatableResponse {
|
||||
DeliveryStatus getDeliveryStatus();
|
||||
|
||||
PodProgressStatus getPodProgressStatus();
|
||||
|
||||
Duration getTimeActive();
|
||||
|
||||
Double getReservoirLevel();
|
||||
|
||||
int getTicksDelivered();
|
||||
|
||||
double getInsulinDelivered();
|
||||
|
||||
double getBolusNotDelivered();
|
||||
|
||||
byte getPodMessageCounter();
|
||||
|
||||
AlertSet getUnacknowledgedAlerts();
|
||||
}
|
|
@ -2,7 +2,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mes
|
|||
|
||||
import org.joda.time.Duration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.FaultEventCode;
|
||||
|
@ -11,18 +14,19 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.Omnipod
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodInfoType;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PodProgressStatus;
|
||||
|
||||
public class PodInfoFaultEvent extends PodInfo {
|
||||
public class PodInfoFaultEvent extends PodInfo implements StatusUpdatableResponse {
|
||||
private static final int MINIMUM_MESSAGE_LENGTH = 21;
|
||||
|
||||
private final PodProgressStatus podProgressStatus;
|
||||
private final DeliveryStatus deliveryStatus;
|
||||
private final double insulinNotDelivered;
|
||||
private final double bolusNotDelivered;
|
||||
private final byte podMessageCounter;
|
||||
private final double totalInsulinDelivered;
|
||||
private final int ticksDelivered;
|
||||
private final double insulinDelivered;
|
||||
private final FaultEventCode faultEventCode;
|
||||
private final Duration faultEventTime;
|
||||
private final Double reservoirLevel;
|
||||
private final Duration timeSinceActivation;
|
||||
private final Duration timeActive;
|
||||
private final AlertSet unacknowledgedAlerts;
|
||||
private final boolean faultAccessingTables;
|
||||
private final LogEventErrorCode logEventErrorType;
|
||||
|
@ -41,9 +45,10 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
|
||||
podProgressStatus = PodProgressStatus.fromByte(encodedData[1]);
|
||||
deliveryStatus = DeliveryStatus.fromByte(encodedData[2]);
|
||||
insulinNotDelivered = OmnipodConstants.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[3], encodedData[4]);
|
||||
bolusNotDelivered = OmnipodConstants.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[3], encodedData[4]);
|
||||
podMessageCounter = encodedData[5];
|
||||
totalInsulinDelivered = OmnipodConstants.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[6], encodedData[7]);
|
||||
ticksDelivered = ByteUtil.toInt(encodedData[6], encodedData[7]);
|
||||
insulinDelivered = OmnipodConstants.POD_PULSE_SIZE * ticksDelivered;
|
||||
faultEventCode = FaultEventCode.fromByte(encodedData[8]);
|
||||
|
||||
int minutesSinceActivation = ByteUtil.toInt(encodedData[9], encodedData[10]);
|
||||
|
@ -62,7 +67,7 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
}
|
||||
|
||||
int minutesActive = ByteUtil.toInt(encodedData[13], encodedData[14]);
|
||||
timeSinceActivation = Duration.standardMinutes(minutesActive);
|
||||
timeActive = Duration.standardMinutes(minutesActive);
|
||||
|
||||
unacknowledgedAlerts = new AlertSet(encodedData[15]);
|
||||
faultAccessingTables = encodedData[16] == 0x02;
|
||||
|
@ -79,24 +84,28 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
return PodInfoType.FAULT_EVENT;
|
||||
}
|
||||
|
||||
public PodProgressStatus getPodProgressStatus() {
|
||||
@Override public PodProgressStatus getPodProgressStatus() {
|
||||
return podProgressStatus;
|
||||
}
|
||||
|
||||
public DeliveryStatus getDeliveryStatus() {
|
||||
@Override public DeliveryStatus getDeliveryStatus() {
|
||||
return deliveryStatus;
|
||||
}
|
||||
|
||||
public double getInsulinNotDelivered() {
|
||||
return insulinNotDelivered;
|
||||
@Override public double getBolusNotDelivered() {
|
||||
return bolusNotDelivered;
|
||||
}
|
||||
|
||||
public byte getPodMessageCounter() {
|
||||
@Override public byte getPodMessageCounter() {
|
||||
return podMessageCounter;
|
||||
}
|
||||
|
||||
public double getTotalInsulinDelivered() {
|
||||
return totalInsulinDelivered;
|
||||
@Override public int getTicksDelivered() {
|
||||
return ticksDelivered;
|
||||
}
|
||||
|
||||
@Override public double getInsulinDelivered() {
|
||||
return insulinDelivered;
|
||||
}
|
||||
|
||||
public FaultEventCode getFaultEventCode() {
|
||||
|
@ -107,15 +116,15 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
return faultEventTime;
|
||||
}
|
||||
|
||||
public Double getReservoirLevel() {
|
||||
@Override public Double getReservoirLevel() {
|
||||
return reservoirLevel;
|
||||
}
|
||||
|
||||
public Duration getTimeSinceActivation() {
|
||||
return timeSinceActivation;
|
||||
@Override public Duration getTimeActive() {
|
||||
return timeActive;
|
||||
}
|
||||
|
||||
public AlertSet getUnacknowledgedAlerts() {
|
||||
@Override public AlertSet getUnacknowledgedAlerts() {
|
||||
return unacknowledgedAlerts;
|
||||
}
|
||||
|
||||
|
@ -147,18 +156,18 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
return unknownValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@Override public String toString() {
|
||||
return "PodInfoFaultEvent{" +
|
||||
"podProgressStatus=" + podProgressStatus +
|
||||
", deliveryStatus=" + deliveryStatus +
|
||||
", insulinNotDelivered=" + insulinNotDelivered +
|
||||
", bolusNotDelivered=" + bolusNotDelivered +
|
||||
", podMessageCounter=" + podMessageCounter +
|
||||
", totalInsulinDelivered=" + totalInsulinDelivered +
|
||||
", ticksDelivered=" + ticksDelivered +
|
||||
", insulinDelivered=" + insulinDelivered +
|
||||
", faultEventCode=" + faultEventCode +
|
||||
", faultEventTime=" + faultEventTime +
|
||||
", reservoirLevel=" + reservoirLevel +
|
||||
", timeSinceActivation=" + timeSinceActivation +
|
||||
", timeActive=" + timeActive +
|
||||
", unacknowledgedAlerts=" + unacknowledgedAlerts +
|
||||
", faultAccessingTables=" + faultAccessingTables +
|
||||
", logEventErrorType=" + logEventErrorType +
|
||||
|
@ -166,7 +175,7 @@ public class PodInfoFaultEvent extends PodInfo {
|
|||
", receiverLowGain=" + receiverLowGain +
|
||||
", radioRSSI=" + radioRSSI +
|
||||
", podProgressStatusAtTimeOfFirstLoggedFaultEvent=" + podProgressStatusAtTimeOfFirstLoggedFaultEvent +
|
||||
", unknownValue=" + ByteUtil.shortHexString(unknownValue) +
|
||||
", unknownValue=" + Arrays.toString(unknownValue) +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ public class OmnipodManager {
|
|||
}
|
||||
} catch (PodFaultException ex) {
|
||||
// Substract units not delivered in case of a Pod failure
|
||||
unitsNotDelivered = ex.getFaultEvent().getInsulinNotDelivered();
|
||||
unitsNotDelivered = ex.getFaultEvent().getBolusNotDelivered();
|
||||
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Caught PodFaultException in bolus completion verification", ex);
|
||||
break;
|
||||
|
@ -374,9 +374,9 @@ public class OmnipodManager {
|
|||
|
||||
try {
|
||||
StatusResponse statusResponse = cancelDelivery(EnumSet.of(DeliveryType.BOLUS), acknowledgementBeep);
|
||||
discardActiveBolusData(statusResponse.getInsulinNotDelivered());
|
||||
discardActiveBolusData(statusResponse.getBolusNotDelivered());
|
||||
} catch (PodFaultException ex) {
|
||||
discardActiveBolusData(ex.getFaultEvent().getInsulinNotDelivered());
|
||||
discardActiveBolusData(ex.getFaultEvent().getBolusNotDelivered());
|
||||
throw ex;
|
||||
} finally {
|
||||
logCommandExecutionFinished("cancelBolus");
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoFaultEvent;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSet;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.AlertSlot;
|
||||
|
@ -57,7 +57,7 @@ public abstract class PodStateManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return true if we have a Pod state (which at least contains an ddress), indicating it is legal to call getters on PodStateManager
|
||||
* @return true if we have a Pod state (which at least contains an address), indicating it is legal to call getters on PodStateManager
|
||||
*/
|
||||
public final boolean hasPodState() {
|
||||
return podState != null;
|
||||
|
@ -88,6 +88,13 @@ public abstract class PodStateManager {
|
|||
return isPodInitialized() && getPodProgressStatus().isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the Pod is initialized and a Fault Event has occurred
|
||||
*/
|
||||
public final boolean isPodFaulted() {
|
||||
return isPodInitialized() && podState.getPodProgressStatus().equals(PodProgressStatus.FAULT_EVENT_OCCURRED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if we have a Pod state and the Pod is dead, meaning it is either in a fault state or activation time has been exceeded or it is deactivated
|
||||
*/
|
||||
|
@ -214,10 +221,15 @@ public abstract class PodStateManager {
|
|||
setSafe(() -> podState.setLastFailedCommunication(dateTime));
|
||||
}
|
||||
|
||||
public final DateTime getLastUpdatedFromStatusResponse() {
|
||||
return getSafe(() -> podState.getLastUpdatedFromStatusResponse());
|
||||
public final DateTime getLastUpdatedFromResponse() {
|
||||
return getSafe(() -> podState.getLastUpdatedFromResponse());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the Pod State contains a fault event. Is the Pod state does not contain
|
||||
* a fault event, this does NOT necessarily mean that the Pod is not faulted. For a reliable
|
||||
* indication on whether or not the pod is faulted, see {@link #isPodFaulted() isPodFaulted()}
|
||||
*/
|
||||
public final boolean hasFaultEvent() {
|
||||
return podState != null && podState.getFaultEvent() != null;
|
||||
}
|
||||
|
@ -374,7 +386,7 @@ public abstract class PodStateManager {
|
|||
/**
|
||||
* Does not automatically store pod state in order to decrease I/O load
|
||||
*/
|
||||
public final void updateFromStatusResponse(StatusResponse statusResponse) {
|
||||
public final void updateFromResponse(StatusUpdatableResponse statusResponse) {
|
||||
setSafe(() -> {
|
||||
if (podState.getActivatedAt() == null) {
|
||||
DateTime activatedAtCalculated = getTime().minus(statusResponse.getTimeActive());
|
||||
|
@ -387,12 +399,12 @@ public abstract class PodStateManager {
|
|||
}
|
||||
|
||||
podState.setSuspended(statusResponse.getDeliveryStatus() == DeliveryStatus.SUSPENDED);
|
||||
podState.setActiveAlerts(statusResponse.getAlerts());
|
||||
podState.setActiveAlerts(statusResponse.getUnacknowledgedAlerts());
|
||||
podState.setLastDeliveryStatus(statusResponse.getDeliveryStatus());
|
||||
podState.setReservoirLevel(statusResponse.getReservoirLevel());
|
||||
podState.setTotalTicksDelivered(statusResponse.getTicksDelivered());
|
||||
podState.setPodProgressStatus(statusResponse.getPodProgressStatus());
|
||||
podState.setLastUpdatedFromStatusResponse(DateTime.now());
|
||||
podState.setLastUpdatedFromResponse(DateTime.now());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -475,7 +487,7 @@ public abstract class PodStateManager {
|
|||
private int messageNumber;
|
||||
private DateTime lastSuccessfulCommunication;
|
||||
private DateTime lastFailedCommunication;
|
||||
private DateTime lastUpdatedFromStatusResponse;
|
||||
private DateTime lastUpdatedFromResponse;
|
||||
private DateTimeZone timeZone;
|
||||
private DateTime activatedAt;
|
||||
private DateTime expiresAt;
|
||||
|
@ -567,12 +579,12 @@ public abstract class PodStateManager {
|
|||
this.lastFailedCommunication = lastFailedCommunication;
|
||||
}
|
||||
|
||||
DateTime getLastUpdatedFromStatusResponse() {
|
||||
return lastUpdatedFromStatusResponse;
|
||||
DateTime getLastUpdatedFromResponse() {
|
||||
return lastUpdatedFromResponse;
|
||||
}
|
||||
|
||||
void setLastUpdatedFromStatusResponse(DateTime lastUpdatedFromStatusResponse) {
|
||||
this.lastUpdatedFromStatusResponse = lastUpdatedFromStatusResponse;
|
||||
void setLastUpdatedFromResponse(DateTime lastUpdatedFromResponse) {
|
||||
this.lastUpdatedFromResponse = lastUpdatedFromResponse;
|
||||
}
|
||||
|
||||
DateTimeZone getTimeZone() {
|
||||
|
@ -734,12 +746,13 @@ public abstract class PodStateManager {
|
|||
", messageNumber=" + messageNumber +
|
||||
", lastSuccessfulCommunication=" + lastSuccessfulCommunication +
|
||||
", lastFailedCommunication=" + lastFailedCommunication +
|
||||
", lastUpdatedFromStatusResponse=" + lastUpdatedFromStatusResponse +
|
||||
", lastUpdatedFromResponse=" + lastUpdatedFromResponse +
|
||||
", timeZone=" + timeZone +
|
||||
", activatedAt=" + activatedAt +
|
||||
", expiresAt=" + expiresAt +
|
||||
", faultEvent=" + faultEvent +
|
||||
", reservoirLevel=" + reservoirLevel +
|
||||
", totalTicksDelivered=" + totalTicksDelivered +
|
||||
", suspended=" + suspended +
|
||||
", nonceState=" + nonceState +
|
||||
", podProgressStatus=" + podProgressStatus +
|
||||
|
|
|
@ -22,7 +22,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.mess
|
|||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodPacket;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.DeactivatePodCommand;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.ErrorResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoFaultEvent;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoResponse;
|
||||
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.MessageBlockType;
|
||||
|
@ -125,8 +125,8 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
|
|||
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock);
|
||||
|
||||
if (responseMessageBlock instanceof StatusResponse) {
|
||||
podStateManager.updateFromStatusResponse((StatusResponse) responseMessageBlock);
|
||||
if (responseMessageBlock instanceof StatusUpdatableResponse) {
|
||||
podStateManager.updateFromResponse((StatusUpdatableResponse) responseMessageBlock);
|
||||
}
|
||||
|
||||
if (responseClass.isInstance(responseMessageBlock)) {
|
||||
|
|
|
@ -48,8 +48,8 @@ public class StatusResponseTest {
|
|||
assertEquals(1201, statusResponse.getTicksDelivered());
|
||||
assertEquals(60.05, statusResponse.getInsulinDelivered(), 0.000001);
|
||||
assertEquals(15, statusResponse.getPodMessageCounter());
|
||||
assertEquals(0, statusResponse.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(0, statusResponse.getAlerts().getAlertSlots().size());
|
||||
assertEquals(0, statusResponse.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(0, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
||||
|
||||
assertArrayEquals(ByteUtil.fromHexString("1d180258f80000146fff"), statusResponse.getRawData());
|
||||
}
|
||||
|
@ -66,9 +66,9 @@ public class StatusResponseTest {
|
|||
assertEquals(3134, statusResponse.getTicksDelivered());
|
||||
assertEquals(156.7, statusResponse.getInsulinDelivered(), 0.000001);
|
||||
assertEquals(13, statusResponse.getPodMessageCounter());
|
||||
assertEquals(0, statusResponse.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(1, statusResponse.getAlerts().getAlertSlots().size());
|
||||
assertEquals(AlertSlot.SLOT3, statusResponse.getAlerts().getAlertSlots().get(0));
|
||||
assertEquals(0, statusResponse.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(1, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
||||
assertEquals(AlertSlot.SLOT3, statusResponse.getUnacknowledgedAlerts().getAlertSlots().get(0));
|
||||
|
||||
assertArrayEquals(ByteUtil.fromHexString("1d19061f6800044295e8"), statusResponse.getRawData());
|
||||
}
|
||||
|
@ -79,13 +79,13 @@ public class StatusResponseTest {
|
|||
StatusResponse statusResponse = new StatusResponse(bytes);
|
||||
|
||||
assertEquals(Duration.standardMinutes(8191).getMillis(), statusResponse.getTimeActive().getMillis());
|
||||
assertEquals(OmnipodConstants.POD_PULSE_SIZE * 1023, statusResponse.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(OmnipodConstants.POD_PULSE_SIZE * 1023, statusResponse.getBolusNotDelivered(), 0.000001);
|
||||
assertNull("Reservoir level should be null", statusResponse.getReservoirLevel());
|
||||
assertEquals(OmnipodConstants.POD_PULSE_SIZE * 8191, statusResponse.getInsulinDelivered(), 0.0000001);
|
||||
assertEquals(8191, statusResponse.getTicksDelivered());
|
||||
assertEquals(OmnipodConstants.POD_PULSE_SIZE * 8191, statusResponse.getInsulinDelivered(), 0.0000001);
|
||||
assertEquals(15, statusResponse.getPodMessageCounter());
|
||||
assertEquals(8, statusResponse.getAlerts().getAlertSlots().size());
|
||||
assertEquals(8, statusResponse.getUnacknowledgedAlerts().getAlertSlots().size());
|
||||
|
||||
assertArrayEquals(ByteUtil.fromHexString("1d11ffffffffffffffff"), statusResponse.getRawData());
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class StatusResponseTest {
|
|||
assertEquals(2589, statusResponse.getTicksDelivered());
|
||||
assertEquals(129.45, statusResponse.getInsulinDelivered(), 0.00001);
|
||||
assertEquals(46.00, statusResponse.getReservoirLevel(), 0.00001);
|
||||
assertEquals(2.2, statusResponse.getInsulinNotDelivered(), 0.0001);
|
||||
assertEquals(2.2, statusResponse.getBolusNotDelivered(), 0.0001);
|
||||
assertEquals(9, statusResponse.getPodMessageCounter());
|
||||
|
||||
assertArrayEquals(ByteUtil.fromHexString("1d19050ec82c08376f98"), statusResponse.getRawData());
|
||||
|
|
|
@ -22,12 +22,12 @@ public class PodInfoFaultEventTest {
|
|||
|
||||
assertEquals(PodProgressStatus.ABOVE_FIFTY_UNITS, podInfoFaultEvent.getPodProgressStatus());
|
||||
assertEquals(DeliveryStatus.NORMAL, podInfoFaultEvent.getDeliveryStatus());
|
||||
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(0, podInfoFaultEvent.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(0x0a, podInfoFaultEvent.getPodMessageCounter());
|
||||
assertEquals(FaultEventCode.NO_FAULTS, podInfoFaultEvent.getFaultEventCode());
|
||||
assertTrue(Duration.ZERO.isEqual(podInfoFaultEvent.getFaultEventTime()));
|
||||
assertNull(podInfoFaultEvent.getReservoirLevel());
|
||||
assertTrue(Duration.standardSeconds(8100).isEqual(podInfoFaultEvent.getTimeSinceActivation()));
|
||||
assertTrue(Duration.standardSeconds(8100).isEqual(podInfoFaultEvent.getTimeActive()));
|
||||
assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue());
|
||||
assertFalse(podInfoFaultEvent.isFaultAccessingTables());
|
||||
assertEquals(LogEventErrorCode.NONE, podInfoFaultEvent.getLogEventErrorType());
|
||||
|
@ -42,12 +42,12 @@ public class PodInfoFaultEventTest {
|
|||
|
||||
assertEquals(PodProgressStatus.INACTIVE, podInfoFaultEvent.getPodProgressStatus());
|
||||
assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus());
|
||||
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(0, podInfoFaultEvent.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(0x09, podInfoFaultEvent.getPodMessageCounter());
|
||||
assertEquals(FaultEventCode.PRIME_OPEN_COUNT_TOO_LOW, podInfoFaultEvent.getFaultEventCode());
|
||||
assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getFaultEventTime()));
|
||||
assertNull(podInfoFaultEvent.getReservoirLevel());
|
||||
assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getTimeSinceActivation()));
|
||||
assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getTimeActive()));
|
||||
assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue());
|
||||
assertFalse(podInfoFaultEvent.isFaultAccessingTables());
|
||||
assertEquals(LogEventErrorCode.NONE, podInfoFaultEvent.getLogEventErrorType());
|
||||
|
@ -62,8 +62,8 @@ public class PodInfoFaultEventTest {
|
|||
|
||||
assertEquals(PodProgressStatus.FAULT_EVENT_OCCURRED, podInfoFaultEvent.getPodProgressStatus());
|
||||
assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus());
|
||||
assertEquals(101.7, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001);
|
||||
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(101.7, podInfoFaultEvent.getInsulinDelivered(), 0.000001);
|
||||
assertEquals(0, podInfoFaultEvent.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(0x04, podInfoFaultEvent.getPodMessageCounter());
|
||||
assertEquals(FaultEventCode.BASAL_OVER_INFUSION_PULSE, podInfoFaultEvent.getFaultEventCode());
|
||||
assertTrue(Duration.standardMinutes(2559).isEqual(podInfoFaultEvent.getFaultEventTime()));
|
||||
|
@ -82,8 +82,8 @@ public class PodInfoFaultEventTest {
|
|||
|
||||
assertEquals(PodProgressStatus.INACTIVE, podInfoFaultEvent.getPodProgressStatus());
|
||||
assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus());
|
||||
assertEquals(11.8, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001);
|
||||
assertEquals(0.05, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
|
||||
assertEquals(11.8, podInfoFaultEvent.getInsulinDelivered(), 0.000001);
|
||||
assertEquals(0.05, podInfoFaultEvent.getBolusNotDelivered(), 0.000001);
|
||||
assertEquals(0x02, podInfoFaultEvent.getPodMessageCounter());
|
||||
assertEquals(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoFaultEvent.getFaultEventCode());
|
||||
assertTrue(Duration.standardMinutes(616).isEqual(podInfoFaultEvent.getFaultEventTime()));
|
||||
|
@ -102,8 +102,8 @@ public class PodInfoFaultEventTest {
|
|||
|
||||
assertEquals(PodProgressStatus.INACTIVE, podInfoFaultEvent.getPodProgressStatus());
|
||||
assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus());
|
||||
assertEquals(11.8, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001);
|
||||
assertEquals(3276.75, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001); // Insane and will not happen, but this verifies that we convert it to an unsigned int
|
||||
assertEquals(11.8, podInfoFaultEvent.getInsulinDelivered(), 0.000001);
|
||||
assertEquals(3276.75, podInfoFaultEvent.getBolusNotDelivered(), 0.000001); // Insane and will not happen, but this verifies that we convert it to an unsigned int
|
||||
assertEquals(0x02, podInfoFaultEvent.getPodMessageCounter());
|
||||
assertEquals(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoFaultEvent.getFaultEventCode());
|
||||
assertTrue(Duration.standardMinutes(616).isEqual(podInfoFaultEvent.getFaultEventTime()));
|
||||
|
|
Loading…
Reference in a new issue