From 484f3a2a98adc2d10f322cd4d8408d7092d9fcd7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Jun 2020 19:28:56 +0200 Subject: [PATCH 1/3] invalidate cache including bg after bg change --- .../nightscout/androidaps/db/DatabaseHelper.java | 4 +++- .../iobCobCalculator/IobCobCalculatorPlugin.java | 15 +++++++++++---- .../events/EventNewHistoryBgData.kt | 5 +++++ 3 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventNewHistoryBgData.kt diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index 4b8d637c47..4d4c52df43 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -52,6 +52,7 @@ import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryBgData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID; import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset; @@ -386,7 +387,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { old.copyFrom(bgReading); getDaoBgReadings().update(old); aapsLogger.debug(LTag.DATABASE, "BG: Updating record from: " + from + " New data: " + old.toString()); - scheduleBgChange(bgReading); + rxBus.send(new EventNewHistoryBgData(old.date)); // trigger cache invalidation + scheduleBgChange(bgReading); // trigger new calculation return false; } } catch (SQLException e) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index 2f49cd9971..205717dc59 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -39,6 +39,7 @@ import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.interfaces.ProfileFunction; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.data.AutosensData; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryBgData; import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHistoryData; import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin; @@ -159,7 +160,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat runCalculation("onNewProfile", System.currentTimeMillis(), false, true, event); }, fabricPrivacy::logException) ); - // EventNewBG + // EventNewBG .... cannot be used for invalidating because only event with last BG is fired disposable.add(rxBus .toObservable(EventNewBG.class) .observeOn(Schedulers.io()) @@ -203,7 +204,13 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat disposable.add(rxBus .toObservable(EventNewHistoryData.class) .observeOn(Schedulers.io()) - .subscribe(this::newHistoryData, fabricPrivacy::logException) + .subscribe(event -> newHistoryData(event, false), fabricPrivacy::logException) + ); + // EventNewHistoryBgData + disposable.add(rxBus + .toObservable(EventNewHistoryBgData.class) + .observeOn(Schedulers.io()) + .subscribe(event -> newHistoryData(new EventNewHistoryData(event.getTimestamp()), true), fabricPrivacy::logException) ); } @@ -822,7 +829,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } // When historical data is changed (comming from NS etc) finished calculations after this date must be invalidated - private void newHistoryData(EventNewHistoryData ev) { + private void newHistoryData(EventNewHistoryData ev, boolean bgDataReload) { //log.debug("Locking onNewHistoryData"); stopCalculation("onEventNewHistoryData"); synchronized (dataLock) { @@ -862,7 +869,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } } } - runCalculation("onEventNewHistoryData", System.currentTimeMillis(), false, true, ev); + runCalculation("onEventNewHistoryData", System.currentTimeMillis(), bgDataReload, true, ev); //log.debug("Releasing onNewHistoryData"); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventNewHistoryBgData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventNewHistoryBgData.kt new file mode 100644 index 0000000000..5f546c2d9f --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/events/EventNewHistoryBgData.kt @@ -0,0 +1,5 @@ +package info.nightscout.androidaps.plugins.iob.iobCobCalculator.events + +import info.nightscout.androidaps.events.Event + +class EventNewHistoryBgData(val timestamp: Long) : Event() \ No newline at end of file From 15378fb2b8db1336b5ec822e805e4a1cf448d2b2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Jun 2020 21:59:51 +0200 Subject: [PATCH 2/3] InMemoryGlucoseValue --- .../iobCobCalculator/InMemoryGlucoseValue.kt | 8 ++++ .../IobCobCalculatorPlugin.java | 48 +++++++++---------- .../iobCobCalculator/IobCobOref1Thread.java | 14 +++--- .../iob/iobCobCalculator/IobCobThread.java | 14 +++--- 4 files changed, 46 insertions(+), 38 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/InMemoryGlucoseValue.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/InMemoryGlucoseValue.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/InMemoryGlucoseValue.kt new file mode 100644 index 0000000000..55acd27b40 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/InMemoryGlucoseValue.kt @@ -0,0 +1,8 @@ +package info.nightscout.androidaps.plugins.iob.iobCobCalculator + +import info.nightscout.androidaps.db.BgReading + +class InMemoryGlucoseValue constructor(var timestamp: Long = 0L, var value: Double = 0.0) { + + constructor(gv: BgReading) : this(gv.date, gv.value) +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java index 205717dc59..9563519107 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.java @@ -80,7 +80,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat private LongSparseArray basalDataTable = new LongSparseArray<>(); // oldest at index 0 private volatile List bgReadings = null; // newest at index 0 - private volatile List bucketed_data = null; + private volatile List bucketed_data = null; private final Object dataLock = new Object(); @@ -232,7 +232,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat this.bgReadings = bgReadings; } - public List getBucketedData() { + public List getBucketedData() { return bucketed_data; } @@ -342,15 +342,15 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat break; if (older.date == newer.date) { // direct hit - bucketed_data.add(newer); + bucketed_data.add(new InMemoryGlucoseValue(newer)); } else { double bgDelta = newer.value - older.value; long timeDiffToNew = newer.date - currentTime; double currentBg = newer.value - (double) timeDiffToNew / (newer.date - older.date) * bgDelta; - BgReading newBgreading = new BgReading(injector); - newBgreading.date = currentTime; - newBgreading.value = Math.round(currentBg); + InMemoryGlucoseValue newBgreading = new InMemoryGlucoseValue(); + newBgreading.setTimestamp(currentTime); + newBgreading.setValue(Math.round(currentBg)); bucketed_data.add(newBgreading); //log.debug("BG: " + newBgreading.value + " (" + new Date(newBgreading.date).toLocaleString() + ") Prev: " + older.value + " (" + new Date(older.date).toLocaleString() + ") Newer: " + newer.value + " (" + new Date(newer.date).toLocaleString() + ")"); } @@ -367,7 +367,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat } bucketed_data = new ArrayList<>(); - bucketed_data.add(bgReadings.get(0)); + bucketed_data.add(new InMemoryGlucoseValue(bgReadings.get(0))); getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString()); int j = 0; for (int i = 1; i < bgReadings.size(); ++i) { @@ -388,12 +388,12 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat while (elapsed_minutes > 5) { nextbgTime = lastbgTime - 5 * 60 * 1000; j++; - BgReading newBgreading = new BgReading(injector); - newBgreading.date = nextbgTime; + InMemoryGlucoseValue newBgreading = new InMemoryGlucoseValue(); + newBgreading.setTimestamp(nextbgTime); double gapDelta = bgReadings.get(i).value - lastbg; //console.error(gapDelta, lastbg, elapsed_minutes); double nextbg = lastbg + (5d / elapsed_minutes * gapDelta); - newBgreading.value = Math.round(nextbg); + newBgreading.setValue(Math.round(nextbg)); //console.error("Interpolated", bucketed_data[j]); bucketed_data.add(newBgreading); getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); @@ -403,38 +403,38 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat lastbgTime = nextbgTime; } j++; - BgReading newBgreading = new BgReading(injector); - newBgreading.value = bgReadings.get(i).value; - newBgreading.date = bgTime; + InMemoryGlucoseValue newBgreading = new InMemoryGlucoseValue(); + newBgreading.setValue(bgReadings.get(i).value); + newBgreading.setTimestamp(bgTime); bucketed_data.add(newBgreading); getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); } else if (Math.abs(elapsed_minutes) > 2) { j++; - BgReading newBgreading = new BgReading(injector); - newBgreading.value = bgReadings.get(i).value; - newBgreading.date = bgTime; + InMemoryGlucoseValue newBgreading = new InMemoryGlucoseValue(); + newBgreading.setValue(bgReadings.get(i).value); + newBgreading.setTimestamp(bgTime); bucketed_data.add(newBgreading); getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString()); } else { - bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2; + bucketed_data.get(j).setValue((bucketed_data.get(j).getValue() + bgReadings.get(i).value) / 2); //log.error("***** Average"); } } // Normalize bucketed data for (int i = bucketed_data.size() - 2; i >= 0; i--) { - BgReading current = bucketed_data.get(i); - BgReading previous = bucketed_data.get(i + 1); - long msecDiff = current.date - previous.date; + InMemoryGlucoseValue current = bucketed_data.get(i); + InMemoryGlucoseValue previous = bucketed_data.get(i + 1); + long msecDiff = current.getTimestamp() - previous.getTimestamp(); long adjusted = (msecDiff - T.mins(5).msecs()) / 1000; - getAapsLogger().debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec"); + getAapsLogger().debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.getTimestamp()) + " to: " + DateUtil.toISOString(previous.getTimestamp() + T.mins(5).msecs()) + " by " + adjusted + " sec"); if (Math.abs(adjusted) > 90) { // too big adjustment, fallback to non 5 min data getAapsLogger().debug(LTag.AUTOSENS, "Fallback to non 5 min data"); createBucketedDataRecalculated(); return; } - current.date = previous.date + T.mins(5).msecs(); + current.setTimestamp(previous.getTimestamp() + T.mins(5).msecs()); } getAapsLogger().debug(LTag.AUTOSENS, "Bucketed data created. Size: " + bucketed_data.size()); @@ -551,8 +551,8 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat if (bucketed_data == null) return null; for (int index = 0; index < bucketed_data.size(); index++) { - if (bucketed_data.get(index).date <= time) - return bucketed_data.get(index).date; + if (bucketed_data.get(index).getTimestamp() <= time) + return bucketed_data.get(index).getTimestamp(); } return null; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java index e0e6edf0c4..431d27f63c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobOref1Thread.java @@ -119,7 +119,7 @@ public class IobCobOref1Thread extends Thread { iobCobCalculatorPlugin.createBucketedData(); rxBus.send(new EventAutosensBgLoaded(cause)); } - List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); + List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); if (bucketed_data == null || bucketed_data.size() < 3) { @@ -127,7 +127,7 @@ public class IobCobOref1Thread extends Thread { return; } - long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); + long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).getTimestamp()); aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime)); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob @@ -141,7 +141,7 @@ public class IobCobOref1Thread extends Thread { return; } // check if data already exists - long bgTime = bucketed_data.get(i).date; + long bgTime = bucketed_data.get(i).getTimestamp(); bgTime = IobCobCalculatorPlugin.roundUpTime(bgTime); if (bgTime > IobCobCalculatorPlugin.roundUpTime(now())) continue; @@ -173,14 +173,14 @@ public class IobCobOref1Thread extends Thread { double bg; double avgDelta; double delta; - bg = bucketed_data.get(i).value; - if (bg < 39 || bucketed_data.get(i + 3).value < 39) { + bg = bucketed_data.get(i).getValue(); + if (bg < 39 || bucketed_data.get(i + 3).getValue() < 39) { aapsLogger.error("! value < 39"); continue; } autosensData.bg = bg; - delta = (bg - bucketed_data.get(i + 1).value); - avgDelta = (bg - bucketed_data.get(i + 3).value) / 3; + delta = (bg - bucketed_data.get(i + 1).getValue()); + avgDelta = (bg - bucketed_data.get(i + 3).getValue()) / 3; IobTotal iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTemps(bgTime, profile); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java index 8cdb88c817..d2d73c1ba9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobThread.java @@ -116,7 +116,7 @@ public class IobCobThread extends Thread { iobCobCalculatorPlugin.createBucketedData(); rxBus.send(new EventAutosensBgLoaded(cause)); } - List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); + List bucketed_data = iobCobCalculatorPlugin.getBucketedData(); LongSparseArray autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); if (bucketed_data == null || bucketed_data.size() < 3) { @@ -124,7 +124,7 @@ public class IobCobThread extends Thread { return; } - long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); + long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).getTimestamp()); aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime)); AutosensData previous = autosensDataTable.get(prevDataTime); // start from oldest to be able sub cob @@ -138,7 +138,7 @@ public class IobCobThread extends Thread { return; } // check if data already exists - long bgTime = bucketed_data.get(i).date; + long bgTime = bucketed_data.get(i).getTimestamp(); bgTime = IobCobCalculatorPlugin.roundUpTime(bgTime); if (bgTime > IobCobCalculatorPlugin.roundUpTime(now())) continue; @@ -170,14 +170,14 @@ public class IobCobThread extends Thread { double bg; double avgDelta; double delta; - bg = bucketed_data.get(i).value; - if (bg < 39 || bucketed_data.get(i + 3).value < 39) { + bg = bucketed_data.get(i).getValue(); + if (bg < 39 || bucketed_data.get(i + 3).getValue() < 39) { aapsLogger.error("! value < 39"); continue; } autosensData.bg = bg; - delta = (bg - bucketed_data.get(i + 1).value); - avgDelta = (bg - bucketed_data.get(i + 3).value) / 3; + delta = (bg - bucketed_data.get(i + 1).getValue()); + avgDelta = (bg - bucketed_data.get(i + 3).getValue()) / 3; IobTotal iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTemps(bgTime, profile); From fbb15cac7036e9d35f9a655ebaa7f48b428ec1b7 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 2 Jun 2020 22:47:32 +0200 Subject: [PATCH 3/3] fix tests --- .../IobCobCalculatorPluginTest.kt | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt index a34d8b5022..93a30ca973 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/iob/iobCobCalculatorPlugin/IobCobCalculatorPluginTest.kt @@ -143,8 +143,8 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(bgReadingList[0].date, iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(bgReadingList[3].date, iobCobCalculatorPlugin.bucketedData[3].date) + Assert.assertEquals(bgReadingList[0].date, iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(bgReadingList[3].date, iobCobCalculatorPlugin.bucketedData[3].timestamp) Assert.assertEquals(bgReadingList.size.toLong(), iobCobCalculatorPlugin.bucketedData.size.toLong()) // Missing value should be replaced @@ -155,8 +155,8 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(bgReadingList[0].date, iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(bgReadingList[2].date, iobCobCalculatorPlugin.bucketedData[3].date) + Assert.assertEquals(bgReadingList[0].date, iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(bgReadingList[2].date, iobCobCalculatorPlugin.bucketedData[3].timestamp) Assert.assertEquals(bgReadingList.size + 1.toLong(), iobCobCalculatorPlugin.bucketedData.size.toLong()) // drift should be cleared @@ -169,10 +169,10 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(T.mins(15).msecs(), iobCobCalculatorPlugin.bucketedData[1].date) - Assert.assertEquals(T.mins(10).msecs(), iobCobCalculatorPlugin.bucketedData[2].date) - Assert.assertEquals(T.mins(5).msecs(), iobCobCalculatorPlugin.bucketedData[3].date) + Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(T.mins(15).msecs(), iobCobCalculatorPlugin.bucketedData[1].timestamp) + Assert.assertEquals(T.mins(10).msecs(), iobCobCalculatorPlugin.bucketedData[2].timestamp) + Assert.assertEquals(T.mins(5).msecs(), iobCobCalculatorPlugin.bucketedData[3].timestamp) Assert.assertEquals(bgReadingList.size.toLong(), iobCobCalculatorPlugin.bucketedData.size.toLong()) // bucketed data should return null if not enough bg data @@ -192,8 +192,8 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(T.mins(50).msecs(), iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[6].date) + Assert.assertEquals(T.mins(50).msecs(), iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[6].timestamp) Assert.assertEquals(7, iobCobCalculatorPlugin.bucketedData.size.toLong()) Assert.assertEquals(100.0, iobCobCalculatorPlugin.bucketedData[0].value, 1.0) Assert.assertEquals(90.0, iobCobCalculatorPlugin.bucketedData[1].value, 1.0) @@ -208,8 +208,8 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(false, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(T.mins(50).msecs(), iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[6].date) + Assert.assertEquals(T.mins(50).msecs(), iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(T.mins(20).msecs(), iobCobCalculatorPlugin.bucketedData[6].timestamp) Assert.assertEquals(7, iobCobCalculatorPlugin.bucketedData.size.toLong()) Assert.assertEquals(100.0, iobCobCalculatorPlugin.bucketedData[0].value, 1.0) Assert.assertEquals(90.0, iobCobCalculatorPlugin.bucketedData[1].value, 1.0) @@ -342,8 +342,8 @@ class IobCobCalculatorPluginTest : TestBase() { iobCobCalculatorPlugin.bgReadings = bgReadingList Assert.assertEquals(true, iobCobCalculatorPlugin.isAbout5minData) iobCobCalculatorPlugin.createBucketedData() - Assert.assertEquals(DateUtil.fromISODateString("2018-09-05T13:34:57Z").time, iobCobCalculatorPlugin.bucketedData[0].date) - Assert.assertEquals(DateUtil.fromISODateString("2018-09-05T03:44:57Z").time, iobCobCalculatorPlugin.bucketedData[iobCobCalculatorPlugin.bucketedData.size - 1].date) + Assert.assertEquals(DateUtil.fromISODateString("2018-09-05T13:34:57Z").time, iobCobCalculatorPlugin.bucketedData[0].timestamp) + Assert.assertEquals(DateUtil.fromISODateString("2018-09-05T03:44:57Z").time, iobCobCalculatorPlugin.bucketedData[iobCobCalculatorPlugin.bucketedData.size - 1].timestamp) // 5min 4sec data bgReadingList.clear()