From af739a3b66438a3a3550e270f43b8b0660c8c5ad Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Thu, 23 May 2019 10:59:28 +0300 Subject: [PATCH] Fixing after comments --- .../automation/triggers/TriggerAutosensValue.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.java index 1dfdd5e95e..1133413d57 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerAutosensValue.java @@ -43,8 +43,9 @@ public class TriggerAutosensValue extends Trigger { private TriggerAutosensValue(TriggerAutosensValue triggerAutosensValue) { super(); - value = triggerAutosensValue.value; + value = new InputDouble(triggerAutosensValue.value); lastRun = triggerAutosensValue.lastRun; + comparator = new Comparator(triggerAutosensValue.comparator); } public double getValue() { @@ -67,12 +68,6 @@ public class TriggerAutosensValue extends Trigger { if (lastRun > DateUtil.now() - T.mins(5).msecs()) return false; - if (autosensData.autosensResult.ratio != 0 && comparator.getValue() == Comparator.Compare.IS_NOT_AVAILABLE) { - if (L.isEnabled(L.AUTOMATION)) - log.debug("Ready for execution: " + friendlyDescription()); - return true; - } - boolean doRun = comparator.getValue().check((autosensData.autosensResult.ratio), (double) (getValue() / 100d)); if (doRun) { if (L.isEnabled(L.AUTOMATION)) @@ -102,7 +97,7 @@ public class TriggerAutosensValue extends Trigger { Trigger fromJSON(String data) { try { JSONObject d = new JSONObject(data); - value.setValue(JsonHelper.safeGetInt(d, "value")); + value.setValue(JsonHelper.safeGetDouble(d, "value")); lastRun = JsonHelper.safeGetLong(d, "lastRun"); comparator.setValue(Comparator.Compare.valueOf(JsonHelper.safeGetString(d, "comparator"))); } catch (Exception e) { @@ -154,4 +149,4 @@ public class TriggerAutosensValue extends Trigger { .add(new LabelWithElement(MainApp.gs(R.string.autosenslabel) + ": ", "", value)) .build(root); } -} \ No newline at end of file +}