medtronic-0.11.11-SNAPSHOT
- #152 fixed double bolus problem: code is now looking for AAPS Events that happened within 2 minutes.
This commit is contained in:
parent
be5c79f370
commit
38f13cd6db
2 changed files with 34 additions and 17 deletions
|
@ -105,7 +105,7 @@ android {
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
versionCode 1500
|
versionCode 1500
|
||||||
// dev_version: 2.3.1-dev
|
// dev_version: 2.3.1-dev
|
||||||
version "medtronic-0.11.10-SNAPSHOT"
|
version "medtronic-0.11.11-SNAPSHOT"
|
||||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||||
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
buildConfigField "String", "HEAD", '"' + generateGitBuild() + '"'
|
||||||
|
|
|
@ -679,6 +679,16 @@ public class MedtronicHistoryData {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* findDbEntry - finds Db entries in database, while theoretically this should have same dateTime they
|
||||||
|
* don't. Entry on pump is few seconds before treatment in AAPS, and on manual boluses on pump there
|
||||||
|
* is no treatment at all. For now we look fro tratment that was from 0s - 1m59s within pump entry.
|
||||||
|
*
|
||||||
|
* @param treatment Pump Entry
|
||||||
|
* @param entriesFromHistory entries from history
|
||||||
|
*
|
||||||
|
* @return DbObject from AAPS (if found)
|
||||||
|
*/
|
||||||
private DbObjectBase findDbEntry(PumpHistoryEntry treatment, List<? extends DbObjectBase> entriesFromHistory) {
|
private DbObjectBase findDbEntry(PumpHistoryEntry treatment, List<? extends DbObjectBase> entriesFromHistory) {
|
||||||
|
|
||||||
long proposedTime = DateTimeUtil.toMillisFromATD(treatment.atechDateTime);
|
long proposedTime = DateTimeUtil.toMillisFromATD(treatment.atechDateTime);
|
||||||
|
@ -691,29 +701,36 @@ public class MedtronicHistoryData {
|
||||||
return entriesFromHistory.get(0);
|
return entriesFromHistory.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int sec = 0; sec <= 40; sec += 10) {
|
for (int min = 0; min <= 2; min++) {
|
||||||
|
for (int sec = 0; sec < 60; sec += 10) {
|
||||||
|
|
||||||
int diff = (sec * 1000);
|
if (min==1 && sec==50) {
|
||||||
|
sec = 59;
|
||||||
List<DbObjectBase> outList = new ArrayList<>();
|
}
|
||||||
|
|
||||||
for (DbObjectBase treatment1 : entriesFromHistory) {
|
int diff = (min * 60 * 1000) + (sec * 1000);
|
||||||
|
|
||||||
if ((treatment1.getDate() > proposedTime - diff) && (treatment1.getDate() < proposedTime + diff)) {
|
List<DbObjectBase> outList = new ArrayList<>();
|
||||||
outList.add(treatment1);
|
|
||||||
|
for (DbObjectBase treatment1 : entriesFromHistory) {
|
||||||
|
|
||||||
|
if ((treatment1.getDate() > proposedTime - diff) && (treatment1.getDate() < proposedTime + diff)) {
|
||||||
|
outList.add(treatment1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// LOG.debug("Entries: (timeDiff=[min={},sec={}],count={},list={})", min, sec, outList.size(),
|
// LOG.debug("Entries: (timeDiff=[min={},sec={}],count={},list={})", min, sec, outList.size(),
|
||||||
// gsonPretty.toJson(outList));
|
// gsonPretty.toJson(outList));
|
||||||
|
|
||||||
if (outList.size() == 1) {
|
if (outList.size() == 1) {
|
||||||
return outList.get(0);
|
return outList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sec == 10 && outList.size() > 1) {
|
if (min == 0 && sec == 10 && outList.size() > 1) {
|
||||||
LOG.error("Too many entries (with too small diff): (timeDiff=[sec={}],count={},list={})",
|
if (isLogEnabled())
|
||||||
sec, outList.size(), gson.toJson(outList));
|
LOG.error("Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
|
||||||
|
min, sec, outList.size(), gson.toJson(outList));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue