From b4998feee11d63418ed1ce288eed7a820529e723 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 10 Jan 2018 15:04:38 +0100 Subject: [PATCH] Disable reading reservoir level units. --- .../plugins/PumpCombo/ComboFragment.java | 6 ++--- .../plugins/PumpCombo/ComboPlugin.java | 22 +++++++------------ .../plugins/PumpCombo/ComboPump.java | 1 - app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 7b72ee5d04..506bce7be5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -172,17 +172,17 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis } // reservoir - int reservoirLevel = plugin.getPump().reservoirLevel; - reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " " - + MainApp.sResources.getString(R.string.treatments_wizard_unit_label)); if (ps.insulinState == PumpState.LOW) { reservoirView.setTextColor(Color.YELLOW); + reservoirView.setText(R.string.combo_reservoir_low); reservoirView.setTypeface(null, Typeface.BOLD); } else if (ps.insulinState == PumpState.EMPTY) { reservoirView.setTextColor(Color.RED); + reservoirView.setText(R.string.combo_reservoir_empty); reservoirView.setTypeface(null, Typeface.BOLD); } else { reservoirView.setTextColor(Color.WHITE); + reservoirView.setText(R.string.combo_reservoir_normal); reservoirView.setTypeface(null, Typeface.NORMAL); } 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 93b2e0af8c..bc27a3ebbc 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 @@ -339,7 +339,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf if (!pump.initialized) { initializePump(); } else { - runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readReservoirLevelAndLastBolus); + runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readPumpState); } } @@ -379,13 +379,10 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf MainApp.bus().post(new EventInitializationChanged()); // ComboFragment updates state fully only after the pump has initialized, so run this manually here - updateLocalData(runCommand(null, 1, ruffyScripter::readReservoirLevelAndLastBolus)); + updateLocalData(readBasalResult); } private void updateLocalData(CommandResult result) { - if (result.reservoirLevel != PumpState.UNKNOWN) { - pump.reservoirLevel = result.reservoirLevel; - } if (result.state.menu != null) { pump.state = result.state; } @@ -470,18 +467,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true); - CommandResult stateResult = runCommand(null, 1, ruffyScripter::readReservoirLevelAndLastBolus); + CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState); long pumpTimeWhenBolusWasRequested = stateResult .state.pumpTime; if (!stateResult.success || pumpTimeWhenBolusWasRequested == 0) { return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered)); } - if (stateResult.reservoirLevel < detailedBolusInfo.insulin) { - return new PumpEnactResult().success(false).enacted(false) - .comment(MainApp.sResources.getString(R.string.combo_reservoir_level_insufficient_for_bolus)); - } - try { pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin); MainApp.bus().post(new EventComboPumpUpdateGUI()); @@ -1034,9 +1026,11 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf try { JSONObject pumpJson = new JSONObject(); pumpJson.put("clock", DateUtil.toISOString(pump.lastSuccessfulCmdTime)); - if (pump.reservoirLevel != -1) { - pumpJson.put("reservoir", pump.reservoirLevel); - } + + int level = 150; + if (pump.state.insulinState == PumpState.LOW) level = 8; + else if (pump.state.insulinState == PumpState.EMPTY) level = 0; + pumpJson.put("reservoir", level); JSONObject statusJson = new JSONObject(); statusJson.put("status", getStateSummary()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java index 0455fa3ada..5980cf11eb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java @@ -17,7 +17,6 @@ class ComboPump { public volatile String activity; @NonNull volatile PumpState state = new PumpState(); - volatile int reservoirLevel = -1; @NonNull volatile BasalProfile basalProfile = new BasalProfile(); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 9438e06d19..8edea19afe 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -778,5 +778,4 @@ Standarwert: 2\nBolus snooze (\"Bolus-Schlummer\") bremst den Loop nach einem Mahleiten-Bolus, damit dieser nicht mit niedrigen TBR reagiert, wenn Du gerade gegessen hast. Beispiel: Der Standardwert 2 bewirkt, dass bei einem 3 Stunden DIA der Bolus snooze während 1.5 Stunden nach dem Bolus linear ausläuft (3 h Dia / 2 = 1.5 h Bolus snooze). Standardwert: 3.0\nDies ist eine Einstellung für die Standard-Kohlenhydrat-Absorptionswirkung pro 5 Minuten. Der Standardwert ist 3mg/dl/5min. Dies wirkt sich darauf aus, wie schnell der COB-Wert fällt und wieviel KH-Absorption bei der Berechnung des vorhergesagten BZ angenommen wird, wenn der BZ stärker als erwartet fällt oder nicht so stark wie erwartet steigt. Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast. - Nicht mehr genug Insulin im Reservoir für den Bolus diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5cfb588165..100d35e2d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -865,6 +865,5 @@ 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. 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. Recovering from connection loss - Not enough insulin left in reservoir for bolus