Merge pull request #24 from jotomo/combo-scripter-v2

feb 2
This commit is contained in:
Simon Pauwels 2018-02-02 15:13:57 +01:00 committed by GitHub
commit e3f9954e62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -199,7 +199,7 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
activityView.setTextSize(14);
activityView.setText(activity);
} else {
activityView.setTextSize(18);
activityView.setTextSize(20);
activityView.setText("{fa-bed}");
}

View file

@ -565,7 +565,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new PumpEnactResult().success(false).enacted(true)
.comment(MainApp.gs(R.string.combo_error_updating_treatment_record));
// partial bolus was delivered
timestampOfLastKnownPumpBolusRecord = lastPumpBolus.timestamp;
// only a partial bolus was delivered
if (Math.abs(lastPumpBolus.amount - detailedBolusInfo.insulin) > 0.01) {
if (cancelBolus) {
return new PumpEnactResult().success(true).enacted(true);
@ -717,11 +719,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
@Override
public PumpEnactResult cancelTempBasal(boolean userRequested) {
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
log.debug("cancelTempBasal called");
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (userRequested) {
log.debug("cancelTempBasal: hard-cancelling TBR since user requested");
if (enforceNew) {
log.debug("cancelTempBasal: hard-cancelling TBR since force requested");
CommandResult commandResult = runCommand(MainApp.gs(R.string.combo_pump_action_cancelling_tbr), 2, ruffyScripter::cancelTbr);
if (!commandResult.state.tbrActive) {
TemporaryBasal tempBasal = new TemporaryBasal();
@ -737,8 +739,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return new PumpEnactResult().success(true).enacted(false);
} else if ((activeTemp.percentRate >= 90 && activeTemp.percentRate <= 110) && activeTemp.getPlannedRemainingMinutes() <= 15) {
// Let fake neutral temp keep run (see below)
// Note that a connection to the pump is still opened, since the queue issues a getPumpStatus() call whenever an empty
// queue receives a new command. Probably not worth optimizing.
// Note that since this runs on the queue a connection is opened regardless, but this
// case doesn't occur all that often, so it's not worth optimizing (1.3k SetTBR vs 4 cancelTBR).
log.debug("cancelTempBasal: skipping changing tbr since it already is at " + activeTemp.percentRate + "% and running for another " + activeTemp.getPlannedRemainingMinutes() + " mins.");
return new PumpEnactResult().success(true).enacted(true)
.comment("cancelTempBasal skipping changing tbr since it already is at "
@ -824,6 +826,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
private CommandResult runOnConnectChecks() {
// connect, get status and check if an alarm is active
CommandResult preCheckResult = ruffyScripter.readPumpState();
for (int retries = 2; !preCheckResult.success && retries > 0; retries--) {
preCheckResult = ruffyScripter.readPumpState();
}
if (!preCheckResult.success) {
return preCheckResult;
}