medtronic-0.11.10-SNAPSHOT
- #151 - when searching for AAPS events (treatments, TempBasals) we don't look at +/- 5 min anymore, just +/- 40s
This commit is contained in:
parent
08cae9a3bb
commit
be5c79f370
4 changed files with 50 additions and 50 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.9-SNAPSHOT"
|
version "medtronic-0.11.10-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() + '"'
|
||||||
|
|
|
@ -747,7 +747,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
|
|
||||||
if (timeDiff > 20) {
|
if (timeDiff > 20) {
|
||||||
|
|
||||||
if ((clock.localDeviceTime.getYear() < 2015) || (timeDiff <= 24 * 60 * 60)) {
|
if ((clock.localDeviceTime.getYear() <= 2015) || (timeDiff <= 24 * 60 * 60)) {
|
||||||
|
|
||||||
if (isLoggingEnabled())
|
if (isLoggingEnabled())
|
||||||
LOG.info("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {} s. Set time on pump.", timeDiff);
|
LOG.info("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {} s. Set time on pump.", timeDiff);
|
||||||
|
@ -759,8 +759,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
MainApp.bus().post(new EventNewNotification(notification));
|
MainApp.bus().post(new EventNewNotification(notification));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (timeDiff > 24 * 60 * 60) {
|
if ((clock.localDeviceTime.getYear() > 2015)) {
|
||||||
LOG.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference is {}, over 24h requested. Doing nothing.", timeDiff);
|
LOG.error("MedtronicPumpPlugin::checkTimeAndOptionallySetTime - Time difference over 24h requested [diff={}]. Doing nothing.", timeDiff);
|
||||||
sendNotification(MedtronicNotificationType.TimeChangeOver24h);
|
sendNotification(MedtronicNotificationType.TimeChangeOver24h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public abstract class MedtronicHistoryEntry implements MedtronicHistoryEntryInte
|
||||||
|
|
||||||
// protected LocalDateTime dateTime;
|
// protected LocalDateTime dateTime;
|
||||||
|
|
||||||
|
public long id;
|
||||||
|
|
||||||
@Expose
|
@Expose
|
||||||
public String DT;
|
public String DT;
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,14 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
/**
|
/**
|
||||||
* Created by andy on 10/12/18.
|
* Created by andy on 10/12/18.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// TODO: After release we need to refactor how data is retrieved from pump, each entry in history needs to be marked, and sorting
|
||||||
|
// needs to happen according those markings, not on time stamp (since AAPS can change time anytime it drifts away). This
|
||||||
|
// needs to include not returning any records if TZ goes into -x area. To fully support this AAPS would need to take note of
|
||||||
|
// all times that time changed (TZ, DST, etc.). Data needs to be returned in batches (time_changed batches, so that we can
|
||||||
|
// handle it. It would help to assign sort_ids to items (from oldest (1) to newest (x)
|
||||||
|
|
||||||
|
|
||||||
public class MedtronicHistoryData {
|
public class MedtronicHistoryData {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
private static final Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||||
|
@ -67,6 +75,8 @@ public class MedtronicHistoryData {
|
||||||
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
|
private DatabaseHelper databaseHelper = MainApp.getDbHelper();
|
||||||
private ClockDTO pumpTime;
|
private ClockDTO pumpTime;
|
||||||
|
|
||||||
|
private long lastIdUsed = 0;
|
||||||
|
|
||||||
|
|
||||||
public MedtronicHistoryData() {
|
public MedtronicHistoryData() {
|
||||||
this.allHistory = new ArrayList<>();
|
this.allHistory = new ArrayList<>();
|
||||||
|
@ -202,18 +212,27 @@ public class MedtronicHistoryData {
|
||||||
|
|
||||||
PumpHistoryEntry pheLast = newHistory.get(0);
|
PumpHistoryEntry pheLast = newHistory.get(0);
|
||||||
|
|
||||||
|
// find last entry
|
||||||
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
||||||
|
|
||||||
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
|
||||||
this.allHistory.add(pumpHistoryEntry);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pumpHistoryEntry.atechDateTime != null && pumpHistoryEntry.isAfter(pheLast.atechDateTime)) {
|
if (pumpHistoryEntry.atechDateTime != null && pumpHistoryEntry.isAfter(pheLast.atechDateTime)) {
|
||||||
pheLast = pumpHistoryEntry;
|
pheLast = pumpHistoryEntry;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add new entries
|
||||||
|
Collections.reverse(newHistory);
|
||||||
|
|
||||||
|
for (PumpHistoryEntry pumpHistoryEntry : newHistory) {
|
||||||
|
|
||||||
|
if (!this.allHistory.contains(pumpHistoryEntry)) {
|
||||||
|
lastIdUsed++;
|
||||||
|
pumpHistoryEntry.id = lastIdUsed;
|
||||||
|
this.allHistory.add(pumpHistoryEntry);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting
|
if (pheLast == null) // if we don't have any valid record we don't do the filtering and setting
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -669,15 +688,12 @@ public class MedtronicHistoryData {
|
||||||
if (entriesFromHistory.size() == 0) {
|
if (entriesFromHistory.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
} else if (entriesFromHistory.size() == 1) {
|
} else if (entriesFromHistory.size() == 1) {
|
||||||
//DbObjectBase treatment1 = entriesFromHistory.get(0);
|
|
||||||
//LocalDateTime ldt = new LocalDateTime(treatment1.getDate());
|
|
||||||
return entriesFromHistory.get(0);
|
return entriesFromHistory.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int min = 0; min < 5; min++) {
|
for (int sec = 0; sec <= 40; sec += 10) {
|
||||||
for (int sec = 0; sec < 60; sec += 10) {
|
|
||||||
|
|
||||||
int diff = (min * 60 * 1000) + (sec * 1000);
|
int diff = (sec * 1000);
|
||||||
|
|
||||||
List<DbObjectBase> outList = new ArrayList<>();
|
List<DbObjectBase> outList = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -695,11 +711,9 @@ public class MedtronicHistoryData {
|
||||||
return outList.get(0);
|
return outList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (min == 0 && sec == 10 && outList.size() > 1) {
|
if (sec == 10 && outList.size() > 1) {
|
||||||
if (isLogEnabled())
|
LOG.error("Too many entries (with too small diff): (timeDiff=[sec={}],count={},list={})",
|
||||||
LOG.error("Too many entries (with too small diff): (timeDiff=[min={},sec={}],count={},list={})",
|
sec, outList.size(), gson.toJson(outList));
|
||||||
min, sec, outList.size(), gson.toJson(outList));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1120,24 +1134,8 @@ public class MedtronicHistoryData {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is same now
|
|
||||||
private long tryToGetByLocalTime(long atechDateTime) {
|
private long tryToGetByLocalTime(long atechDateTime) {
|
||||||
|
return DateTimeUtil.toMillisFromATD(atechDateTime);
|
||||||
GregorianCalendar gc = DateTimeUtil.toGregorianCalendar(atechDateTime);
|
|
||||||
return gc.getTimeInMillis();
|
|
||||||
|
|
||||||
// LocalDateTime ldt = DateTimeUtil.toLocalDateTime(atechDateTime);
|
|
||||||
//
|
|
||||||
// ldt = ldt.plusSeconds(pumpTime.timeDifference);
|
|
||||||
// ldt = ldt.millisOfSecond().setCopy(000);
|
|
||||||
//
|
|
||||||
// if (isLogEnabled())
|
|
||||||
// LOG.debug("tryToGetByLocalTime: [TimeOfEntry={}, ClockPump={}, LocalTime={}, DifferenceSec={}, "
|
|
||||||
// + "NewTimeOfEntry={}, time={}", atechDateTime, pumpTime.pumpTime.toString("HH:mm:ss"),
|
|
||||||
// pumpTime.localDeviceTime.toString("HH:mm:ss"), pumpTime.timeDifference, ldt.toString("HH:mm:ss"), ldt
|
|
||||||
// .toDate().getTime());
|
|
||||||
//
|
|
||||||
// return ldt.toDate().getTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1147,7 +1145,7 @@ public class MedtronicHistoryData {
|
||||||
PumpHistoryEntry currentTreatment = null;
|
PumpHistoryEntry currentTreatment = null;
|
||||||
|
|
||||||
if (isCollectionEmpty(treatments)) {
|
if (isCollectionEmpty(treatments)) {
|
||||||
return 10; // default return of 10 minutes
|
return 6; // default return of 6 (5 for diif on history reading + 1 for max allowed difference) minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PumpHistoryEntry treatment : treatments) {
|
for (PumpHistoryEntry treatment : treatments) {
|
||||||
|
@ -1163,14 +1161,14 @@ public class MedtronicHistoryData {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
oldestEntryTime = DateTimeUtil.toLocalDateTime(dt);
|
oldestEntryTime = DateTimeUtil.toLocalDateTime(dt);
|
||||||
oldestEntryTime = oldestEntryTime.minusMinutes(5);
|
oldestEntryTime = oldestEntryTime.minusMinutes(1);
|
||||||
|
|
||||||
if (this.pumpTime.timeDifference < 0) {
|
// if (this.pumpTime.timeDifference < 0) {
|
||||||
oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
// oldestEntryTime = oldestEntryTime.plusSeconds(this.pumpTime.timeDifference);
|
||||||
}
|
// }
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
LOG.error("Problem decoding date from last record: {}" + currentTreatment);
|
||||||
return 10; // default return of 10 minutes
|
return 6; // default return of 6 minutes
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalDateTime now = new LocalDateTime();
|
LocalDateTime now = new LocalDateTime();
|
||||||
|
|
Loading…
Reference in a new issue