From bffd1239c061aae005b28c6665d06487a82e19d2 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 30 Oct 2017 16:20:43 +0100 Subject: [PATCH] Disable reading history while incomplete. --- .../plugins/PumpCombo/ComboPlugin.java | 16 +++++++++++++++- .../commands/ReadHistoryCommand.java | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 958dff424b..1e0fdd999f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -234,7 +234,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { // TODO fuse the below into 'sync'? or make checkForTbrMismatch jut a trigger to issue a sync if needed; don't run sync twice as is nice // checkForTbrMismatch(); - checkPumpHistory(); +// checkPumpHistory(); } /** @@ -582,21 +582,34 @@ public class ComboPlugin implements PluginBase, PumpInterface { private synchronized CommandResult runCommand(String activity, CommandExecution commandExecution) { if (activity != null) { + // danar has this is message on the overview screen, no? pump.activity = activity; MainApp.bus().post(new EventComboPumpUpdateGUI()); } + // TODO should probably specialize this: + // smb, tbr stuff can be retried. + // non-smb bolus shall be blocked if same amount already delivered within last 1 min + + // i need a version of this which sets activity, updates local state etc and one + // which just does something, read history etc. + // retrying: separate r/o and r/w commands? flag for it? + // CommandResult precheck = ruffyScripter.readPumpState(); // tbrcheck? // check for active alert; if warning confirm; on warning confirm, read history (bolus, errors), which shall raise alerts if appropriate // // precheck. + // todo don't send out commands requining run mode if pump is suspended + // CommandResult commandResult = commandExecution.execute(); pump.lastCmdResult = commandResult; pump.lastConnectionAttempt = System.currentTimeMillis(); if (commandResult.success) { pump.lastSuccessfulConnection = System.currentTimeMillis(); + } else { + // TODO set flag to force sync on next connect; try to run immediately? or would this make things worse and we should just wait till the next iteratio?L } // copy over state (as supplied) so it will still be available when another command runs that doesn't return that data @@ -694,6 +707,7 @@ public class ComboPlugin implements PluginBase, PumpInterface { } } if (sync) { + // todo just return the PHR? runFullSync(new PumpHistoryRequest().tbrHistory(System.currentTimeMillis() - 3 * 60 * 60 * 1000)); } diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java index ed32619f7d..8db1218c60 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java @@ -43,7 +43,7 @@ public class ReadHistoryCommand extends BaseCommand { if (request.bolusHistory != PumpHistoryRequest.SKIP) { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); if (totalRecords > 0) { - if (true || request.bolusHistory == PumpHistoryRequest.LAST) { + if (request.bolusHistory == PumpHistoryRequest.LAST) { Bolus bolus = readBolusRecord(); history.bolusHistory.add(bolus); } else { @@ -58,7 +58,7 @@ public class ReadHistoryCommand extends BaseCommand { if (request.pumpErrorHistory != PumpHistoryRequest.SKIP) { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); if (totalRecords > 0) { - if (true || request.pumpErrorHistory == PumpHistoryRequest.LAST) { + if (request.pumpErrorHistory == PumpHistoryRequest.LAST) { PumpError error = readErrorRecord(); history.pumpErrorHistory.add(error); } else {