change database structures
This commit is contained in:
parent
3330c6a3fd
commit
6004a17594
|
@ -43,7 +43,7 @@ android {
|
||||||
applicationId "info.nightscout.androidaps"
|
applicationId "info.nightscout.androidaps"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1400
|
versionCode 1450
|
||||||
version "1.45"
|
version "1.45"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
buildConfigField "String", "BUILDVERSION", generateGitBuild()
|
||||||
|
|
|
@ -180,11 +180,10 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE);
|
bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE);
|
||||||
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
|
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
|
||||||
bgReading.battery_level = bundle.getInt(Intents.EXTRA_SENSOR_BATTERY);
|
bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP);
|
||||||
bgReading.timeIndex = bundle.getLong(Intents.EXTRA_TIMESTAMP);
|
|
||||||
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
|
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
|
||||||
|
|
||||||
if (bgReading.timeIndex < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) {
|
if (bgReading.date < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) {
|
||||||
if (Config.logIncommingBG)
|
if (Config.logIncommingBG)
|
||||||
log.debug("Ignoring old XDRIPREC BG " + bgReading.toString());
|
log.debug("Ignoring old XDRIPREC BG " + bgReading.toString());
|
||||||
return;
|
return;
|
||||||
|
@ -209,8 +208,7 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
bgReading.value = bundle.getDouble("mySGV");
|
bgReading.value = bundle.getDouble("mySGV");
|
||||||
bgReading.direction = bundle.getString("myTrend");
|
bgReading.direction = bundle.getString("myTrend");
|
||||||
bgReading.battery_level = bundle.getInt("myBatLvl");
|
bgReading.date = bundle.getLong("myTimestamp");
|
||||||
bgReading.timeIndex = bundle.getLong("myTimestamp");
|
|
||||||
bgReading.raw = 0;
|
bgReading.raw = 0;
|
||||||
|
|
||||||
if (Config.logIncommingBG)
|
if (Config.logIncommingBG)
|
||||||
|
@ -247,10 +245,10 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
bgReading.value = json_object.getDouble("sgv");
|
bgReading.value = json_object.getDouble("sgv");
|
||||||
bgReading.direction = json_object.getString("direction");
|
bgReading.direction = json_object.getString("direction");
|
||||||
bgReading.timeIndex = json_object.getLong("date");
|
bgReading.date = json_object.getLong("date");
|
||||||
bgReading.raw = json_object.getDouble("sgv");
|
bgReading.raw = json_object.getDouble("sgv");
|
||||||
|
|
||||||
if (bgReading.timeIndex < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) {
|
if (bgReading.date < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) {
|
||||||
if (Config.logIncommingBG)
|
if (Config.logIncommingBG)
|
||||||
log.debug("Ignoring old MM640g BG " + bgReading.toString());
|
log.debug("Ignoring old MM640g BG " + bgReading.toString());
|
||||||
return;
|
return;
|
||||||
|
@ -451,7 +449,7 @@ public class DataService extends IntentService {
|
||||||
JSONObject sgvJson = new JSONObject(sgvstring);
|
JSONObject sgvJson = new JSONObject(sgvstring);
|
||||||
NSSgv nsSgv = new NSSgv(sgvJson);
|
NSSgv nsSgv = new NSSgv(sgvJson);
|
||||||
BgReading bgReading = new BgReading(nsSgv);
|
BgReading bgReading = new BgReading(nsSgv);
|
||||||
if (bgReading.timeIndex < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000l) {
|
if (bgReading.date < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000l) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Ignoring old BG: " + bgReading.toString());
|
log.debug("Ignoring old BG: " + bgReading.toString());
|
||||||
return;
|
return;
|
||||||
|
@ -468,7 +466,7 @@ public class DataService extends IntentService {
|
||||||
JSONObject sgvJson = jsonArray.getJSONObject(i);
|
JSONObject sgvJson = jsonArray.getJSONObject(i);
|
||||||
NSSgv nsSgv = new NSSgv(sgvJson);
|
NSSgv nsSgv = new NSSgv(sgvJson);
|
||||||
BgReading bgReading = new BgReading(nsSgv);
|
BgReading bgReading = new BgReading(nsSgv);
|
||||||
if (bgReading.timeIndex < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000l) {
|
if (bgReading.date < new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000l) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Ignoring old BG: " + bgReading.toString());
|
log.debug("Ignoring old BG: " + bgReading.toString());
|
||||||
} else {
|
} else {
|
||||||
|
@ -502,10 +500,10 @@ public class DataService extends IntentService {
|
||||||
Treatment stored = null;
|
Treatment stored = null;
|
||||||
String _id = trJson.getString("_id");
|
String _id = trJson.getString("_id");
|
||||||
|
|
||||||
if (trJson.has("timeIndex")) {
|
if (trJson.has("date")) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("ADD: timeIndex found: " + trstring);
|
log.debug("ADD: date found: " + trstring);
|
||||||
stored = MainApp.getDbHelper().findTreatmentByTimeIndex(trJson.getLong("timeIndex"));
|
stored = MainApp.getDbHelper().findTreatmentByTimeIndex(trJson.getLong("date"));
|
||||||
} else {
|
} else {
|
||||||
stored = MainApp.getDbHelper().findTreatmentById(_id);
|
stored = MainApp.getDbHelper().findTreatmentById(_id);
|
||||||
}
|
}
|
||||||
|
@ -513,7 +511,7 @@ public class DataService extends IntentService {
|
||||||
if (stored != null) {
|
if (stored != null) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("ADD: Existing treatment: " + trstring);
|
log.debug("ADD: Existing treatment: " + trstring);
|
||||||
if (trJson.has("timeIndex")) {
|
if (trJson.has("date")) {
|
||||||
stored._id = _id;
|
stored._id = _id;
|
||||||
int updated = MainApp.getDbHelper().update(stored);
|
int updated = MainApp.getDbHelper().update(stored);
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
|
@ -528,7 +526,7 @@ public class DataService extends IntentService {
|
||||||
treatment._id = _id;
|
treatment._id = _id;
|
||||||
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
|
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
|
||||||
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
||||||
treatment.created_at = new Date(trJson.getLong("mills"));
|
treatment.date = trJson.getLong("mills");
|
||||||
if (trJson.has("eventType")) {
|
if (trJson.has("eventType")) {
|
||||||
treatment.mealBolus = true;
|
treatment.mealBolus = true;
|
||||||
if (trJson.get("eventType").equals("Correction Bolus"))
|
if (trJson.get("eventType").equals("Correction Bolus"))
|
||||||
|
@ -543,7 +541,6 @@ public class DataService extends IntentService {
|
||||||
if (carbs <= 0)
|
if (carbs <= 0)
|
||||||
treatment.mealBolus = false;
|
treatment.mealBolus = false;
|
||||||
}
|
}
|
||||||
treatment.setTimeIndex(treatment.getTimeIndex());
|
|
||||||
MainApp.getDbHelper().createOrUpdate(treatment);
|
MainApp.getDbHelper().createOrUpdate(treatment);
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("ADD: Stored treatment: " + treatment.log());
|
log.debug("ADD: Stored treatment: " + treatment.log());
|
||||||
|
@ -563,10 +560,10 @@ public class DataService extends IntentService {
|
||||||
|
|
||||||
Treatment stored;
|
Treatment stored;
|
||||||
|
|
||||||
if (trJson.has("timeIndex")) {
|
if (trJson.has("date")) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("ADD: timeIndex found: " + trstring);
|
log.debug("ADD: date found: " + trstring);
|
||||||
stored = MainApp.getDbHelper().findTreatmentByTimeIndex(trJson.getLong("timeIndex"));
|
stored = MainApp.getDbHelper().findTreatmentByTimeIndex(trJson.getLong("date"));
|
||||||
} else {
|
} else {
|
||||||
stored = MainApp.getDbHelper().findTreatmentById(_id);
|
stored = MainApp.getDbHelper().findTreatmentById(_id);
|
||||||
}
|
}
|
||||||
|
@ -586,7 +583,7 @@ public class DataService extends IntentService {
|
||||||
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
|
treatment.carbs = trJson.has("carbs") ? trJson.getDouble("carbs") : 0;
|
||||||
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
||||||
//treatment.created_at = DateUtil.fromISODateString(trJson.getString("created_at"));
|
//treatment.created_at = DateUtil.fromISODateString(trJson.getString("created_at"));
|
||||||
treatment.created_at = new Date(trJson.getLong("mills"));
|
treatment.date = trJson.getLong("mills");
|
||||||
if (trJson.has("eventType")) {
|
if (trJson.has("eventType")) {
|
||||||
treatment.mealBolus = true;
|
treatment.mealBolus = true;
|
||||||
if (trJson.get("eventType").equals("Correction Bolus"))
|
if (trJson.get("eventType").equals("Correction Bolus"))
|
||||||
|
@ -601,7 +598,6 @@ public class DataService extends IntentService {
|
||||||
if (carbs <= 0)
|
if (carbs <= 0)
|
||||||
treatment.mealBolus = false;
|
treatment.mealBolus = false;
|
||||||
}
|
}
|
||||||
treatment.setTimeIndex(treatment.getTimeIndex());
|
|
||||||
Dao.CreateOrUpdateStatus status = MainApp.getDbHelper().createOrUpdate(treatment);
|
Dao.CreateOrUpdateStatus status = MainApp.getDbHelper().createOrUpdate(treatment);
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Records updated: " + status.getNumLinesChanged());
|
log.debug("Records updated: " + status.getNumLinesChanged());
|
||||||
|
@ -621,10 +617,10 @@ public class DataService extends IntentService {
|
||||||
// Record does not exists. Ignore
|
// Record does not exists. Ignore
|
||||||
} else if (list.size() == 1) {
|
} else if (list.size() == 1) {
|
||||||
DanaRHistoryRecord record = list.get(0);
|
DanaRHistoryRecord record = list.get(0);
|
||||||
if (record.get_id() == null || record.get_id() != trJson.getString("_id")) {
|
if (record._id == null || !record._id.equals(trJson.getString("_id"))) {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Updating _id in DanaR history database: " + trJson.getString("_id"));
|
log.debug("Updating _id in DanaR history database: " + trJson.getString("_id"));
|
||||||
record.set_id(trJson.getString("_id"));
|
record._id = trJson.getString("_id");
|
||||||
daoHistoryRecords.update(record);
|
daoHistoryRecords.update(record);
|
||||||
} else {
|
} else {
|
||||||
// already set
|
// already set
|
||||||
|
@ -655,7 +651,7 @@ public class DataService extends IntentService {
|
||||||
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
|
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.eq("_id", trJson.getString("_id")).or().eq("timeIndex", trJson.getLong("mills"));
|
where.eq("_id", trJson.getString("_id")).or().eq("date", trJson.getLong("mills"));
|
||||||
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
|
||||||
List<TempTarget> list = daoTempTargets.query(preparedQuery);
|
List<TempTarget> list = daoTempTargets.query(preparedQuery);
|
||||||
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
|
||||||
|
@ -664,13 +660,12 @@ public class DataService extends IntentService {
|
||||||
if (list.size() == 0) {
|
if (list.size() == 0) {
|
||||||
// Record does not exists. add
|
// Record does not exists. add
|
||||||
TempTarget newRecord = new TempTarget();
|
TempTarget newRecord = new TempTarget();
|
||||||
newRecord.timeStart = new Date(trJson.getLong("mills"));
|
newRecord.date = trJson.getLong("mills");
|
||||||
newRecord.duration = trJson.getInt("duration");
|
newRecord.durationInMinutes = trJson.getInt("duration");
|
||||||
newRecord.low = NSProfile.toMgdl(trJson.getDouble("targetBottom"), units);
|
newRecord.low = NSProfile.toMgdl(trJson.getDouble("targetBottom"), units);
|
||||||
newRecord.high = NSProfile.toMgdl(trJson.getDouble("targetTop"), units);
|
newRecord.high = NSProfile.toMgdl(trJson.getDouble("targetTop"), units);
|
||||||
newRecord.reason = trJson.getString("reason");
|
newRecord.reason = trJson.getString("reason");
|
||||||
newRecord._id = trJson.getString("_id");
|
newRecord._id = trJson.getString("_id");
|
||||||
newRecord.setTimeIndex(newRecord.getTimeIndex());
|
|
||||||
daoTempTargets.createIfNotExists(newRecord);
|
daoTempTargets.createIfNotExists(newRecord);
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Adding TempTarget record to database: " + newRecord.log());
|
log.debug("Adding TempTarget record to database: " + newRecord.log());
|
||||||
|
@ -679,8 +674,8 @@ public class DataService extends IntentService {
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Updating TempTarget record in database: " + trJson.getString("_id"));
|
log.debug("Updating TempTarget record in database: " + trJson.getString("_id"));
|
||||||
TempTarget record = list.get(0);
|
TempTarget record = list.get(0);
|
||||||
record.timeStart = new Date(trJson.getLong("mills"));
|
record.date = trJson.getLong("mills");
|
||||||
record.duration = trJson.getInt("duration");
|
record.durationInMinutes = trJson.getInt("duration");
|
||||||
record.low = NSProfile.toMgdl(trJson.getDouble("targetBottom"), units);
|
record.low = NSProfile.toMgdl(trJson.getDouble("targetBottom"), units);
|
||||||
record.high = NSProfile.toMgdl(trJson.getDouble("targetTop"), units);
|
record.high = NSProfile.toMgdl(trJson.getDouble("targetTop"), units);
|
||||||
record.reason = trJson.getString("reason");
|
record.reason = trJson.getString("reason");
|
||||||
|
|
|
@ -73,12 +73,12 @@ public class GlucoseStatus {
|
||||||
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
List<BgReading> data = MainApp.getDbHelper().getBgreadingsDataFromTime(fromtime, false);
|
||||||
|
|
||||||
int sizeRecords = data.size();
|
int sizeRecords = data.size();
|
||||||
if (sizeRecords < 1 || data.get(0).timeIndex < new Date().getTime() - 7 * 60 * 1000L) {
|
if (sizeRecords < 1 || data.get(0).date < new Date().getTime() - 7 * 60 * 1000L) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BgReading now = data.get(0);
|
BgReading now = data.get(0);
|
||||||
long now_date = now.timeIndex;
|
long now_date = now.date;
|
||||||
double change;
|
double change;
|
||||||
|
|
||||||
if (sizeRecords < 2) {
|
if (sizeRecords < 2) {
|
||||||
|
@ -98,7 +98,7 @@ public class GlucoseStatus {
|
||||||
for (int i = 1; i < data.size(); i++) {
|
for (int i = 1; i < data.size(); i++) {
|
||||||
if (data.get(i).value > 38) {
|
if (data.get(i).value > 38) {
|
||||||
BgReading then = data.get(i);
|
BgReading then = data.get(i);
|
||||||
long then_date = then.timeIndex;
|
long then_date = then.date;
|
||||||
double avgdelta = 0;
|
double avgdelta = 0;
|
||||||
long minutesago;
|
long minutesago;
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ public class GlucoseStatus {
|
||||||
try {
|
try {
|
||||||
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
|
Dao<BgReading, Long> daoBgReadings = MainApp.getDbHelper().getDaoBgReadings();
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgReadings.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", false);
|
queryBuilder.orderBy("date", false);
|
||||||
queryBuilder.limit(1L);
|
queryBuilder.limit(1L);
|
||||||
queryBuilder.where().gt("value", 38);
|
queryBuilder.where().gt("value", 38);
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
|
@ -179,7 +179,7 @@ public class GlucoseStatus {
|
||||||
if (lastBg == null)
|
if (lastBg == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (lastBg.timeIndex > new Date().getTime() - 9 * 60 * 1000)
|
if (lastBg.date > new Date().getTime() - 9 * 60 * 1000)
|
||||||
return lastBg;
|
return lastBg;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -11,41 +11,38 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_BGREADINGS)
|
||||||
public class BgReading implements DataPointInterface {
|
public class BgReading implements DataPointInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(BgReading.class);
|
private static Logger log = LoggerFactory.getLogger(BgReading.class);
|
||||||
|
|
||||||
public long getTimeIndex() {
|
@DatabaseField(id = true)
|
||||||
return timeIndex;
|
public long date;
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeIndex(long timeIndex) {
|
@DatabaseField
|
||||||
this.timeIndex = timeIndex;
|
public boolean isValid = true;
|
||||||
}
|
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
|
||||||
public long timeIndex;
|
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double value;
|
public double value;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public String direction;
|
public String direction;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double raw;
|
public double raw;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int battery_level;
|
public int source = Source.NONE;
|
||||||
|
@DatabaseField
|
||||||
|
public String _id = null; // NS _id
|
||||||
|
|
||||||
|
|
||||||
public static String units = Constants.MGDL;
|
public static String units = Constants.MGDL;
|
||||||
|
|
||||||
public BgReading() {}
|
public BgReading() {}
|
||||||
|
|
||||||
public BgReading(NSSgv sgv) {
|
public BgReading(NSSgv sgv) {
|
||||||
timeIndex = sgv.getMills();
|
date = sgv.getMills();
|
||||||
value = sgv.getMgdl();
|
value = sgv.getMgdl();
|
||||||
raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
|
raw = sgv.getFiltered() != null ? sgv.getFiltered() : value;
|
||||||
direction = sgv.getDirection();
|
direction = sgv.getDirection();
|
||||||
|
@ -101,18 +98,17 @@ public class BgReading implements DataPointInterface {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BgReading{" +
|
return "BgReading{" +
|
||||||
"timeIndex=" + timeIndex +
|
"date=" + date +
|
||||||
", date=" + new Date(timeIndex) +
|
", date=" + DateUtil.dateAndTimeString(date) +
|
||||||
", value=" + value +
|
", value=" + value +
|
||||||
", direction=" + direction +
|
", direction=" + direction +
|
||||||
", raw=" + raw +
|
", raw=" + raw +
|
||||||
", battery_level=" + battery_level +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return timeIndex;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,38 +8,38 @@ import java.util.Date;
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_DANARHISTORY)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_DANARHISTORY)
|
||||||
public class DanaRHistoryRecord {
|
public class DanaRHistoryRecord {
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private String _id;
|
public String _id;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private byte recordCode;
|
public byte recordCode;
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
@DatabaseField(id = true)
|
||||||
private String bytes;
|
public String bytes;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private long recordDate;
|
public long recordDate;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private double recordValue;
|
public double recordValue;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private String bolusType;
|
public String bolusType;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private String stringRecordValue;
|
public String stringRecordValue;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private int recordDuration;
|
public int recordDuration;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private double recordDailyBasal;
|
public double recordDailyBasal;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private double recordDailyBolus;
|
public double recordDailyBolus;
|
||||||
|
|
||||||
@DatabaseField(useGetSet = true)
|
@DatabaseField
|
||||||
private String recordAlarm;
|
public String recordAlarm;
|
||||||
|
|
||||||
public DanaRHistoryRecord() {
|
public DanaRHistoryRecord() {
|
||||||
this.recordDate = 0;
|
this.recordDate = 0;
|
||||||
|
@ -50,74 +50,6 @@ public class DanaRHistoryRecord {
|
||||||
this._id = null;
|
this._id = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRecordDate(Date dtRecordDate) {
|
|
||||||
this.recordDate = dtRecordDate.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getRecordDate() {
|
|
||||||
return this.recordDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordDate(long dtRecordDate) {
|
|
||||||
this.recordDate = dtRecordDate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRecordValue() {
|
|
||||||
return this.recordValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordValue(double dRecordValue) {
|
|
||||||
this.recordValue = dRecordValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBolusType() {
|
|
||||||
return this.bolusType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBolusType(String strRecordType) {
|
|
||||||
this.bolusType = strRecordType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStringRecordValue() {
|
|
||||||
return this.stringRecordValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStringRecordValue(String strRecordValue) {
|
|
||||||
this.stringRecordValue = strRecordValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte getRecordCode() {
|
|
||||||
return this.recordCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordCode(byte cRecordCode) {
|
|
||||||
this.recordCode = cRecordCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRecordDuration() {
|
|
||||||
return this.recordDuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordDuration(int dRecordDuraion) {
|
|
||||||
this.recordDuration = dRecordDuraion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRecordDailyBasal() {
|
|
||||||
return this.recordDailyBasal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordDailyBasal(double dRecordDailyBasal) {
|
|
||||||
this.recordDailyBasal = dRecordDailyBasal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRecordDailyBolus() {
|
|
||||||
return this.recordDailyBolus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordDailyBolus(double dRecordDailyBolus) {
|
|
||||||
this.recordDailyBolus = dRecordDailyBolus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRecordLevel(double dExLow, double dLow, double dHigh, double dExHigh) {
|
public int getRecordLevel(double dExLow, double dLow, double dHigh, double dExHigh) {
|
||||||
if (this.recordValue < dExLow)
|
if (this.recordValue < dExLow)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -128,34 +60,10 @@ public class DanaRHistoryRecord {
|
||||||
return this.recordValue < dExHigh ? 3 : 4;
|
return this.recordValue < dExHigh ? 3 : 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRecordAlarm() {
|
|
||||||
return this.recordAlarm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecordAlarm(String strAlarm) {
|
|
||||||
this.recordAlarm = strAlarm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String get_id() {
|
|
||||||
return this._id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set_id(String _id) {
|
|
||||||
this._id = _id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBytes(byte[] raw) {
|
public void setBytes(byte[] raw) {
|
||||||
this.bytes = bytesToHex(raw);
|
this.bytes = bytesToHex(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBytes(String bytes) {
|
|
||||||
this.bytes = bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBytes() {
|
|
||||||
return this.bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||||
|
|
||||||
public static String bytesToHex(byte[] bytes) {
|
public static String bytesToHex(byte[] bytes) {
|
||||||
|
|
|
@ -36,13 +36,15 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public static final String DATABASE_NAME = "AndroidAPSDb";
|
public static final String DATABASE_NAME = "AndroidAPSDb";
|
||||||
public static final String DATABASE_BGREADINGS = "BgReadings";
|
public static final String DATABASE_BGREADINGS = "BgReadings";
|
||||||
public static final String DATABASE_TEMPBASALS = "TempBasals";
|
public static final String DATABASE_TEMPEXBASALS = "TempBasals";
|
||||||
|
public static final String DATABASE_TEMPORARYBASALS = "TemporaryBasals";
|
||||||
|
public static final String DATABASE_EXTENDEDBOLUSES = "ExtendedBoluses";
|
||||||
public static final String DATABASE_TEMPTARGETS = "TempTargets";
|
public static final String DATABASE_TEMPTARGETS = "TempTargets";
|
||||||
public static final String DATABASE_TREATMENTS = "Treatments";
|
public static final String DATABASE_TREATMENTS = "Treatments";
|
||||||
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
public static final String DATABASE_DANARHISTORY = "DanaRHistory";
|
||||||
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
public static final String DATABASE_DBREQUESTS = "DBRequests";
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 6;
|
private static final int DATABASE_VERSION = 7;
|
||||||
|
|
||||||
private static Long latestTreatmentChange = null;
|
private static Long latestTreatmentChange = null;
|
||||||
|
|
||||||
|
@ -59,7 +61,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
|
||||||
try {
|
try {
|
||||||
log.info("onCreate");
|
log.info("onCreate");
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempBasal.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempExBasal.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
||||||
|
@ -75,7 +77,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
try {
|
try {
|
||||||
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
||||||
TableUtils.dropTable(connectionSource, TempBasal.class, true);
|
TableUtils.dropTable(connectionSource, TempExBasal.class, true);
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
||||||
|
@ -99,19 +101,19 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void cleanUpDatabases() {
|
public void cleanUpDatabases() {
|
||||||
// TODO: call it somewhere
|
// TODO: call it somewhere
|
||||||
log.debug("Before BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
log.debug("Before BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
||||||
getWritableDatabase().delete(DATABASE_BGREADINGS, "timeIndex" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
getWritableDatabase().delete(DATABASE_BGREADINGS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
||||||
log.debug("After BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
log.debug("After BgReadings size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_BGREADINGS));
|
||||||
|
|
||||||
log.debug("Before TempBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPBASALS));
|
log.debug("Before TempBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPEXBASALS));
|
||||||
getWritableDatabase().delete(DATABASE_TEMPBASALS, "timeIndex" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
getWritableDatabase().delete(DATABASE_TEMPEXBASALS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
||||||
log.debug("After TempBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPBASALS));
|
log.debug("After TempBasals size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPEXBASALS));
|
||||||
|
|
||||||
log.debug("Before TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
log.debug("Before TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
||||||
getWritableDatabase().delete(DATABASE_TEMPTARGETS, "timeIndex" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
getWritableDatabase().delete(DATABASE_TEMPTARGETS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
||||||
log.debug("After TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
log.debug("After TempTargets size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TEMPTARGETS));
|
||||||
|
|
||||||
log.debug("Before Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
log.debug("Before Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
||||||
getWritableDatabase().delete(DATABASE_TREATMENTS, "timeIndex" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
getWritableDatabase().delete(DATABASE_TREATMENTS, "date" + " < '" + (new Date().getTime() - Constants.hoursToKeepInDatabase * 60 * 60 * 1000L) + "'", null);
|
||||||
log.debug("After Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
log.debug("After Treatments size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_TREATMENTS));
|
||||||
|
|
||||||
log.debug("Before History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
|
log.debug("Before History size: " + DatabaseUtils.queryNumEntries(getReadableDatabase(), DATABASE_DANARHISTORY));
|
||||||
|
@ -121,13 +123,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public void resetDatabases() {
|
public void resetDatabases() {
|
||||||
try {
|
try {
|
||||||
TableUtils.dropTable(connectionSource, TempBasal.class, true);
|
TableUtils.dropTable(connectionSource, TempExBasal.class, true);
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
TableUtils.dropTable(connectionSource, BgReading.class, true);
|
||||||
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
TableUtils.dropTable(connectionSource, DanaRHistoryRecord.class, true);
|
||||||
//DbRequests can be cleared from NSClient fragment
|
//DbRequests can be cleared from NSClient fragment
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempBasal.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempExBasal.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
TableUtils.createTableIfNotExists(connectionSource, TempTarget.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
||||||
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
TableUtils.createTableIfNotExists(connectionSource, BgReading.class);
|
||||||
|
@ -157,8 +159,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dao<TempBasal, Long> getDaoTempBasals() throws SQLException {
|
public Dao<TempExBasal, Long> getDaoTempBasals() throws SQLException {
|
||||||
return getDao(TempBasal.class);
|
return getDao(TempExBasal.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dao<TempTarget, Long> getDaoTempTargets() throws SQLException {
|
public Dao<TempTarget, Long> getDaoTempTargets() throws SQLException {
|
||||||
|
@ -190,9 +192,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
Dao<BgReading, Long> daoBgreadings = getDaoBgReadings();
|
||||||
List<BgReading> bgReadings;
|
List<BgReading> bgReadings;
|
||||||
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
QueryBuilder<BgReading, Long> queryBuilder = daoBgreadings.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", ascending);
|
queryBuilder.orderBy("date", ascending);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("timeIndex", mills).and().gt("value", 38);
|
where.ge("date", mills).and().gt("value", 38);
|
||||||
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<BgReading> preparedQuery = queryBuilder.prepare();
|
||||||
bgReadings = daoBgreadings.query(preparedQuery);
|
bgReadings = daoBgreadings.query(preparedQuery);
|
||||||
return bgReadings;
|
return bgReadings;
|
||||||
|
@ -261,7 +263,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
// TREATMENT HANDLING
|
// TREATMENT HANDLING
|
||||||
|
|
||||||
public boolean affectingIobCob(Treatment t) {
|
public boolean affectingIobCob(Treatment t) {
|
||||||
Treatment existing = findTreatmentByTimeIndex(t.timeIndex);
|
Treatment existing = findTreatmentByTimeIndex(t.date);
|
||||||
if (existing == null)
|
if (existing == null)
|
||||||
return true;
|
return true;
|
||||||
if (existing.insulin == t.insulin && existing.carbs == t.carbs)
|
if (existing.insulin == t.insulin && existing.carbs == t.carbs)
|
||||||
|
@ -275,7 +277,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
boolean historyChange = affectingIobCob(treatment);
|
boolean historyChange = affectingIobCob(treatment);
|
||||||
updated = getDaoTreatments().update(treatment);
|
updated = getDaoTreatments().update(treatment);
|
||||||
if (historyChange)
|
if (historyChange)
|
||||||
latestTreatmentChange = treatment.getTimeIndex();
|
latestTreatmentChange = treatment.date;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -289,7 +291,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
boolean historyChange = affectingIobCob(treatment);
|
boolean historyChange = affectingIobCob(treatment);
|
||||||
status = getDaoTreatments().createOrUpdate(treatment);
|
status = getDaoTreatments().createOrUpdate(treatment);
|
||||||
if (historyChange)
|
if (historyChange)
|
||||||
latestTreatmentChange = treatment.getTimeIndex();
|
latestTreatmentChange = treatment.date;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -300,7 +302,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void create(Treatment treatment) {
|
public void create(Treatment treatment) {
|
||||||
try {
|
try {
|
||||||
getDaoTreatments().create(treatment);
|
getDaoTreatments().create(treatment);
|
||||||
latestTreatmentChange = treatment.getTimeIndex();
|
latestTreatmentChange = treatment.date;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -310,7 +312,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public void delete(Treatment treatment) {
|
public void delete(Treatment treatment) {
|
||||||
try {
|
try {
|
||||||
getDaoTreatments().delete(treatment);
|
getDaoTreatments().delete(treatment);
|
||||||
latestTreatmentChange = treatment.getTimeIndex();
|
latestTreatmentChange = treatment.date;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -329,7 +331,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
if (Config.logIncommingData)
|
if (Config.logIncommingData)
|
||||||
log.debug("Records removed: " + removed);
|
log.debug("Records removed: " + removed);
|
||||||
latestTreatmentChange = stored.getTimeIndex();
|
latestTreatmentChange = stored.date;
|
||||||
scheduleTreatmentChange();
|
scheduleTreatmentChange();
|
||||||
} else {
|
} else {
|
||||||
log.debug("REMOVE: Not stored treatment (ignoring): " + _id);
|
log.debug("REMOVE: Not stored treatment (ignoring): " + _id);
|
||||||
|
@ -367,7 +369,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.eq("timeIndex", timeIndex);
|
where.eq("date", timeIndex);
|
||||||
queryBuilder.limit(10L);
|
queryBuilder.limit(10L);
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
List<Treatment> trList = daoTreatments.query(preparedQuery);
|
List<Treatment> trList = daoTreatments.query(preparedQuery);
|
||||||
|
@ -409,9 +411,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
Dao<Treatment, Long> daoTreatments = getDaoTreatments();
|
||||||
List<Treatment> treatments;
|
List<Treatment> treatments;
|
||||||
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
QueryBuilder<Treatment, Long> queryBuilder = daoTreatments.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", ascending);
|
queryBuilder.orderBy("date", ascending);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("timeIndex", mills);
|
where.ge("date", mills);
|
||||||
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<Treatment> preparedQuery = queryBuilder.prepare();
|
||||||
treatments = daoTreatments.query(preparedQuery);
|
treatments = daoTreatments.query(preparedQuery);
|
||||||
return treatments;
|
return treatments;
|
||||||
|
@ -421,11 +423,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return new ArrayList<Treatment>();
|
return new ArrayList<Treatment>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int update(TempBasal tempBasal) {
|
public int update(TempExBasal tempBasal) {
|
||||||
int updated = 0;
|
int updated = 0;
|
||||||
try {
|
try {
|
||||||
updated = getDaoTempBasals().update(tempBasal);
|
updated = getDaoTempBasals().update(tempBasal);
|
||||||
latestTreatmentChange = tempBasal.getTimeIndex();
|
latestTreatmentChange = tempBasal.timeIndex;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -433,20 +435,20 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create(TempBasal tempBasal) {
|
public void create(TempExBasal tempBasal) {
|
||||||
try {
|
try {
|
||||||
getDaoTempBasals().create(tempBasal);
|
getDaoTempBasals().create(tempBasal);
|
||||||
latestTreatmentChange = tempBasal.getTimeIndex();
|
latestTreatmentChange = tempBasal.timeIndex;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
scheduleTreatmentChange();
|
scheduleTreatmentChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(TempBasal tempBasal) {
|
public void delete(TempExBasal tempBasal) {
|
||||||
try {
|
try {
|
||||||
getDaoTempBasals().delete(tempBasal);
|
getDaoTempBasals().delete(tempBasal);
|
||||||
latestTreatmentChange = tempBasal.getTimeIndex();
|
latestTreatmentChange = tempBasal.timeIndex;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -458,9 +460,9 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
Dao<TempTarget, Long> daoTempTargets = getDaoTempTargets();
|
Dao<TempTarget, Long> daoTempTargets = getDaoTempTargets();
|
||||||
List<TempTarget> tempTargets;
|
List<TempTarget> tempTargets;
|
||||||
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
|
QueryBuilder<TempTarget, Long> queryBuilder = daoTempTargets.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", ascending);
|
queryBuilder.orderBy("date", ascending);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("timeIndex", mills);
|
where.ge("date", mills);
|
||||||
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<TempTarget> preparedQuery = queryBuilder.prepare();
|
||||||
tempTargets = daoTempTargets.query(preparedQuery);
|
tempTargets = daoTempTargets.query(preparedQuery);
|
||||||
return tempTargets;
|
return tempTargets;
|
||||||
|
@ -471,21 +473,21 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<TempBasal> getTempbasalsDataFromTime(long mills, boolean ascending, boolean isExtended) {
|
public List<TempExBasal> getTempbasalsDataFromTime(long mills, boolean ascending, boolean isExtended) {
|
||||||
try {
|
try {
|
||||||
Dao<TempBasal, Long> daoTempbasals = getDaoTempBasals();
|
Dao<TempExBasal, Long> daoTempbasals = getDaoTempBasals();
|
||||||
List<TempBasal> tempbasals;
|
List<TempExBasal> tempbasals;
|
||||||
QueryBuilder<TempBasal, Long> queryBuilder = daoTempbasals.queryBuilder();
|
QueryBuilder<TempExBasal, Long> queryBuilder = daoTempbasals.queryBuilder();
|
||||||
queryBuilder.orderBy("timeIndex", ascending);
|
queryBuilder.orderBy("date", ascending);
|
||||||
Where where = queryBuilder.where();
|
Where where = queryBuilder.where();
|
||||||
where.ge("timeIndex", mills).and().eq("isExtended", isExtended);
|
where.ge("date", mills).and().eq("isExtended", isExtended);
|
||||||
PreparedQuery<TempBasal> preparedQuery = queryBuilder.prepare();
|
PreparedQuery<TempExBasal> preparedQuery = queryBuilder.prepare();
|
||||||
tempbasals = daoTempbasals.query(preparedQuery);
|
tempbasals = daoTempbasals.query(preparedQuery);
|
||||||
return tempbasals;
|
return tempbasals;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return new ArrayList<TempBasal>();
|
return new ArrayList<TempExBasal>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,7 @@ import org.slf4j.LoggerFactory;
|
||||||
public class DbRequest {
|
public class DbRequest {
|
||||||
private static Logger log = LoggerFactory.getLogger(DbRequest.class);
|
private static Logger log = LoggerFactory.getLogger(DbRequest.class);
|
||||||
|
|
||||||
public String getNsClientID() {
|
@DatabaseField(id = true)
|
||||||
return nsClientID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNsClientID(String nsClientID) {
|
|
||||||
this.nsClientID = nsClientID;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
|
||||||
public String nsClientID = null;
|
public String nsClientID = null;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
|
|
|
@ -0,0 +1,187 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 21.05.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.Constants;
|
||||||
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
import info.nightscout.utils.Round;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 21.05.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_EXTENDEDBOLUSES)
|
||||||
|
public class ExtendedBolus implements Interval {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(ExtendedBolus.class);
|
||||||
|
|
||||||
|
@DatabaseField(id = true)
|
||||||
|
public long date;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public boolean isValid = true;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int source = Source.NONE;
|
||||||
|
@DatabaseField
|
||||||
|
public String _id = null; // NS _id
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public double insulin = 0d;
|
||||||
|
@DatabaseField
|
||||||
|
public int durationInMinutes = 0; // duration == 0 means end of temp basal
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
||||||
|
@DatabaseField
|
||||||
|
public double dia = Constants.defaultDIA;
|
||||||
|
|
||||||
|
|
||||||
|
// -------- Interval interface ---------
|
||||||
|
|
||||||
|
Long cuttedEnd = null;
|
||||||
|
|
||||||
|
public long durationInMsec() {
|
||||||
|
return durationInMinutes * 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long start() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
// planned end time at time of creation
|
||||||
|
public long originalEnd() {
|
||||||
|
return date + durationInMinutes * 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// end time after cut
|
||||||
|
public long end() {
|
||||||
|
if (cuttedEnd != null)
|
||||||
|
return cuttedEnd;
|
||||||
|
return originalEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cutEndTo(long end) {
|
||||||
|
cuttedEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean match(long time) {
|
||||||
|
if (start() <= time && end() >= time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean before(long time) {
|
||||||
|
if (end() < time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean after(long time) {
|
||||||
|
if (start() > time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Interval interface end ---------
|
||||||
|
|
||||||
|
public String log() {
|
||||||
|
return "Bolus{" +
|
||||||
|
"date= " + date +
|
||||||
|
", date= " + DateUtil.dateAndTimeString(date) +
|
||||||
|
", isValid=" + isValid +
|
||||||
|
", _id= " + _id +
|
||||||
|
", insulin= " + insulin +
|
||||||
|
", durationInMinutes= " + durationInMinutes +
|
||||||
|
"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
double absoluteRate() {
|
||||||
|
return Round.roundTo(insulin / durationInMinutes * 60, 0.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IobTotal iobCalc(long time) {
|
||||||
|
IobTotal result = new IobTotal(time);
|
||||||
|
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||||
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
int realDuration = getDurationToTime(time);
|
||||||
|
|
||||||
|
if (realDuration > 0) {
|
||||||
|
Double dia_ago = time - profile.getDia() * 60 * 60 * 1000;
|
||||||
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
|
double spacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
|
||||||
|
for (Long j = 0L; j < aboutFiveMinIntervals; j++) {
|
||||||
|
// find middle of the interval
|
||||||
|
Long calcdate = (long) (date + j * spacing * 60 * 1000 + 0.5d * spacing * 60 * 1000);
|
||||||
|
|
||||||
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
|
double tempBolusSize = absoluteRate() * spacing / 60d;
|
||||||
|
|
||||||
|
Treatment tempBolusPart = new Treatment(insulinInterface);
|
||||||
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, profile.getDia());
|
||||||
|
result.iob += aIOB.iobContrib;
|
||||||
|
result.activity += aIOB.activityContrib;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRealDuration() {
|
||||||
|
return getDurationToTime(new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getDurationToTime(long time) {
|
||||||
|
long endTime = Math.min(time, end());
|
||||||
|
long msecs = endTime - date;
|
||||||
|
return Math.round(msecs / 60f / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlannedRemainingMinutes() {
|
||||||
|
float remainingMin = (end() - new Date().getTime()) / 1000f / 60;
|
||||||
|
return (remainingMin < 0) ? 0 : Math.round(remainingMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInProgress() {
|
||||||
|
return match(new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h @" +
|
||||||
|
DateUtil.timeString(date) +
|
||||||
|
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toStringShort() {
|
||||||
|
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h ";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toStringMedium() {
|
||||||
|
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h ("
|
||||||
|
+ getRealDuration() + "/" + durationInMinutes + ") ";
|
||||||
|
}
|
||||||
|
}
|
11
app/src/main/java/info/nightscout/androidaps/db/Source.java
Normal file
11
app/src/main/java/info/nightscout/androidaps/db/Source.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 21.05.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Source {
|
||||||
|
public final static int NONE = 0;
|
||||||
|
public final static int PUMP = 1;
|
||||||
|
public final static int NIGHTSCOUT = 2;
|
||||||
|
}
|
|
@ -8,7 +8,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
@ -17,19 +16,11 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPBASALS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPEXBASALS)
|
||||||
public class TempBasal {
|
public class TempExBasal {
|
||||||
private static Logger log = LoggerFactory.getLogger(TempBasal.class);
|
private static Logger log = LoggerFactory.getLogger(TempExBasal.class);
|
||||||
|
|
||||||
public long getTimeIndex() {
|
@DatabaseField(id = true)
|
||||||
return timeStart.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeIndex(long timeIndex) {
|
|
||||||
this.timeIndex = timeIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
|
||||||
public long timeIndex;
|
public long timeIndex;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
|
@ -96,7 +87,7 @@ public class TempBasal {
|
||||||
|
|
||||||
Treatment tempBolusPart = new Treatment(insulinInterface);
|
Treatment tempBolusPart = new Treatment(insulinInterface);
|
||||||
tempBolusPart.insulin = tempBolusSize;
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
tempBolusPart.created_at = new Date(date);
|
tempBolusPart.date = date;
|
||||||
|
|
||||||
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, profile.getDia());
|
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, profile.getDia());
|
||||||
result.basaliob += aIOB.iobContrib;
|
result.basaliob += aIOB.iobContrib;
|
||||||
|
@ -184,7 +175,7 @@ public class TempBasal {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String log() {
|
public String log() {
|
||||||
return "TempBasal{" +
|
return "TempExBasal{" +
|
||||||
"timeIndex=" + timeIndex +
|
"timeIndex=" + timeIndex +
|
||||||
", timeStart=" + timeStart +
|
", timeStart=" + timeStart +
|
||||||
", timeEnd=" + timeEnd +
|
", timeEnd=" + timeEnd +
|
|
@ -10,26 +10,25 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPTARGETS)
|
||||||
public class TempTarget {
|
public class TempTarget implements Interval {
|
||||||
private static Logger log = LoggerFactory.getLogger(TempTarget.class);
|
private static Logger log = LoggerFactory.getLogger(TempTarget.class);
|
||||||
|
|
||||||
public long getTimeIndex() {
|
@DatabaseField(id = true)
|
||||||
return timeStart.getTime() - timeStart.getTime() % 1000;
|
public long date;
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeIndex(long timeIndex) {
|
|
||||||
this.timeIndex = timeIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
|
||||||
public long timeIndex;
|
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public Date timeStart;
|
public boolean isValid = true;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int source = Source.NONE;
|
||||||
|
@DatabaseField
|
||||||
|
public String _id = null; // NS _id
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public double low; // in mgdl
|
public double low; // in mgdl
|
||||||
|
@ -41,15 +40,56 @@ public class TempTarget {
|
||||||
public String reason;
|
public String reason;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int duration; // in minutes
|
public int durationInMinutes;
|
||||||
|
|
||||||
@DatabaseField
|
// -------- Interval interface ---------
|
||||||
public String _id; // NS _id
|
|
||||||
|
|
||||||
public Date getPlannedTimeEnd() {
|
Long cuttedEnd = null;
|
||||||
return new Date(timeStart.getTime() + 60 * 1_000 * duration);
|
|
||||||
|
public long durationInMsec() {
|
||||||
|
return durationInMinutes * 60 * 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long start() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
// planned end time at time of creation
|
||||||
|
public long originalEnd() {
|
||||||
|
return date + durationInMinutes * 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// end time after cut
|
||||||
|
public long end() {
|
||||||
|
if (cuttedEnd != null)
|
||||||
|
return cuttedEnd;
|
||||||
|
return originalEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cutEndTo(long end) {
|
||||||
|
cuttedEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean match(long time) {
|
||||||
|
if (start() <= time && end() >= time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean before(long time) {
|
||||||
|
if (end() < time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean after(long time) {
|
||||||
|
if (start() > time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Interval interface end ---------
|
||||||
|
|
||||||
public String lowValueToUnitsToString(String units) {
|
public String lowValueToUnitsToString(String units) {
|
||||||
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(low);
|
if (units.equals(Constants.MGDL)) return DecimalFormatter.to0Decimal(low);
|
||||||
else return DecimalFormatter.to1Decimal(low * Constants.MGDL_TO_MMOLL);
|
else return DecimalFormatter.to1Decimal(low * Constants.MGDL_TO_MMOLL);
|
||||||
|
@ -61,14 +101,15 @@ public class TempTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInProgress() {
|
public boolean isInProgress() {
|
||||||
return ((TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class)).getTempTargetInProgress(new Date().getTime()) == this;
|
return match(new Date().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String log() {
|
public String log() {
|
||||||
return "TempTarget{" +
|
return "TemporaryTarget{" +
|
||||||
"timeIndex=" + timeIndex +
|
"date=" + date +
|
||||||
", timeStart=" + timeStart +
|
"date=" + DateUtil.dateAndTimeString(date) +
|
||||||
", duration=" + duration +
|
", isValid=" + isValid +
|
||||||
|
", duration=" + durationInMinutes +
|
||||||
", reason=" + reason +
|
", reason=" + reason +
|
||||||
", low=" + low +
|
", low=" + low +
|
||||||
", high=" + high +
|
", high=" + high +
|
||||||
|
|
|
@ -0,0 +1,220 @@
|
||||||
|
package info.nightscout.androidaps.db;
|
||||||
|
|
||||||
|
import com.j256.ormlite.field.DatabaseField;
|
||||||
|
import com.j256.ormlite.table.DatabaseTable;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.data.Iob;
|
||||||
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 21.05.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@DatabaseTable(tableName = DatabaseHelper.DATABASE_TEMPORARYBASALS)
|
||||||
|
public class TemporaryBasal implements Interval {
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TemporaryBasal.class);
|
||||||
|
|
||||||
|
@DatabaseField(id = true)
|
||||||
|
public long date;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public boolean isValid = true;
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int source = Source.NONE;
|
||||||
|
@DatabaseField
|
||||||
|
public String _id = null; // NS _id
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int durationInMinutes = 0; // duration == 0 means end of temp basal
|
||||||
|
@DatabaseField
|
||||||
|
public boolean isAbsolute = false;
|
||||||
|
@DatabaseField
|
||||||
|
public int percentRate = 0;
|
||||||
|
@DatabaseField
|
||||||
|
public double absoluteRate = 0d;
|
||||||
|
|
||||||
|
// -------- Interval interface ---------
|
||||||
|
|
||||||
|
Long cuttedEnd = null;
|
||||||
|
|
||||||
|
public long durationInMsec() {
|
||||||
|
return durationInMinutes * 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long start() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
// planned end time at time of creation
|
||||||
|
public long originalEnd() {
|
||||||
|
return date + durationInMinutes * 60 * 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// end time after cut
|
||||||
|
public long end() {
|
||||||
|
if (cuttedEnd != null)
|
||||||
|
return cuttedEnd;
|
||||||
|
return originalEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cutEndTo(long end) {
|
||||||
|
cuttedEnd = end;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean match(long time) {
|
||||||
|
if (start() <= time && end() >= time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean before(long time) {
|
||||||
|
if (end() < time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean after(long time) {
|
||||||
|
if (start() > time)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Interval interface end ---------
|
||||||
|
|
||||||
|
public IobTotal iobCalc(long time) {
|
||||||
|
IobTotal result = new IobTotal(time);
|
||||||
|
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||||
|
InsulinInterface insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||||
|
|
||||||
|
if (profile == null)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
int realDuration = getDurationToTime(time);
|
||||||
|
Double netBasalAmount = 0d;
|
||||||
|
|
||||||
|
if (realDuration > 0) {
|
||||||
|
Double netBasalRate = 0d;
|
||||||
|
|
||||||
|
Double dia_ago = time - profile.getDia() * 60 * 60 * 1000;
|
||||||
|
int aboutFiveMinIntervals = (int) Math.ceil(realDuration / 5d);
|
||||||
|
double tempBolusSpacing = realDuration / aboutFiveMinIntervals;
|
||||||
|
|
||||||
|
for (Long j = 0L; j < aboutFiveMinIntervals; j++) {
|
||||||
|
// find middle of the interval
|
||||||
|
Long calcdate = (long) (date + j * tempBolusSpacing * 60 * 1000 + 0.5d * tempBolusSpacing * 60 * 1000);
|
||||||
|
|
||||||
|
Double basalRate = profile.getBasal(NSProfile.secondsFromMidnight(calcdate));
|
||||||
|
|
||||||
|
if (basalRate == null)
|
||||||
|
continue;
|
||||||
|
if (isAbsolute) {
|
||||||
|
netBasalRate = absoluteRate - basalRate;
|
||||||
|
} else {
|
||||||
|
netBasalRate = (percentRate - 100) / 100d * basalRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calcdate > dia_ago && calcdate <= time) {
|
||||||
|
double tempBolusSize = netBasalRate * tempBolusSpacing / 60d;
|
||||||
|
netBasalAmount += tempBolusSize;
|
||||||
|
|
||||||
|
Treatment tempBolusPart = new Treatment(insulinInterface);
|
||||||
|
tempBolusPart.insulin = tempBolusSize;
|
||||||
|
tempBolusPart.date = calcdate;
|
||||||
|
|
||||||
|
Iob aIOB = insulinInterface.iobCalcForTreatment(tempBolusPart, time, profile.getDia());
|
||||||
|
result.basaliob += aIOB.iobContrib;
|
||||||
|
result.activity += aIOB.activityContrib;
|
||||||
|
result.netbasalinsulin += tempBolusPart.insulin;
|
||||||
|
if (tempBolusPart.insulin > 0) {
|
||||||
|
result.hightempinsulin += tempBolusPart.insulin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.netRatio = netBasalRate; // ratio at the end of interval
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.netInsulin = netBasalAmount;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRealDuration() {
|
||||||
|
return getDurationToTime(new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getDurationToTime(long time) {
|
||||||
|
long endTime = Math.min(time, end());
|
||||||
|
long msecs = endTime - date;
|
||||||
|
return Math.round(msecs / 60f / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPlannedRemainingMinutes() {
|
||||||
|
float remainingMin = (end() - new Date().getTime()) / 1000f / 60;
|
||||||
|
return (remainingMin < 0) ? 0 : Math.round(remainingMin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInProgress() {
|
||||||
|
return match(new Date().getTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double tempBasalConvertedToAbsolute(Date time) {
|
||||||
|
if (isAbsolute) return absoluteRate;
|
||||||
|
else {
|
||||||
|
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||||
|
return profile.getBasal(NSProfile.secondsFromMidnight(time)) * percentRate / 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String log() {
|
||||||
|
return "TemporaryBasal{" +
|
||||||
|
"date=" + date +
|
||||||
|
", date=" + DateUtil.dateAndTimeString(date) +
|
||||||
|
", isValid=" + isValid +
|
||||||
|
", _id=" + _id +
|
||||||
|
", percentRate=" + percentRate +
|
||||||
|
", absoluteRate=" + absoluteRate +
|
||||||
|
", durationInMinutes=" + durationInMinutes +
|
||||||
|
", isAbsolute=" + isAbsolute +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if (isAbsolute) {
|
||||||
|
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h @" +
|
||||||
|
DateUtil.timeString(date) +
|
||||||
|
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||||
|
} else { // percent
|
||||||
|
return percentRate + "% @" +
|
||||||
|
DateUtil.timeString(date) +
|
||||||
|
" " + getRealDuration() + "/" + durationInMinutes + "min";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toStringShort() {
|
||||||
|
if (isAbsolute) {
|
||||||
|
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h ";
|
||||||
|
} else { // percent
|
||||||
|
return percentRate + "% ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toStringMedium() {
|
||||||
|
if (isAbsolute) {
|
||||||
|
return DecimalFormatter.to2Decimal(absoluteRate) + "U/h ("
|
||||||
|
+ getRealDuration() + "/" + durationInMinutes + ") ";
|
||||||
|
} else { // percent
|
||||||
|
return percentRate + "% (" + getRealDuration() + "/" + durationInMinutes + ") ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
|
||||||
|
@ -26,81 +25,67 @@ import info.nightscout.utils.DecimalFormatter;
|
||||||
public class Treatment implements DataPointWithLabelInterface {
|
public class Treatment implements DataPointWithLabelInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(Treatment.class);
|
private static Logger log = LoggerFactory.getLogger(Treatment.class);
|
||||||
|
|
||||||
public long getTimeIndex() {
|
@DatabaseField(id = true)
|
||||||
return created_at.getTime();
|
public long date;
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeIndex(long timeIndex) {
|
@DatabaseField
|
||||||
this.timeIndex = timeIndex;
|
public boolean isValid = true;
|
||||||
}
|
|
||||||
|
|
||||||
@DatabaseField(id = true, useGetSet = true)
|
|
||||||
public long timeIndex;
|
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int source = Source.NONE;
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public String _id;
|
public String _id;
|
||||||
|
|
||||||
@DatabaseField
|
|
||||||
public Date created_at;
|
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public Double insulin = 0d;
|
public Double insulin = 0d;
|
||||||
|
|
||||||
@DatabaseField
|
|
||||||
public int insulinType = InsulinInterface.FASTACTINGINSULIN;
|
|
||||||
|
|
||||||
@DatabaseField
|
|
||||||
public double dia = Constants.defaultDIA;
|
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public Double carbs = 0d;
|
public Double carbs = 0d;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public boolean mealBolus = true; // true for meal bolus , false for correction bolus
|
public boolean mealBolus = true; // true for meal bolus , false for correction bolus
|
||||||
|
|
||||||
|
@DatabaseField
|
||||||
|
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
||||||
|
@DatabaseField
|
||||||
|
public double dia = Constants.defaultDIA;
|
||||||
|
|
||||||
public Treatment() {
|
public Treatment() {
|
||||||
InsulinInterface insulin = MainApp.getConfigBuilder().getActiveInsulin();
|
|
||||||
if (insulin != null) {
|
|
||||||
insulinType = insulin.getId();
|
|
||||||
dia = insulin.getDia();
|
|
||||||
} else {
|
|
||||||
insulinType = InsulinInterface.FASTACTINGINSULIN;
|
|
||||||
dia = Constants.defaultDIA;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Treatment(InsulinInterface insulin) {
|
public Treatment(InsulinInterface insulin) {
|
||||||
insulinType = insulin.getId();
|
insulinInterfaceID = insulin.getId();
|
||||||
dia = insulin.getDia();
|
dia = insulin.getDia();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyFrom(Treatment t) {
|
public void copyFrom(Treatment t) {
|
||||||
|
this.date = t.date;
|
||||||
|
this.isValid = t.isValid;
|
||||||
|
this.source = t.source;
|
||||||
this._id = t._id;
|
this._id = t._id;
|
||||||
this.created_at = t.created_at;
|
|
||||||
this.insulin = t.insulin;
|
this.insulin = t.insulin;
|
||||||
this.carbs = t.carbs;
|
this.carbs = t.carbs;
|
||||||
this.mealBolus = t.mealBolus;
|
this.mealBolus = t.mealBolus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getMillisecondsFromStart() {
|
public long getMillisecondsFromStart() {
|
||||||
return new Date().getTime() - created_at.getTime();
|
return new Date().getTime() - date;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String log() {
|
public String log() {
|
||||||
return "Treatment{" +
|
return "Treatment{" +
|
||||||
"timeIndex: " + timeIndex +
|
"date= " + date +
|
||||||
", _id: " + _id +
|
"date= " + DateUtil.dateAndTimeString(date) +
|
||||||
", insulin: " + insulin +
|
", isValid= " + isValid +
|
||||||
", carbs: " + carbs +
|
", _id= " + _id +
|
||||||
", mealBolus: " + mealBolus +
|
", insulin= " + insulin +
|
||||||
", created_at: " +
|
", carbs= " + carbs +
|
||||||
|
", mealBolus= " + mealBolus +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// DataPointInterface
|
// ----------------- DataPointInterface --------------------
|
||||||
@Override
|
@Override
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return timeIndex;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
// default when no sgv around available
|
// default when no sgv around available
|
||||||
|
@ -125,12 +110,14 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
if (profile == null) return;
|
if (profile == null) return;
|
||||||
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
|
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
|
||||||
BgReading reading = bgReadingsArray.get(r);
|
BgReading reading = bgReadingsArray.get(r);
|
||||||
if (reading.timeIndex > timeIndex) continue;
|
if (reading.date > date) continue;
|
||||||
yValue = NSProfile.fromMgdlToUnits(reading.value, profile.getUnits());
|
yValue = NSProfile.fromMgdlToUnits(reading.value, profile.getUnits());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------- DataPointInterface end --------------------
|
||||||
|
|
||||||
public void sendToNSClient() {
|
public void sendToNSClient() {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
@ -140,8 +127,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
data.put("eventType", "Correction Bolus");
|
data.put("eventType", "Correction Bolus");
|
||||||
if (insulin != 0d) data.put("insulin", insulin);
|
if (insulin != 0d) data.put("insulin", insulin);
|
||||||
if (carbs != 0d) data.put("carbs", carbs.intValue());
|
if (carbs != 0d) data.put("carbs", carbs.intValue());
|
||||||
data.put("created_at", DateUtil.toISOString(created_at));
|
data.put("created_at", DateUtil.toISOString(date));
|
||||||
data.put("timeIndex", timeIndex);
|
data.put("timeIndex", date);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -149,7 +136,7 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iob iobCalc(long time, double dia) {
|
public Iob iobCalc(long time, double dia) {
|
||||||
InsulinInterface insulinInterface = MainApp.getInsulinIterfaceById(insulinType);
|
InsulinInterface insulinInterface = MainApp.getInsulinIterfaceById(insulinInterfaceID);
|
||||||
if (insulinInterface == null)
|
if (insulinInterface == null)
|
||||||
insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
insulinInterface = ConfigBuilderPlugin.getActiveInsulin();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 21.05.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface Interval {
|
||||||
|
long durationInMsec();
|
||||||
|
long start();
|
||||||
|
|
||||||
|
// planned end time at time of creation
|
||||||
|
long originalEnd();
|
||||||
|
|
||||||
|
// end time after cut
|
||||||
|
long end();
|
||||||
|
|
||||||
|
void cutEndTo(long end);
|
||||||
|
boolean match(long time);
|
||||||
|
boolean before(long time);
|
||||||
|
boolean after(long time);
|
||||||
|
}
|
|
@ -7,7 +7,6 @@ import org.json.JSONObject;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package info.nightscout.androidaps.interfaces;
|
package info.nightscout.androidaps.interfaces;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
|
||||||
|
@ -28,20 +27,20 @@ public interface TreatmentsInterface {
|
||||||
|
|
||||||
// real basals on pump
|
// real basals on pump
|
||||||
boolean isRealTempBasalInProgress();
|
boolean isRealTempBasalInProgress();
|
||||||
TempBasal getRealTempBasal (long time);
|
TempExBasal getRealTempBasal (long time);
|
||||||
|
|
||||||
void tempBasalStart(TempBasal tempBasal);
|
void tempBasalStart(TempExBasal tempBasal);
|
||||||
void tempBasalStop(long time);
|
void tempBasalStop(long time);
|
||||||
|
|
||||||
// basal that can be faked by extended boluses
|
// basal that can be faked by extended boluses
|
||||||
boolean isTempBasalInProgress();
|
boolean isTempBasalInProgress();
|
||||||
TempBasal getTempBasal (long time);
|
TempExBasal getTempBasal (long time);
|
||||||
double getTempBasalAbsoluteRate();
|
double getTempBasalAbsoluteRate();
|
||||||
double getTempBasalRemainingMinutes();
|
double getTempBasalRemainingMinutes();
|
||||||
|
|
||||||
boolean isExtendedBoluslInProgress();
|
boolean isExtendedBoluslInProgress();
|
||||||
TempBasal getExtendedBolus (long time);
|
TempExBasal getExtendedBolus (long time);
|
||||||
void extendedBolusStart(TempBasal extendedBolus);
|
void extendedBolusStart(TempExBasal extendedBolus);
|
||||||
void extendedBolusStop(long time);
|
void extendedBolusStop(long time);
|
||||||
|
|
||||||
long oldestDataAvaialable();
|
long oldestDataAvaialable();
|
||||||
|
|
|
@ -649,17 +649,16 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
TempTarget tempTarget = new TempTarget();
|
TempTarget tempTarget = new TempTarget();
|
||||||
tempTarget.timeStart = eventTime;
|
tempTarget.date = eventTime.getTime();
|
||||||
tempTarget.duration = data.getInt("duration");
|
tempTarget.durationInMinutes = data.getInt("duration");
|
||||||
tempTarget.reason = data.getString("reason");
|
tempTarget.reason = data.getString("reason");
|
||||||
if(tempTarget.duration != 0) {
|
if(tempTarget.durationInMinutes != 0) {
|
||||||
tempTarget.low = NSProfile.toMgdl(data.getDouble("targetBottom"), ConfigBuilderPlugin.getActiveProfile().getProfile().getUnits());
|
tempTarget.low = NSProfile.toMgdl(data.getDouble("targetBottom"), ConfigBuilderPlugin.getActiveProfile().getProfile().getUnits());
|
||||||
tempTarget.high = NSProfile.toMgdl(data.getDouble("targetTop"), ConfigBuilderPlugin.getActiveProfile().getProfile().getUnits());
|
tempTarget.high = NSProfile.toMgdl(data.getDouble("targetTop"), ConfigBuilderPlugin.getActiveProfile().getProfile().getUnits());
|
||||||
} else {
|
} else {
|
||||||
tempTarget.low = 0;
|
tempTarget.low = 0;
|
||||||
tempTarget.high = 0;
|
tempTarget.high = 0;
|
||||||
}
|
}
|
||||||
tempTarget.setTimeIndex(tempTarget.getTimeIndex());
|
|
||||||
Dao<TempTarget, Long> dao = MainApp.getDbHelper().getDaoTempTargets();
|
Dao<TempTarget, Long> dao = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
log.debug("Creating new TempTarget db record: " + tempTarget.log());
|
log.debug("Creating new TempTarget db record: " + tempTarget.log());
|
||||||
dao.createIfNotExists(tempTarget);
|
dao.createIfNotExists(tempTarget);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.Services.Intents;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventBolusRequested;
|
import info.nightscout.androidaps.events.EventBolusRequested;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -54,7 +54,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogr
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgError;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgError;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
|
||||||
import info.nightscout.utils.BatteryLevel;
|
import info.nightscout.utils.BatteryLevel;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -440,10 +439,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
t.insulin = result.bolusDelivered;
|
t.insulin = result.bolusDelivered;
|
||||||
if (carbTime == 0)
|
if (carbTime == 0)
|
||||||
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
|
t.carbs = (double) result.carbsDelivered; // with different carbTime record will come back from nightscout
|
||||||
t.created_at = new Date();
|
t.date = new Date().getDate();
|
||||||
t.mealBolus = result.carbsDelivered > 0;
|
t.mealBolus = result.carbsDelivered > 0;
|
||||||
MainApp.getDbHelper().create(t);
|
MainApp.getDbHelper().create(t);
|
||||||
t.setTimeIndex(t.getTimeIndex());
|
|
||||||
t.carbs = (double) result.carbsDelivered;
|
t.carbs = (double) result.carbsDelivered;
|
||||||
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
uploadBolusWizardRecord(t, glucose, glucoseType, carbTime, boluscalc);
|
||||||
}
|
}
|
||||||
|
@ -453,10 +451,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
Treatment t = new Treatment(insulinType);
|
Treatment t = new Treatment(insulinType);
|
||||||
t.insulin = insulin;
|
t.insulin = insulin;
|
||||||
t.carbs = (double) carbs;
|
t.carbs = (double) carbs;
|
||||||
t.created_at = new Date();
|
t.date = new Date().getDate();
|
||||||
t.mealBolus = t.carbs > 0;
|
t.mealBolus = t.carbs > 0;
|
||||||
MainApp.getDbHelper().create(t);
|
MainApp.getDbHelper().create(t);
|
||||||
t.setTimeIndex(t.getTimeIndex());
|
|
||||||
t.sendToNSClient();
|
t.sendToNSClient();
|
||||||
result = new PumpEnactResult();
|
result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -507,10 +504,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
Treatment t = new Treatment(insulinType);
|
Treatment t = new Treatment(insulinType);
|
||||||
t.insulin = result.bolusDelivered;
|
t.insulin = result.bolusDelivered;
|
||||||
t.carbs = (double) result.carbsDelivered;
|
t.carbs = (double) result.carbsDelivered;
|
||||||
t.created_at = new Date();
|
t.date = new Date().getDate();
|
||||||
t.mealBolus = t.carbs > 0;
|
t.mealBolus = t.carbs > 0;
|
||||||
MainApp.getDbHelper().create(t);
|
MainApp.getDbHelper().create(t);
|
||||||
t.setTimeIndex(t.getTimeIndex());
|
|
||||||
t.sendToNSClient();
|
t.sendToNSClient();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -519,10 +515,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
Treatment t = new Treatment(insulinType);
|
Treatment t = new Treatment(insulinType);
|
||||||
t.insulin = insulin;
|
t.insulin = insulin;
|
||||||
t.carbs = (double) carbs;
|
t.carbs = (double) carbs;
|
||||||
t.created_at = new Date();
|
t.date = new Date().getDate();
|
||||||
t.mealBolus = t.carbs > 0;
|
t.mealBolus = t.carbs > 0;
|
||||||
MainApp.getDbHelper().create(t);
|
MainApp.getDbHelper().create(t);
|
||||||
t.setTimeIndex(t.getTimeIndex());
|
|
||||||
t.sendToNSClient();
|
t.sendToNSClient();
|
||||||
result = new PumpEnactResult();
|
result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -1027,8 +1022,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
data.put("eventType", "Bolus Wizard");
|
data.put("eventType", "Bolus Wizard");
|
||||||
if (t.insulin != 0d) data.put("insulin", t.insulin);
|
if (t.insulin != 0d) data.put("insulin", t.insulin);
|
||||||
if (t.carbs != 0d) data.put("carbs", t.carbs.intValue());
|
if (t.carbs != 0d) data.put("carbs", t.carbs.intValue());
|
||||||
data.put("created_at", DateUtil.toISOString(t.created_at));
|
data.put("created_at", DateUtil.toISOString(t.date));
|
||||||
data.put("timeIndex", t.timeIndex);
|
data.put("date", t.date);
|
||||||
if (glucose != 0d) data.put("glucose", glucose);
|
if (glucose != 0d) data.put("glucose", glucose);
|
||||||
data.put("glucoseType", glucoseType);
|
data.put("glucoseType", glucoseType);
|
||||||
data.put("boluscalc", boluscalc);
|
data.put("boluscalc", boluscalc);
|
||||||
|
@ -1184,7 +1179,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getRealTempBasal(long time) {
|
public TempExBasal getRealTempBasal(long time) {
|
||||||
return activeTreatments.getRealTempBasal(time);
|
return activeTreatments.getRealTempBasal(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,7 +1189,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getTempBasal(long time) {
|
public TempExBasal getTempBasal(long time) {
|
||||||
return activeTreatments.getTempBasal(time);
|
return activeTreatments.getTempBasal(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,7 +1204,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tempBasalStart(TempBasal tempBasal) {
|
public void tempBasalStart(TempExBasal tempBasal) {
|
||||||
activeTreatments.tempBasalStart(tempBasal);
|
activeTreatments.tempBasalStart(tempBasal);
|
||||||
MainApp.bus().post(new EventTempBasalChange());
|
MainApp.bus().post(new EventTempBasalChange());
|
||||||
}
|
}
|
||||||
|
@ -1226,12 +1221,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getExtendedBolus(long time) {
|
public TempExBasal getExtendedBolus(long time) {
|
||||||
return activeTreatments.getExtendedBolus(time);
|
return activeTreatments.getExtendedBolus(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extendedBolusStart(TempBasal tempBasal) {
|
public void extendedBolusStart(TempExBasal tempBasal) {
|
||||||
activeTreatments.extendedBolusStart(tempBasal);
|
activeTreatments.extendedBolusStart(tempBasal);
|
||||||
MainApp.bus().post(new EventExtendedBolusChange());
|
MainApp.bus().post(new EventExtendedBolusChange());
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 21.04.2017.
|
* Created by mike on 21.04.2017.
|
||||||
|
@ -40,8 +39,7 @@ public class ActivityGraph extends GraphView {
|
||||||
int hours = (int) Math.floor(dia + 1);
|
int hours = (int) Math.floor(dia + 1);
|
||||||
|
|
||||||
Treatment t = new Treatment(insulin);
|
Treatment t = new Treatment(insulin);
|
||||||
t.created_at = new Date(0);
|
t.date = 0;
|
||||||
t.timeIndex = 0;
|
|
||||||
t.insulin = 1d;
|
t.insulin = 1d;
|
||||||
|
|
||||||
LineGraphSeries<DataPoint> activitySeries = null;
|
LineGraphSeries<DataPoint> activitySeries = null;
|
||||||
|
|
|
@ -103,22 +103,22 @@ public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
|
||||||
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
|
public Iob iobCalcForTreatment(Treatment treatment, long time, Double dia) {
|
||||||
Iob result = new Iob();
|
Iob result = new Iob();
|
||||||
|
|
||||||
Double scaleFactor = 3.0 / dia;
|
double scaleFactor = 3.0 / dia;
|
||||||
Double peak = 75d;
|
double peak = 75d;
|
||||||
Double end = 180d;
|
double end = 180d;
|
||||||
|
|
||||||
if (treatment.insulin != 0d) {
|
if (treatment.insulin != 0d) {
|
||||||
Long bolusTime = treatment.created_at.getTime();
|
long bolusTime = treatment.date;
|
||||||
Double minAgo = scaleFactor * (time - bolusTime) / 1000d / 60d;
|
double minAgo = scaleFactor * (time - bolusTime) / 1000d / 60d;
|
||||||
|
|
||||||
if (minAgo < peak) {
|
if (minAgo < peak) {
|
||||||
Double x1 = minAgo / 5d + 1;
|
double x1 = minAgo / 5d + 1;
|
||||||
result.iobContrib = treatment.insulin * (1 - 0.001852 * x1 * x1 + 0.001852 * x1);
|
result.iobContrib = treatment.insulin * (1 - 0.001852 * x1 * x1 + 0.001852 * x1);
|
||||||
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
|
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
|
||||||
result.activityContrib = treatment.insulin * (2 / dia / 60 / peak) * minAgo;
|
result.activityContrib = treatment.insulin * (2 / dia / 60 / peak) * minAgo;
|
||||||
|
|
||||||
} else if (minAgo < end) {
|
} else if (minAgo < end) {
|
||||||
Double x2 = (minAgo - 75) / 5;
|
double x2 = (minAgo - 75) / 5;
|
||||||
result.iobContrib = treatment.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556);
|
result.iobContrib = treatment.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556);
|
||||||
result.activityContrib = treatment.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
|
result.activityContrib = treatment.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,26 +104,26 @@ public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInte
|
||||||
Iob result = new Iob();
|
Iob result = new Iob();
|
||||||
|
|
||||||
//Double scaleFactor = 3.0 / dia;
|
//Double scaleFactor = 3.0 / dia;
|
||||||
Double peak = 75d * dia / 6.0;
|
double peak = 75d * dia / 6.0;
|
||||||
Double tail = 180d * dia / 6.0;
|
double tail = 180d * dia / 6.0;
|
||||||
Double end = 360d * dia / 6.0;
|
double end = 360d * dia / 6.0;
|
||||||
Double Total = 2 * peak + (tail - peak) * 5 / 2 + (end - tail) / 2;
|
double Total = 2 * peak + (tail - peak) * 5 / 2 + (end - tail) / 2;
|
||||||
|
|
||||||
if (treatment.insulin != 0d) {
|
if (treatment.insulin != 0d) {
|
||||||
Long bolusTime = treatment.created_at.getTime();
|
long bolusTime = treatment.date;
|
||||||
Double minAgo = (time - bolusTime) / 1000d / 60d;
|
double minAgo = (time - bolusTime) / 1000d / 60d;
|
||||||
|
|
||||||
if (minAgo < peak) {
|
if (minAgo < peak) {
|
||||||
Double x1 = 6 / dia * minAgo / 5d + 1;
|
double x1 = 6 / dia * minAgo / 5d + 1;
|
||||||
result.iobContrib = treatment.insulin * (1 - 0.0012595 * x1 * x1 + 0.0012595 * x1);
|
result.iobContrib = treatment.insulin * (1 - 0.0012595 * x1 * x1 + 0.0012595 * x1);
|
||||||
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
|
// units: BG (mg/dL) = (BG/U) * U insulin * scalar
|
||||||
result.activityContrib = treatment.insulin * ((2 * peak / Total) * 2 / peak / peak * minAgo);
|
result.activityContrib = treatment.insulin * ((2 * peak / Total) * 2 / peak / peak * minAgo);
|
||||||
} else if (minAgo < tail) {
|
} else if (minAgo < tail) {
|
||||||
Double x2 = (6 / dia * (minAgo - peak)) / 5;
|
double x2 = (6 / dia * (minAgo - peak)) / 5;
|
||||||
result.iobContrib = treatment.insulin * (0.00074 * x2 * x2 - 0.0403 * x2 + 0.69772);
|
result.iobContrib = treatment.insulin * (0.00074 * x2 * x2 - 0.0403 * x2 + 0.69772);
|
||||||
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 3 / 4) / (tail - peak) * (minAgo - peak) + (2 * peak / Total) * 2 / peak);
|
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 3 / 4) / (tail - peak) * (minAgo - peak) + (2 * peak / Total) * 2 / peak);
|
||||||
} else if (minAgo < end) {
|
} else if (minAgo < end) {
|
||||||
Double x3 = (6 / dia * (minAgo - tail)) / 5;
|
double x3 = (6 / dia * (minAgo - tail)) / 5;
|
||||||
result.iobContrib = treatment.insulin * (0.0001323 * x3 * x3 - 0.0097 * x3 + 0.17776);
|
result.iobContrib = treatment.insulin * (0.0001323 * x3 * x3 - 0.0097 * x3 + 0.17776);
|
||||||
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 1 / 4) / (end - tail) * (minAgo - tail) + (2 * peak / Total) * 2 / peak / 4);
|
result.activityContrib = treatment.insulin * (-((2 * peak / Total) * 2 / peak * 1 / 4) / (end - tail) * (minAgo - tail) + (2 * peak / Total) * 2 / peak / 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||||
|
@ -139,7 +138,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
|
|
||||||
private static int indexNewerThan(long time) {
|
private static int indexNewerThan(long time) {
|
||||||
for (int index = 0; index < bucketed_data.size(); index++) {
|
for (int index = 0; index < bucketed_data.size(); index++) {
|
||||||
if (bucketed_data.get(index).timeIndex < time)
|
if (bucketed_data.get(index).date < time)
|
||||||
return index - 1;
|
return index - 1;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -174,8 +173,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
bucketed_data.add(bgReadings.get(0));
|
bucketed_data.add(bgReadings.get(0));
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 1; i < bgReadings.size(); ++i) {
|
for (int i = 1; i < bgReadings.size(); ++i) {
|
||||||
long bgTime = bgReadings.get(i).getTimeIndex();
|
long bgTime = bgReadings.get(i).date;
|
||||||
long lastbgTime = bgReadings.get(i - 1).getTimeIndex();
|
long lastbgTime = bgReadings.get(i - 1).date;
|
||||||
//log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value + " Previous: " + new Date(lastbgTime).toString() + " " + bgReadings.get(i - 1).value);
|
//log.error("Processing " + i + ": " + new Date(bgTime).toString() + " " + bgReadings.get(i).value + " Previous: " + new Date(lastbgTime).toString() + " " + bgReadings.get(i - 1).value);
|
||||||
if (bgReadings.get(i).value < 39 || bgReadings.get(i - 1).value < 39) {
|
if (bgReadings.get(i).value < 39 || bgReadings.get(i - 1).value < 39) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -192,14 +191,14 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
nextbgTime = lastbgTime - 5 * 60 * 1000;
|
nextbgTime = lastbgTime - 5 * 60 * 1000;
|
||||||
j++;
|
j++;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.timeIndex = nextbgTime;
|
newBgreading.date = nextbgTime;
|
||||||
double gapDelta = bgReadings.get(i).value - lastbg;
|
double gapDelta = bgReadings.get(i).value - lastbg;
|
||||||
//console.error(gapDelta, lastbg, elapsed_minutes);
|
//console.error(gapDelta, lastbg, elapsed_minutes);
|
||||||
double nextbg = lastbg + (5d / elapsed_minutes * gapDelta);
|
double nextbg = lastbg + (5d / elapsed_minutes * gapDelta);
|
||||||
newBgreading.value = Math.round(nextbg);
|
newBgreading.value = Math.round(nextbg);
|
||||||
//console.error("Interpolated", bucketed_data[j]);
|
//console.error("Interpolated", bucketed_data[j]);
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
//log.error("******************************************************************************************************* Adding:" + new Date(newBgreading.timeIndex).toString() + " " + newBgreading.value);
|
//log.error("******************************************************************************************************* Adding:" + new Date(newBgreading.date).toString() + " " + newBgreading.value);
|
||||||
|
|
||||||
elapsed_minutes = elapsed_minutes - 5;
|
elapsed_minutes = elapsed_minutes - 5;
|
||||||
lastbg = nextbg;
|
lastbg = nextbg;
|
||||||
|
@ -208,16 +207,16 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
j++;
|
j++;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.value = bgReadings.get(i).value;
|
newBgreading.value = bgReadings.get(i).value;
|
||||||
newBgreading.timeIndex = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
//log.error("******************************************************************************************************* Copying:" + new Date(newBgreading.timeIndex).toString() + " " + newBgreading.value);
|
//log.error("******************************************************************************************************* Copying:" + new Date(newBgreading.date).toString() + " " + newBgreading.value);
|
||||||
} else if (Math.abs(elapsed_minutes) > 2) {
|
} else if (Math.abs(elapsed_minutes) > 2) {
|
||||||
j++;
|
j++;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.value = bgReadings.get(i).value;
|
newBgreading.value = bgReadings.get(i).value;
|
||||||
newBgreading.timeIndex = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
//log.error("******************************************************************************************************* Copying:" + new Date(newBgreading.timeIndex).toString() + " " + newBgreading.value);
|
//log.error("******************************************************************************************************* Copying:" + new Date(newBgreading.date).toString() + " " + newBgreading.value);
|
||||||
} else {
|
} else {
|
||||||
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
||||||
//log.error("***** Average");
|
//log.error("***** Average");
|
||||||
|
@ -243,13 +242,13 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long prevDataTime = roundUpTime(bucketed_data.get(bucketed_data.size() - 3).timeIndex);
|
long prevDataTime = roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date);
|
||||||
log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString());
|
log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString());
|
||||||
AutosensData previous = autosensDataTable.get(prevDataTime);
|
AutosensData previous = autosensDataTable.get(prevDataTime);
|
||||||
// start from oldest to be able sub cob
|
// start from oldest to be able sub cob
|
||||||
for (int i = bucketed_data.size() - 4; i >= 0; i--) {
|
for (int i = bucketed_data.size() - 4; i >= 0; i--) {
|
||||||
// check if data already exists
|
// check if data already exists
|
||||||
long bgTime = bucketed_data.get(i).timeIndex;
|
long bgTime = bucketed_data.get(i).date;
|
||||||
bgTime = roundUpTime(bgTime);
|
bgTime = roundUpTime(bgTime);
|
||||||
|
|
||||||
AutosensData existing;
|
AutosensData existing;
|
||||||
|
@ -350,8 +349,8 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
if (bucketed_data == null)
|
if (bucketed_data == null)
|
||||||
return null;
|
return null;
|
||||||
for (int index = 0; index < bucketed_data.size(); index++) {
|
for (int index = 0; index < bucketed_data.size(); index++) {
|
||||||
if (bucketed_data.get(index).timeIndex < time)
|
if (bucketed_data.get(index).date < time)
|
||||||
return bucketed_data.get(index).timeIndex;
|
return bucketed_data.get(index).date;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
|
@ -232,7 +232,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||||
|
|
||||||
// as we have non default temps longer than 30 mintues
|
// as we have non default temps longer than 30 mintues
|
||||||
TempBasal tempBasal = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
TempExBasal tempBasal = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||||
if(tempBasal != null){
|
if(tempBasal != null){
|
||||||
mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration());
|
mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
package info.nightscout.androidaps.plugins.OpenAPSAMA;
|
||||||
|
|
||||||
import android.os.Parcel;
|
|
||||||
import android.os.Parcelable;
|
|
||||||
|
|
||||||
import com.eclipsesource.v8.V8Object;
|
import com.eclipsesource.v8.V8Object;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -102,7 +99,7 @@ public class DetermineBasalResultAMA extends APSResult {
|
||||||
for (int i = 1; i < iob.length(); i ++) {
|
for (int i = 1; i < iob.length(); i ++) {
|
||||||
BgReading bg = new BgReading();
|
BgReading bg = new BgReading();
|
||||||
bg.value = iob.getInt(i);
|
bg.value = iob.getInt(i);
|
||||||
bg.timeIndex = startTime + i * 5 * 60 * 1000L;
|
bg.date = startTime + i * 5 * 60 * 1000L;
|
||||||
array.add(bg);
|
array.add(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +108,7 @@ public class DetermineBasalResultAMA extends APSResult {
|
||||||
for (int i = 1; i < iob.length(); i ++) {
|
for (int i = 1; i < iob.length(); i ++) {
|
||||||
BgReading bg = new BgReading();
|
BgReading bg = new BgReading();
|
||||||
bg.value = iob.getInt(i);
|
bg.value = iob.getInt(i);
|
||||||
bg.timeIndex = startTime + i * 5 * 60 * 1000L;
|
bg.date = startTime + i * 5 * 60 * 1000L;
|
||||||
array.add(bg);
|
array.add(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,7 +117,7 @@ public class DetermineBasalResultAMA extends APSResult {
|
||||||
for (int i = 1; i < iob.length(); i ++) {
|
for (int i = 1; i < iob.length(); i ++) {
|
||||||
BgReading bg = new BgReading();
|
BgReading bg = new BgReading();
|
||||||
bg.value = iob.getInt(i);
|
bg.value = iob.getInt(i);
|
||||||
bg.timeIndex = startTime + i * 5 * 60 * 1000L;
|
bg.date = startTime + i * 5 * 60 * 1000L;
|
||||||
array.add(bg);
|
array.add(bg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -897,7 +897,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
calibrationButton.setVisibility(View.GONE);
|
calibrationButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TempBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
TempExBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||||
cancelTempButton.setVisibility(View.VISIBLE);
|
cancelTempButton.setVisibility(View.VISIBLE);
|
||||||
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
|
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
|
||||||
|
@ -1007,7 +1007,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
flag &= ~Paint.STRIKE_THRU_TEXT_FLAG;
|
flag &= ~Paint.STRIKE_THRU_TEXT_FLAG;
|
||||||
bgView.setPaintFlags(flag);
|
bgView.setPaintFlags(flag);
|
||||||
|
|
||||||
Long agoMsec = new Date().getTime() - lastBG.timeIndex;
|
Long agoMsec = new Date().getTime() - lastBG.date;
|
||||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||||
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
|
timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
|
||||||
|
|
||||||
|
@ -1083,7 +1083,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
double lastBaseBasal = 0;
|
double lastBaseBasal = 0;
|
||||||
double lastTempBasal = 0;
|
double lastTempBasal = 0;
|
||||||
for (long time = fromTime; time < now; time += 5 * 60 * 1000L) {
|
for (long time = fromTime; time < now; time += 5 * 60 * 1000L) {
|
||||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(time);
|
TempExBasal tb = MainApp.getConfigBuilder().getTempBasal(time);
|
||||||
double baseBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time)));
|
double baseBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time)));
|
||||||
double baseLineValue = baseBasalValue;
|
double baseLineValue = baseBasalValue;
|
||||||
double tempBasalValue = 0;
|
double tempBasalValue = 0;
|
||||||
|
@ -1377,7 +1377,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
for (int tx = 0; tx < treatments.size(); tx++) {
|
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||||
Treatment t = treatments.get(tx);
|
Treatment t = treatments.get(tx);
|
||||||
if (t.getTimeIndex() < fromTime || t.getTimeIndex() > now) continue;
|
if (t.date < fromTime || t.date > now) continue;
|
||||||
t.setYValue(bgReadingsArray);
|
t.setYValue(bgReadingsArray);
|
||||||
filteredTreatments.add(t);
|
filteredTreatments.add(t);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
|
@ -31,7 +31,6 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ public class PersistentNotificationPlugin implements PluginBase{
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||||
TempBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
TempExBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||||
line1 += " " + activeTemp.toStringShort();
|
line1 += " " + activeTemp.toStringShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -35,7 +35,6 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||||
|
@ -671,7 +670,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
||||||
extended.put("PumpIOB", getDanaRPump().iob);
|
extended.put("PumpIOB", getDanaRPump().iob);
|
||||||
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
|
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
|
||||||
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
TempExBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||||
|
|
|
@ -273,12 +273,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
||||||
DanaRHistoryRecord record = historyList.get(position);
|
DanaRHistoryRecord record = historyList.get(position);
|
||||||
holder.time.setText(DateUtil.dateAndTimeString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateAndTimeString(record.recordDate));
|
||||||
holder.value.setText(DecimalFormatter.to2Decimal(record.getRecordValue()));
|
holder.value.setText(DecimalFormatter.to2Decimal(record.recordValue));
|
||||||
holder.stringvalue.setText(record.getStringRecordValue());
|
holder.stringvalue.setText(record.stringRecordValue);
|
||||||
holder.bolustype.setText(record.getBolusType());
|
holder.bolustype.setText(record.bolusType);
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(record.getRecordDuration()));
|
holder.duration.setText(DecimalFormatter.to0Decimal(record.recordDuration));
|
||||||
holder.alarm.setText(record.getRecordAlarm());
|
holder.alarm.setText(record.recordAlarm);
|
||||||
switch (showingType) {
|
switch (showingType) {
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
|
@ -303,10 +303,10 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + "U");
|
||||||
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + "U");
|
||||||
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus() + record.getRecordDailyBasal()) + "U");
|
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus + record.recordDailyBasal) + "U");
|
||||||
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateString(record.recordDate));
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
holder.value.setVisibility(View.GONE);
|
holder.value.setVisibility(View.GONE);
|
||||||
holder.stringvalue.setVisibility(View.GONE);
|
holder.stringvalue.setVisibility(View.GONE);
|
||||||
|
@ -318,7 +318,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
holder.value.setText(NSProfile.toUnitsString(record.getRecordValue(), record.getRecordValue() * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
holder.value.setText(NSProfile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
||||||
// rest is the same
|
// rest is the same
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
|
|
|
@ -58,69 +58,69 @@ public class DanaRNSHistorySync {
|
||||||
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
|
EventDanaRSyncStatus ev = new EventDanaRSyncStatus();
|
||||||
for (DanaRHistoryRecord record : historyRecords) {
|
for (DanaRHistoryRecord record : historyRecords) {
|
||||||
processing++;
|
processing++;
|
||||||
if (record.get_id() != null) continue;
|
if (record._id != null) continue;
|
||||||
//log.debug(record.getBytes());
|
//log.debug(record.bytes);
|
||||||
JSONObject nsrec = new JSONObject();
|
JSONObject nsrec = new JSONObject();
|
||||||
ev.message = MainApp.sResources.getString(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations
|
ev.message = MainApp.sResources.getString(R.string.uploading) + " " + processing + "/" + records + " "; // TODO: translations
|
||||||
switch (record.getRecordCode()) {
|
switch (record.recordCode) {
|
||||||
case RecordTypes.RECORD_TYPE_BOLUS:
|
case RecordTypes.RECORD_TYPE_BOLUS:
|
||||||
if ((what & SYNC_BOLUS) == 0) break;
|
if ((what & SYNC_BOLUS) == 0) break;
|
||||||
switch (record.getBolusType()) {
|
switch (record.bolusType) {
|
||||||
case "S":
|
case "S":
|
||||||
log.debug("Syncing standard bolus record " + record.getRecordValue() + "U " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing standard bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Meal Bolus");
|
nsrec.put("eventType", "Meal Bolus");
|
||||||
nsrec.put("insulin", record.getRecordValue());
|
nsrec.put("insulin", record.recordValue);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
ev.message += MainApp.sResources.getString(R.string.danar_sbolus);
|
ev.message += MainApp.sResources.getString(R.string.danar_sbolus);
|
||||||
break;
|
break;
|
||||||
case "E":
|
case "E":
|
||||||
if (record.getRecordDuration() > 0) {
|
if (record.recordDuration > 0) {
|
||||||
log.debug("Syncing extended bolus record " + record.getRecordValue() + "U " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Combo Bolus");
|
nsrec.put("eventType", "Combo Bolus");
|
||||||
nsrec.put("insulin", 0);
|
nsrec.put("insulin", 0);
|
||||||
nsrec.put("duration", record.getRecordDuration());
|
nsrec.put("duration", record.recordDuration);
|
||||||
nsrec.put("relative", record.getRecordValue() / record.getRecordDuration() * 60);
|
nsrec.put("relative", record.recordValue / record.recordDuration * 60);
|
||||||
nsrec.put("splitNow", 0);
|
nsrec.put("splitNow", 0);
|
||||||
nsrec.put("splitExt", 100);
|
nsrec.put("splitExt", 100);
|
||||||
cal.setTimeInMillis(record.getRecordDate());
|
cal.setTimeInMillis(record.recordDate);
|
||||||
cal.add(Calendar.MINUTE, -1 * record.getRecordDuration());
|
cal.add(Calendar.MINUTE, -1 * record.recordDuration);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
|
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
ev.message += MainApp.sResources.getString(R.string.danar_ebolus);
|
ev.message += MainApp.sResources.getString(R.string.danar_ebolus);
|
||||||
} else {
|
} else {
|
||||||
log.debug("NOT Syncing extended bolus record " + record.getRecordValue() + "U " + DateUtil.toISOString(record.getRecordDate()) + " zero duration");
|
log.debug("NOT Syncing extended bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate) + " zero duration");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "DS":
|
case "DS":
|
||||||
log.debug("Syncing dual(S) bolus record " + record.getRecordValue() + "U " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing dual(S) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Combo Bolus");
|
nsrec.put("eventType", "Combo Bolus");
|
||||||
nsrec.put("insulin", record.getRecordValue());
|
nsrec.put("insulin", record.recordValue);
|
||||||
nsrec.put("splitNow", 100);
|
nsrec.put("splitNow", 100);
|
||||||
nsrec.put("splitExt", 0);
|
nsrec.put("splitExt", 0);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
ev.message += MainApp.sResources.getString(R.string.danar_dsbolus);
|
ev.message += MainApp.sResources.getString(R.string.danar_dsbolus);
|
||||||
break;
|
break;
|
||||||
case "DE":
|
case "DE":
|
||||||
log.debug("Syncing dual(E) bolus record " + record.getRecordValue() + "U " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing dual(E) bolus record " + record.recordValue + "U " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Combo Bolus");
|
nsrec.put("eventType", "Combo Bolus");
|
||||||
nsrec.put("duration", record.getRecordDuration());
|
nsrec.put("duration", record.recordDuration);
|
||||||
nsrec.put("relative", record.getRecordValue() / record.getRecordDuration() * 60);
|
nsrec.put("relative", record.recordValue / record.recordDuration * 60);
|
||||||
nsrec.put("splitNow", 0);
|
nsrec.put("splitNow", 0);
|
||||||
nsrec.put("splitExt", 100);
|
nsrec.put("splitExt", 100);
|
||||||
cal.setTimeInMillis(record.getRecordDate());
|
cal.setTimeInMillis(record.recordDate);
|
||||||
cal.add(Calendar.MINUTE, -1 * record.getRecordDuration());
|
cal.add(Calendar.MINUTE, -1 * record.recordDuration);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
|
nsrec.put("created_at", DateUtil.toISOString(cal.getTime()));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
|
@ -134,11 +134,11 @@ public class DanaRNSHistorySync {
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_ERROR:
|
case RecordTypes.RECORD_TYPE_ERROR:
|
||||||
if ((what & SYNC_ERROR) == 0) break;
|
if ((what & SYNC_ERROR) == 0) break;
|
||||||
log.debug("Syncing error record " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing error record " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Note");
|
nsrec.put("eventType", "Note");
|
||||||
nsrec.put("notes", "Error");
|
nsrec.put("notes", "Error");
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
|
@ -146,11 +146,11 @@ public class DanaRNSHistorySync {
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_REFILL:
|
case RecordTypes.RECORD_TYPE_REFILL:
|
||||||
if ((what & SYNC_REFILL) == 0) break;
|
if ((what & SYNC_REFILL) == 0) break;
|
||||||
log.debug("Syncing refill record " + record.getRecordValue() + " " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing refill record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Insulin Change");
|
nsrec.put("eventType", "Insulin Change");
|
||||||
nsrec.put("notes", "Refill " + record.getRecordValue() + "U");
|
nsrec.put("notes", "Refill " + record.recordValue + "U");
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
|
@ -158,28 +158,28 @@ public class DanaRNSHistorySync {
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
if ((what & SYNC_BASALHOURS) == 0) break;
|
if ((what & SYNC_BASALHOURS) == 0) break;
|
||||||
log.debug("Syncing basal hour record " + record.getRecordValue() + " " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing basal hour record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Temp Basal");
|
nsrec.put("eventType", "Temp Basal");
|
||||||
nsrec.put("absolute", record.getRecordValue());
|
nsrec.put("absolute", record.recordValue);
|
||||||
nsrec.put("duration", 60);
|
nsrec.put("duration", 60);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
ev.message += MainApp.sResources.getString(R.string.danar_basalhour);
|
ev.message += MainApp.sResources.getString(R.string.danar_basalhour);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_TB:
|
case RecordTypes.RECORD_TYPE_TB:
|
||||||
//log.debug("Ignoring TB record " + record.getBytes() + " " + DateUtil.toISOString(record.getRecordDate()));
|
//log.debug("Ignoring TB record " + record.bytes + " " + DateUtil.toISOString(record.recordDate));
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
if ((what & SYNC_GLUCOSE) == 0) break;
|
if ((what & SYNC_GLUCOSE) == 0) break;
|
||||||
log.debug("Syncing glucose record " + record.getRecordValue() + " " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "BG Check");
|
nsrec.put("eventType", "BG Check");
|
||||||
nsrec.put("glucose", NSProfile.fromMgdlToUnits(record.getRecordValue(), profile.getUnits()));
|
nsrec.put("glucose", NSProfile.fromMgdlToUnits(record.recordValue, profile.getUnits()));
|
||||||
nsrec.put("glucoseType", "Finger");
|
nsrec.put("glucoseType", "Finger");
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
|
@ -187,11 +187,11 @@ public class DanaRNSHistorySync {
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
if ((what & SYNC_CARBO) == 0) break;
|
if ((what & SYNC_CARBO) == 0) break;
|
||||||
log.debug("Syncing carbo record " + record.getRecordValue() + "g " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing carbo record " + record.recordValue + "g " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Meal Bolus");
|
nsrec.put("eventType", "Meal Bolus");
|
||||||
nsrec.put("carbs", record.getRecordValue());
|
nsrec.put("carbs", record.recordValue);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
|
@ -199,11 +199,11 @@ public class DanaRNSHistorySync {
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
if ((what & SYNC_ALARM) == 0) break;
|
if ((what & SYNC_ALARM) == 0) break;
|
||||||
log.debug("Syncing alarm record " + record.getRecordAlarm() + " " + DateUtil.toISOString(record.getRecordDate()));
|
log.debug("Syncing alarm record " + record.recordAlarm + " " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.getBytes());
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "Note");
|
nsrec.put("eventType", "Note");
|
||||||
nsrec.put("notes", "Alarm: " + record.getRecordAlarm());
|
nsrec.put("notes", "Alarm: " + record.recordAlarm);
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.getRecordDate()));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", MainApp.sResources.getString(R.string.app_name));
|
||||||
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
ConfigBuilderPlugin.uploadCareportalEntryToNS(nsrec);
|
||||||
uploaded++;
|
uploaded++;
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
double weighted07 = 0d;
|
double weighted07 = 0d;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
|
|
||||||
// Create the table row
|
// Create the table row
|
||||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
@ -392,19 +392,19 @@ public class DanaRStatsActivity extends Activity {
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
labelDATE.setId(200 + i);
|
labelDATE.setId(200 + i);
|
||||||
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
labelDATE.setText(df.format(new Date(record.recordDate)));
|
||||||
labelDATE.setTextColor(Color.WHITE);
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelDATE);
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
labelBASAL.setId(300 + i);
|
labelBASAL.setId(300 + i);
|
||||||
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + " U");
|
||||||
labelBASAL.setTextColor(Color.WHITE);
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBASAL);
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
labelBOLUS.setId(400 + i);
|
labelBOLUS.setId(400 + i);
|
||||||
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + " U");
|
||||||
labelBOLUS.setTextColor(Color.WHITE);
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBOLUS);
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).recordDate)).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
weighted03 = tdd;
|
weighted03 = tdd;
|
||||||
weighted05 = tdd;
|
weighted05 = tdd;
|
||||||
|
|
|
@ -39,82 +39,82 @@ public class MsgHistoryAll extends MessageBase {
|
||||||
|
|
||||||
DanaRHistoryRecord danaRHistoryRecord = new DanaRHistoryRecord();
|
DanaRHistoryRecord danaRHistoryRecord = new DanaRHistoryRecord();
|
||||||
|
|
||||||
danaRHistoryRecord.setRecordCode(recordCode);
|
danaRHistoryRecord.recordCode = recordCode;
|
||||||
danaRHistoryRecord.setBytes(bytes);
|
danaRHistoryRecord.setBytes(bytes);
|
||||||
|
|
||||||
String messageType = "";
|
String messageType = "";
|
||||||
|
|
||||||
switch (recordCode) {
|
switch (recordCode) {
|
||||||
case RecordTypes.RECORD_TYPE_BOLUS:
|
case RecordTypes.RECORD_TYPE_BOLUS:
|
||||||
danaRHistoryRecord.setRecordDate(datetime);
|
danaRHistoryRecord.recordDate = datetime.getTime();
|
||||||
switch (0xF0 & paramByte8) {
|
switch (0xF0 & paramByte8) {
|
||||||
case 0xA0:
|
case 0xA0:
|
||||||
danaRHistoryRecord.setBolusType("DS");
|
danaRHistoryRecord.bolusType = "DS";
|
||||||
messageType += "DS bolus";
|
messageType += "DS bolus";
|
||||||
break;
|
break;
|
||||||
case 0xC0:
|
case 0xC0:
|
||||||
danaRHistoryRecord.setBolusType("E");
|
danaRHistoryRecord.bolusType = "E";
|
||||||
messageType += "E bolus";
|
messageType += "E bolus";
|
||||||
break;
|
break;
|
||||||
case 0x80:
|
case 0x80:
|
||||||
danaRHistoryRecord.setBolusType("S");
|
danaRHistoryRecord.bolusType = "S";
|
||||||
messageType += "S bolus";
|
messageType += "S bolus";
|
||||||
break;
|
break;
|
||||||
case 0x90:
|
case 0x90:
|
||||||
danaRHistoryRecord.setBolusType("DE");
|
danaRHistoryRecord.bolusType = "DE";
|
||||||
messageType += "DE bolus";
|
messageType += "DE bolus";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
danaRHistoryRecord.setBolusType("None");
|
danaRHistoryRecord.bolusType = "None";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
danaRHistoryRecord.setRecordDuration(((int) paramByte8 & 0x0F) * 60 + (int) paramByte7);
|
danaRHistoryRecord.recordDuration = ((int) paramByte8 & 0x0F) * 60 + (int) paramByte7;
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
messageType += "dailyinsulin";
|
messageType += "dailyinsulin";
|
||||||
danaRHistoryRecord.setRecordDate(date);
|
danaRHistoryRecord.recordDate = date.getTime();
|
||||||
danaRHistoryRecord.setRecordDailyBasal(dailyBasal);
|
danaRHistoryRecord.recordDailyBasal = dailyBasal;
|
||||||
danaRHistoryRecord.setRecordDailyBolus(dailyBolus);
|
danaRHistoryRecord.recordDailyBolus = dailyBolus;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_PRIME:
|
case RecordTypes.RECORD_TYPE_PRIME:
|
||||||
messageType += "prime";
|
messageType += "prime";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_ERROR:
|
case RecordTypes.RECORD_TYPE_ERROR:
|
||||||
messageType += "error";
|
messageType += "error";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_REFILL:
|
case RecordTypes.RECORD_TYPE_REFILL:
|
||||||
messageType += "refill";
|
messageType += "refill";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
messageType += "basal hour";
|
messageType += "basal hour";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_TB:
|
case RecordTypes.RECORD_TYPE_TB:
|
||||||
messageType += "tb";
|
messageType += "tb";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
messageType += "glucose";
|
messageType += "glucose";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value);
|
danaRHistoryRecord.recordValue = value;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
messageType += "carbo";
|
messageType += "carbo";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
danaRHistoryRecord.setRecordValue(value);
|
danaRHistoryRecord.recordValue = value;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
messageType += "alarm";
|
messageType += "alarm";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
String strAlarm = "None";
|
String strAlarm = "None";
|
||||||
switch ((int) paramByte8) {
|
switch ((int) paramByte8) {
|
||||||
case 67:
|
case 67:
|
||||||
|
@ -130,16 +130,16 @@ public class MsgHistoryAll extends MessageBase {
|
||||||
strAlarm = "Shutdown";
|
strAlarm = "Shutdown";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
danaRHistoryRecord.setRecordAlarm(strAlarm);
|
danaRHistoryRecord.recordAlarm = strAlarm;
|
||||||
danaRHistoryRecord.setRecordValue(value * 0.01);
|
danaRHistoryRecord.recordValue = value * 0.01;
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_SUSPEND:
|
case RecordTypes.RECORD_TYPE_SUSPEND:
|
||||||
messageType += "suspend";
|
messageType += "suspend";
|
||||||
danaRHistoryRecord.setRecordDate(datetimewihtsec);
|
danaRHistoryRecord.recordDate = datetimewihtsec.getTime();
|
||||||
String strRecordValue = "Off";
|
String strRecordValue = "Off";
|
||||||
if ((int) paramByte8 == 79)
|
if ((int) paramByte8 == 79)
|
||||||
strRecordValue = "On";
|
strRecordValue = "On";
|
||||||
danaRHistoryRecord.setStringRecordValue(strRecordValue);
|
danaRHistoryRecord.stringRecordValue = strRecordValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class MsgHistoryAll extends MessageBase {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ev.message = DateUtil.dateAndTimeString(danaRHistoryRecord.getRecordDate());
|
ev.message = DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate);
|
||||||
ev.message += " " + messageType;
|
ev.message += " " + messageType;
|
||||||
MainApp.bus().post(ev);
|
MainApp.bus().post(ev);
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
|
||||||
|
@ -69,13 +69,13 @@ public class MsgStatusBolusExtended extends MessageBase {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
|
|
||||||
if (treatmentsInterface.isExtendedBoluslInProgress()) {
|
if (treatmentsInterface.isExtendedBoluslInProgress()) {
|
||||||
TempBasal extendedBolus = treatmentsInterface.getExtendedBolus(new Date().getTime());
|
TempExBasal extendedBolus = treatmentsInterface.getExtendedBolus(new Date().getTime());
|
||||||
if (pump.isExtendedInProgress) {
|
if (pump.isExtendedInProgress) {
|
||||||
if (extendedBolus.absolute != pump.extendedBolusAbsoluteRate) {
|
if (extendedBolus.absolute != pump.extendedBolusAbsoluteRate) {
|
||||||
// Close current extended
|
// Close current extended
|
||||||
treatmentsInterface.extendedBolusStop(now);
|
treatmentsInterface.extendedBolusStop(now);
|
||||||
// Create new
|
// Create new
|
||||||
TempBasal newExtended = new TempBasal();
|
TempExBasal newExtended = new TempExBasal();
|
||||||
newExtended.timeStart = new Date(now);
|
newExtended.timeStart = new Date(now);
|
||||||
newExtended.absolute = pump.extendedBolusAbsoluteRate;
|
newExtended.absolute = pump.extendedBolusAbsoluteRate;
|
||||||
newExtended.isAbsolute = true;
|
newExtended.isAbsolute = true;
|
||||||
|
@ -90,7 +90,7 @@ public class MsgStatusBolusExtended extends MessageBase {
|
||||||
} else {
|
} else {
|
||||||
if (pump.isExtendedInProgress) {
|
if (pump.isExtendedInProgress) {
|
||||||
// Create new
|
// Create new
|
||||||
TempBasal newExtended = new TempBasal();
|
TempExBasal newExtended = new TempExBasal();
|
||||||
newExtended.timeStart = new Date(now);
|
newExtended.timeStart = new Date(now);
|
||||||
newExtended.absolute = pump.extendedBolusAbsoluteRate;
|
newExtended.absolute = pump.extendedBolusAbsoluteRate;
|
||||||
newExtended.isAbsolute = true;
|
newExtended.isAbsolute = true;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
|
||||||
|
@ -63,13 +63,13 @@ public class MsgStatusTempBasal extends MessageBase {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
|
|
||||||
if (treatmentsInterface.isTempBasalInProgress()) {
|
if (treatmentsInterface.isTempBasalInProgress()) {
|
||||||
TempBasal tempBasal = treatmentsInterface.getTempBasal(new Date().getTime());
|
TempExBasal tempBasal = treatmentsInterface.getTempBasal(new Date().getTime());
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
if (tempBasal.percent != danaRPump.tempBasalPercent) {
|
if (tempBasal.percent != danaRPump.tempBasalPercent) {
|
||||||
// Close current temp basal
|
// Close current temp basal
|
||||||
treatmentsInterface.tempBasalStop(now);
|
treatmentsInterface.tempBasalStop(now);
|
||||||
// Create new
|
// Create new
|
||||||
TempBasal newTempBasal = new TempBasal();
|
TempExBasal newTempBasal = new TempExBasal();
|
||||||
newTempBasal.timeStart = new Date(now);
|
newTempBasal.timeStart = new Date(now);
|
||||||
newTempBasal.percent = danaRPump.tempBasalPercent;
|
newTempBasal.percent = danaRPump.tempBasalPercent;
|
||||||
newTempBasal.isAbsolute = false;
|
newTempBasal.isAbsolute = false;
|
||||||
|
@ -84,7 +84,7 @@ public class MsgStatusTempBasal extends MessageBase {
|
||||||
} else {
|
} else {
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
// Create new
|
// Create new
|
||||||
TempBasal newTempBasal = new TempBasal();
|
TempExBasal newTempBasal = new TempExBasal();
|
||||||
newTempBasal.timeStart = new Date(now);
|
newTempBasal.timeStart = new Date(now);
|
||||||
newTempBasal.percent = danaRPump.tempBasalPercent;
|
newTempBasal.percent = danaRPump.tempBasalPercent;
|
||||||
newTempBasal.isAbsolute = false;
|
newTempBasal.isAbsolute = false;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -306,8 +306,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
return pump.currentBasal;
|
return pump.currentBasal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TempBasal getTempBasal(long time) {
|
public TempExBasal getTempBasal(long time) {
|
||||||
TempBasal temp = MainApp.getConfigBuilder().getTempBasal(time);
|
TempExBasal temp = MainApp.getConfigBuilder().getTempBasal(time);
|
||||||
if (temp != null) return temp;
|
if (temp != null) return temp;
|
||||||
if (useExtendedBoluses)
|
if (useExtendedBoluses)
|
||||||
return MainApp.getConfigBuilder().getExtendedBolus(time);
|
return MainApp.getConfigBuilder().getExtendedBolus(time);
|
||||||
|
@ -681,7 +681,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
extended.put("PumpIOB", pump.iob);
|
extended.put("PumpIOB", pump.iob);
|
||||||
// extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
|
// extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
|
||||||
// extended.put("LastBolusAmount", pump.lastBolusAmount);
|
// extended.put("LastBolusAmount", pump.lastBolusAmount);
|
||||||
TempBasal tb = getTempBasal(new Date().getTime());
|
TempExBasal tb = getTempBasal(new Date().getTime());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||||
|
|
|
@ -272,12 +272,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
||||||
DanaRHistoryRecord record = historyList.get(position);
|
DanaRHistoryRecord record = historyList.get(position);
|
||||||
holder.time.setText(DateUtil.dateAndTimeString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateAndTimeString(record.recordDate));
|
||||||
holder.value.setText(DecimalFormatter.to2Decimal(record.getRecordValue()));
|
holder.value.setText(DecimalFormatter.to2Decimal(record.recordValue));
|
||||||
holder.stringvalue.setText(record.getStringRecordValue());
|
holder.stringvalue.setText(record.stringRecordValue);
|
||||||
holder.bolustype.setText(record.getBolusType());
|
holder.bolustype.setText(record.bolusType);
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(record.getRecordDuration()));
|
holder.duration.setText(DecimalFormatter.to0Decimal(record.recordDuration));
|
||||||
holder.alarm.setText(record.getRecordAlarm());
|
holder.alarm.setText(record.recordAlarm);
|
||||||
switch (showingType) {
|
switch (showingType) {
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
|
@ -302,10 +302,10 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + "U");
|
||||||
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + "U");
|
||||||
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus() + record.getRecordDailyBasal()) + "U");
|
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus + record.recordDailyBasal) + "U");
|
||||||
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateString(record.recordDate));
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
holder.value.setVisibility(View.GONE);
|
holder.value.setVisibility(View.GONE);
|
||||||
holder.stringvalue.setVisibility(View.GONE);
|
holder.stringvalue.setVisibility(View.GONE);
|
||||||
|
@ -317,7 +317,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
holder.value.setText(NSProfile.toUnitsString(record.getRecordValue(), record.getRecordValue() * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
holder.value.setText(NSProfile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
||||||
// rest is the same
|
// rest is the same
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
double weighted07 = 0d;
|
double weighted07 = 0d;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
|
|
||||||
// Create the table row
|
// Create the table row
|
||||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
@ -392,19 +392,19 @@ public class DanaRStatsActivity extends Activity {
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
labelDATE.setId(200 + i);
|
labelDATE.setId(200 + i);
|
||||||
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
labelDATE.setText(df.format(new Date(record.recordDate)));
|
||||||
labelDATE.setTextColor(Color.WHITE);
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelDATE);
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
labelBASAL.setId(300 + i);
|
labelBASAL.setId(300 + i);
|
||||||
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + " U");
|
||||||
labelBASAL.setTextColor(Color.WHITE);
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBASAL);
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
labelBOLUS.setId(400 + i);
|
labelBOLUS.setId(400 + i);
|
||||||
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + " U");
|
||||||
labelBOLUS.setTextColor(Color.WHITE);
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBOLUS);
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).recordDate)).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
weighted03 = tdd;
|
weighted03 = tdd;
|
||||||
weighted05 = tdd;
|
weighted05 = tdd;
|
||||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
|
@ -591,7 +591,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
|
||||||
extended.put("PumpIOB", getDanaRPump().iob);
|
extended.put("PumpIOB", getDanaRPump().iob);
|
||||||
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
|
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
|
||||||
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
TempExBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||||
|
|
|
@ -273,12 +273,12 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
public void onBindViewHolder(HistoryViewHolder holder, int position) {
|
||||||
DanaRHistoryRecord record = historyList.get(position);
|
DanaRHistoryRecord record = historyList.get(position);
|
||||||
holder.time.setText(DateUtil.dateAndTimeString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateAndTimeString(record.recordDate));
|
||||||
holder.value.setText(DecimalFormatter.to2Decimal(record.getRecordValue()));
|
holder.value.setText(DecimalFormatter.to2Decimal(record.recordValue));
|
||||||
holder.stringvalue.setText(record.getStringRecordValue());
|
holder.stringvalue.setText(record.stringRecordValue);
|
||||||
holder.bolustype.setText(record.getBolusType());
|
holder.bolustype.setText(record.bolusType);
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(record.getRecordDuration()));
|
holder.duration.setText(DecimalFormatter.to0Decimal(record.recordDuration));
|
||||||
holder.alarm.setText(record.getRecordAlarm());
|
holder.alarm.setText(record.recordAlarm);
|
||||||
switch (showingType) {
|
switch (showingType) {
|
||||||
case RecordTypes.RECORD_TYPE_ALARM:
|
case RecordTypes.RECORD_TYPE_ALARM:
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
|
@ -303,10 +303,10 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_DAILY:
|
case RecordTypes.RECORD_TYPE_DAILY:
|
||||||
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + "U");
|
holder.dailybasal.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + "U");
|
||||||
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + "U");
|
holder.dailybolus.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + "U");
|
||||||
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus() + record.getRecordDailyBasal()) + "U");
|
holder.dailytotal.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus + record.recordDailyBasal) + "U");
|
||||||
holder.time.setText(DateUtil.dateString(record.getRecordDate()));
|
holder.time.setText(DateUtil.dateString(record.recordDate));
|
||||||
holder.time.setVisibility(View.VISIBLE);
|
holder.time.setVisibility(View.VISIBLE);
|
||||||
holder.value.setVisibility(View.GONE);
|
holder.value.setVisibility(View.GONE);
|
||||||
holder.stringvalue.setVisibility(View.GONE);
|
holder.stringvalue.setVisibility(View.GONE);
|
||||||
|
@ -318,7 +318,7 @@ public class DanaRHistoryActivity extends Activity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
holder.value.setText(NSProfile.toUnitsString(record.getRecordValue(), record.getRecordValue() * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
holder.value.setText(NSProfile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
||||||
// rest is the same
|
// rest is the same
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
|
|
|
@ -379,7 +379,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
double weighted07 = 0d;
|
double weighted07 = 0d;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
|
|
||||||
// Create the table row
|
// Create the table row
|
||||||
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
TableRow tr = new TableRow(DanaRStatsActivity.this);
|
||||||
|
@ -392,19 +392,19 @@ public class DanaRStatsActivity extends Activity {
|
||||||
// Here create the TextView dynamically
|
// Here create the TextView dynamically
|
||||||
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
TextView labelDATE = new TextView(DanaRStatsActivity.this);
|
||||||
labelDATE.setId(200 + i);
|
labelDATE.setId(200 + i);
|
||||||
labelDATE.setText(df.format(new Date(record.getRecordDate())));
|
labelDATE.setText(df.format(new Date(record.recordDate)));
|
||||||
labelDATE.setTextColor(Color.WHITE);
|
labelDATE.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelDATE);
|
tr.addView(labelDATE);
|
||||||
|
|
||||||
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
TextView labelBASAL = new TextView(DanaRStatsActivity.this);
|
||||||
labelBASAL.setId(300 + i);
|
labelBASAL.setId(300 + i);
|
||||||
labelBASAL.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBasal()) + " U");
|
labelBASAL.setText(DecimalFormatter.to2Decimal(record.recordDailyBasal) + " U");
|
||||||
labelBASAL.setTextColor(Color.WHITE);
|
labelBASAL.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBASAL);
|
tr.addView(labelBASAL);
|
||||||
|
|
||||||
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
TextView labelBOLUS = new TextView(DanaRStatsActivity.this);
|
||||||
labelBOLUS.setId(400 + i);
|
labelBOLUS.setId(400 + i);
|
||||||
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.getRecordDailyBolus()) + " U");
|
labelBOLUS.setText(DecimalFormatter.to2Decimal(record.recordDailyBolus) + " U");
|
||||||
labelBOLUS.setTextColor(Color.WHITE);
|
labelBOLUS.setTextColor(Color.WHITE);
|
||||||
tr.addView(labelBOLUS);
|
tr.addView(labelBOLUS);
|
||||||
|
|
||||||
|
@ -461,7 +461,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
TableLayout.LayoutParams.WRAP_CONTENT));
|
TableLayout.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).getRecordDate())).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
if (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).recordDate)).equals(df.format(new Date(System.currentTimeMillis() - 1000 * 60 * 60 * 24))))) {
|
||||||
statsMessage.setVisibility(View.VISIBLE);
|
statsMessage.setVisibility(View.VISIBLE);
|
||||||
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
statsMessage.setText(getString(R.string.danar_stats_olddata_Message));
|
||||||
|
|
||||||
|
@ -474,7 +474,7 @@ public class DanaRStatsActivity extends Activity {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
for (DanaRHistoryRecord record : historyList) {
|
for (DanaRHistoryRecord record : historyList) {
|
||||||
double tdd = record.getRecordDailyBolus() + record.getRecordDailyBasal();
|
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
weighted03 = tdd;
|
weighted03 = tdd;
|
||||||
weighted05 = tdd;
|
weighted05 = tdd;
|
||||||
|
|
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
@ -17,7 +16,7 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
|
@ -240,7 +239,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
PumpEnactResult result = cancelTempBasal();
|
PumpEnactResult result = cancelTempBasal();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
TempBasal tempBasal = new TempBasal();
|
TempExBasal tempBasal = new TempExBasal();
|
||||||
tempBasal.timeStart = new Date();
|
tempBasal.timeStart = new Date();
|
||||||
tempBasal.isAbsolute = true;
|
tempBasal.isAbsolute = true;
|
||||||
tempBasal.absolute = absoluteRate;
|
tempBasal.absolute = absoluteRate;
|
||||||
|
@ -268,7 +267,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
TempBasal tempBasal = new TempBasal();
|
TempExBasal tempBasal = new TempExBasal();
|
||||||
tempBasal.timeStart = new Date();
|
tempBasal.timeStart = new Date();
|
||||||
tempBasal.isAbsolute = false;
|
tempBasal.isAbsolute = false;
|
||||||
tempBasal.percent = percent;
|
tempBasal.percent = percent;
|
||||||
|
@ -294,7 +293,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
PumpEnactResult result = cancelExtendedBolus();
|
PumpEnactResult result = cancelExtendedBolus();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
TempBasal extendedBolus = new TempBasal();
|
TempExBasal extendedBolus = new TempExBasal();
|
||||||
extendedBolus.timeStart = new Date();
|
extendedBolus.timeStart = new Date();
|
||||||
extendedBolus.isExtended = true;
|
extendedBolus.isExtended = true;
|
||||||
extendedBolus.absolute = insulin * 60d / durationInMinutes;
|
extendedBolus.absolute = insulin * 60d / durationInMinutes;
|
||||||
|
@ -368,7 +367,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
|
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
TempBasal tb;
|
TempExBasal tb;
|
||||||
if ((tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime())) != null) {
|
if ((tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime())) != null) {
|
||||||
status.put("tempbasalpct", tb.percent);
|
status.put("tempbasalpct", tb.percent);
|
||||||
status.put("tempbasalstart", DateUtil.toISOString(tb.timeStart));
|
status.put("tempbasalstart", DateUtil.toISOString(tb.timeStart));
|
||||||
|
|
|
@ -246,7 +246,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
if (actualBG != null) {
|
if (actualBG != null) {
|
||||||
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||||
} else if (lastBG != null) {
|
} else if (lastBG != null) {
|
||||||
Long agoMsec = new Date().getTime() - lastBG.timeIndex;
|
Long agoMsec = new Date().getTime() - lastBG.date;
|
||||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||||
reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", ";
|
reply = MainApp.sResources.getString(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(MainApp.sResources.getString(R.string.sms_minago), agoMin) + ", ";
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,14 +77,14 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||||
if (profile == null) return;
|
if (profile == null) return;
|
||||||
TempTarget tempTarget = tempTargetList.get(position);
|
TempTarget tempTarget = tempTargetList.get(position);
|
||||||
if (tempTarget.duration != 0) {
|
if (tempTarget.durationInMinutes != 0) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.timeStart) + " - " + DateUtil.timeString(tempTargetList.get(position).getPlannedTimeEnd()));
|
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTargetList.get(position).originalEnd()));
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.duration) + " min");
|
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
|
||||||
holder.low.setText(tempTarget.lowValueToUnitsToString(profile.getUnits()));
|
holder.low.setText(tempTarget.lowValueToUnitsToString(profile.getUnits()));
|
||||||
holder.high.setText(tempTarget.highValueToUnitsToString(profile.getUnits()));
|
holder.high.setText(tempTarget.highValueToUnitsToString(profile.getUnits()));
|
||||||
holder.reason.setText(tempTarget.reason);
|
holder.reason.setText(tempTarget.reason);
|
||||||
} else {
|
} else {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.timeStart));
|
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date));
|
||||||
holder.duration.setText(R.string.cancel);
|
holder.duration.setText(R.string.cancel);
|
||||||
holder.low.setText("");
|
holder.low.setText("");
|
||||||
holder.high.setText("");
|
holder.high.setText("");
|
||||||
|
@ -145,7 +145,7 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
case R.id.temptargetrange_remove:
|
case R.id.temptargetrange_remove:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.timeStart));
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = tempTarget._id;
|
final String _id = tempTarget._id;
|
||||||
|
|
|
@ -114,10 +114,10 @@ public class TempTargetRangePlugin implements PluginBase {
|
||||||
public TempTarget getTempTargetInProgress(long time) {
|
public TempTarget getTempTargetInProgress(long time) {
|
||||||
for (int i = 0; i < tempTargets.size(); i++) {
|
for (int i = 0; i < tempTargets.size(); i++) {
|
||||||
// a zero-duration temp target will cancel all prior targets
|
// a zero-duration temp target will cancel all prior targets
|
||||||
if (tempTargets.get(i).duration == 0) return null;
|
if (tempTargets.get(i).durationInMinutes == 0) return null;
|
||||||
|
|
||||||
if (tempTargets.get(i).timeStart.getTime() > time) continue;
|
if (tempTargets.get(i).date > time) continue;
|
||||||
if (tempTargets.get(i).getPlannedTimeEnd().getTime() >= time) return tempTargets.get(i);
|
if (tempTargets.get(i).date >= time) return tempTargets.get(i);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,11 @@ package info.nightscout.androidaps.plugins.Treatments;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
@ -22,13 +20,12 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
@ -48,8 +45,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
public static IobTotal lastTempBasalsCalculation;
|
public static IobTotal lastTempBasalsCalculation;
|
||||||
|
|
||||||
public static List<Treatment> treatments;
|
public static List<Treatment> treatments;
|
||||||
private static List<TempBasal> tempBasals;
|
private static List<TempExBasal> tempBasals;
|
||||||
private static List<TempBasal> extendedBoluses;
|
private static List<TempExBasal> extendedBoluses;
|
||||||
|
|
||||||
private static boolean useExtendedBoluses = false;
|
private static boolean useExtendedBoluses = false;
|
||||||
|
|
||||||
|
@ -156,10 +153,10 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkForExpired(List<TempBasal> list) {
|
private static void checkForExpired(List<TempExBasal> list) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
for (int position = list.size() - 1; position >= 0; position--) {
|
for (int position = list.size() - 1; position >= 0; position--) {
|
||||||
TempBasal t = list.get(position);
|
TempExBasal t = list.get(position);
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
if (t.timeEnd == null && t.getPlannedTimeEnd() < now) {
|
if (t.timeEnd == null && t.getPlannedTimeEnd() < now) {
|
||||||
t.timeEnd = new Date(t.getPlannedTimeEnd());
|
t.timeEnd = new Date(t.getPlannedTimeEnd());
|
||||||
|
@ -209,7 +206,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
if (t.created_at.getTime() > time) continue;
|
if (t.date > time) continue;
|
||||||
Iob tIOB = t.iobCalc(time, dia);
|
Iob tIOB = t.iobCalc(time, dia);
|
||||||
total.iob += tIOB.iobContrib;
|
total.iob += tIOB.iobContrib;
|
||||||
total.activity += tIOB.activityContrib;
|
total.activity += tIOB.activityContrib;
|
||||||
|
@ -237,7 +234,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
||||||
|
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
long t = treatment.created_at.getTime();
|
long t = treatment.date;
|
||||||
if (t > dia_ago && t <= now) {
|
if (t > dia_ago && t <= now) {
|
||||||
if (treatment.carbs >= 1) {
|
if (treatment.carbs >= 1) {
|
||||||
result.carbs += treatment.carbs;
|
result.carbs += treatment.carbs;
|
||||||
|
@ -265,7 +262,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
List<Treatment> in5minback = new ArrayList<>();
|
List<Treatment> in5minback = new ArrayList<>();
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
if (t.created_at.getTime() <= time && t.created_at.getTime() > time - 5 * 60 * 1000)
|
if (t.date <= time && t.date > time - 5 * 60 * 1000)
|
||||||
in5minback.add(t);
|
in5minback.add(t);
|
||||||
}
|
}
|
||||||
return in5minback;
|
return in5minback;
|
||||||
|
@ -288,7 +285,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
IobTotal total = new IobTotal(time);
|
IobTotal total = new IobTotal(time);
|
||||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||||
TempBasal t = tempBasals.get(pos);
|
TempExBasal t = tempBasals.get(pos);
|
||||||
if (t.timeStart.getTime() > time) continue;
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(time);
|
IobTotal calc = t.iobCalc(time);
|
||||||
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
||||||
|
@ -296,7 +293,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
}
|
}
|
||||||
if (useExtendedBoluses) {
|
if (useExtendedBoluses) {
|
||||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||||
TempBasal t = extendedBoluses.get(pos);
|
TempExBasal t = extendedBoluses.get(pos);
|
||||||
if (t.timeStart.getTime() > time) continue;
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(time);
|
IobTotal calc = t.iobCalc(time);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
|
@ -322,9 +319,9 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TempBasal getRealTempBasal(long time) {
|
public TempExBasal getRealTempBasal(long time) {
|
||||||
checkForExpired(tempBasals);
|
checkForExpired(tempBasals);
|
||||||
for (TempBasal t : tempBasals) {
|
for (TempExBasal t : tempBasals) {
|
||||||
if (t.isInProgress(time)) return t;
|
if (t.isInProgress(time)) return t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -332,7 +329,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getTempBasal(long time) {
|
public TempExBasal getTempBasal(long time) {
|
||||||
if (isRealTempBasalInProgress())
|
if (isRealTempBasalInProgress())
|
||||||
return getRealTempBasal(time);
|
return getRealTempBasal(time);
|
||||||
if (isExtendedBoluslInProgress() && useExtendedBoluses)
|
if (isExtendedBoluslInProgress() && useExtendedBoluses)
|
||||||
|
@ -347,22 +344,22 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getExtendedBolus(long time) {
|
public TempExBasal getExtendedBolus(long time) {
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
for (TempBasal t : extendedBoluses) {
|
for (TempExBasal t : extendedBoluses) {
|
||||||
if (t.isInProgress(time)) return t;
|
if (t.isInProgress(time)) return t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extendedBolusStart(TempBasal extendedBolus) {
|
public void extendedBolusStart(TempExBasal extendedBolus) {
|
||||||
MainApp.getDbHelper().create(extendedBolus);
|
MainApp.getDbHelper().create(extendedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extendedBolusStop(long time) {
|
public void extendedBolusStop(long time) {
|
||||||
TempBasal extendedBolus = getExtendedBolus(time);
|
TempExBasal extendedBolus = getExtendedBolus(time);
|
||||||
if (extendedBolus != null) {
|
if (extendedBolus != null) {
|
||||||
extendedBolus.timeEnd = new Date(time);
|
extendedBolus.timeEnd = new Date(time);
|
||||||
MainApp.getDbHelper().update(extendedBolus);
|
MainApp.getDbHelper().update(extendedBolus);
|
||||||
|
@ -373,7 +370,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
public double getTempBasalAbsoluteRate() {
|
public double getTempBasalAbsoluteRate() {
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
TempBasal tb = getTempBasal(new Date().getTime());
|
TempExBasal tb = getTempBasal(new Date().getTime());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
if (tb.isAbsolute) {
|
if (tb.isAbsolute) {
|
||||||
return tb.absolute;
|
return tb.absolute;
|
||||||
|
@ -383,7 +380,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
return tempRate;
|
return tempRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TempBasal eb = getExtendedBolus(new Date().getTime());
|
TempExBasal eb = getExtendedBolus(new Date().getTime());
|
||||||
if (eb != null && useExtendedBoluses) {
|
if (eb != null && useExtendedBoluses) {
|
||||||
return pump.getBaseBasalRate() + eb.absolute;
|
return pump.getBaseBasalRate() + eb.absolute;
|
||||||
}
|
}
|
||||||
|
@ -400,13 +397,13 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tempBasalStart(TempBasal tempBasal) {
|
public void tempBasalStart(TempExBasal tempBasal) {
|
||||||
MainApp.getDbHelper().create(tempBasal);
|
MainApp.getDbHelper().create(tempBasal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tempBasalStop(long time) {
|
public void tempBasalStop(long time) {
|
||||||
TempBasal tempBasal = getTempBasal(time);
|
TempExBasal tempBasal = getTempBasal(time);
|
||||||
if (tempBasal != null) {
|
if (tempBasal != null) {
|
||||||
tempBasal.timeEnd = new Date(time);
|
tempBasal.timeEnd = new Date(time);
|
||||||
MainApp.getDbHelper().update(tempBasal);
|
MainApp.getDbHelper().update(tempBasal);
|
||||||
|
@ -425,15 +422,15 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
||||||
return oldestTemp;
|
return oldestTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<TempBasal> getMergedList() {
|
public static List<TempExBasal> getMergedList() {
|
||||||
if (useExtendedBoluses) {
|
if (useExtendedBoluses) {
|
||||||
List<TempBasal> merged = new ArrayList<TempBasal>();
|
List<TempExBasal> merged = new ArrayList<TempExBasal>();
|
||||||
merged.addAll(tempBasals);
|
merged.addAll(tempBasals);
|
||||||
if (useExtendedBoluses)
|
if (useExtendedBoluses)
|
||||||
merged.addAll(extendedBoluses);
|
merged.addAll(extendedBoluses);
|
||||||
|
|
||||||
class CustomComparator implements Comparator<TempBasal> {
|
class CustomComparator implements Comparator<TempExBasal> {
|
||||||
public int compare(TempBasal object1, TempBasal object2) {
|
public int compare(TempExBasal object1, TempExBasal object2) {
|
||||||
return (int) (object2.timeIndex - object1.timeIndex);
|
return (int) (object2.timeIndex - object1.timeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).created_at));
|
holder.date.setText(DateUtil.dateAndTimeString(treatments.get(position).date));
|
||||||
holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U");
|
holder.insulin.setText(DecimalFormatter.to2Decimal(treatments.get(position).insulin) + " U");
|
||||||
holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g");
|
holder.carbs.setText(DecimalFormatter.to0Decimal(treatments.get(position).carbs) + " g");
|
||||||
Iob iob = treatments.get(position).iobCalc(new Date().getTime(), profile.getDia());
|
Iob iob = treatments.get(position).iobCalc(new Date().getTime(), profile.getDia());
|
||||||
|
@ -134,7 +134,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
case R.id.treatments_remove:
|
case R.id.treatments_remove:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.created_at));
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
|
||||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
final String _id = treatment._id;
|
final String _id = treatment._id;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -49,9 +49,9 @@ public class TreatmentsTempBasalsFragment extends Fragment {
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> {
|
||||||
|
|
||||||
List<TempBasal> tempBasalList;
|
List<TempExBasal> tempBasalList;
|
||||||
|
|
||||||
RecyclerViewAdapter(List<TempBasal> tempBasalList) {
|
RecyclerViewAdapter(List<TempExBasal> tempBasalList) {
|
||||||
this.tempBasalList = tempBasalList;
|
this.tempBasalList = tempBasalList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class TreatmentsTempBasalsFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TempBasalsViewHolder holder, int position) {
|
public void onBindViewHolder(TempBasalsViewHolder holder, int position) {
|
||||||
TempBasal tempBasal = tempBasalList.get(position);
|
TempExBasal tempBasal = tempBasalList.get(position);
|
||||||
if (tempBasal.timeEnd != null) {
|
if (tempBasal.timeEnd != null) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempBasal.timeStart) + " - " + DateUtil.timeString(tempBasalList.get(position).timeEnd));
|
holder.date.setText(DateUtil.dateAndTimeString(tempBasal.timeStart) + " - " + DateUtil.timeString(tempBasalList.get(position).timeEnd));
|
||||||
} else {
|
} else {
|
||||||
|
@ -138,7 +138,7 @@ public class TreatmentsTempBasalsFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
final TempBasal tempBasal = (TempBasal) v.getTag();
|
final TempExBasal tempBasal = (TempExBasal) v.getTag();
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.tempbasals_remove:
|
case R.id.tempbasals_remove:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
|
|
@ -2,16 +2,12 @@ package info.nightscout.androidaps.plugins.TreatmentsFromHistory;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import com.j256.ormlite.dao.Dao;
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -22,12 +18,9 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Iob;
|
import info.nightscout.androidaps.data.Iob;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
@ -35,7 +28,6 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,8 +40,8 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
public static IobTotal lastTempBasalsCalculation;
|
public static IobTotal lastTempBasalsCalculation;
|
||||||
|
|
||||||
public static List<Treatment> treatments;
|
public static List<Treatment> treatments;
|
||||||
private static List<TempBasal> tempBasals;
|
private static List<TempExBasal> tempBasals;
|
||||||
private static List<TempBasal> extendedBoluses;
|
private static List<TempExBasal> extendedBoluses;
|
||||||
|
|
||||||
private static boolean fragmentEnabled = true;
|
private static boolean fragmentEnabled = true;
|
||||||
private static boolean fragmentVisible = true;
|
private static boolean fragmentVisible = true;
|
||||||
|
@ -153,10 +145,10 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkForExpired(List<TempBasal> list) {
|
private static void checkForExpired(List<TempExBasal> list) {
|
||||||
long now = new Date().getTime();
|
long now = new Date().getTime();
|
||||||
for (int position = list.size() - 1; position >= 0; position--) {
|
for (int position = list.size() - 1; position >= 0; position--) {
|
||||||
TempBasal t = list.get(position);
|
TempExBasal t = list.get(position);
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
if (t.timeEnd == null && t.getPlannedTimeEnd() < now) {
|
if (t.timeEnd == null && t.getPlannedTimeEnd() < now) {
|
||||||
t.timeEnd = new Date(t.getPlannedTimeEnd());
|
t.timeEnd = new Date(t.getPlannedTimeEnd());
|
||||||
|
@ -206,7 +198,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
|
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
if (t.created_at.getTime() > time) continue;
|
if (t.date > time) continue;
|
||||||
Iob tIOB = t.iobCalc(time, dia);
|
Iob tIOB = t.iobCalc(time, dia);
|
||||||
total.iob += tIOB.iobContrib;
|
total.iob += tIOB.iobContrib;
|
||||||
total.activity += tIOB.activityContrib;
|
total.activity += tIOB.activityContrib;
|
||||||
|
@ -216,7 +208,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
|
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||||
TempBasal t = extendedBoluses.get(pos);
|
TempExBasal t = extendedBoluses.get(pos);
|
||||||
if (t.timeStart.getTime() > time) continue;
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(time);
|
IobTotal calc = t.iobCalc(time);
|
||||||
total.plus(calc);
|
total.plus(calc);
|
||||||
|
@ -242,7 +234,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
|
||||||
|
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
long t = treatment.created_at.getTime();
|
long t = treatment.date;
|
||||||
if (t > dia_ago && t <= now) {
|
if (t > dia_ago && t <= now) {
|
||||||
if (treatment.carbs >= 1) {
|
if (treatment.carbs >= 1) {
|
||||||
result.carbs += treatment.carbs;
|
result.carbs += treatment.carbs;
|
||||||
|
@ -270,7 +262,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
List<Treatment> in5minback = new ArrayList<>();
|
List<Treatment> in5minback = new ArrayList<>();
|
||||||
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
for (Integer pos = 0; pos < treatments.size(); pos++) {
|
||||||
Treatment t = treatments.get(pos);
|
Treatment t = treatments.get(pos);
|
||||||
if (t.created_at.getTime() <= time && t.created_at.getTime() > time - 5 * 60 * 1000)
|
if (t.date <= time && t.date > time - 5 * 60 * 1000)
|
||||||
in5minback.add(t);
|
in5minback.add(t);
|
||||||
}
|
}
|
||||||
return in5minback;
|
return in5minback;
|
||||||
|
@ -282,7 +274,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getRealTempBasal(long time) {
|
public TempExBasal getRealTempBasal(long time) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +304,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
checkForExpired(tempBasals);
|
checkForExpired(tempBasals);
|
||||||
IobTotal total = new IobTotal(time);
|
IobTotal total = new IobTotal(time);
|
||||||
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
for (Integer pos = 0; pos < tempBasals.size(); pos++) {
|
||||||
TempBasal t = tempBasals.get(pos);
|
TempExBasal t = tempBasals.get(pos);
|
||||||
if (t.timeStart.getTime() > time) continue;
|
if (t.timeStart.getTime() > time) continue;
|
||||||
IobTotal calc = t.iobCalc(time);
|
IobTotal calc = t.iobCalc(time);
|
||||||
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
//log.debug("BasalIOB " + new Date(time) + " >>> " + calc.basaliob);
|
||||||
|
@ -330,25 +322,25 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getTempBasal(long time) {
|
public TempExBasal getTempBasal(long time) {
|
||||||
checkForExpired(tempBasals);
|
checkForExpired(tempBasals);
|
||||||
for (TempBasal t : tempBasals) {
|
for (TempExBasal t : tempBasals) {
|
||||||
if (t.isInProgress(time)) return t;
|
if (t.isInProgress(time)) return t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TempBasal getExtendedBolus(long time) {
|
public TempExBasal getExtendedBolus(long time) {
|
||||||
checkForExpired(extendedBoluses);
|
checkForExpired(extendedBoluses);
|
||||||
for (TempBasal t : extendedBoluses) {
|
for (TempExBasal t : extendedBoluses) {
|
||||||
if (t.isInProgress(time)) return t;
|
if (t.isInProgress(time)) return t;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extendedBolusStart(TempBasal extendedBolus) {
|
public void extendedBolusStart(TempExBasal extendedBolus) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +353,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
public double getTempBasalAbsoluteRate() {
|
public double getTempBasalAbsoluteRate() {
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
TempBasal tb = getTempBasal(new Date().getTime());
|
TempExBasal tb = getTempBasal(new Date().getTime());
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
if (tb.isAbsolute) {
|
if (tb.isAbsolute) {
|
||||||
return tb.absolute;
|
return tb.absolute;
|
||||||
|
@ -382,7 +374,7 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tempBasalStart(TempBasal tempBasal) {
|
public void tempBasalStart(TempExBasal tempBasal) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -285,7 +285,7 @@ public class ActionStringHandler {
|
||||||
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
ret += "Temp Target: " + NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits());
|
ret += "Temp Target: " + NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits());
|
||||||
ret += "\nuntil: " + DateUtil.timeString(tempTarget.getPlannedTimeEnd());
|
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
||||||
ret += "\n\n";
|
ret += "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -354,17 +354,16 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
private static void generateTempTarget(int duration, double low, double high) {
|
private static void generateTempTarget(int duration, double low, double high) {
|
||||||
TempTarget tempTarget = new TempTarget();
|
TempTarget tempTarget = new TempTarget();
|
||||||
tempTarget.timeStart = new Date();
|
tempTarget.date = new Date().getTime();
|
||||||
tempTarget.duration = duration;
|
tempTarget.durationInMinutes = duration;
|
||||||
tempTarget.reason = "WearPlugin";
|
tempTarget.reason = "WearPlugin";
|
||||||
if(tempTarget.duration != 0) {
|
if(tempTarget.durationInMinutes != 0) {
|
||||||
tempTarget.low = low;
|
tempTarget.low = low;
|
||||||
tempTarget.high = high;
|
tempTarget.high = high;
|
||||||
} else {
|
} else {
|
||||||
tempTarget.low = 0;
|
tempTarget.low = 0;
|
||||||
tempTarget.high = 0;
|
tempTarget.high = 0;
|
||||||
}
|
}
|
||||||
tempTarget.setTimeIndex(tempTarget.getTimeIndex());
|
|
||||||
Dao<TempTarget, Long> dao = null;
|
Dao<TempTarget, Long> dao = null;
|
||||||
try {
|
try {
|
||||||
dao = MainApp.getDbHelper().getDaoTempTargets();
|
dao = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
|
|
|
@ -28,7 +28,7 @@ import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
@ -237,7 +237,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
|
|
||||||
int battery = getBatteryLevel(getApplicationContext());
|
int battery = getBatteryLevel(getApplicationContext());
|
||||||
dataMap.putString("sgvString", lastBG.valueToUnitsToString(profile.getUnits()));
|
dataMap.putString("sgvString", lastBG.valueToUnitsToString(profile.getUnits()));
|
||||||
dataMap.putDouble("timestamp", lastBG.getTimeIndex());
|
dataMap.putDouble("timestamp", lastBG.date);
|
||||||
if(glucoseStatus == null) {
|
if(glucoseStatus == null) {
|
||||||
dataMap.putString("slopeArrow", "" );
|
dataMap.putString("slopeArrow", "" );
|
||||||
dataMap.putString("delta", "");
|
dataMap.putString("delta", "");
|
||||||
|
@ -346,8 +346,8 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
double beginBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(beginBasalSegmentTime)));
|
double beginBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(beginBasalSegmentTime)));
|
||||||
double endBasalValue = beginBasalValue;
|
double endBasalValue = beginBasalValue;
|
||||||
|
|
||||||
TempBasal tb1 = MainApp.getConfigBuilder().getTempBasal(runningTime);
|
TempExBasal tb1 = MainApp.getConfigBuilder().getTempBasal(runningTime);
|
||||||
TempBasal tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime);
|
TempExBasal tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime);
|
||||||
double tb_before = beginBasalValue;
|
double tb_before = beginBasalValue;
|
||||||
double tb_amount = beginBasalValue;
|
double tb_amount = beginBasalValue;
|
||||||
long tb_start = runningTime;
|
long tb_start = runningTime;
|
||||||
|
@ -536,7 +536,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
if (treatmentsInterface.isTempBasalInProgress()) {
|
if (treatmentsInterface.isTempBasalInProgress()) {
|
||||||
TempBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
|
TempExBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
|
||||||
if (shortString) {
|
if (shortString) {
|
||||||
status += activeTemp.toStringShort();
|
status += activeTemp.toStringShort();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Date;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.db.TempBasal;
|
import info.nightscout.androidaps.db.TempExBasal;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
|
@ -22,7 +22,6 @@ import info.nightscout.androidaps.events.EventRefreshGui;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||||
|
@ -165,7 +164,7 @@ public class StatuslinePlugin implements PluginBase {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
if (treatmentsInterface.isTempBasalInProgress()) {
|
if (treatmentsInterface.isTempBasalInProgress()) {
|
||||||
TempBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
|
TempExBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
|
||||||
if (shortString) {
|
if (shortString) {
|
||||||
status += activeTemp.toStringShort();
|
status += activeTemp.toStringShort();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,6 +8,8 @@ import android.support.v4.util.LongSparseArray;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.interfaces.Interval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.05.2017.
|
* Created by mike on 09.05.2017.
|
||||||
*/
|
*/
|
||||||
|
@ -19,59 +21,6 @@ public class OverlappingIntervals {
|
||||||
private Object dataLock = new Object();
|
private Object dataLock = new Object();
|
||||||
|
|
||||||
|
|
||||||
public abstract class Interval {
|
|
||||||
Long start = null;
|
|
||||||
Long duration = null;
|
|
||||||
Long cuttedEnd = null;
|
|
||||||
|
|
||||||
public Interval(long start, long duration) {
|
|
||||||
this.start = start;
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
long durationInMsec() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
long start() {
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
// planned end time at time of creation
|
|
||||||
long originalEnd() {
|
|
||||||
return start + duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
// end time after cut
|
|
||||||
long end() {
|
|
||||||
if (cuttedEnd != null)
|
|
||||||
return cuttedEnd;
|
|
||||||
return originalEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
void cutEndTo(long end) {
|
|
||||||
cuttedEnd = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean match(long time) {
|
|
||||||
if (start() <= time && end() >= time)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean before(long time) {
|
|
||||||
if (end() < time)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean after(long time) {
|
|
||||||
if (start() > time)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LongSparseArray<Interval> rawData = new LongSparseArray<>(); // oldest at index 0
|
private static LongSparseArray<Interval> rawData = new LongSparseArray<>(); // oldest at index 0
|
||||||
|
|
||||||
public OverlappingIntervals() {
|
public OverlappingIntervals() {
|
||||||
|
@ -142,4 +91,4 @@ public class OverlappingIntervals {
|
||||||
return ~lo; // value not present
|
return ~lo; // value not present
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue