Merge pull request #103 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge

Some small Omnipod improvements
This commit is contained in:
Milos Kozak 2020-12-08 20:59:19 +01:00 committed by GitHub
commit 9fe88ecde9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 35 deletions

View file

@ -151,7 +151,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
private final Handler loopHandler = new Handler(Looper.getMainLooper()); private final Handler loopHandler = new Handler(Looper.getMainLooper());
private final Runnable statusChecker; private final Runnable statusChecker;
private boolean isSetTempBasalRunning;
private boolean isCancelTempBasalRunning; private boolean isCancelTempBasalRunning;
@Inject @Inject
@ -303,23 +302,23 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
.toObservable(EventPreferenceChange.class) .toObservable(EventPreferenceChange.class)
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
.subscribe(event -> { .subscribe(event -> {
if (event.isChanged(getResourceHelper(), R.string.key_omnipod_basal_beeps_enabled) || if (event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.BASAL_BEEPS_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_bolus_beeps_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.BOLUS_BEEPS_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_tbr_beeps_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_smb_beeps_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SMB_BEEPS_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_suspend_delivery_button_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_pulse_log_button_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_rileylink_stats_button_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_tbr_sound_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_smb_sound_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_automatically_acknowledge_alerts_enabled)) { event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED)) {
aapsOmnipodManager.reloadSettings(); aapsOmnipodManager.reloadSettings();
} else if (event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_enabled) || } else if (event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.EXPIRATION_REMINDER_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_hours_before_shutdown) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_low_reservoir_alert_enabled) || event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.LOW_RESERVOIR_ALERT_ENABLED) ||
event.isChanged(getResourceHelper(), R.string.key_omnipod_low_reservoir_alert_units)) { event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.LOW_RESERVOIR_ALERT_UNITS)) {
if (!verifyPodAlertConfiguration()) { if (!verifyPodAlertConfiguration()) {
getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null); getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null);
} }
@ -364,11 +363,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
private void handleUncertainTbrRecovery() { private void handleUncertainTbrRecovery() {
// Ignore changes in certainty during tbr commands; these are normal
if (isSetTempBasalRunning || isCancelTempBasalRunning) {
return;
}
TemporaryBasal tempBasal = activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis()); TemporaryBasal tempBasal = activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
if (podStateManager.isTempBasalRunning() && tempBasal == null) { if (podStateManager.isTempBasalRunning() && tempBasal == null) {
@ -661,13 +655,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
} }
} }
isSetTempBasalRunning = true; PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TEMPORARY_BASAL, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes)));
PumpEnactResult result;
try {
result = executeCommand(OmnipodCommandType.SET_TEMPORARY_BASAL, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes)));
} finally {
isSetTempBasalRunning = false;
}
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - setTBR. Response: " + result.success); aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - setTBR. Response: " + result.success);

View file

