Provide total insulin delivered from Pod available in PodStateManager

This commit is contained in:
Steffen Müthing 2020-08-22 17:08:30 +02:00
parent 00b9379b8c
commit 61d6c638b7

View file

@ -302,6 +302,8 @@ public abstract class PodStateManager {
return getSafe(() -> podState.getReservoirLevel());
}
public final Double getTotalInsulinDelivered() { return getSafe(() -> podState.getTotalInsulinDelivered()); }
public final Duration getScheduleOffset() {
DateTime now = getTime();
return new Duration(now.withTimeAtStartOfDay(), now);
@ -373,6 +375,7 @@ public abstract class PodStateManager {
podState.setActiveAlerts(statusResponse.getAlerts());
podState.setLastDeliveryStatus(statusResponse.getDeliveryStatus());
podState.setReservoirLevel(statusResponse.getReservoirLevel());
podState.setTotalTicksDelivered(statusResponse.getTicksDelivered());
podState.setPodProgressStatus(statusResponse.getPodProgressStatus());
podState.setLastUpdatedFromStatusResponse(DateTime.now());
});
@ -469,6 +472,7 @@ public abstract class PodStateManager {
private DateTime expiresAt;
private PodInfoFaultEvent faultEvent;
private Double reservoirLevel;
private Integer totalTicksDelivered;
private boolean suspended;
private NonceState nonceState;
private PodProgressStatus podProgressStatus;
@ -602,6 +606,20 @@ public abstract class PodStateManager {
this.reservoirLevel = reservoirLevel;
}
public Integer getTotalTicksDelivered() {
return totalTicksDelivered;
}
public Double getTotalInsulinDelivered() {
if (totalTicksDelivered != null) {
return totalTicksDelivered * OmnipodConst.POD_PULSE_SIZE;
} else {
return null;
}
}
void setTotalTicksDelivered(Integer totalTicksDelivered) { this.totalTicksDelivered = totalTicksDelivered; }
public boolean isSuspended() {
return suspended;
}