Minor tewaks and cleanups.

This commit is contained in:
Johannes Mockenhaupt 2017-12-13 15:22:08 +01:00
parent 618e00d71d
commit b6bc957813
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
6 changed files with 29 additions and 13 deletions

View file

@ -35,6 +35,16 @@
It might be interesting to experiment with the Config software to set lower menu or display timeouts It might be interesting to experiment with the Config software to set lower menu or display timeouts
(or whatever they're called ...) to improve recovery speed. (or whatever they're called ...) to improve recovery speed.
- [ ] Same as above while bolusing must report an error and NOT retry the command - [ ] Same as above while bolusing must report an error and NOT retry the command
- [ ] Recovery from connection issues during bolusing
- [ ] Bolusing still works => No error dialog, record is added to treatments
- [ ] Cancelling the bolus still works (while bolus is in progress)
- [ ] Pressing a button on the pump during delivery => Progress dialog freezes, then states that recovery
is in process and then closes; no error dialog, record correctly added to treatments
- [ ] Breaking the connection e.g. by moving the pump away from phone for up to a minute => same as above
- [ ] Same as above but put pump out of reach for 5 minutes => Error dialog, no record in treatments
- [ ] Starting a bolus bigger than what's left in the reservoir => Error dialog and a record in treatments with the partially delivered bolus
- [ ] When the connection breaks during bolusing, pressing the cancel button should not interfere with recovery and
the delivered bolus should be added to treatments
- [ ] AAPS start - [ ] AAPS start
- [ ] Starting AAPS without a reachable pump must show something sensible in the Combo tab - [ ] Starting AAPS without a reachable pump must show something sensible in the Combo tab
(not hanging indefinitely with "initializing" activity) (not hanging indefinitely with "initializing" activity)

View file

@ -405,7 +405,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
event.status = MainApp.sResources.getString(R.string.bolusstopped); event.status = MainApp.sResources.getString(R.string.bolusstopped);
break; break;
case RECOVERING: case RECOVERING:
event.status = "Connection was interrupted. Please wait while recovery takes place."; event.status = MainApp.sResources.getString(R.string.combo_error_bolus_recovery_progress);
case FINISHED: case FINISHED:
// no state, just percent below to close bolus progress dialog // no state, just percent below to close bolus progress dialog
break; break;
@ -504,19 +504,20 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
/** /**
* If there was an error during BolusCommand the scripter try to reconnect. The pump refuses * If there was an error during BolusCommand the scripter reconnects and cleans up. The pump
* connections while a bolus delivery is still in progress (once bolus delivery started it * refuses connections while a bolus delivery is still in progress (once bolus delivery started
* continues regardless of a connection loss), retry the read history command a few * it continues regardless of a connection loss).
* times if we run into the 90s connect timeout (with 3 retries, a bolus of up to 54 U could * Then verify the bolus record we read has a date which is >= the time the bolus was requested
* be delivered until we give up).
* Then verify the bolus record we read has a date which is >= the time the bolus was requested
* (using the pump's time!). If there is such a bolus with <= the requested amount, then it's * (using the pump's time!). If there is such a bolus with <= the requested amount, then it's
* from this command and shall be added to treatments. If the bolus wasn't delivered in full * from this command and shall be added to treatments. If the bolus wasn't delivered in full,
* add it but raise a warning. Raise a warning as well if no bolus was delivered at all. * add it to treatments but raise a warning. Raise a warning as well if no bolus was delivered
* at all.
* This all still might fail for very large boluses and earthquakes in which case an error
* is raised asking to user to deal with it.
*/ */
private PumpEnactResult recoverFromErrorDuringBolusDelivery(DetailedBolusInfo detailedBolusInfo, long pumpTimeWhenBolusWasRequested) { private PumpEnactResult recoverFromErrorDuringBolusDelivery(DetailedBolusInfo detailedBolusInfo, long pumpTimeWhenBolusWasRequested) {
log.debug("Trying to determine from pump history what was actually delivered"); log.debug("Trying to determine from pump history what was actually delivered");
CommandResult readLastBolusResult = runCommand(null , 3, CommandResult readLastBolusResult = runCommand(null , 2,
() -> ruffyScripter.readHistory(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST))); () -> ruffyScripter.readHistory(new PumpHistoryRequest().bolusHistory(PumpHistoryRequest.LAST)));
if (!readLastBolusResult.success || readLastBolusResult.history == null) { if (!readLastBolusResult.success || readLastBolusResult.history == null) {
// this happens when the cartridge runs empty during delivery, the pump will be in an error // this happens when the cartridge runs empty during delivery, the pump will be in an error
@ -527,7 +528,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory; List<Bolus> bolusHistory = readLastBolusResult.history.bolusHistory;
Bolus lastBolus = !bolusHistory.isEmpty() ? bolusHistory.get(0) : null; Bolus lastBolus = !bolusHistory.isEmpty() ? bolusHistory.get(0) : null;
log.debug("Last bolus read from history: " + lastBolus + ", request time: " + pumpTimeWhenBolusWasRequested); log.debug("Last bolus read from history: " + lastBolus + ", request time: " +
pumpTimeWhenBolusWasRequested + " (" + new Date(pumpTimeWhenBolusWasRequested) + ")");
if (lastBolus == null // no bolus ever given if (lastBolus == null // no bolus ever given
|| lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for || lastBolus.timestamp < pumpTimeWhenBolusWasRequested // this is not the bolus you're looking for

View file

@ -11,6 +11,8 @@
android:id="@+id/overview_bolusprogress_status" android:id="@+id/overview_bolusprogress_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
<TextView <TextView

View file

@ -11,7 +11,8 @@
android:id="@+id/overview_error_status" android:id="@+id/overview_error_status"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="15dp" android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
<Button <Button

View file

@ -841,5 +841,6 @@
<string name="combo_error_partial_bolus_delivered">Only %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string> <string name="combo_error_partial_bolus_delivered">Only %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions.</string>
<string name="combo_activity_verifying_delivered_bolus">Verifying delivered bolus</string> <string name="combo_activity_verifying_delivered_bolus">Verifying delivered bolus</string>
<string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered.</string> <string name="combo_error_bolus_verification_failed">Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered.</string>
<string name="combo_error_bolus_recovery_progress">Recovering from connection loss</string>
</resources> </resources>

View file

@ -39,7 +39,7 @@ public class Bolus extends HistoryRecord {
@Override @Override
public String toString() { public String toString() {
return "Bolus{" + return "Bolus{" +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" + "timestamp=" + timestamp + " (" + new Date(timestamp) + ")" +
", amount=" + amount + ", amount=" + amount +
'}'; '}';
} }