@ -6,7 +6,9 @@ import java.util.List;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
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.driver.communication.message.command.CancelDeliveryCommand;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.GetStatusCommand; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.command.GetStatusCommand;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.DeliveryType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.MessageBlockType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.MessageBlockType;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodCrc; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.OmnipodCrc;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketType; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.PacketType;
@ -145,6 +147,14 @@ public class OmnipodMessage {
return false; return false;
} }
public boolean isSetTempBasalMessage() {
return messageBlocks.size() >= 2 && messageBlocks.get(0).getType() == MessageBlockType.SET_INSULIN_SCHEDULE && messageBlocks.get(1).getType() == MessageBlockType.TEMP_BASAL_EXTRA;
}
public boolean isCancelTempBasalMessage() {
return messageBlocks.size() >= 1 && messageBlocks.get(0).getType() == MessageBlockType.CANCEL_DELIVERY && ((CancelDeliveryCommand) messageBlocks.get(0)).getDeliveryTypes().contains(DeliveryType.TEMP_BASAL);
}
@Override @Override
public String toString() { public String toString() {
return "OmnipodMessage{" + return "OmnipodMessage{" +

View file

@ -60,6 +60,10 @@ public class CancelDeliveryCommand extends NonceResyncableMessageBlock {
encode(); encode();
} }
public EnumSet<DeliveryType> getDeliveryTypes() {
return deliveryTypes.clone();
}
@Override @Override
public String toString() { public String toString() {
return "CancelDeliveryCommand{" + return "CancelDeliveryCommand{" +

View file

@ -21,6 +21,7 @@ import java.util.function.Supplier;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.OmnipodMessage;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.StatusUpdatableResponse;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoDetailedStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.communication.message.response.podinfo.PodInfoDetailedStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress; import info.nightscout.androidaps.plugins.pump.omnipod.driver.definition.ActivationProgress;
@ -550,7 +551,7 @@ public abstract class PodStateManager {
/** /**
* Does not automatically store pod state in order to decrease I/O load * Does not automatically store pod state in order to decrease I/O load
*/ */
public final void updateFromResponse(StatusUpdatableResponse status) { public final void updateFromResponse(StatusUpdatableResponse status, OmnipodMessage requestMessage) {
setSafe(() -> { setSafe(() -> {
if (podState.getActivatedAt() == null) { if (podState.getActivatedAt() == null) {
DateTime activatedAtCalculated = DateTime.now().withZone(podState.getTimeZone()).minus(status.getTimeActive()); DateTime activatedAtCalculated = DateTime.now().withZone(podState.getTimeZone()).minus(status.getTimeActive());
@ -581,7 +582,10 @@ public abstract class PodStateManager {
} }
if (!isTempBasalCertain) { if (!isTempBasalCertain) {
podState.setTempBasalCertain(true); podState.setTempBasalCertain(true);
onUncertainTbrRecovered(); if (!requestMessage.isSetTempBasalMessage() // We always set TBR to uncertain before sending the set temp basal command, so this is not an actual recovery
&& !requestMessage.isCancelTempBasalMessage()) { // Delivery status changed, so we can't recover here
onUncertainTbrRecovered();
}
} }
if (!isBasalCertain) { if (!isBasalCertain) {
podState.setBasalCertain(true); podState.setBasalCertain(true);

View file

@ -167,7 +167,7 @@ public class AapsOmnipodManager {
pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false); pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false);
rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED, false); rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED, false);
timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true); timeChangeEventEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED, true);
notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, true); notificationUncertainTbrSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED, false);
notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true); notificationUncertainSmbSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED, true);
notificationUncertainBolusSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED, true); notificationUncertainBolusSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED, true);
automaticallyAcknowledgeAlertsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED, false); automaticallyAcknowledgeAlertsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED, false);

View file

@ -129,11 +129,11 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock); aapsLogger.debug(LTag.PUMPBTCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock);
if (responseMessageBlock instanceof StatusUpdatableResponse) { if (responseMessageBlock instanceof StatusUpdatableResponse) {
podStateManager.updateFromResponse((StatusUpdatableResponse) responseMessageBlock); podStateManager.updateFromResponse((StatusUpdatableResponse) responseMessageBlock, message);
} else if (responseMessageBlock instanceof PodInfoResponse) { } else if (responseMessageBlock instanceof PodInfoResponse) {
PodInfo podInfo = ((PodInfoResponse) responseMessageBlock).getPodInfo(); PodInfo podInfo = ((PodInfoResponse) responseMessageBlock).getPodInfo();
if (podInfo instanceof StatusUpdatableResponse) { if (podInfo instanceof StatusUpdatableResponse) {
podStateManager.updateFromResponse((StatusUpdatableResponse) podInfo); podStateManager.updateFromResponse((StatusUpdatableResponse) podInfo, message);
} }
} }

View file

@ -82,7 +82,7 @@
<PreferenceCategory android:title="@string/omnipod_preference_category_notifications"> <PreferenceCategory android:title="@string/omnipod_preference_category_notifications">
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="false"
android:key="@string/key_omnipod_notification_uncertain_tbr_sound_enabled" android:key="@string/key_omnipod_notification_uncertain_tbr_sound_enabled"
android:title="@string/omnipod_config_notification_uncertain_tbr_sound_enabled" /> android:title="@string/omnipod_config_notification_uncertain_tbr_sound_enabled" />