Merge pull request #103 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge
Some small Omnipod improvements
This commit is contained in:
commit
9fe88ecde9
|
@ -151,7 +151,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
private final Handler loopHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private final Runnable statusChecker;
|
||||
private boolean isSetTempBasalRunning;
|
||||
private boolean isCancelTempBasalRunning;
|
||||
|
||||
@Inject
|
||||
|
@ -303,23 +302,23 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
.toObservable(EventPreferenceChange.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(event -> {
|
||||
if (event.isChanged(getResourceHelper(), R.string.key_omnipod_basal_beeps_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_bolus_beeps_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_tbr_beeps_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_smb_beeps_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_suspend_delivery_button_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_pulse_log_button_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_rileylink_stats_button_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_time_change_event_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_tbr_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_smb_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_notification_uncertain_bolus_sound_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_automatically_acknowledge_alerts_enabled)) {
|
||||
if (event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.BASAL_BEEPS_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.BOLUS_BEEPS_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TBR_BEEPS_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SMB_BEEPS_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.SUSPEND_DELIVERY_BUTTON_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.TIME_CHANGE_EVENT_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_TBR_SOUND_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_SMB_SOUND_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED)) {
|
||||
aapsOmnipodManager.reloadSettings();
|
||||
} else if (event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_expiration_reminder_hours_before_shutdown) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_low_reservoir_alert_enabled) ||
|
||||
event.isChanged(getResourceHelper(), R.string.key_omnipod_low_reservoir_alert_units)) {
|
||||
} else if (event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.EXPIRATION_REMINDER_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.EXPIRATION_REMINDER_HOURS_BEFORE_SHUTDOWN) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.LOW_RESERVOIR_ALERT_ENABLED) ||
|
||||
event.isChanged(getResourceHelper(), OmnipodStorageKeys.Preferences.LOW_RESERVOIR_ALERT_UNITS)) {
|
||||
if (!verifyPodAlertConfiguration()) {
|
||||
getCommandQueue().customCommand(new CommandUpdateAlertConfiguration(), null);
|
||||
}
|
||||
|
@ -364,11 +363,6 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
|
||||
private void handleUncertainTbrRecovery() {
|
||||
// Ignore changes in certainty during tbr commands; these are normal
|
||||
if (isSetTempBasalRunning || isCancelTempBasalRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
TemporaryBasal tempBasal = activePlugin.getActiveTreatments().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
|
||||
if (podStateManager.isTempBasalRunning() && tempBasal == null) {
|
||||
|
@ -661,13 +655,7 @@ public class OmnipodPumpPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
}
|
||||
|
||||
isSetTempBasalRunning = true;
|
||||
PumpEnactResult result;
|
||||
try {
|
||||
result = executeCommand(OmnipodCommandType.SET_TEMPORARY_BASAL, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes)));
|
||||
} finally {
|
||||
isSetTempBasalRunning = false;
|
||||
}
|
||||
PumpEnactResult result = executeCommand(OmnipodCommandType.SET_TEMPORARY_BASAL, () -> aapsOmnipodManager.setTemporaryBasal(new TempBasalPair(absoluteRate, false, durationInMinutes)));
|
||||
|
||||
aapsLogger.info(LTag.PUMP, "setTempBasalAbsolute - setTBR. Response: " + result.success);
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||
import info.nightscout.androidaps.logging.LTag;
|
||||
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.definition.DeliveryType;
|
||||
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.PacketType;
|
||||
|
@ -145,6 +147,14 @@ public class OmnipodMessage {
|
|||
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
|
||||
public String toString() {
|
||||
return "OmnipodMessage{" +
|
||||
|
|
|
@ -60,6 +60,10 @@ public class CancelDeliveryCommand extends NonceResyncableMessageBlock {
|
|||
encode();
|
||||
}
|
||||
|
||||
public EnumSet<DeliveryType> getDeliveryTypes() {
|
||||
return deliveryTypes.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CancelDeliveryCommand{" +
|
||||
|
|
|
@ -21,6 +21,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.OmnipodMessage;
|
||||
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.definition.ActivationProgress;
|
||||
|
@ -550,7 +551,7 @@ public abstract class PodStateManager {
|
|||
/**
|
||||
* 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(() -> {
|
||||
if (podState.getActivatedAt() == null) {
|
||||
DateTime activatedAtCalculated = DateTime.now().withZone(podState.getTimeZone()).minus(status.getTimeActive());
|
||||
|
@ -581,7 +582,10 @@ public abstract class PodStateManager {
|
|||
}
|
||||
if (!isTempBasalCertain) {
|
||||
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) {
|
||||
podState.setBasalCertain(true);
|
||||
|
|
|
@ -167,7 +167,7 @@ public class AapsOmnipodManager {
|
|||
pulseLogButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.PULSE_LOG_BUTTON_ENABLED, false);
|
||||
rileylinkStatsButtonEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.RILEYLINK_STATS_BUTTON_ENABLED, false);
|
||||
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);
|
||||
notificationUncertainBolusSoundEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.NOTIFICATION_UNCERTAIN_BOLUS_SOUND_ENABLED, true);
|
||||
automaticallyAcknowledgeAlertsEnabled = sp.getBoolean(OmnipodStorageKeys.Preferences.AUTOMATICALLY_ACKNOWLEDGE_ALERTS_ENABLED, false);
|
||||
|
|
|
@ -129,11 +129,11 @@ public class OmnipodRileyLinkCommunicationManager extends RileyLinkCommunication
|
|||
aapsLogger.debug(LTag.PUMPBTCOMM, "Received response from the Pod [responseMessageBlock={}]", responseMessageBlock);
|
||||
|
||||
if (responseMessageBlock instanceof StatusUpdatableResponse) {
|
||||
podStateManager.updateFromResponse((StatusUpdatableResponse) responseMessageBlock);
|
||||
podStateManager.updateFromResponse((StatusUpdatableResponse) responseMessageBlock, message);
|
||||
} else if (responseMessageBlock instanceof PodInfoResponse) {
|
||||
PodInfo podInfo = ((PodInfoResponse) responseMessageBlock).getPodInfo();
|
||||
if (podInfo instanceof StatusUpdatableResponse) {
|
||||
podStateManager.updateFromResponse((StatusUpdatableResponse) podInfo);
|
||||
podStateManager.updateFromResponse((StatusUpdatableResponse) podInfo, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
<PreferenceCategory android:title="@string/omnipod_preference_category_notifications">
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_omnipod_notification_uncertain_tbr_sound_enabled"
|
||||
android:title="@string/omnipod_config_notification_uncertain_tbr_sound_enabled" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue