From c5e0eb9968fba6ca4cdec948ba9b52e233efba6f Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Tue, 13 Feb 2018 20:37:34 +0100 Subject: [PATCH] Don't disconnect after history read when queue is busy. Temporary hack, ComboPlugin.runCommand will still run commands synchronously. --- .../plugins/PumpCombo/ComboPlugin.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 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 006f38f362..e0772da979 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 @@ -50,6 +50,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest; import info.nightscout.androidaps.queue.Callback; +import info.nightscout.androidaps.queue.CommandQueue; import info.nightscout.utils.DateUtil; /** @@ -1114,12 +1115,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } } - /** - * Reads the pump's history and updates the DB accordingly. - *

- * Only ever called by #readAllPumpData which is triggered by the user via the combo fragment - * which warns the user against doing this. - */ + /**Reads the pump's history and updates the DB accordingly. */ private boolean readHistory(@Nullable PumpHistoryRequest request) { CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request)); if (!historyResult.success) { @@ -1176,8 +1172,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL)); // } // }, post); - post.run(); - ruffyScripter.disconnect(); + if (post != null) { + post.run(); + } + CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue(); + if (commandQueue.performing() == null && commandQueue.size() == 0) { + ruffyScripter.disconnect(); + } } // TODO use queue once ready @@ -1188,8 +1189,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL)); // } // }, post); - post.run(); - ruffyScripter.disconnect(); + if (post != null) { + post.run(); + } + CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue(); + if (commandQueue.performing() == null && commandQueue.size() == 0) { + ruffyScripter.disconnect(); + } } // TODO use queue once ready @@ -1207,8 +1213,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } // } // }, post); - post.run(); - ruffyScripter.disconnect(); + if (post != null) { + post.run(); + } + CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue(); + if (commandQueue.performing() == null && commandQueue.size() == 0) { + ruffyScripter.disconnect(); + } } /**