2018-03-14 00:57:48 +01:00
|
|
|
package info.nightscout.androidaps.db;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-11-05 17:49:59 +01:00
|
|
|
import com.google.common.base.MoreObjects;
|
|
|
|
import com.j256.ormlite.field.DatabaseField;
|
|
|
|
import com.j256.ormlite.table.DatabaseTable;
|
2018-03-14 00:57:48 +01:00
|
|
|
|
2018-07-30 15:46:20 +02:00
|
|
|
import info.nightscout.androidaps.logging.L;
|
|
|
|
|
2018-03-14 00:57:48 +01:00
|
|
|
/**
|
|
|
|
* Created by mike on 20.09.2017.
|
|
|
|
*/
|
|
|
|
|
|
|
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TDDS)
|
|
|
|
public class TDD {
|
2018-11-05 17:49:59 +01:00
|
|
|
|
2018-07-30 15:46:20 +02:00
|
|
|
private static Logger log = LoggerFactory.getLogger(L.DATABASE);
|
2018-03-14 00:57:48 +01:00
|
|
|
|
|
|
|
@DatabaseField(id = true)
|
|
|
|
public long date;
|
|
|
|
|
|
|
|
@DatabaseField
|
|
|
|
public double bolus;
|
|
|
|
|
|
|
|
@DatabaseField
|
|
|
|
public double basal;
|
|
|
|
|
|
|
|
@DatabaseField
|
|
|
|
public double total;
|
|
|
|
|
|
|
|
|
2018-11-05 17:49:59 +01:00
|
|
|
public double getTotal() {
|
|
|
|
return (total > 0d) ? total : (bolus + basal);
|
2018-03-14 00:57:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-05 17:49:59 +01:00
|
|
|
public TDD() {
|
|
|
|
}
|
|
|
|
|
2018-03-14 00:57:48 +01:00
|
|
|
|
2018-11-05 17:49:59 +01:00
|
|
|
public TDD(long date, double bolus, double basal, double total) {
|
2018-03-14 00:57:48 +01:00
|
|
|
this.date = date;
|
|
|
|
this.bolus = bolus;
|
|
|
|
this.basal = basal;
|
|
|
|
this.total = total;
|
|
|
|
}
|
2018-11-05 17:49:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return MoreObjects.toStringHelper(this) //
|
|
|
|
.add("date", date) //
|
|
|
|
.add("bolus", bolus) //
|
|
|
|
.add("basal", basal) //
|
|
|
|
.add("total", total) //
|
|
|
|
.toString();
|
|
|
|
}
|
2018-03-14 00:57:48 +01:00
|
|
|
}
|