Don't disconnect after history read when queue is busy.

Temporary hack, ComboPlugin.runCommand will still run commands
synchronously.
This commit is contained in:
Johannes Mockenhaupt 2018-02-13 20:37:34 +01:00
parent aae9f7d153
commit c5e0eb9968
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -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.PumpHistory;
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest; import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.CommandQueue;
import info.nightscout.utils.DateUtil; 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. */
* Reads the pump's history and updates the DB accordingly.
* <p>
* Only ever called by #readAllPumpData which is triggered by the user via the combo fragment
* which warns the user against doing this.
*/
private boolean readHistory(@Nullable PumpHistoryRequest request) { private boolean readHistory(@Nullable PumpHistoryRequest request) {
CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request)); CommandResult historyResult = runCommand(MainApp.gs(R.string.combo_activity_reading_pump_history), 3, () -> ruffyScripter.readHistory(request));
if (!historyResult.success) { if (!historyResult.success) {
@ -1176,9 +1172,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL)); readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL));
// } // }
// }, post); // }, post);
if (post != null) {
post.run(); post.run();
}
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
if (commandQueue.performing() == null && commandQueue.size() == 0) {
ruffyScripter.disconnect(); ruffyScripter.disconnect();
} }
}
// TODO use queue once ready // TODO use queue once ready
void readAlertData(Callback post) { void readAlertData(Callback post) {
@ -1188,9 +1189,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL)); readHistory(new PumpHistoryRequest().pumpErrorHistory(PumpHistoryRequest.FULL));
// } // }
// }, post); // }, post);
if (post != null) {
post.run(); post.run();
}
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
if (commandQueue.performing() == null && commandQueue.size() == 0) {
ruffyScripter.disconnect(); ruffyScripter.disconnect();
} }
}
// TODO use queue once ready // TODO use queue once ready
void readAllPumpData(Callback post) { void readAllPumpData(Callback post) {
@ -1207,9 +1213,14 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
// } // }
// }, post); // }, post);
if (post != null) {
post.run(); post.run();
}
CommandQueue commandQueue = ConfigBuilderPlugin.getCommandQueue();
if (commandQueue.performing() == null && commandQueue.size() == 0) {
ruffyScripter.disconnect(); ruffyScripter.disconnect();
} }
}
/** /**
* Reads QuickInfo to update reservoir level and determine if new boluses exist on the pump * Reads QuickInfo to update reservoir level and determine if new boluses exist on the pump