diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java b/app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java index de3d266d7b..7b6609b79c 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/Constraint.java @@ -64,7 +64,7 @@ public class Constraint { } public Constraint reason(String reason, Object from) { - reasons.add(from.getClass().getSimpleName() + ": " + reason); + reasons.add(from.getClass().getSimpleName().replace("Plugin", "") + ": " + reason); return this; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java index 958743234d..9b851c64c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java @@ -40,6 +40,8 @@ public class APSResult { public double smb = 0d; // super micro bolus in units public long deliverAt = 0; + public Constraint inputConstraints; + public Constraint rateConstraint; public Constraint smbConstraint; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java index 6c720adc48..dcba600fb4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBFragment.java @@ -16,6 +16,9 @@ import org.json.JSONException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; @@ -24,19 +27,32 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateRes import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.JSONFormatter; -public class OpenAPSSMBFragment extends SubscriberFragment implements View.OnClickListener { +public class OpenAPSSMBFragment extends SubscriberFragment { private static Logger log = LoggerFactory.getLogger(OpenAPSSMBFragment.class); + @BindView(R.id.openapsma_run) Button run; + @BindView(R.id.openapsma_lastrun) TextView lastRunView; + @BindView(R.id.openapsma_constraints) + TextView constraintsView; + @BindView(R.id.openapsma_glucosestatus) TextView glucoseStatusView; + @BindView(R.id.openapsma_currenttemp) TextView currentTempView; + @BindView(R.id.openapsma_iobdata) TextView iobDataView; + @BindView(R.id.openapsma_profile) TextView profileView; + @BindView(R.id.openapsma_mealdata) TextView mealDataView; + @BindView(R.id.openapsma_autosensdata) TextView autosensDataView; + @BindView(R.id.openapsma_result) TextView resultView; + @BindView(R.id.openapsma_scriptdebugdata) TextView scriptdebugView; + @BindView(R.id.openapsma_request) TextView requestView; @Override @@ -44,32 +60,14 @@ public class OpenAPSSMBFragment extends SubscriberFragment implements View.OnCli Bundle savedInstanceState) { View view = inflater.inflate(R.layout.openapsama_fragment, container, false); - run = (Button) view.findViewById(R.id.openapsma_run); - run.setOnClickListener(this); - lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun); - glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus); - currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp); - iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata); - profileView = (TextView) view.findViewById(R.id.openapsma_profile); - mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata); - autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata); - scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata); - resultView = (TextView) view.findViewById(R.id.openapsma_result); - requestView = (TextView) view.findViewById(R.id.openapsma_request); - - updateGUI(); + unbinder = ButterKnife.bind(this, view); return view; } - @Override - public void onClick(View view) { - switch (view.getId()) { - case R.id.openapsma_run: - OpenAPSSMBPlugin.getPlugin().invoke("OpenAPSSMB button"); - FabricPrivacy.getInstance().logCustom(new CustomEvent("OpenAPS_SMB_Run")); - break; - } - + @OnClick(R.id.openapsma_run) + public void onRunClick() { + OpenAPSSMBPlugin.getPlugin().invoke("OpenAPSSMB button"); + FabricPrivacy.getInstance().logCustom(new CustomEvent("OpenAPS_SMB_Run")); } @Subscribe @@ -109,6 +107,8 @@ public class OpenAPSSMBFragment extends SubscriberFragment implements View.OnCli profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam())); mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam())); scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug()); + if (lastAPSResult != null && lastAPSResult.inputConstraints != null) + constraintsView.setText(lastAPSResult.inputConstraints.getReasons()); } if (plugin.lastAPSRun != null) { lastRunView.setText(plugin.lastAPSRun.toLocaleString()); 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 af0810cfa6..7ea785988d 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 @@ -180,7 +180,11 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface { String units = profile.getUnits(); - double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value(); + Constraint inputConstraints = new Constraint<>(0d); // fake. only for collecting all results + + Constraint maxBasalConstraint = MainApp.getConstraintChecker().getMaxBasalAllowed(profile); + inputConstraints.copyReasons(maxBasalConstraint); + double maxBasal = maxBasalConstraint.value(); double minBg = Profile.toMgdl(profile.getTargetLow(), units); double maxBg = Profile.toMgdl(profile.getTargetHigh(), units); double targetBg = Profile.toMgdl(profile.getTarget(), units); @@ -269,6 +273,8 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface { log.error("Unhandled exception", e); } + determineBasalResultSMB.inputConstraints = inputConstraints; + lastDetermineBasalAdapterSMBJS = determineBasalAdapterSMBJS; lastAPSResult = determineBasalResultSMB; lastAPSRun = new Date(now); diff --git a/app/src/main/res/layout/configbuilder_fragment.xml b/app/src/main/res/layout/configbuilder_fragment.xml index 2b2a7ef185..90e0026418 100644 --- a/app/src/main/res/layout/configbuilder_fragment.xml +++ b/app/src/main/res/layout/configbuilder_fragment.xml @@ -184,7 +184,7 @@ android:layout_marginBottom="5dp" android:background="@color/mdtp_circle_color" android:paddingLeft="5dp" - android:text="@string/configbuilder_constraints" + android:text="@string/constraints" android:textAllCaps="true" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@android:color/black" diff --git a/app/src/main/res/layout/openapsama_fragment.xml b/app/src/main/res/layout/openapsama_fragment.xml index a471429567..bfe3b73d69 100644 --- a/app/src/main/res/layout/openapsama_fragment.xml +++ b/app/src/main/res/layout/openapsama_fragment.xml @@ -89,9 +89,45 @@ + + + + + + + + + + Общи дни Минимална продължителност - Ограничения + Ограничения Loop Loop APS diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index a62329ae4b..30cd42c89e 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -47,7 +47,7 @@ Konfigurace APS Zdroj glykémie - Omezení + Omezení Obecné Smyčka Profil diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index bbe2ed5497..0bad8b97e0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -141,7 +141,7 @@ Eingegeben durch Anderes Split - Beschränkungen + Beschränkungen Generell Behandlungen Beschränkungen angewendet! diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 1b7fdf8022..d071fa7f8e 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -86,7 +86,7 @@ Γενικά ημέρες Ελάχ.Διάρκεια - Περιορισμοί + Περιορισμοί Κύκλωμα Κύκλωμα APS diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index af936ed618..ee63a899c3 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -78,7 +78,7 @@ General días Duración mínima - Restricciones + Restricciones Lazo Lazo APS diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 67ecda2b0f..2d0d2ff32d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -81,7 +81,7 @@ Général Jours Durée minimale - Restrictions + Restrictions Loop Loop APS diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 352f802ee6..3c738259b3 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -71,7 +71,7 @@ Configurazione Strutturale APS Origine glicemia - Costrizione + Costrizione Generale Insulina Loop diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 46f1cb3525..89d0dca30d 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -84,7 +84,7 @@ 일반 최소기간 - 제한 + 제한 Loop Loop APS diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index ca73dcbffa..86cab639c4 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -129,7 +129,7 @@ Configurator APS BG bron - Beperkingen + Beperkingen Algemeen Insuline curve Ledig wachtrij diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index aca835b34d..e6ade785bb 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -83,7 +83,7 @@ General zile Durată minimă - Constrângeri + Constrângeri Loop Loop diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index ddc446b62c..f1e03c7251 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -84,7 +84,7 @@ конфигуратор APS источник СК - ограничения + ограничения общее инсулин замкнутый цикл diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 669f96e4e9..47bd827e0a 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -84,7 +84,7 @@ Konfigurationsverktyg APS BG Källa - Begränsningar + Begränsningar Generell Insulin Loop diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9e6bbe311b..4ff9bce87d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,7 +89,7 @@ General days Minimal duration - Constraints + Constraints Loop Loop @@ -967,7 +967,7 @@ Closed loop mode disabled in preferences Autosens disabled in preferences SMB disabled in preferences - Limiting basal rate to %.2f U/h because of %s + Limiting max basal rate to %.2f U/h because of %s pump limit openapsma_max_basal openapsama_current_basal_safety_multiplier @@ -978,7 +978,7 @@ openapsma_max_iob A bolus was delivered within the last 3 minutes, skipping SMB Basal set correctly - Limiting percent rate to %d%% because of %s + Limiting max percent rate to %d%% because of %s treatmentssafety_maxbolus Limiting bolus to %.1f U because of %s Limiting max IOB to %.1f U because of %s