A few fixes.

This commit is contained in:
Johannes Mockenhaupt 2018-02-03 23:44:17 +01:00
parent 956a611af4
commit 87771e8753
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -532,8 +532,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
// if the last bolus was given in the current minute, wait till the pump clock moves // if the last bolus was given in the current minute, wait till the pump clock moves
// to the next minute to ensure timestamps are unique and can be imported // to the next minute to ensure timestamps are unique and can be imported
CommandResult timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState); CommandResult timeCheckResult = stateResult;
long maxWaitTimeout = System.currentTimeMillis() + 65 * 1000; long waitStartTime = System.currentTimeMillis();
long maxWaitTimeout = waitStartTime + 65 * 1000;
int waitLoops = 0; int waitLoops = 0;
while (previousBolus.timestamp == timeCheckResult.state.pumpTime while (previousBolus.timestamp == timeCheckResult.state.pumpTime
&& maxWaitTimeout < System.currentTimeMillis()) { && maxWaitTimeout < System.currentTimeMillis()) {
@ -544,16 +545,17 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new PumpEnactResult().success(false).enacted(false) return new PumpEnactResult().success(false).enacted(false)
.comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered)); .comment(MainApp.gs(R.string.combo_error_no_connection_no_bolus_delivered));
} }
SystemClock.sleep(5000); SystemClock.sleep(2000);
timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState); timeCheckResult = runCommand(null, 0, ruffyScripter::readPumpState);
waitLoops++; waitLoops++;
} }
if (waitLoops > 0) { if (waitLoops > 0) {
long waitDuration = (System.currentTimeMillis() - waitStartTime) / 1000;
Answers.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait") Answers.getInstance().logCustom(new CustomEvent("ComboBolusTimestampWait")
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION) .putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
.putCustomAttribute("version", BuildConfig.VERSION) .putCustomAttribute("version", BuildConfig.VERSION)
.putCustomAttribute("waitTimeSecs", String.valueOf(waitLoops * 5))); .putCustomAttribute("waitTimeSecs", String.valueOf(waitDuration)));
log.debug("Waited " + (waitLoops * 5) + "s for pump to switch to a fresh minute before bolusing"); log.debug("Waited " + waitDuration + "s for pump to switch to a fresh minute before bolusing");
} }
if (cancelBolus) { if (cancelBolus) {
@ -811,9 +813,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
CommandResult commandResult; CommandResult commandResult;
try { try {
if (!ruffyScripter.isConnected()) { if (!ruffyScripter.isConnected()) {
String originalActivity = pump.activity;
pump.activity = MainApp.gs(R.string.combo_activity_checking_pump_state); pump.activity = MainApp.gs(R.string.combo_activity_checking_pump_state);
MainApp.bus().post(new EventComboPumpUpdateGUI()); MainApp.bus().post(new EventComboPumpUpdateGUI());
CommandResult preCheckError = runOnConnectChecks(); CommandResult preCheckError = runOnConnectChecks();
pump.activity = originalActivity;
if (preCheckError != null) { if (preCheckError != null) {
updateLocalData(preCheckError); updateLocalData(preCheckError);
return preCheckError; return preCheckError;