Rename 'error' to 'alert' when referring to Combo pump alerts.
This commit is contained in:
parent
bb2e885b95
commit
b4d2d9f71d
|
@ -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
|
||||
|
|
|
@ -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<PumpError> errors = ComboPlugin.getPlugin().getPump().errorHistory;
|
||||
List<PumpAlert> 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 {
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<PumpError> errorHistory = new ArrayList<>(0);
|
||||
List<PumpAlert> errorHistory = new ArrayList<>(0);
|
||||
List<Tdd> tddHistory = new ArrayList<>(0);
|
||||
}
|
||||
|
|
|
@ -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 +
|
|
@ -14,7 +14,7 @@ public class PumpHistory {
|
|||
@NonNull
|
||||
public List<Tbr> tbrHistory = new ArrayList<>();
|
||||
@NonNull
|
||||
public List<PumpError> pumpErrorHistory = new LinkedList<>();
|
||||
public List<PumpAlert> pumpAlertHistory = new LinkedList<>();
|
||||
@NonNull
|
||||
public List<Tdd> tddHistory = new ArrayList<>();
|
||||
|
||||
|
@ -28,8 +28,8 @@ public class PumpHistory {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PumpHistory pumpErrorHistory(List<PumpError> pumpErrorHistory) {
|
||||
this.pumpErrorHistory = pumpErrorHistory;
|
||||
public PumpHistory pumpErrorHistory(List<PumpAlert> 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() +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -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) + ")") : "") +
|
||||
'}';
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue