Rename 'error' to 'alert' when referring to Combo pump alerts.

This commit is contained in:
Johannes Mockenhaupt 2017-11-22 00:41:28 +01:00
parent bb2e885b95
commit b4d2d9f71d
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
9 changed files with 40 additions and 47 deletions

View file

@ -84,8 +84,8 @@
- [-] Display errors in combo tab(?), nope notifications are better suited; also there's the alerts thing already - [-] 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?) - [x] Option to raise overview notifications as android notification with noise (for urgent ones?)
- [ ] Low prio - [ ] Low prio
- [ ] Naming is messed up: pump has warnings and errors, which cause alerts; W+E are thus alerts, - [x] 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 e.g. pumpAlertHistory should be renamed to alertHistory
- [ ] Enable BT if disabled? does dana does this? - [ ] Enable BT if disabled? does dana does this?
- [ ] Finish and test German translation - [ ] Finish and test German translation
- [ ] No clean startup/shutdown; RuffyScripter is instanciated once, idle disconnect thread never killed - [ ] No clean startup/shutdown; RuffyScripter is instanciated once, idle disconnect thread never killed

View file

@ -7,29 +7,26 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.List; import java.util.List;
import de.jotomo.ruffy.spi.history.PumpError; import de.jotomo.ruffy.spi.history.PumpAlert;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
public class ComboErrorHistoryDialog extends DialogFragment { public class ComboAlertHistoryDialog extends DialogFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.combo_error_history_fragment, container, false); View layout = inflater.inflate(R.layout.combo_error_history_fragment, container, false);
TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text); TextView text = (TextView) layout.findViewById(R.id.combo_error_history_text);
List<PumpError> errors = ComboPlugin.getPlugin().getPump().errorHistory; List<PumpAlert> errors = ComboPlugin.getPlugin().getPump().errorHistory;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// TODO i18n // TODO i18n
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM. HH:mm"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd.MM. HH:mm");
if (errors.isEmpty()) { 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 { } else {
boolean first = true; boolean first = true;
for (PumpError error : errors) { for (PumpAlert error : errors) {
if (first) { if (first) {
first = false; first = false;
} else { } else {

View file

@ -62,8 +62,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis
new Thread(() -> ComboPlugin.getPlugin().refreshDataFromPump("User request")).start(); new Thread(() -> ComboPlugin.getPlugin().refreshDataFromPump("User request")).start();
break; break;
case R.id.combo_error_history: case R.id.combo_error_history:
ComboErrorHistoryDialog ehd = new ComboErrorHistoryDialog(); ComboAlertHistoryDialog ehd = new ComboAlertHistoryDialog();
ehd.show(getFragmentManager(), ComboErrorHistoryDialog.class.getSimpleName()); ehd.show(getFragmentManager(), ComboAlertHistoryDialog.class.getSimpleName());
break; break;
case R.id.combo_tdd_history: case R.id.combo_tdd_history:
ComboTddHistoryDialog thd = new ComboTddHistoryDialog(); ComboTddHistoryDialog thd = new ComboTddHistoryDialog();

View file

@ -12,18 +12,15 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.BolusProgressReporter; import de.jotomo.ruffy.spi.BolusProgressReporter;
import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.PumpWarningCodes; import de.jotomo.ruffy.spi.PumpWarningCodes;
import de.jotomo.ruffy.spi.RuffyCommands; import de.jotomo.ruffy.spi.RuffyCommands;
import de.jotomo.ruffy.spi.history.Bolus; 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.PumpHistory;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
import de.jotomo.ruffy.spi.history.Tbr; import de.jotomo.ruffy.spi.history.Tbr;
import de.jotomo.ruffy.spi.history.Tdd;
import de.jotomo.ruffy.spi.history.WarningOrErrorCode; import de.jotomo.ruffy.spi.history.WarningOrErrorCode;
import de.jotomo.ruffyscripter.RuffyCommandsV1Impl; import de.jotomo.ruffyscripter.RuffyCommandsV1Impl;
import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.BuildConfig;
@ -877,8 +874,8 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pump.lastHistoryTbrTime = history.tbrHistory.get(0).timestamp; pump.lastHistoryTbrTime = history.tbrHistory.get(0).timestamp;
} }
if (!history.pumpErrorHistory.isEmpty()) { if (!history.pumpAlertHistory.isEmpty()) {
pump.errorHistory = history.pumpErrorHistory; pump.errorHistory = history.pumpAlertHistory;
} }
if (!history.tddHistory.isEmpty()) { if (!history.tddHistory.isEmpty()) {
pump.tddHistory = history.tddHistory; pump.tddHistory = history.tddHistory;

View file

@ -10,8 +10,7 @@ import de.jotomo.ruffy.spi.BasalProfile;
import de.jotomo.ruffy.spi.CommandResult; import de.jotomo.ruffy.spi.CommandResult;
import de.jotomo.ruffy.spi.PumpState; import de.jotomo.ruffy.spi.PumpState;
import de.jotomo.ruffy.spi.history.Bolus; 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.PumpHistoryRequest;
import de.jotomo.ruffy.spi.history.Tdd; import de.jotomo.ruffy.spi.history.Tdd;
@ -37,6 +36,6 @@ class ComboPump {
long lastHistoryTbrTime = PumpHistoryRequest.FULL; long lastHistoryTbrTime = PumpHistoryRequest.FULL;
// Alert and TDD histories are not stored in DB, but are read on demand and just cached here // Alert and TDD histories are not stored in DB, but are read on demand and just cached here
List<PumpError> errorHistory = new ArrayList<>(0); List<PumpAlert> errorHistory = new ArrayList<>(0);
List<Tdd> tddHistory = new ArrayList<>(0); List<Tdd> tddHistory = new ArrayList<>(0);
} }

View file

@ -2,13 +2,13 @@ package de.jotomo.ruffy.spi.history;
import java.util.Date; import java.util.Date;
public class PumpError extends HistoryRecord { public class PumpAlert extends HistoryRecord {
public final Integer warningCode; public final Integer warningCode;
public final Integer errorCode; public final Integer errorCode;
/** Error message, in the language configured on the pump. */ /** Error message, in the language configured on the pump. */
public final String message; 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); super(timestamp);
this.warningCode = warningCode; this.warningCode = warningCode;
this.errorCode = errorCode; this.errorCode = errorCode;
@ -20,14 +20,14 @@ public class PumpError extends HistoryRecord {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
PumpError pumpError = (PumpError) o; PumpAlert pumpAlert = (PumpAlert) o;
if (timestamp != pumpError.timestamp) return false; if (timestamp != pumpAlert.timestamp) return false;
if (warningCode != null ? !warningCode.equals(pumpError.warningCode) : pumpError.warningCode != null) if (warningCode != null ? !warningCode.equals(pumpAlert.warningCode) : pumpAlert.warningCode != null)
return false; 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 false;
return message != null ? message.equals(pumpError.message) : pumpError.message == null; return message != null ? message.equals(pumpAlert.message) : pumpAlert.message == null;
} }
@Override @Override
@ -41,7 +41,7 @@ public class PumpError extends HistoryRecord {
@Override @Override
public String toString() { public String toString() {
return "PumpError{" + return "PumpAlert{" +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" + "timestamp=" + timestamp + "(" + new Date(timestamp) + ")" +
", warningCode=" + warningCode + ", warningCode=" + warningCode +
", errorCode=" + errorCode + ", errorCode=" + errorCode +

View file

@ -14,7 +14,7 @@ public class PumpHistory {
@NonNull @NonNull
public List<Tbr> tbrHistory = new ArrayList<>(); public List<Tbr> tbrHistory = new ArrayList<>();
@NonNull @NonNull
public List<PumpError> pumpErrorHistory = new LinkedList<>(); public List<PumpAlert> pumpAlertHistory = new LinkedList<>();
@NonNull @NonNull
public List<Tdd> tddHistory = new ArrayList<>(); public List<Tdd> tddHistory = new ArrayList<>();
@ -28,8 +28,8 @@ public class PumpHistory {
return this; return this;
} }
public PumpHistory pumpErrorHistory(List<PumpError> pumpErrorHistory) { public PumpHistory pumpErrorHistory(List<PumpAlert> pumpAlertHistory) {
this.pumpErrorHistory = pumpErrorHistory; this.pumpAlertHistory = pumpAlertHistory;
return this; return this;
} }
@ -43,7 +43,7 @@ public class PumpHistory {
return "PumpHistory{" + return "PumpHistory{" +
"bolusHistory=" + bolusHistory.size() + "bolusHistory=" + bolusHistory.size() +
", tbrHistory=" + tbrHistory.size() + ", tbrHistory=" + tbrHistory.size() +
", pumpErrorHistory=" + pumpErrorHistory.size() + ", pumpAlertHistory=" + pumpAlertHistory.size() +
", tddHistory=" + tddHistory.size() + ", tddHistory=" + tddHistory.size() +
'}'; '}';
} }

View file

@ -42,7 +42,7 @@ public class PumpHistoryRequest {
return "PumpHistoryRequest{" + return "PumpHistoryRequest{" +
"bolusHistory=" + bolusHistory + (bolusHistory > 0 ? ("(" + new Date(bolusHistory) + ")") : "") + "bolusHistory=" + bolusHistory + (bolusHistory > 0 ? ("(" + new Date(bolusHistory) + ")") : "") +
", tbrHistory=" + tbrHistory + (tbrHistory > 0 ? ("(" + new Date(tbrHistory) + ")") : "") + ", 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) + ")") : "") + ", tddHistory=" + tddHistory + (tddHistory > 0 ? ("(" + new Date(tddHistory) + ")") : "") +
'}'; '}';
} }

View file

@ -14,7 +14,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import de.jotomo.ruffy.spi.history.Bolus; 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.PumpHistory;
import de.jotomo.ruffy.spi.history.PumpHistoryRequest; import de.jotomo.ruffy.spi.history.PumpHistoryRequest;
import de.jotomo.ruffy.spi.history.Tbr; 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); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
if (totalRecords > 0) { if (totalRecords > 0) {
if (request.pumpErrorHistory == PumpHistoryRequest.LAST) { if (request.pumpErrorHistory == PumpHistoryRequest.LAST) {
PumpError error = readErrorRecord(); PumpAlert error = readAlertRecord();
history.pumpErrorHistory.add(error); history.pumpAlertHistory.add(error);
} else { } else {
readErrorRecords(request.pumpErrorHistory); readAlertRecords(request.pumpErrorHistory);
} }
} }
} }
@ -107,10 +107,10 @@ public class ReadHistoryCommand extends BaseCommand {
log.debug(new Date(bolus.timestamp) + ": " + bolus.toString()); log.debug(new Date(bolus.timestamp) + ": " + bolus.toString());
} }
} }
if (!history.pumpErrorHistory.isEmpty()) { if (!history.pumpAlertHistory.isEmpty()) {
log.debug("Read error history (" + history.pumpErrorHistory.size() + "):"); log.debug("Read error history (" + history.pumpAlertHistory.size() + "):");
for (PumpError pumpError : history.pumpErrorHistory) { for (PumpAlert pumpAlert : history.pumpAlertHistory) {
log.debug(new Date(pumpError.timestamp) + ": " + pumpError.toString()); log.debug(new Date(pumpAlert.timestamp) + ": " + pumpAlert.toString());
} }
} }
if (!history.tddHistory.isEmpty()) { if (!history.tddHistory.isEmpty()) {
@ -230,16 +230,16 @@ public class ReadHistoryCommand extends BaseCommand {
return new Bolus(recordDate, bolus, isValid); 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 record = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.CURRENT_RECORD);
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD); int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
while (true) { while (true) {
PumpError error = readErrorRecord(); PumpAlert error = readAlertRecord();
if (requestedTime != PumpHistoryRequest.FULL && error.timestamp <= requestedTime) { if (requestedTime != PumpHistoryRequest.FULL && error.timestamp <= requestedTime) {
break; break;
} }
log.debug("Read error record #" + record + "/" + totalRecords); log.debug("Read alert record #" + record + "/" + totalRecords);
history.pumpErrorHistory.add(error); history.pumpAlertHistory.add(error);
log.debug("Parsed " + scripter.getCurrentMenu().toString() + " => " + error); log.debug("Parsed " + scripter.getCurrentMenu().toString() + " => " + error);
if (record == totalRecords) { if (record == totalRecords) {
break; break;
@ -251,14 +251,14 @@ public class ReadHistoryCommand extends BaseCommand {
} }
@NonNull @NonNull
private PumpError readErrorRecord() { private PumpAlert readAlertRecord() {
scripter.verifyMenuIsDisplayed(MenuType.ERROR_DATA); scripter.verifyMenuIsDisplayed(MenuType.ERROR_DATA);
Integer warningCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.WARNING); Integer warningCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.WARNING);
Integer errorCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.ERROR); Integer errorCode = (Integer) scripter.getCurrentMenu().getAttribute(MenuAttribute.ERROR);
String message = (String) scripter.getCurrentMenu().getAttribute(MenuAttribute.MESSAGE); String message = (String) scripter.getCurrentMenu().getAttribute(MenuAttribute.MESSAGE);
long recordDate = readRecordDate(); long recordDate = readRecordDate();
return new PumpError(recordDate, warningCode, errorCode, message); return new PumpAlert(recordDate, warningCode, errorCode, message);
} }
private long readRecordDate() { private long readRecordDate() {