From d8798e0bcf26c711b9e6a747203c9d3c61d7ba54 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Nov 2017 13:23:25 +0100 Subject: [PATCH 1/5] use mills from status if available --- .../plugins/NSClientInternal/data/NSDeviceStatus.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java index 2df50b2bd1..2bd61aa4a9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java @@ -336,7 +336,9 @@ public class NSDeviceStatus { try { long clock = 0L; - if (object.has("created_at")) + if (object.has("mills")) + clock = object.getLong("mills"); + else if (object.has("created_at")) clock = DateUtil.fromISODateString(object.getString("created_at")).getTime(); String device = getDevice(); Integer battery = null; From 297617467e880784c04335f5bf13184385e1d047 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Nov 2017 13:34:13 +0100 Subject: [PATCH 2/5] fix format and add test for fromISODateString --- .../java/info/nightscout/utils/DateUtil.java | 4 +-- .../info/nightscout/utils/DateUtilTest.java | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/src/test/java/info/nightscout/utils/DateUtilTest.java diff --git a/app/src/main/java/info/nightscout/utils/DateUtil.java b/app/src/main/java/info/nightscout/utils/DateUtil.java index 3e32557adb..1e399ddd58 100644 --- a/app/src/main/java/info/nightscout/utils/DateUtil.java +++ b/app/src/main/java/info/nightscout/utils/DateUtil.java @@ -27,8 +27,8 @@ public class DateUtil { /** * The date format in iso. */ - private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; + private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ"; + private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; /** * Takes in an ISO date string of the following format: diff --git a/app/src/test/java/info/nightscout/utils/DateUtilTest.java b/app/src/test/java/info/nightscout/utils/DateUtilTest.java new file mode 100644 index 0000000000..f269253ba8 --- /dev/null +++ b/app/src/test/java/info/nightscout/utils/DateUtilTest.java @@ -0,0 +1,25 @@ +package info.nightscout.utils; + + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Created by mike on 20.11.2017. + */ + +public class DateUtilTest { + + public DateUtilTest() { + super(); + } + + @Test + public void fromISODateStringTest() throws Exception { + assertEquals( 1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime()); + assertEquals( 1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime()); + } + + +} From 777aedd5db77bb839d9d980003596a60d28e0b1c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Nov 2017 15:25:44 +0100 Subject: [PATCH 3/5] fix setting of TRB when low basal rate is running --- .../androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 12f1f46c1c..c074e7a8d0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -564,7 +564,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain if (Config.logCongigBuilderActions) log.debug("applyAPSRequest: " + request.toString()); - if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < 0.05) { + if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < getPumpDescription().basalStep) { if (isTempBasalInProgress()) { if (Config.logCongigBuilderActions) log.debug("applyAPSRequest: cancelTempBasal()"); From 0f0f39dfb4c4536f0b0936844f8547d7eff1f135 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Nov 2017 17:26:03 +0100 Subject: [PATCH 4/5] log profiles if different --- .../plugins/ConfigBuilder/ConfigBuilderPlugin.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index c074e7a8d0..eb8f6cb442 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -409,9 +409,13 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain @Override public boolean isThisProfileSet(Profile profile) { - if (activePump != null) - return activePump.isThisProfileSet(profile); - else return true; + if (activePump != null) { + boolean result = activePump.isThisProfileSet(profile); + if (result == false) { + log.debug("Current profile: " + getProfile().getData().toString()); + log.debug("New profile: " + profile.getData().toString()); + } + } else return true; } @Override From 2f0599fbc73c50dc8cc583b0fbb634c682a061be Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 20 Nov 2017 17:38:06 +0100 Subject: [PATCH 5/5] missing return --- .../androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index eb8f6cb442..51021f150d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -415,6 +415,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain log.debug("Current profile: " + getProfile().getData().toString()); log.debug("New profile: " + profile.getData().toString()); } + return result; } else return true; }