From b4d2d9f71dc28b6e54ce9a1f48d1ddff8c84ab18 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 22 Nov 2017 00:41:28 +0100 Subject: [PATCH] Rename 'error' to 'alert' when referring to Combo pump alerts. --- TODO-Combo.md | 4 +-- ...alog.java => ComboAlertHistoryDialog.java} | 13 ++++----- .../plugins/PumpCombo/ComboFragment.java | 4 +-- .../plugins/PumpCombo/ComboPlugin.java | 7 ++--- .../plugins/PumpCombo/ComboPump.java | 5 ++-- .../{PumpError.java => PumpAlert.java} | 16 +++++------ .../jotomo/ruffy/spi/history/PumpHistory.java | 8 +++--- .../ruffy/spi/history/PumpHistoryRequest.java | 2 +- .../commands/ReadHistoryCommand.java | 28 +++++++++---------- 9 files changed, 40 insertions(+), 47 deletions(-) rename app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/{ComboErrorHistoryDialog.java => ComboAlertHistoryDialog.java} (83%) rename ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/{PumpError.java => PumpAlert.java} (69%) diff --git a/TODO-Combo.md b/TODO-Combo.md index 063138d1ea..38a0d8cc65 100644 --- a/TODO-Combo.md +++ b/TODO-Combo.md @@ -84,8 +84,8 @@ - [-] Display errors in combo tab(?), nope notifications are better suited; also there's the alerts thing already - [x] Option to raise overview notifications as android notification with noise (for urgent ones?) - [ ] Low prio - - [ ] Naming is messed up: pump has warnings and errors, which cause alerts; W+E are thus alerts, - e.g. pumpErrorHistory should be renamed to alertHistory + - [x] Naming is messed up: pump has warnings and errors, which cause alerts; W+E are thus alerts, + e.g. pumpAlertHistory should be renamed to alertHistory - [ ] Enable BT if disabled? does dana does this? - [ ] Finish and test German translation - [ ] No clean startup/shutdown; RuffyScripter is instanciated once, idle disconnect thread never killed diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboErrorHistoryDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java similarity index 83% rename from app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboErrorHistoryDialog.java rename to app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java index 051e70d9c4..9fda099190 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboErrorHistoryDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboAlertHistoryDialog.java @@ -7,29 +7,26 @@ import android.view.View; import android.view.ViewGroup; import android.widget.TextView; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.SimpleDateFormat; import java.util.List; -import de.jotomo.ruffy.spi.history.PumpError; +import de.jotomo.ruffy.spi.history.PumpAlert; import info.nightscout.androidaps.R; -public class ComboErrorHistoryDialog extends DialogFragment { +public class ComboAlertHistoryDialog extends DialogFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.combo_error_history_fragment, container, false); TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text); - List errors = ComboPlugin.getPlugin().getPump().errorHistory; + List errors = ComboPlugin.getPlugin().getPump().errorHistory; StringBuilder sb = new StringBuilder(); // TODO i18n SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM. HH:mm"); if (errors.isEmpty()) { - text.setText("To retrieve the error history from the pump, long press the Refresh button."); + text.setText("To retrieve the alert history from the pump, long press the Refresh button."); } else { boolean first = true; - for (PumpError error : errors) { + for (PumpAlert error : errors) { if (first) { first = false; } else { 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 fd330b96a0..647bbf6515 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 @@ -62,8 +62,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis new Thread(() -> ComboPlugin.getPlugin().refreshDataFromPump("User request")).start(); break; case R.id.combo_error_history: - ComboErrorHistoryDialog ehd = new ComboErrorHistoryDialog(); - ehd.show(getFragmentManager(), ComboErrorHistoryDialog.class.getSimpleName()); + ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog(); + ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName()); break; case R.id.combo_tdd_history: ComboTddHistoryDialog thd = new ComboTddHistoryDialog(); 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 2f5b0ab867..f79d66fe0f 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 @@ -12,18 +12,15 @@ import java.util.Date; import java.util.List; import java.util.Objects; -import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffy.spi.BolusProgressReporter; import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffy.spi.RuffyCommands; import de.jotomo.ruffy.spi.history.Bolus; -import de.jotomo.ruffy.spi.history.PumpError; import de.jotomo.ruffy.spi.history.PumpHistory; import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffy.spi.history.Tbr; -import de.jotomo.ruffy.spi.history.Tdd; import de.jotomo.ruffy.spi.history.WarningOrErrorCode; import de.jotomo.ruffyscripter.RuffyCommandsV1Impl; import info.nightscout.androidaps.BuildConfig; @@ -877,8 +874,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf pump.lastHistoryTbrTime = history.tbrHistory.get(0).timestamp; } - if (!history.pumpErrorHistory.isEmpty()) { - pump.errorHistory = history.pumpErrorHistory; + if (!history.pumpAlertHistory.isEmpty()) { + pump.errorHistory = history.pumpAlertHistory; } if (!history.tddHistory.isEmpty()) { pump.tddHistory = history.tddHistory; 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 fd23cdd49d..f1054f0f8e 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 @@ -10,8 +10,7 @@ import de.jotomo.ruffy.spi.BasalProfile; import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffy.spi.history.Bolus; -import de.jotomo.ruffy.spi.history.PumpError; -import de.jotomo.ruffy.spi.history.PumpHistory; +import de.jotomo.ruffy.spi.history.PumpAlert; import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffy.spi.history.Tdd; @@ -37,6 +36,6 @@ class ComboPump { long lastHistoryTbrTime = PumpHistoryRequest.FULL; // Alert and TDD histories are not stored in DB, but are read on demand and just cached here - List errorHistory = new ArrayList<>(0); + List errorHistory = new ArrayList<>(0); List tddHistory = new ArrayList<>(0); } diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpError.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpAlert.java similarity index 69% rename from ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpError.java rename to ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpAlert.java index da2e3453c9..39ff2df69c 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpError.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpAlert.java @@ -2,13 +2,13 @@ package de.jotomo.ruffy.spi.history; import java.util.Date; -public class PumpError extends HistoryRecord { +public class PumpAlert extends HistoryRecord { public final Integer warningCode; public final Integer errorCode; /** Error message, in the language configured on the pump. */ public final String message; - public PumpError(long timestamp, Integer warningCode, Integer errorCode, String message) { + public PumpAlert(long timestamp, Integer warningCode, Integer errorCode, String message) { super(timestamp); this.warningCode = warningCode; this.errorCode = errorCode; @@ -20,14 +20,14 @@ public class PumpError extends HistoryRecord { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - PumpError pumpError = (PumpError) o; + PumpAlert pumpAlert = (PumpAlert) o; - if (timestamp != pumpError.timestamp) return false; - if (warningCode != null ? !warningCode.equals(pumpError.warningCode) : pumpError.warningCode != null) + if (timestamp != pumpAlert.timestamp) return false; + if (warningCode != null ? !warningCode.equals(pumpAlert.warningCode) : pumpAlert.warningCode != null) return false; - if (errorCode != null ? !errorCode.equals(pumpError.errorCode) : pumpError.errorCode != null) + if (errorCode != null ? !errorCode.equals(pumpAlert.errorCode) : pumpAlert.errorCode != null) return false; - return message != null ? message.equals(pumpError.message) : pumpError.message == null; + return message != null ? message.equals(pumpAlert.message) : pumpAlert.message == null; } @Override @@ -41,7 +41,7 @@ public class PumpError extends HistoryRecord { @Override public String toString() { - return "PumpError{" + + return "PumpAlert{" + "timestamp=" + timestamp + "(" + new Date(timestamp) + ")" + ", warningCode=" + warningCode + ", errorCode=" + errorCode + diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistory.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistory.java index 6b2a17676a..4c7a7a5d47 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistory.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistory.java @@ -14,7 +14,7 @@ public class PumpHistory { @NonNull public List tbrHistory = new ArrayList<>(); @NonNull - public List pumpErrorHistory = new LinkedList<>(); + public List pumpAlertHistory = new LinkedList<>(); @NonNull public List tddHistory = new ArrayList<>(); @@ -28,8 +28,8 @@ public class PumpHistory { return this; } - public PumpHistory pumpErrorHistory(List pumpErrorHistory) { - this.pumpErrorHistory = pumpErrorHistory; + public PumpHistory pumpErrorHistory(List pumpAlertHistory) { + this.pumpAlertHistory = pumpAlertHistory; return this; } @@ -43,7 +43,7 @@ public class PumpHistory { return "PumpHistory{" + "bolusHistory=" + bolusHistory.size() + ", tbrHistory=" + tbrHistory.size() + - ", pumpErrorHistory=" + pumpErrorHistory.size() + + ", pumpAlertHistory=" + pumpAlertHistory.size() + ", tddHistory=" + tddHistory.size() + '}'; } diff --git a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistoryRequest.java b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistoryRequest.java index 9478cdb399..9d89241399 100644 --- a/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistoryRequest.java +++ b/ruffy-spi/src/main/java/de/jotomo/ruffy/spi/history/PumpHistoryRequest.java @@ -42,7 +42,7 @@ public class PumpHistoryRequest { return "PumpHistoryRequest{" + "bolusHistory=" + bolusHistory + (bolusHistory > 0 ? ("(" + new Date(bolusHistory) + ")") : "") + ", tbrHistory=" + tbrHistory + (tbrHistory > 0 ? ("(" + new Date(tbrHistory) + ")") : "") + - ", pumpErrorHistory=" + pumpErrorHistory + (pumpErrorHistory > 0 ? ("(" + new Date(pumpErrorHistory) + ")") : "") + + ", pumpAlertHistory=" + pumpErrorHistory + (pumpErrorHistory > 0 ? ("(" + new Date(pumpErrorHistory) + ")") : "") + ", tddHistory=" + tddHistory + (tddHistory > 0 ? ("(" + new Date(tddHistory) + ")") : "") + '}'; } diff --git a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java index be01b78e60..81da3738d7 100644 --- a/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java +++ b/ruffyscripter/src/main/java/de/jotomo/ruffyscripter/commands/ReadHistoryCommand.java @@ -14,7 +14,7 @@ import java.util.Calendar; import java.util.Date; import de.jotomo.ruffy.spi.history.Bolus; -import de.jotomo.ruffy.spi.history.PumpError; +import de.jotomo.ruffy.spi.history.PumpAlert; import de.jotomo.ruffy.spi.history.PumpHistory; import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffy.spi.history.Tbr; @@ -62,10 +62,10 @@ public class ReadHistoryCommand extends BaseCommand { int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); if (totalRecords > 0) { if (request.pumpErrorHistory == PumpHistoryRequest.LAST) { - PumpError error = readErrorRecord(); - history.pumpErrorHistory.add(error); + PumpAlert error = readAlertRecord(); + history.pumpAlertHistory.add(error); } else { - readErrorRecords(request.pumpErrorHistory); + readAlertRecords(request.pumpErrorHistory); } } } @@ -107,10 +107,10 @@ public class ReadHistoryCommand extends BaseCommand { log.debug(new Date(bolus.timestamp) + ": " + bolus.toString()); } } - if (!history.pumpErrorHistory.isEmpty()) { - log.debug("Read error history (" + history.pumpErrorHistory.size() + "):"); - for (PumpError pumpError : history.pumpErrorHistory) { - log.debug(new Date(pumpError.timestamp) + ": " + pumpError.toString()); + if (!history.pumpAlertHistory.isEmpty()) { + log.debug("Read error history (" + history.pumpAlertHistory.size() + "):"); + for (PumpAlert pumpAlert : history.pumpAlertHistory) { + log.debug(new Date(pumpAlert.timestamp) + ": " + pumpAlert.toString()); } } if (!history.tddHistory.isEmpty()) { @@ -230,16 +230,16 @@ public class ReadHistoryCommand extends BaseCommand { return new Bolus(recordDate, bolus, isValid); } - private void readErrorRecords(long requestedTime) { + private void readAlertRecords(long requestedTime) { int record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); while (true) { - PumpError error = readErrorRecord(); + PumpAlert error = readAlertRecord(); if (requestedTime != PumpHistoryRequest.FULL && error.timestamp <= requestedTime) { break; } - log.debug("Read error record #" + record + "/" + totalRecords); - history.pumpErrorHistory.add(error); + log.debug("Read alert record #" + record + "/" + totalRecords); + history.pumpAlertHistory.add(error); log.debug("Parsed " + scripter.getCurrentMenu().toString() + " => " + error); if (record == totalRecords) { break; @@ -251,14 +251,14 @@ public class ReadHistoryCommand extends BaseCommand { } @NonNull - private PumpError readErrorRecord() { + private PumpAlert readAlertRecord() { scripter.verifyMenuIsDisplayed(MenuType.ERROR_DATA); Integer warningCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.WARNING); Integer errorCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.ERROR); String message = (String) scripter.getCurrentMenu().getAttribute(MenuAttribute.MESSAGE); long recordDate = readRecordDate(); - return new PumpError(recordDate, warningCode, errorCode, message); + return new PumpAlert(recordDate, warningCode, errorCode, message); } private long readRecordDate() {