From 777542dbb80355b3407ea357d9e2bffdbfa92ca6 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 22 Jul 2018 17:57:17 +0200 Subject: [PATCH] Abort APS run if AS requested but not yet available. Should only occur during startup or when something else is broken already, so just return. --- .../androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 6 +++++- .../androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 60853ed4d1..28cc0b328c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; +import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -173,7 +174,10 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { startPart = new Date(); if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) { - lastAutosensResult = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin").autosensResult; + AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin"); + if (autosensData == null) { + return; + } } else { lastAutosensResult = new AutosensResult(); lastAutosensResult.sensResult = "autosens disabled"; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index 1bb4c25bb3..62729e869d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps.plugins.OpenAPSSMB; +import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -180,7 +181,11 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { startPart = new Date(); if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) { - lastAutosensResult = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin").autosensResult; + AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin"); + if (autosensData == null) { + return; + } + lastAutosensResult = autosensData.autosensResult; } else { lastAutosensResult = new AutosensResult(); lastAutosensResult.sensResult = "autosens disabled";