Check for active alerts on the pump, confirm and re-raise in AAPS.

This commit is contained in:
Johannes Mockenhaupt 2017-10-20 15:23:16 +02:00
parent 57be9bb9b1
commit 491caadd71
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 44 additions and 1 deletions

View file

@ -34,6 +34,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpCombo.events.EventComboPumpUpdateGUI;
import info.nightscout.utils.DateUtil;
@ -560,8 +562,18 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private CommandResult runCommand(String status, CommandExecution commandExecution) {
MainApp.bus().post(new EventComboPumpUpdateGUI(status));
// TODO handle running into WARNING_OR_ERROR ... or scripter? purge it
CommandResult commandResult = commandExecution.execute();
if (commandResult.state.errorMsg != null) {
CommandResult takeOverAlarmResult = ruffyScripter.takeOverAlarm();
Notification notification = new Notification(Notification.IC_MISSING, "Pump alarm: " + takeOverAlarmResult.message
/*ainApp.sResources.getString(R.string.icmissing)*/, Notification.URGENT);
MainApp.bus().post(new EventNewNotification(notification));
commandResult.state = takeOverAlarmResult.state;
}
pump.lastCmdResult = commandResult;
pump.state = commandResult.state;
// TOOD

View file

@ -13,6 +13,11 @@ public interface RuffyCommands {
CommandResult cancelTbr();
/** Confirms an active alarm on the pump. The state returned is the state after the alarm
* has been confirmed. The message field contains the displayed error message that was
* confirmed. */
CommandResult takeOverAlarm();
boolean isPumpAvailable();
boolean isPumpBusy();

View file

@ -22,6 +22,11 @@ public class RuffyCommandsV1Impl implements RuffyCommands {
private RuffyCommandsV1Impl() {
}
@Override
public CommandResult takeOverAlarm() {
return delegate.takeOverAlarm();
}
@Override
public CommandResult deliverBolus(double amount, BolusProgressReporter bolusProgressReporter) {
return delegate.deliverBolus(amount, bolusProgressReporter);

View file

@ -764,6 +764,27 @@ public class RuffyScripter implements RuffyCommands {
return runCommand(new CancelTbrCommand());
}
@Override
public CommandResult takeOverAlarm() {
if (getCurrentMenu().getType() != MenuType.WARNING_OR_ERROR) {
return new CommandResult().success(false).enacted(false).message("No alarm active on the pump");
}
// confirm alert
verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR);
pressCheckKey();
// dismiss alert
verifyMenuIsDisplayed(MenuType.WARNING_OR_ERROR);
pressCheckKey();
waitForMenuToBeLeft(MenuType.WARNING_OR_ERROR);
PumpState pumpState = readPumpStateInternal();
return new CommandResult()
.success(true)
.enacted(false /* well, no treatments were enacted ... */)
.message(pumpState.errorMsg) // todo yikes?
.state(pumpState);
}
@Override
public CommandResult readHistory(PumpHistoryRequest request) {
return runCommand(new ReadHistoryCommand(request));