allow return GlucoseStatus with only 1 actual value

This commit is contained in:
Milos Kozak 2017-04-04 10:29:46 +02:00
parent e5012d8633
commit 42883a81a0

View file

@ -73,7 +73,7 @@ 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 < 4 || data.get(0).timeIndex < new Date().getTime() - 7 * 60 * 1000L) { if (sizeRecords < 1 || data.get(0).timeIndex < new Date().getTime() - 7 * 60 * 1000L) {
return null; return null;
} }
@ -81,6 +81,16 @@ public class GlucoseStatus {
long now_date = now.timeIndex; long now_date = now.timeIndex;
double change; double change;
if (sizeRecords < 2) {
GlucoseStatus status = new GlucoseStatus();
status.glucose = now.value;
status.short_avgdelta = 0d;
status.delta = 0d;
status.long_avgdelta = 0d;
status.avgdelta = 0d; // for OpenAPS MA
return status.round();
}
ArrayList<Double> last_deltas = new ArrayList<Double>(); ArrayList<Double> last_deltas = new ArrayList<Double>();
ArrayList<Double> short_deltas = new ArrayList<Double>(); ArrayList<Double> short_deltas = new ArrayList<Double>();
ArrayList<Double> long_deltas = new ArrayList<Double>(); ArrayList<Double> long_deltas = new ArrayList<Double>();