medtronic-0.11.12-SNAPSHOT
- another look at duplicate bolus problem. This should have fixed the problem, if we still get duplicated, we will have to investigate NS angle
This commit is contained in:
parent
38f13cd6db
commit
7713270524
|
@ -105,7 +105,7 @@ android {
|
|||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
// dev_version: 2.3.1-dev
|
||||
version "medtronic-0.11.11-SNAPSHOT"
|
||||
version "medtronic-0.11.12-SNAPSHOT"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||
|
|
|
@ -31,7 +31,7 @@ public interface TreatmentsInterface {
|
|||
|
||||
List<Treatment> getTreatmentsFromHistory();
|
||||
List<Treatment> getTreatments5MinBackFromHistory(long time);
|
||||
List<Treatment> getTreatmentsFromHistoryXMinutesAgo(int minutesAgo);
|
||||
List<Treatment> getTreatmentsFromHistoryAfterTimestamp(long timestamp);
|
||||
long getLastBolusTime();
|
||||
|
||||
// real basals (not faked by extended bolus)
|
||||
|
|
|
@ -147,7 +147,7 @@ public class MedtronicPumpHistoryDecoder extends MedtronicHistoryDecoder<PumpHis
|
|||
RecordDecodeStatus decoded = decodeRecord(pe);
|
||||
|
||||
if ((decoded == RecordDecodeStatus.OK) || (decoded == RecordDecodeStatus.Ignored)) {
|
||||
Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||
//Log.i(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||
} else {
|
||||
Log.w(TAG, "#" + record + " " + decoded.getDescription() + " " + pe);
|
||||
}
|
||||
|
|
|
@ -515,9 +515,9 @@ public class MedtronicHistoryData {
|
|||
|
||||
private void processBolusEntries(List<PumpHistoryEntry> entryList) {
|
||||
|
||||
int dateDifference = getOldestDateDifference(entryList);
|
||||
long oldestTimestamp = getOldestTimestamp(entryList);
|
||||
|
||||
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntries(dateDifference, ProcessHistoryRecord.Bolus);
|
||||
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.Bolus);
|
||||
|
||||
// LOG.debug(processHistoryRecord.getDescription() + " List (before filter): {}, FromDb={}", gsonPretty.toJson(entryList),
|
||||
// gsonPretty.toJson(entriesFromHistory));
|
||||
|
@ -568,9 +568,9 @@ public class MedtronicHistoryData {
|
|||
}
|
||||
}
|
||||
|
||||
int dateDifference = getOldestDateDifference(entryList);
|
||||
long oldestTimestamp = getOldestTimestamp(entryList);
|
||||
|
||||
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntries(dateDifference, ProcessHistoryRecord.TBR);
|
||||
List<? extends DbObjectBase> entriesFromHistory = getDatabaseEntriesByLastTimestamp(oldestTimestamp, ProcessHistoryRecord.TBR);
|
||||
|
||||
if (isLogEnabled())
|
||||
LOG.debug(ProcessHistoryRecord.TBR.getDescription() + " List (before filter): {}, FromDb={}", gson.toJson(entryList),
|
||||
|
@ -693,7 +693,7 @@ public class MedtronicHistoryData {
|
|||
|
||||
long proposedTime = DateTimeUtil.toMillisFromATD(treatment.atechDateTime);
|
||||
|
||||
proposedTime += (this.pumpTime.timeDifference * 1000);
|
||||
//proposedTime += (this.pumpTime.timeDifference * 1000);
|
||||
|
||||
if (entriesFromHistory.size() == 0) {
|
||||
return null;
|
||||
|
@ -701,14 +701,11 @@ public class MedtronicHistoryData {
|
|||
return entriesFromHistory.get(0);
|
||||
}
|
||||
|
||||
for (int min = 0; min <= 2; min++) {
|
||||
for (int sec = 0; sec < 60; sec += 10) {
|
||||
for (int min = 0; min <= 2; min += 1) {
|
||||
|
||||
if (min==1 && sec==50) {
|
||||
sec = 59;
|
||||
}
|
||||
for (int sec = 0; sec <= 40; sec += 10) {
|
||||
|
||||
int diff = (min * 60 * 1000) + (sec * 1000);
|
||||
int diff = (sec * 1000);
|
||||
|
||||
List<DbObjectBase> outList = new ArrayList<>();
|
||||
|
||||
|
@ -738,16 +735,11 @@ public class MedtronicHistoryData {
|
|||
}
|
||||
|
||||
|
||||
private List<? extends DbObjectBase> getDatabaseEntries(int dateDifference, ProcessHistoryRecord processHistoryRecord) {
|
||||
private List<? extends DbObjectBase> getDatabaseEntriesByLastTimestamp(long startTimestamp, ProcessHistoryRecord processHistoryRecord) {
|
||||
if (processHistoryRecord == ProcessHistoryRecord.Bolus) {
|
||||
return TreatmentsPlugin.getPlugin().getTreatmentsFromHistoryXMinutesAgo(
|
||||
dateDifference);
|
||||
return TreatmentsPlugin.getPlugin().getTreatmentsFromHistoryAfterTimestamp(startTimestamp);
|
||||
} else {
|
||||
|
||||
GregorianCalendar gc = new GregorianCalendar();
|
||||
gc.add(Calendar.MINUTE, (-1) * dateDifference);
|
||||
|
||||
return databaseHelper.getTemporaryBasalsDataFromTime(gc.getTimeInMillis(), true);
|
||||
return databaseHelper.getTemporaryBasalsDataFromTime(startTimestamp, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1162,7 +1154,7 @@ public class MedtronicHistoryData {
|
|||
PumpHistoryEntry currentTreatment = null;
|
||||
|
||||
if (isCollectionEmpty(treatments)) {
|
||||
return 6; // default return of 6 (5 for diif on history reading + 1 for max allowed difference) minutes
|
||||
return 8; // default return of 6 (5 for diif on history reading + 2 for max allowed difference) minutes
|
||||
}
|
||||
|
||||
for (PumpHistoryEntry treatment : treatments) {
|
||||
|
@ -1178,14 +1170,14 @@ public class MedtronicHistoryData {
|
|||
try {
|
||||
|
||||
oldestEntryTime = DateTimeUtil.toLocalDateTime(dt);
|
||||
oldestEntryTime = oldestEntryTime.minusMinutes(1);
|
||||
oldestEntryTime = oldestEntryTime.minusMinutes(3);
|
||||
|
||||
// if (this.pumpTime.timeDifference < 0) {
|
||||
// oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
||||
// }
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
||||
return 6; // default return of 6 minutes
|
||||
return 8; // default return of 6 minutes
|
||||
}
|
||||
|
||||
LocalDateTime now = new LocalDateTime();
|
||||
|
@ -1201,6 +1193,40 @@ public class MedtronicHistoryData {
|
|||
}
|
||||
|
||||
|
||||
private long getOldestTimestamp(List<PumpHistoryEntry> treatments) {
|
||||
|
||||
long dt = Long.MAX_VALUE;
|
||||
PumpHistoryEntry currentTreatment = null;
|
||||
|
||||
for (PumpHistoryEntry treatment : treatments) {
|
||||
|
||||
if (treatment.atechDateTime < dt) {
|
||||
dt = treatment.atechDateTime;
|
||||
currentTreatment = treatment;
|
||||
}
|
||||
}
|
||||
|
||||
//LocalDateTime oldestEntryTime = null;
|
||||
|
||||
try {
|
||||
|
||||
GregorianCalendar oldestEntryTime = DateTimeUtil.toGregorianCalendar(dt);
|
||||
oldestEntryTime.add(Calendar.MINUTE, -2);
|
||||
|
||||
return oldestEntryTime.getTimeInMillis();
|
||||
|
||||
// if (this.pumpTime.timeDifference < 0) {
|
||||
// oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
||||
// }
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
||||
return 8; // default return of 6 minutes
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private PumpHistoryEntryType getTDDType() {
|
||||
|
||||
if (MedtronicUtil.getMedtronicPumpModel() == null) {
|
||||
|
|
|
@ -310,14 +310,14 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
|||
|
||||
|
||||
@Override
|
||||
public List<Treatment> getTreatmentsFromHistoryXMinutesAgo(int minutesAgo) {
|
||||
public List<Treatment> getTreatmentsFromHistoryAfterTimestamp(long fromTimestamp) {
|
||||
List<Treatment> in5minback = new ArrayList<>();
|
||||
long time = System.currentTimeMillis();
|
||||
synchronized (treatments) {
|
||||
for (Treatment t : treatments) {
|
||||
if (!t.isValid)
|
||||
continue;
|
||||
if (t.date <= time && t.date > (time - minutesAgo * 60 * 1000))
|
||||
if (t.date <= time && t.date >= fromTimestamp)
|
||||
in5minback.add(t);
|
||||
}
|
||||
return in5minback;
|
||||
|
|
Loading…
Reference in a new issue