toString, equals.

This commit is contained in:
Johannes Mockenhaupt 2017-11-12 17:08:18 +01:00
parent 7b7bc6efb6
commit f2bfc73b88
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
7 changed files with 23 additions and 13 deletions

View file

@ -65,7 +65,7 @@ public class CommandResult {
@Override
public String toString() {
return "CommandResult{" +
", success=" + success +
"success=" + success +
", exception=" + exception +
", state=" + state +
", history=" + history +

View file

@ -1,5 +1,7 @@
package de.jotomo.ruffy.spi.history;
import java.util.Date;
public class Bolus extends HistoryRecord {
public final double amount;
public final boolean isValid;
@ -20,7 +22,7 @@ public class Bolus extends HistoryRecord {
if (timestamp != bolus.timestamp) return false;
if (isValid != bolus.isValid) return false;
return Double.compare(bolus.amount, amount) == 0;
return Math.abs(bolus.amount - amount) <= 0.05;
}
@Override
@ -37,7 +39,7 @@ public class Bolus extends HistoryRecord {
@Override
public String toString() {
return "Bolus{" +
"timestamp=" + timestamp +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" +
", amount=" + amount +
'}';
}

View file

@ -1,5 +1,7 @@
package de.jotomo.ruffy.spi.history;
import java.util.Date;
public class PumpError extends HistoryRecord {
public final Integer warningCode;
public final Integer errorCode;
@ -40,7 +42,7 @@ public class PumpError extends HistoryRecord {
@Override
public String toString() {
return "PumpError{" +
"timestamp=" + timestamp +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" +
", warningCode=" + warningCode +
", errorCode=" + errorCode +
", message='" + message + '\'' +

View file

@ -41,7 +41,7 @@ public class PumpHistory {
@Override
public String toString() {
return "PumpHistory{" +
", bolusHistory=" + bolusHistory.size() +
"bolusHistory=" + bolusHistory.size() +
", tbrHistory=" + tbrHistory.size() +
", pumpErrorHistory=" + pumpErrorHistory.size() +
", tddHistory=" + tddHistory.size() +

View file

@ -1,5 +1,7 @@
package de.jotomo.ruffy.spi.history;
import java.util.Date;
/** What data a 'read history' request should return. */
public class PumpHistoryRequest {
/* History to read:
@ -38,10 +40,10 @@ public class PumpHistoryRequest {
@Override
public String toString() {
return "PumpHistoryRequest{" +
", bolusHistory=" + bolusHistory +
", tbrHistory=" + tbrHistory +
", pumpErrorHistory=" + pumpErrorHistory +
", tddHistory=" + tddHistory +
"bolusHistory=" + bolusHistory + (bolusHistory > 0 ? ("(" + new Date(bolusHistory) + ")") : "") +
", tbrHistory=" + tbrHistory + (tbrHistory > 0 ? ("(" + new Date(tbrHistory) + ")") : "") +
", pumpErrorHistory=" + pumpErrorHistory + (pumpErrorHistory > 0 ? ("(" + new Date(pumpErrorHistory) + ")") : "") +
", tddHistory=" + tddHistory + (tddHistory > 0 ? ("(" + new Date(tddHistory) + ")") : "") +
'}';
}
}

View file

@ -1,7 +1,9 @@
package de.jotomo.ruffy.spi.history;
/** Note: the timestamp is the time the TBR **ended**, not started .*/
import java.util.Date;
public class Tbr extends HistoryRecord {
/** Duration in minutes */
public final int duration;
public final int percent;
@ -34,7 +36,7 @@ public class Tbr extends HistoryRecord {
@Override
public String toString() {
return "Tbr{" +
"timestamp=" + timestamp +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" +
", duration=" + duration +
", percent=" + percent +
'}';

View file

@ -1,5 +1,7 @@
package de.jotomo.ruffy.spi.history;
import java.util.Date;
/** Total daily dosage; amount of insulin delivered over a full day. */
public class Tdd extends HistoryRecord {
public final double total;
@ -17,7 +19,7 @@ public class Tdd extends HistoryRecord {
Tdd tdd = (Tdd) o;
if (timestamp != tdd.timestamp) return false;
return Double.compare(tdd.total, total) == 0;
return Math.abs(tdd.total - total) <= 0.05;
}
@Override
@ -33,7 +35,7 @@ public class Tdd extends HistoryRecord {
@Override
public String toString() {
return "Tdd{" +
"timestamp=" + timestamp +
"timestamp=" + timestamp + "(" + new Date(timestamp) + ")" +
", total=" + total +
'}';
}