Refactored fixed pump unreachable alerts into separate 'fixed pump unreachable alert' and 'custom pump unreachable alert check'

This commit is contained in:
Bart Sopers 2020-03-03 23:23:19 +01:00
parent 2c8c0e705d
commit fcc37eb688
5 changed files with 56 additions and 51 deletions

View file

@ -56,6 +56,7 @@ public class PumpDescription {
public boolean needsManualTDDLoad;
public boolean hasFixedUnreachableAlert;
public boolean hasCustomUnreachableAlertCheck;
public void resetSettings() {
isBolusCapable = true;
@ -90,6 +91,7 @@ public class PumpDescription {
needsManualTDDLoad = true;
hasFixedUnreachableAlert = false;
hasCustomUnreachableAlertCheck = false;
}
public void setPumpDescription(PumpType pumpType) {
@ -139,6 +141,7 @@ public class PumpDescription {
is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min);
hasFixedUnreachableAlert = pumpType.getHasFixedUnreachableAlert();
hasCustomUnreachableAlertCheck = pumpType.getHasCustomUnreachableAlertCheck();
}
}

View file

@ -101,8 +101,8 @@ public interface PumpInterface {
*/
void timezoneOrDSTChanged(TimeChangeType timeChangeType);
/* Only used for pump types where hasFixedUnreachableAlert=true */
default boolean isFixedUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
/* Only used for pump types where hasCustomUnreachableAlertCheck=true */
default boolean isUnreachableAlertTimeoutExceeded(long alertTimeoutMilliseconds) {
return false;
}

View file

@ -23,7 +23,7 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Percent, //
new DoseSettings(10, 30, 24 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities, false), //
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities, false, false), //
// Cellnovo
@ -31,7 +31,7 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 24 * 60, 1d, null),
PumpTempBasalType.Percent,
new DoseSettings(5, 30, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities, false), //
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities, false, false), //
// Accu-Chek
@ -39,32 +39,32 @@ public enum PumpType {
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities, false), //
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities, false, false), //
AccuChekSpirit("Accu-Chek Spirit", ManufacturerType.Roche, "Spirit", 0.1d, null, //
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities, false), //
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities, false, false), //
AccuChekInsight("Accu-Chek Insight", ManufacturerType.Roche, "Insight", 0.05d, DoseStepSize.InsightBolus, //
new DoseSettings(0.05d, 15, 24 * 60, 0.05d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, null, PumpCapability.InsightCapabilities, false), //
0.02d, 0.01d, null, PumpCapability.InsightCapabilities, false, false), //
AccuChekInsightBluetooth("Accu-Chek Insight", ManufacturerType.Roche, "Insight", 0.01d, null, //
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
PumpTempBasalType.Percent,
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities, false), //
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities, false, false), //
// Animas
AnimasVibe("Animas Vibe", ManufacturerType.Animas, "Vibe", 0.05d, null, // AnimasBolus?
new DoseSettings(0.05d, 30, 12 * 60, 0.05d), //
PumpTempBasalType.Percent, //
new DoseSettings(10, 30, 24 * 60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities, false), //
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities, false, false), //
AnimasPing("Animas Ping", "Ping", AnimasVibe),
@ -73,42 +73,41 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Percent, //
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
0.04d, 0.01d, null, PumpCapability.DanaCapabilities, false),
0.04d, 0.01d, null, PumpCapability.DanaCapabilities, false, false),
DanaRKorean("DanaR Korean", ManufacturerType.Sooil, "DanaRKorean", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Percent, //
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
0.1d, 0.01d, null, PumpCapability.DanaCapabilities, false),
0.1d, 0.01d, null, PumpCapability.DanaCapabilities, false, false),
DanaRS("DanaRS", ManufacturerType.Sooil, "DanaRS", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Percent, //
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities, false),
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities, false, false),
DanaRv2("DanaRv2", "DanaRv2", DanaRS),
// Insulet
Insulet_Omnipod("Insulet Omnipod", ManufacturerType.Insulet, "Omnipod (Eros)", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
0.05d, 0.05d, null, PumpCapability.OmnipodCapabilities, true),
0.05d, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true),
Insulet_Omnipod_Dash("Insulet Omnipod Dash", ManufacturerType.Insulet, "Omnipod Dash", 0.05d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, //
0.05d, 0.05d, null, PumpCapability.OmnipodCapabilities, true), // TODO just copied OmniPod for now
0.05d, 0.05d, null, PumpCapability.OmnipodCapabilities, true, true), // TODO just copied OmniPod for now
// Medtronic
Medtronic_512_712("Medtronic 512/712", ManufacturerType.Medtronic, "512/712", 0.1d, null, //
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
0.05d, 0.05d, null, PumpCapability.MedtronicCapabilities, false), //
0.05d, 0.05d, null, PumpCapability.MedtronicCapabilities, false, false), //
Medtronic_515_715("Medtronic 515/715", "515/715", Medtronic_512_712),
Medtronic_522_722("Medtronic 522/722", "522/722", Medtronic_512_712),
@ -117,7 +116,7 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.MedtronicCapabilities, false), //
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.MedtronicCapabilities, false, false), //
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", "554/754 (Veo)", Medtronic_523_723_Revel), // TODO
@ -125,14 +124,14 @@ public enum PumpType {
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
PumpTempBasalType.Absolute, //
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities, false), //
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities, false, false), //
// Tandem
TandemTSlim("Tandem t:slim", ManufacturerType.Tandem, "t:slim", 0.01d, null, //
new DoseSettings(0.01d, 15, 8 * 60, 0.4d),
PumpTempBasalType.Percent,
new DoseSettings(1, 15, 8 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities, false),
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities, false, false),
TandemTFlex("Tandem t:flex", "t:flex", TandemTSlim), //
TandemTSlimG4("Tandem t:slim G4", "t:slim G4", TandemTSlim), //
@ -141,7 +140,6 @@ public enum PumpType {
// MDI
MDI("MDI", ManufacturerType.AndroidAPS, "MDI");
private String description;
private ManufacturerType manufacturer;
private String model;
@ -157,6 +155,7 @@ public enum PumpType {
private DoseStepSize baseBasalSpecialSteps; //
private PumpCapability pumpCapability;
private boolean hasFixedUnreachableAlert;
private boolean hasCustomUnreachableAlertCheck;
private PumpType parent;
private static Map<String, PumpType> mapByDescription;
@ -194,15 +193,15 @@ public enum PumpType {
PumpType(String description, ManufacturerType manufacturer, String model, double bolusSize, DoseStepSize specialBolusSize, //
DoseSettings extendedBolusSettings, //
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability, boolean hasFixedUnreachableAlert) {
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability, hasFixedUnreachableAlert);
double baseBasalMinValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability, boolean hasFixedUnreachableAlert, boolean hasCustomUnreachableAlertCheck) {
this(description, manufacturer, model, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability, hasFixedUnreachableAlert, hasCustomUnreachableAlertCheck);
}
PumpType(String description, ManufacturerType manufacturer, String model, double bolusSize, DoseStepSize specialBolusSize, //
DoseSettings extendedBolusSettings, //
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, //
PumpCapability pumpCapability, boolean hasFixedUnreachableAlert) {
PumpCapability pumpCapability, boolean hasFixedUnreachableAlert, boolean hasCustomUnreachableAlertCheck) {
this.description = description;
this.manufacturer = manufacturer;
this.model = model;
@ -218,11 +217,17 @@ public enum PumpType {
this.baseBasalSpecialSteps = baseBasalSpecialSteps;
this.pumpCapability = pumpCapability;
this.hasFixedUnreachableAlert = hasFixedUnreachableAlert;
this.hasCustomUnreachableAlertCheck = hasCustomUnreachableAlertCheck;
}
public boolean getHasFixedUnreachableAlert() {
return hasFixedUnreachableAlert;
}
public boolean getHasCustomUnreachableAlertCheck() {
return hasFixedUnreachableAlert;
}
public String getDescription() {
return description;
}

View file

@ -980,7 +980,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
@Override
public boolean isFixedUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
public boolean isUnreachableAlertTimeoutExceeded(long unreachableTimeoutMilliseconds) {
getPodPumpStatusObject();
if (pumpStatusLocal.lastConnection != 0 || pumpStatusLocal.lastErrorConnection != 0) {

View file

@ -36,41 +36,38 @@ public class LocalAlertUtils {
public static void checkPumpUnreachableAlarm(long lastConnection, boolean isStatusOutdated) {
PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump();
if (activePump != null && activePump.getPumpDescription().hasFixedUnreachableAlert) {
checkPumpUnreachableAlarmStatic(activePump);
} else {
checkPumpUnreachableAlarmConfigured(lastConnection, isStatusOutdated);
boolean alertsEnabled = Config.APS && //
((activePump != null && activePump.getPumpDescription().hasFixedUnreachableAlert) //
|| SP.getBoolean(MainApp.gs(R.string.key_enable_pump_unreachable_alert), true));
if (alertsEnabled) {
boolean isUnreachable;
if (activePump != null && activePump.getPumpDescription().hasCustomUnreachableAlertCheck) {
isUnreachable = checkCustomPumpUnreachableAlarm(activePump);
} else {
isUnreachable = checkDefaultPumpUnreachableAlarm(lastConnection, isStatusOutdated);
}
if (isUnreachable) {
log.debug("Generating pump unreachable alarm.");
showUnreachableNotification(pumpUnreachableThreshold());
} else {
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PUMP_UNREACHABLE));
}
}
}
private static void checkPumpUnreachableAlarmStatic(PumpInterface pump) {
if (pump == null) {
return;
}
long pumpUnreachableThresholdMilliseconds = pumpUnreachableThreshold();
if (pump.isFixedUnreachableAlertTimeoutExceeded(pumpUnreachableThresholdMilliseconds)) {
log.debug("Generating static pump unreachable alarm.");
showUnreachableNotification(pumpUnreachableThresholdMilliseconds);
} else {
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PUMP_UNREACHABLE));
}
private static boolean checkCustomPumpUnreachableAlarm(PumpInterface pump) {
return pump != null && pump.isUnreachableAlertTimeoutExceeded(pumpUnreachableThreshold());
}
private static void checkPumpUnreachableAlarmConfigured(long lastConnection, boolean isStatusOutdated) {
private static boolean checkDefaultPumpUnreachableAlarm(long lastConnection, boolean isStatusOutdated) {
boolean alarmTimeoutExpired = lastConnection + pumpUnreachableThreshold() < System.currentTimeMillis();
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
if (Config.APS && SP.getBoolean(MainApp.gs(R.string.key_enable_pump_unreachable_alert), true)
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !LoopPlugin.getPlugin().isDisconnected()) {
log.debug("Generating configured pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated);
showUnreachableNotification(pumpUnreachableThreshold());
}
if (!isStatusOutdated && !alarmTimeoutExpired)
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PUMP_UNREACHABLE));
return isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !LoopPlugin.getPlugin().isDisconnected();
}
private static void showUnreachableNotification(long nextAlarmTimeoutMillis) {