unsafe usage checks update.
This commit is contained in:
parent
8b7725c076
commit
be5f7e68a7
|
@ -640,6 +640,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
private void checkForUnsupportedBoluses(CommandResult commandResult) {
|
||||
long lastViolation = 0;
|
||||
if (commandResult.state.unsafeUsageDetected) {
|
||||
lastViolation = System.currentTimeMillis();
|
||||
}
|
||||
if (commandResult.lastBolus != null && !commandResult.lastBolus.isValid) {
|
||||
lastViolation = commandResult.lastBolus.timestamp;
|
||||
} else if (commandResult.history != null) {
|
||||
|
@ -649,16 +652,17 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastViolation > 0) {
|
||||
closedLoopDisabledUntil = lastViolation + 6 * 60 * 60 * 1000;
|
||||
if (closedLoopDisabledUntil > System.currentTimeMillis()) {
|
||||
if (closedLoopDisabledUntil > System.currentTimeMillis() && violationWarningRaisedFor != closedLoopDisabledUntil) {
|
||||
// TODO add message to either Combo tab or its errors popup
|
||||
// TODO warn once; after that the user gets suggesiotn from open loop mode as a reminder...
|
||||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||
MainApp.sResources.getString(R.string.combo_force_disabled),
|
||||
Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
MainApp.bus().post(new EventNewNotification(n));
|
||||
violationWarningRaisedFor = closedLoopDisabledUntil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -920,15 +924,16 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
|
||||
// Constraints interface
|
||||
private long closedLoopDisabledUntil = 0;
|
||||
private long violationWarningRaisedFor = 0;
|
||||
|
||||
@Override
|
||||
public boolean isLoopEnabled() {
|
||||
return true;
|
||||
return closedLoopDisabledUntil < System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosedModeEnabled() {
|
||||
return closedLoopDisabledUntil < System.currentTimeMillis();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -794,11 +794,11 @@
|
|||
<string name="enable_pump_unreachable_alert">Alert if pump unreachable for 30 min</string>
|
||||
<string name="combo_pump_never_connected">Never</string>
|
||||
<string name="combo_reservoir_level_insufficant_for_bolus">Not enough insulin left in reservoir for bolus</string>
|
||||
<string name="combo_pump_bolus_history_state_mismatch">A bolus has been given recently on the pump directly of which AndroidAPS has only just become aware of. The pump\'s history is currently being read. Please check the Combo page, verify the last bolus and IOB and bolus again if needed. No bolus has been given.</string>
|
||||
<string name="combo_pump_bolus_history_state_mismatch">A bolus has been delivered directly on the pump recently, of which AndroidAPS has only just become aware of. The pump\'s history is currently being read. Please check the Combo page, verify the last bolus and IOB and bolus again if needed. No bolus has been delivered.</string>
|
||||
<string name="combo_pump_bolus_verification_failed">Bolus delivery verification failed. The pump history will be read again on the next loop run or when refreshing from the Combo page. Please check and bolus again if needed.</string>
|
||||
<string name="combo_pump_unsupported_operation">Requested operation not supported by pump</string>
|
||||
<string name="combo_bolus_bolus_delivery_failed">Bolus delivery failed. A (partial) bolus might have been delivered. Attempting to update history from pump. Please check the Combo page and bolus again as needed.</string>
|
||||
<string name="combo_force_disabled">Unsafe usage: extended or multiwave boluses have been delivered within the last 6h. Closed loop mode forcefully disabled. Only normal boluses are supported when running in closed loop mode.</string>
|
||||
<string name="combo_force_disabled">Unsafe usage: extended or multiwave boluses have been delivered within the last 6 hours. Loop mode has been disabled until 6 hours after the last unsupported bolus. Only normal boluses are supported in loop mode.</string>
|
||||
<string name="bolus_frequency_exceeded">A bolus with the same amount was requested within the last minute. For safety reasons this is disallowed.</string>
|
||||
</resources>
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ public class PumpState {
|
|||
public int insulinState = UNKNOWN;
|
||||
|
||||
public int activeBasalProfileNumber;
|
||||
/** True if use of an extended or multiwave bolus has been detected */
|
||||
public boolean unsafeUsageDetected;
|
||||
|
||||
public PumpState menu(String menu) {
|
||||
this.menu = menu;
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.monkey.d.ruffy.ruffy.driver.IRuffyService;
|
|||
import org.monkey.d.ruffy.ruffy.driver.display.Menu;
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.MenuAttribute;
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.MenuType;
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.menu.BolusType;
|
||||
import org.monkey.d.ruffy.ruffy.driver.display.menu.MenuTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -440,7 +441,11 @@ public class RuffyScripter implements RuffyCommands {
|
|||
|
||||
if (menuType == MenuType.MAIN_MENU) {
|
||||
Double tbrPercentage = (Double) menu.getAttribute(MenuAttribute.TBR);
|
||||
if (tbrPercentage != 100) {
|
||||
BolusType bolusType = (BolusType) menu.getAttribute(MenuAttribute.BOLUS_TYPE);
|
||||
if (bolusType != null && bolusType != BolusType.NORMAL) {
|
||||
// unsupported Extended/Multiwave bolus running
|
||||
state.unsafeUsageDetected = true;
|
||||
} else if (tbrPercentage != 100) {
|
||||
state.tbrActive = true;
|
||||
Double displayedTbr = (Double) menu.getAttribute(MenuAttribute.TBR);
|
||||
state.tbrPercent = displayedTbr.intValue();
|
||||
|
|
Loading…
Reference in a new issue