Call podStateChangedHandler when setting fault event, rename FaultEventCode to FaultEventType

This commit is contained in:
Bart Sopers 2019-12-15 23:42:46 +01:00
parent a8f702ddac
commit 80c1feb1d2
10 changed files with 52 additions and 47 deletions

View file

@ -7,12 +7,12 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
public class PodInfoDataLog extends PodInfo { public class PodInfoDataLog extends PodInfo {
private static final int MINIMUM_MESSAGE_LENGTH = 8; private static final int MINIMUM_MESSAGE_LENGTH = 8;
private final FaultEventCode faultEventCode; private final FaultEventType faultEventType;
private final Duration timeFaultEvent; private final Duration timeFaultEvent;
private final Duration timeSinceActivation; private final Duration timeSinceActivation;
private final byte dataChunkSize; private final byte dataChunkSize;
@ -26,7 +26,7 @@ public class PodInfoDataLog extends PodInfo {
throw new IllegalArgumentException("Not enough data"); throw new IllegalArgumentException("Not enough data");
} }
faultEventCode = FaultEventCode.fromByte(encodedData[1]); faultEventType = FaultEventType.fromByte(encodedData[1]);
timeFaultEvent = Duration.standardMinutes(ByteUtil.toInt(encodedData[2], encodedData[3])); timeFaultEvent = Duration.standardMinutes(ByteUtil.toInt(encodedData[2], encodedData[3]));
timeSinceActivation = Duration.standardMinutes(ByteUtil.toInt(encodedData[4], encodedData[5])); timeSinceActivation = Duration.standardMinutes(ByteUtil.toInt(encodedData[4], encodedData[5]));
dataChunkSize = encodedData[6]; dataChunkSize = encodedData[6];
@ -45,8 +45,8 @@ public class PodInfoDataLog extends PodInfo {
return PodInfoType.DATA_LOG; return PodInfoType.DATA_LOG;
} }
public FaultEventCode getFaultEventCode() { public FaultEventType getFaultEventType() {
return faultEventCode; return faultEventType;
} }
public Duration getTimeFaultEvent() { public Duration getTimeFaultEvent() {
@ -72,7 +72,7 @@ public class PodInfoDataLog extends PodInfo {
@Override @Override
public String toString() { public String toString() {
return "PodInfoDataLog{" + return "PodInfoDataLog{" +
"faultEventCode=" + faultEventCode + "faultEventType=" + faultEventType +
", timeFaultEvent=" + timeFaultEvent + ", timeFaultEvent=" + timeFaultEvent +
", timeSinceActivation=" + timeSinceActivation + ", timeSinceActivation=" + timeSinceActivation +
", dataChunkSize=" + dataChunkSize + ", dataChunkSize=" + dataChunkSize +

View file

@ -3,12 +3,12 @@ package info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.po
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
public class PodInfoFaultAndInitializationTime extends PodInfo { public class PodInfoFaultAndInitializationTime extends PodInfo {
private static final int MINIMUM_MESSAGE_LENGTH = 17; private static final int MINIMUM_MESSAGE_LENGTH = 17;
private final FaultEventCode faultEventCode; private final FaultEventType faultEventType;
private final Duration timeFaultEvent; private final Duration timeFaultEvent;
private final DateTime initializationTime; private final DateTime initializationTime;
@ -19,7 +19,7 @@ public class PodInfoFaultAndInitializationTime extends PodInfo {
throw new IllegalArgumentException("Not enough data"); throw new IllegalArgumentException("Not enough data");
} }
faultEventCode = FaultEventCode.fromByte(encodedData[1]); faultEventType = FaultEventType.fromByte(encodedData[1]);
timeFaultEvent = Duration.standardMinutes(((encodedData[2] & 0b1) << 8) + encodedData[3]); timeFaultEvent = Duration.standardMinutes(((encodedData[2] & 0b1) << 8) + encodedData[3]);
// We ignore time zones here because we don't keep the time zone in which the pod was initially set up // We ignore time zones here because we don't keep the time zone in which the pod was initially set up
// Which is fine because we don't use the initialization time for anything important anyway // Which is fine because we don't use the initialization time for anything important anyway
@ -31,8 +31,8 @@ public class PodInfoFaultAndInitializationTime extends PodInfo {
return PodInfoType.FAULT_AND_INITIALIZATION_TIME; return PodInfoType.FAULT_AND_INITIALIZATION_TIME;
} }
public FaultEventCode getFaultEventCode() { public FaultEventType getFaultEventType() {
return faultEventCode; return faultEventType;
} }
public Duration getTimeFaultEvent() { public Duration getTimeFaultEvent() {
@ -46,7 +46,7 @@ public class PodInfoFaultAndInitializationTime extends PodInfo {
@Override @Override
public String toString() { public String toString() {
return "PodInfoFaultAndInitializationTime{" + return "PodInfoFaultAndInitializationTime{" +
"faultEventCode=" + faultEventCode + "faultEventType=" + faultEventType +
", timeFaultEvent=" + timeFaultEvent + ", timeFaultEvent=" + timeFaultEvent +
", initializationTime=" + initializationTime + ", initializationTime=" + initializationTime +
'}'; '}';

View file

@ -5,7 +5,7 @@ import org.joda.time.Duration;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus; import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.LogEventErrorCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.LogEventErrorCode;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
@ -19,7 +19,7 @@ public class PodInfoFaultEvent extends PodInfo {
private final double insulinNotDelivered; private final double insulinNotDelivered;
private final byte podMessageCounter; private final byte podMessageCounter;
private final double totalInsulinDelivered; private final double totalInsulinDelivered;
private final FaultEventCode faultEventCode; private final FaultEventType faultEventType;
private final Duration faultEventTime; private final Duration faultEventTime;
private final Double reservoirLevel; private final Double reservoirLevel;
private final Duration timeSinceActivation; private final Duration timeSinceActivation;
@ -44,7 +44,7 @@ public class PodInfoFaultEvent extends PodInfo {
insulinNotDelivered = OmnipodConst.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[3], encodedData[4]); insulinNotDelivered = OmnipodConst.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[3], encodedData[4]);
podMessageCounter = encodedData[5]; podMessageCounter = encodedData[5];
totalInsulinDelivered = OmnipodConst.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[6], encodedData[7]); totalInsulinDelivered = OmnipodConst.POD_PULSE_SIZE * ByteUtil.toInt(encodedData[6], encodedData[7]);
faultEventCode = FaultEventCode.fromByte(encodedData[8]); faultEventType = FaultEventType.fromByte(encodedData[8]);
int minutesSinceActivation = ByteUtil.toInt(encodedData[9], encodedData[10]); int minutesSinceActivation = ByteUtil.toInt(encodedData[9], encodedData[10]);
if (minutesSinceActivation == 0xffff) { if (minutesSinceActivation == 0xffff) {
@ -99,8 +99,8 @@ public class PodInfoFaultEvent extends PodInfo {
return totalInsulinDelivered; return totalInsulinDelivered;
} }
public FaultEventCode getFaultEventCode() { public FaultEventType getFaultEventType() {
return faultEventCode; return faultEventType;
} }
public Duration getFaultEventTime() { public Duration getFaultEventTime() {
@ -155,7 +155,7 @@ public class PodInfoFaultEvent extends PodInfo {
", insulinNotDelivered=" + insulinNotDelivered + ", insulinNotDelivered=" + insulinNotDelivered +
", podMessageCounter=" + podMessageCounter + ", podMessageCounter=" + podMessageCounter +
", totalInsulinDelivered=" + totalInsulinDelivered + ", totalInsulinDelivered=" + totalInsulinDelivered +
", faultEventCode=" + faultEventCode + ", faultEventType=" + faultEventType +
", faultEventTime=" + faultEventTime + ", faultEventTime=" + faultEventTime +
", reservoirLevel=" + reservoirLevel + ", reservoirLevel=" + reservoirLevel +
", timeSinceActivation=" + timeSinceActivation + ", timeSinceActivation=" + timeSinceActivation +

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.defs;
import java.util.Locale; import java.util.Locale;
public enum FaultEventCode { public enum FaultEventType {
NO_FAULTS((byte) 0x00), NO_FAULTS((byte) 0x00),
FAILED_FLASH_ERASE((byte) 0x01), FAILED_FLASH_ERASE((byte) 0x01),
FAILED_FLASH_STORE((byte) 0x02), FAILED_FLASH_STORE((byte) 0x02),
@ -124,17 +124,17 @@ public enum FaultEventCode {
private byte value; private byte value;
FaultEventCode(byte value) { FaultEventType(byte value) {
this.value = value; this.value = value;
} }
public static FaultEventCode fromByte(byte value) { public static FaultEventType fromByte(byte value) {
for (FaultEventCode type : values()) { for (FaultEventType type : values()) {
if (type.value == value) { if (type.value == value) {
return type; return type;
} }
} }
throw new IllegalArgumentException("Unknown FaultEventCode: " + value); throw new IllegalArgumentException("Unknown FaultEventType: " + value);
} }
public byte getValue() { public byte getValue() {

View file

@ -10,6 +10,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.StatusResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoFaultEvent;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSet;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
@ -215,6 +216,13 @@ public class PodSessionState extends PodState {
return lastDeliveryStatus; return lastDeliveryStatus;
} }
@Override
public void setFaultEvent(PodInfoFaultEvent faultEvent) {
super.setFaultEvent(faultEvent);
suspended = true;
store();
}
@Override @Override
public void updateFromStatusResponse(StatusResponse statusResponse) { public void updateFromStatusResponse(StatusResponse statusResponse) {
DateTime activatedAtCalculated = getTime().minus(statusResponse.getTimeActive()); DateTime activatedAtCalculated = getTime().minus(statusResponse.getTimeActive());
@ -244,11 +252,7 @@ public class PodSessionState extends PodState {
@Override @Override
public String toString() { public String toString() {
return "PodSessionState{" + return "PodSessionState{" +
"address=" + address + "configuredAlerts=" + configuredAlerts +
", packetNumber=" + packetNumber +
", messageNumber=" + messageNumber +
", faultEvent=" + faultEvent +
", configuredAlerts=" + configuredAlerts +
", stateChangedHandler=" + stateChangedHandler + ", stateChangedHandler=" + stateChangedHandler +
", activatedAt=" + activatedAt + ", activatedAt=" + activatedAt +
", expiresAt=" + expiresAt + ", expiresAt=" + expiresAt +
@ -264,6 +268,10 @@ public class PodSessionState extends PodState {
", activeAlerts=" + activeAlerts + ", activeAlerts=" + activeAlerts +
", basalSchedule=" + basalSchedule + ", basalSchedule=" + basalSchedule +
", lastDeliveryStatus=" + lastDeliveryStatus + ", lastDeliveryStatus=" + lastDeliveryStatus +
", address=" + address +
", packetNumber=" + packetNumber +
", messageNumber=" + messageNumber +
", faultEvent=" + faultEvent +
'}'; '}';
} }
} }

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.pump.omnipod.driver.comm;
import android.text.TextUtils; import android.text.TextUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.joda.time.Duration; import org.joda.time.Duration;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -18,7 +17,6 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
@ -35,7 +33,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.Sta
import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse; import info.nightscout.androidaps.plugins.pump.omnipod.comm.message.response.podinfo.PodInfoResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertSlot;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.AlertType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface; import info.nightscout.androidaps.plugins.pump.omnipod.defs.OmnipodCommunicationManagerInterface;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInfoType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodInitActionType;
@ -131,7 +129,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
pumpStatus.lastBolusTime = lastBolusTime; pumpStatus.lastBolusTime = lastBolusTime;
pumpStatus.lastBolusAmount = lastBolusUnits; pumpStatus.lastBolusAmount = lastBolusUnits;
pumpStatus.reservoirRemainingUnits = podSessionState.getReservoirLevel() == null ? 75.0 : podSessionState.getReservoirLevel(); pumpStatus.reservoirRemainingUnits = podSessionState.getReservoirLevel() == null ? 75.0 : podSessionState.getReservoirLevel();
pumpStatus.pumpStatusType = (podSessionState.hasFaultEvent() || podSessionState.isSuspended()) ? PumpStatusType.Suspended : PumpStatusType.Running; pumpStatus.pumpStatusType = podSessionState.isSuspended() ? PumpStatusType.Suspended : PumpStatusType.Running;
sendEvent(new EventOmnipodPumpValuesChanged()); sendEvent(new EventOmnipodPumpValuesChanged());
} }
} }
@ -143,7 +141,6 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
return Math.abs(expectedUnitsRemaining - pumpStatus.reservoirRemainingUnits) < 0.000001; return Math.abs(expectedUnitsRemaining - pumpStatus.reservoirRemainingUnits) < 0.000001;
} }
@NotNull
private List<String> translateActiveAlerts(PodSessionState podSessionState) { private List<String> translateActiveAlerts(PodSessionState podSessionState) {
List<String> alerts = new ArrayList<>(); List<String> alerts = new ArrayList<>();
for (AlertSlot alertSlot : podSessionState.getActiveAlerts().getAlertSlots()) { for (AlertSlot alertSlot : podSessionState.getActiveAlerts().getAlertSlots()) {
@ -425,9 +422,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
PodHistory podHistory = new PodHistory(requestTime, entryType); PodHistory podHistory = new PodHistory(requestTime, entryType);
if (data!=null) { if (data != null) {
if (data instanceof String) { if (data instanceof String) {
podHistory.setData((String)data); podHistory.setData((String) data);
} else { } else {
podHistory.setData(OmnipodUtil.getGsonInstance().toJson(data)); podHistory.setData(OmnipodUtil.getGsonInstance().toJson(data));
} }
@ -487,9 +484,9 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
comment = getStringResource(R.string.omnipod_driver_error_not_enough_data); comment = getStringResource(R.string.omnipod_driver_error_not_enough_data);
} else if (ex instanceof PodFaultException) { } else if (ex instanceof PodFaultException) {
// TODO handle pod fault with some kind of dialog that has a button to start pod deactivation // TODO handle pod fault with some kind of dialog that has a button to start pod deactivation
FaultEventCode faultEventCode = ((PodFaultException) ex).getFaultEvent().getFaultEventCode(); FaultEventType faultEventType = ((PodFaultException) ex).getFaultEvent().getFaultEventType();
comment = getStringResource(R.string.omnipod_driver_error_pod_fault, comment = getStringResource(R.string.omnipod_driver_error_pod_fault,
ByteUtil.convertUnsignedByteToInt(faultEventCode.getValue()), faultEventCode.name()); ByteUtil.convertUnsignedByteToInt(faultEventType.getValue()), faultEventType.name());
} else if (ex instanceof PodReturnedErrorResponseException) { } else if (ex instanceof PodReturnedErrorResponseException) {
comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response); comment = getStringResource(R.string.omnipod_driver_error_pod_returned_error_response);
} else { } else {

View file

@ -6,7 +6,7 @@ public class PodFaultException extends OmnipodException {
private final PodInfoFaultEvent faultEvent; private final PodInfoFaultEvent faultEvent;
public PodFaultException(PodInfoFaultEvent faultEvent) { public PodFaultException(PodInfoFaultEvent faultEvent) {
super(faultEvent.getFaultEventCode().toString(), true); super(faultEvent.getFaultEventType().toString(), true);
this.faultEvent = faultEvent; this.faultEvent = faultEvent;
} }

View file

@ -4,7 +4,7 @@ import org.joda.time.Duration;
import org.junit.Test; import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -14,7 +14,7 @@ public class PodInfoDataLogTest {
public void testDecoding() { public void testDecoding() {
PodInfoDataLog podInfoDataLog = new PodInfoDataLog(ByteUtil.fromHexString("030100010001043c"), 8); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift PodInfoDataLog podInfoDataLog = new PodInfoDataLog(ByteUtil.fromHexString("030100010001043c"), 8); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
assertEquals(FaultEventCode.FAILED_FLASH_ERASE, podInfoDataLog.getFaultEventCode()); assertEquals(FaultEventType.FAILED_FLASH_ERASE, podInfoDataLog.getFaultEventType());
assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeFaultEvent())); assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeFaultEvent()));
assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeSinceActivation())); assertTrue(Duration.standardMinutes(1).isEqual(podInfoDataLog.getTimeSinceActivation()));
assertEquals(4, podInfoDataLog.getDataChunkSize()); assertEquals(4, podInfoDataLog.getDataChunkSize());

View file

@ -5,7 +5,7 @@ import org.joda.time.Duration;
import org.junit.Test; import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -15,7 +15,7 @@ public class PodInfoFaultAndInitializationTimeTest {
public void testDecoding() { public void testDecoding() {
PodInfoFaultAndInitializationTime podInfoFaultAndInitializationTime = new PodInfoFaultAndInitializationTime(ByteUtil.fromHexString("059200010000000000000000091912170e")); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift PodInfoFaultAndInitializationTime podInfoFaultAndInitializationTime = new PodInfoFaultAndInitializationTime(ByteUtil.fromHexString("059200010000000000000000091912170e")); // From https://github.com/ps2/rileylink_ios/blob/omnipod-testing/OmniKitTests/PodInfoTests.swift
assertEquals(FaultEventCode.BAD_PUMP_REQ_2_STATE, podInfoFaultAndInitializationTime.getFaultEventCode()); assertEquals(FaultEventType.BAD_PUMP_REQ_2_STATE, podInfoFaultAndInitializationTime.getFaultEventType());
assertTrue(Duration.standardMinutes(1).isEqual(podInfoFaultAndInitializationTime.getTimeFaultEvent())); assertTrue(Duration.standardMinutes(1).isEqual(podInfoFaultAndInitializationTime.getTimeFaultEvent()));
DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime(); DateTime dateTime = podInfoFaultAndInitializationTime.getInitializationTime();

View file

@ -5,7 +5,7 @@ import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus; import info.nightscout.androidaps.plugins.pump.omnipod.defs.DeliveryStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.FaultEventType;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.LogEventErrorCode; import info.nightscout.androidaps.plugins.pump.omnipod.defs.LogEventErrorCode;
import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus; import info.nightscout.androidaps.plugins.pump.omnipod.defs.PodProgressStatus;
@ -24,7 +24,7 @@ public class PodInfoFaultEventTest {
assertEquals(DeliveryStatus.NORMAL, podInfoFaultEvent.getDeliveryStatus()); assertEquals(DeliveryStatus.NORMAL, podInfoFaultEvent.getDeliveryStatus());
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001); assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
assertEquals(0x0a, podInfoFaultEvent.getPodMessageCounter()); assertEquals(0x0a, podInfoFaultEvent.getPodMessageCounter());
assertEquals(FaultEventCode.NO_FAULTS, podInfoFaultEvent.getFaultEventCode()); assertEquals(FaultEventType.NO_FAULTS, podInfoFaultEvent.getFaultEventType());
assertTrue(Duration.ZERO.isEqual(podInfoFaultEvent.getFaultEventTime())); assertTrue(Duration.ZERO.isEqual(podInfoFaultEvent.getFaultEventTime()));
assertNull(podInfoFaultEvent.getReservoirLevel()); assertNull(podInfoFaultEvent.getReservoirLevel());
assertTrue(Duration.standardSeconds(8100).isEqual(podInfoFaultEvent.getTimeSinceActivation())); assertTrue(Duration.standardSeconds(8100).isEqual(podInfoFaultEvent.getTimeSinceActivation()));
@ -44,7 +44,7 @@ public class PodInfoFaultEventTest {
assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus()); assertEquals(DeliveryStatus.SUSPENDED, podInfoFaultEvent.getDeliveryStatus());
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001); assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
assertEquals(0x09, podInfoFaultEvent.getPodMessageCounter()); assertEquals(0x09, podInfoFaultEvent.getPodMessageCounter());
assertEquals(FaultEventCode.PRIME_OPEN_COUNT_TOO_LOW, podInfoFaultEvent.getFaultEventCode()); assertEquals(FaultEventType.PRIME_OPEN_COUNT_TOO_LOW, podInfoFaultEvent.getFaultEventType());
assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getFaultEventTime())); assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getFaultEventTime()));
assertNull(podInfoFaultEvent.getReservoirLevel()); assertNull(podInfoFaultEvent.getReservoirLevel());
assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getTimeSinceActivation())); assertTrue(Duration.standardSeconds(60).isEqual(podInfoFaultEvent.getTimeSinceActivation()));
@ -65,7 +65,7 @@ public class PodInfoFaultEventTest {
assertEquals(101.7, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001); assertEquals(101.7, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001);
assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001); assertEquals(0, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
assertEquals(0x04, podInfoFaultEvent.getPodMessageCounter()); assertEquals(0x04, podInfoFaultEvent.getPodMessageCounter());
assertEquals(FaultEventCode.BASAL_OVER_INFUSION_PULSE, podInfoFaultEvent.getFaultEventCode()); assertEquals(FaultEventType.BASAL_OVER_INFUSION_PULSE, podInfoFaultEvent.getFaultEventType());
assertTrue(Duration.standardMinutes(2559).isEqual(podInfoFaultEvent.getFaultEventTime())); assertTrue(Duration.standardMinutes(2559).isEqual(podInfoFaultEvent.getFaultEventTime()));
assertNull(podInfoFaultEvent.getReservoirLevel()); assertNull(podInfoFaultEvent.getReservoirLevel());
assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue()); assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue());
@ -85,7 +85,7 @@ public class PodInfoFaultEventTest {
assertEquals(11.8, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001); assertEquals(11.8, podInfoFaultEvent.getTotalInsulinDelivered(), 0.000001);
assertEquals(0.05, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001); assertEquals(0.05, podInfoFaultEvent.getInsulinNotDelivered(), 0.000001);
assertEquals(0x02, podInfoFaultEvent.getPodMessageCounter()); assertEquals(0x02, podInfoFaultEvent.getPodMessageCounter());
assertEquals(FaultEventCode.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoFaultEvent.getFaultEventCode()); assertEquals(FaultEventType.OCCLUSION_CHECK_ABOVE_THRESHOLD, podInfoFaultEvent.getFaultEventType());
assertTrue(Duration.standardMinutes(616).isEqual(podInfoFaultEvent.getFaultEventTime())); assertTrue(Duration.standardMinutes(616).isEqual(podInfoFaultEvent.getFaultEventTime()));
assertNull(podInfoFaultEvent.getReservoirLevel()); assertNull(podInfoFaultEvent.getReservoirLevel());
assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue()); assertEquals(0, podInfoFaultEvent.getUnacknowledgedAlerts().getRawValue());