Round to supported rates for basal, temp basal and bolus
This commit is contained in:
parent
d4df928aac
commit
a2255a83cc
4 changed files with 11 additions and 10 deletions
|
@ -94,13 +94,13 @@ public enum PumpType {
|
||||||
Insulet_Omnipod("Insulet Omnipod", ManufacturerType.Insulet, "Omnipod (Eros)", 0.05d, null, //
|
Insulet_Omnipod("Insulet Omnipod", ManufacturerType.Insulet, "Omnipod (Eros)", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
|
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO just copied OmniPod for now
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO just copied OmniPod for now
|
||||||
|
|
||||||
// Medtronic
|
// Medtronic
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.TimeZone;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.action.AcknowledgeAlertsAction;
|
||||||
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;
|
||||||
|
@ -201,10 +200,10 @@ public class OmnipodManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CAUTION: cancels temp basal and then sets new temp basal. An OmnipodException[certainFailure=false] indicates that the pod might have cancelled the previous temp basal, but did not set a new temp basal
|
// CAUTION: cancels temp basal and then sets new temp basal. An OmnipodException[certainFailure=false] indicates that the pod might have cancelled the previous temp basal, but did not set a new temp basal
|
||||||
public synchronized void setTemporaryBasal(TempBasalPair tempBasalPair, boolean acknowledgementBeep, boolean completionBeep) {
|
public synchronized void setTemporaryBasal(double rate, Duration duration, boolean acknowledgementBeep, boolean completionBeep) {
|
||||||
assertReadyForDelivery();
|
assertReadyForDelivery();
|
||||||
|
|
||||||
logStartingCommandExecution("setTemporaryBasal [tempBasalPair=" + tempBasalPair + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]");
|
logStartingCommandExecution("setTemporaryBasal [rate=" + rate + ", duration=" + duration + ", acknowledgementBeep=" + acknowledgementBeep + ", completionBeep=" + completionBeep + "]");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
|
cancelDelivery(EnumSet.of(DeliveryType.TEMP_BASAL), acknowledgementBeep);
|
||||||
|
@ -215,7 +214,7 @@ public class OmnipodManager {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(
|
executeAndVerify(() -> communicationService.executeAction(new SetTempBasalAction(
|
||||||
podState, tempBasalPair.getInsulinRate(), Duration.standardMinutes(tempBasalPair.getDurationMinutes()),
|
podState, rate, duration,
|
||||||
acknowledgementBeep, completionBeep)));
|
acknowledgementBeep, completionBeep)));
|
||||||
} catch (OmnipodException ex) {
|
} catch (OmnipodException ex) {
|
||||||
// Treat all exceptions as uncertain failures, because all delivery has been suspended here.
|
// Treat all exceptions as uncertain failures, because all delivery has been suspended here.
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class BasalScheduleEntry {
|
||||||
private final Duration startTime;
|
private final Duration startTime;
|
||||||
|
|
||||||
public BasalScheduleEntry(double rate, Duration startTime) {
|
public BasalScheduleEntry(double rate, Duration startTime) {
|
||||||
if (startTime.isLongerThan(Duration.standardHours(24).minus(Duration.standardSeconds(1))) || startTime.isShorterThan(Duration.ZERO)) {
|
if (startTime.isLongerThan(Duration.standardHours(24).minus(Duration.standardSeconds(1))) || startTime.isShorterThan(Duration.ZERO) || startTime.getStandardSeconds() % 1800 != 0) {
|
||||||
throw new IllegalArgumentException("Invalid start time");
|
throw new IllegalArgumentException("Invalid start time");
|
||||||
} else if (rate < 0D) {
|
} else if (rate < 0D) {
|
||||||
throw new IllegalArgumentException("Rate should be >= 0");
|
throw new IllegalArgumentException("Rate should be >= 0");
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewB
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
import info.nightscout.androidaps.plugins.pump.common.data.TempBasalPair;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil;
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
import info.nightscout.androidaps.plugins.pump.omnipod.comm.OmnipodCommunicationService;
|
||||||
|
@ -284,7 +285,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
|
|
||||||
Date bolusStarted;
|
Date bolusStarted;
|
||||||
try {
|
try {
|
||||||
bolusCommandResult = delegate.bolus(detailedBolusInfo.insulin, beepsEnabled, beepsEnabled, detailedBolusInfo.isSMB ? null :
|
bolusCommandResult = delegate.bolus(PumpType.Insulet_Omnipod.determineCorrectBolusSize(detailedBolusInfo.insulin), beepsEnabled, beepsEnabled, detailedBolusInfo.isSMB ? null :
|
||||||
(estimatedUnitsDelivered, percentage) -> {
|
(estimatedUnitsDelivered, percentage) -> {
|
||||||
EventOverviewBolusProgress progressUpdateEvent = EventOverviewBolusProgress.INSTANCE;
|
EventOverviewBolusProgress progressUpdateEvent = EventOverviewBolusProgress.INSTANCE;
|
||||||
progressUpdateEvent.setStatus(getStringResource(R.string.bolusdelivering, detailedBolusInfo.insulin));
|
progressUpdateEvent.setStatus(getStringResource(R.string.bolusdelivering, detailedBolusInfo.insulin));
|
||||||
|
@ -355,7 +356,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
boolean beepsEnabled = isTempBasalBeepsEnabled();
|
boolean beepsEnabled = isTempBasalBeepsEnabled();
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
delegate.setTemporaryBasal(tempBasalPair, beepsEnabled, beepsEnabled);
|
delegate.setTemporaryBasal(PumpType.Insulet_Omnipod.determineCorrectBasalSize(tempBasalPair.getInsulinRate()), Duration.standardMinutes(tempBasalPair.getDurationMinutes()), beepsEnabled, beepsEnabled);
|
||||||
time = System.currentTimeMillis();
|
time = System.currentTimeMillis();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (ex instanceof PodFaultException) {
|
if (ex instanceof PodFaultException) {
|
||||||
|
@ -723,7 +724,8 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
|
||||||
}
|
}
|
||||||
List<BasalScheduleEntry> entries = new ArrayList<>();
|
List<BasalScheduleEntry> entries = new ArrayList<>();
|
||||||
for (Profile.ProfileValue basalValue : basalValues) {
|
for (Profile.ProfileValue basalValue : basalValues) {
|
||||||
entries.add(new BasalScheduleEntry(basalValue.value, Duration.standardSeconds(basalValue.timeAsSeconds)));
|
entries.add(new BasalScheduleEntry(PumpType.Insulet_Omnipod.determineCorrectBasalSize(basalValue.value),
|
||||||
|
Duration.standardSeconds(basalValue.timeAsSeconds)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new BasalSchedule(entries);
|
return new BasalSchedule(entries);
|
||||||
|
|
Loading…
Reference in a new issue