From 063a5ba6b9197ca2f6850c6e006dfc0873c3e5ff Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Fri, 8 Dec 2017 12:04:24 +0100 Subject: [PATCH] Only read Tdd and Alerts through buttons on Combo tab, not treatment history. --- .../PumpCombo/ComboAlertHistoryDialog.java | 2 +- .../plugins/PumpCombo/ComboFragment.java | 5 ++- .../plugins/PumpCombo/ComboPlugin.java | 34 ++++--------------- .../PumpCombo/ComboTddHistoryDialog.java | 2 +- app/src/main/res/values/strings.xml | 3 +- 5 files changed, 14 insertions(+), 32 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java index a0912a5064..9b4b2f98d8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java @@ -20,7 +20,7 @@ public class ComboAlertHistoryDialog extends DialogFragment { TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text); List errors = ComboPlugin.getPlugin().getPump().errorHistory; if (errors.isEmpty()) { - text.setText(R.string.combo_empty_history_note); + text.setText(R.string.combo_no_alert_data_note); } else { StringBuilder sb = new StringBuilder(); DateFormat dateTimeFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); 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 4ca48f53bf..fe4dce770a 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 @@ -84,8 +84,11 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis @Override public boolean onLongClick(View view) { switch (view.getId()) { + case R.id.combo_error_history: + new Thread(() -> ComboPlugin.getPlugin().readAlertData()).start(); + return true; case R.id.combo_tdd_history: - new Thread(() -> ComboPlugin.getPlugin().readAllPumpData()).start(); + new Thread(() -> ComboPlugin.getPlugin().readTddData()).start(); return true; } return false; 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 a60837b6e3..29a7987f4c 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 @@ -96,7 +96,6 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf private volatile boolean bolusInProgress; private volatile boolean cancelBolus; private Bolus lastRequestedBolus; - private long pumpHistoryLastChecked; public static ComboPlugin getPlugin() { if (plugin == null) @@ -869,34 +868,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } } - void readAllPumpData() { - long lastCheckInitiated = System.currentTimeMillis(); + void readTddData() { + readHistory(new PumpHistoryRequest().tddHistory(PumpHistoryRequest.FULL)); + } - boolean readHistorySuccess = readHistory(new PumpHistoryRequest() - .bolusHistory(pumpHistoryLastChecked) - .tbrHistory(pumpHistoryLastChecked) - .pumpErrorHistory(PumpHistoryRequest.FULL) - .tddHistory(PumpHistoryRequest.FULL)); - if (!readHistorySuccess) { - return; - } - - pumpHistoryLastChecked = lastCheckInitiated; - -/* not displayed in the UI anymore due to pump bug - CommandResult reservoirResult = runCommand("Checking reservoir level", 2, - ruffyScripter::readReservoirLevelAndLastBolus); - if (!reservoirResult.success) { - return; - } -*/ - - CommandResult basalResult = runCommand("Reading basal profile", 2, ruffyScripter::readBasalProfile); - if (!basalResult.success) { - return; - } - - pump.basalProfile = basalResult.basalProfile; + void readAlertData() { + readHistory(new PumpHistoryRequest() + .pumpErrorHistory(PumpHistoryRequest.FULL)); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboTddHistoryDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboTddHistoryDialog.java index 6f4e785776..71ab8f2515 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboTddHistoryDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboTddHistoryDialog.java @@ -21,7 +21,7 @@ public class ComboTddHistoryDialog extends DialogFragment { TextView text = (TextView) layout.findViewById(R.id.combo_tdd_history_text); List tdds = ComboPlugin.getPlugin().getPump().tddHistory; if (tdds.isEmpty()) { - text.setText(R.string.combo_empty_history_note); + text.setText(R.string.combo_no_tdd_data_note); } else { StringBuilder sb = new StringBuilder(); DateFormat dateFormatter = DateFormat.getDateInstance(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 97716e60a1..07987a5332 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -822,7 +822,8 @@ Pump cartridge level is low Pump battery is low Pump is in an error state, please check the pump - To read all data from the pump, long press the TDDS button. Besides alerts and TDDs, this will read boluses and TBRs from the pump and update the treatments accordingly.\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided. + To read the pump\'s error history, long press the ALERTS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided. + To read the pump\'s TDD history, long press the TDDS button\n\nWARNING: this can trigger a bug which causes the pump to reject all connection attempts and requires pressing a button on the pump to recover and should therefore be avoided. sync_profile_to_pump Minimum: %3.1f U Average: %3.1f U