show max basal limit on smb fragment
This commit is contained in:
parent
ad8ff15cdc
commit
3f5808eca3
19 changed files with 87 additions and 43 deletions
|
@ -64,7 +64,7 @@ public class Constraint<T extends Comparable> {
|
|||
}
|
||||
|
||||
public Constraint reason(String reason, Object from) {
|
||||
reasons.add(from.getClass().getSimpleName() + ": " + reason);
|
||||
reasons.add(from.getClass().getSimpleName().replace("Plugin", "") + ": " + reason);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ public class APSResult {
|
|||
public double smb = 0d; // super micro bolus in units
|
||||
public long deliverAt = 0;
|
||||
|
||||
public Constraint<Double> inputConstraints;
|
||||
|
||||
public Constraint<Double> rateConstraint;
|
||||
public Constraint<Double> smbConstraint;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -180,7 +180,11 @@ public class OpenAPSSMBPlugin implements PluginBase, APSInterface {
|
|||
|
||||
String units = profile.getUnits();
|
||||
|
||||
double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||
Constraint<Double> inputConstraints = new Constraint<>(0d); // fake. only for collecting all results
|
||||
|
||||
Constraint<Double> 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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -89,9 +89,45 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:gravity="end"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/constraints"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingEnd="2dp"
|
||||
android:paddingStart="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/openapsma_constraints"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="5dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dip"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<string name="configbuilder_general">Общи</string>
|
||||
<string name="days">дни</string>
|
||||
<string name="objectives_minimalduration">Минимална продължителност</string>
|
||||
<string name="configbuilder_constraints">Ограничения</string>
|
||||
<string name="constraints">Ограничения</string>
|
||||
<string name="loop">Loop</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<string name="configbuilder">Konfigurace</string>
|
||||
<string name="configbuilder_aps">APS</string>
|
||||
<string name="configbuilder_bgsource">Zdroj glykémie</string>
|
||||
<string name="configbuilder_constraints">Omezení</string>
|
||||
<string name="constraints">Omezení</string>
|
||||
<string name="configbuilder_general">Obecné</string>
|
||||
<string name="configbuilder_loop">Smyčka</string>
|
||||
<string name="configbuilder_profile">Profil</string>
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
<string name="careportal_newnstreatment_enteredby_title">Eingegeben durch</string>
|
||||
<string name="careportal_newnstreatment_other">Anderes</string>
|
||||
<string name="careportal_newnstreatment_split_label">Split</string>
|
||||
<string name="configbuilder_constraints">Beschränkungen</string>
|
||||
<string name="constraints">Beschränkungen</string>
|
||||
<string name="configbuilder_general">Generell</string>
|
||||
<string name="configbuilder_treatments">Behandlungen</string>
|
||||
<string name="constraintapllied">Beschränkungen angewendet!</string>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<string name="configbuilder_general">Γενικά</string>
|
||||
<string name="days">ημέρες</string>
|
||||
<string name="objectives_minimalduration">Ελάχ.Διάρκεια</string>
|
||||
<string name="configbuilder_constraints">Περιορισμοί</string>
|
||||
<string name="constraints">Περιορισμοί</string>
|
||||
<string name="loop">Κύκλωμα</string>
|
||||
<string name="configbuilder_loop">Κύκλωμα</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
<string name="configbuilder_general">General</string>
|
||||
<string name="days">días</string>
|
||||
<string name="objectives_minimalduration">Duración mínima</string>
|
||||
<string name="configbuilder_constraints">Restricciones</string>
|
||||
<string name="constraints">Restricciones</string>
|
||||
<string name="loop">Lazo</string>
|
||||
<string name="configbuilder_loop">Lazo</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
<string name="configbuilder_general">Général</string>
|
||||
<string name="days">Jours</string>
|
||||
<string name="objectives_minimalduration">Durée minimale</string>
|
||||
<string name="configbuilder_constraints">Restrictions</string>
|
||||
<string name="constraints">Restrictions</string>
|
||||
<string name="loop">Loop</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<string name="configbuilder">Configurazione Strutturale</string>
|
||||
<string name="configbuilder_aps">APS</string>
|
||||
<string name="configbuilder_bgsource">Origine glicemia</string>
|
||||
<string name="configbuilder_constraints">Costrizione</string>
|
||||
<string name="constraints">Costrizione</string>
|
||||
<string name="configbuilder_general">Generale</string>
|
||||
<string name="configbuilder_insulin">Insulina</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<string name="configbuilder_general">일반</string>
|
||||
<string name="days">일</string>
|
||||
<string name="objectives_minimalduration">최소기간</string>
|
||||
<string name="configbuilder_constraints">제한</string>
|
||||
<string name="constraints">제한</string>
|
||||
<string name="loop">Loop</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<string name="configbuilder">Configurator</string>
|
||||
<string name="configbuilder_aps">APS</string>
|
||||
<string name="configbuilder_bgsource">BG bron</string>
|
||||
<string name="configbuilder_constraints">Beperkingen</string>
|
||||
<string name="constraints">Beperkingen</string>
|
||||
<string name="configbuilder_general">Algemeen</string>
|
||||
<string name="configbuilder_insulin">Insuline curve</string>
|
||||
<string name="clear_queue">Ledig wachtrij</string>
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<string name="configbuilder_general">General</string>
|
||||
<string name="days">zile</string>
|
||||
<string name="objectives_minimalduration">Durată minimă</string>
|
||||
<string name="configbuilder_constraints">Constrângeri</string>
|
||||
<string name="constraints">Constrângeri</string>
|
||||
|
||||
<string name="loop">Loop</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<string name="configbuilder">конфигуратор</string>
|
||||
<string name="configbuilder_aps">APS</string>
|
||||
<string name="configbuilder_bgsource">источник СК</string>
|
||||
<string name="configbuilder_constraints">ограничения</string>
|
||||
<string name="constraints">ограничения</string>
|
||||
<string name="configbuilder_general">общее</string>
|
||||
<string name="configbuilder_insulin">инсулин</string>
|
||||
<string name="configbuilder_loop">замкнутый цикл</string>
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
<string name="configbuilder">Konfigurationsverktyg</string>
|
||||
<string name="configbuilder_aps">APS</string>
|
||||
<string name="configbuilder_bgsource">BG Källa</string>
|
||||
<string name="configbuilder_constraints">Begränsningar</string>
|
||||
<string name="constraints">Begränsningar</string>
|
||||
<string name="configbuilder_general">Generell</string>
|
||||
<string name="configbuilder_insulin">Insulin</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<string name="configbuilder_general">General</string>
|
||||
<string name="days">days</string>
|
||||
<string name="objectives_minimalduration">Minimal duration</string>
|
||||
<string name="configbuilder_constraints">Constraints</string>
|
||||
<string name="constraints">Constraints</string>
|
||||
|
||||
<string name="loop">Loop</string>
|
||||
<string name="configbuilder_loop">Loop</string>
|
||||
|
@ -967,7 +967,7 @@
|
|||
<string name="closedmodedisabledinpreferences">Closed loop mode disabled in preferences</string>
|
||||
<string name="autosensdisabledinpreferences">Autosens disabled in preferences</string>
|
||||
<string name="smbdisabledinpreferences">SMB disabled in preferences</string>
|
||||
<string name="limitingbasalratio">Limiting basal rate to %.2f U/h because of %s</string>
|
||||
<string name="limitingbasalratio">Limiting max basal rate to %.2f U/h because of %s</string>
|
||||
<string name="pumplimit">pump limit</string>
|
||||
<string name="key_openapsma_max_basal" translatable="false">openapsma_max_basal</string>
|
||||
<string name="key_openapsama_current_basal_safety_multiplier" translatable="false">openapsama_current_basal_safety_multiplier</string>
|
||||
|
@ -978,7 +978,7 @@
|
|||
<string name="key_openapsma_max_iob" translatable="false">openapsma_max_iob</string>
|
||||
<string name="smb_frequency_exceeded">A bolus was delivered within the last 3 minutes, skipping SMB</string>
|
||||
<string name="basal_set_correctly">Basal set correctly</string>
|
||||
<string name="limitingpercentrate" formatted="false">Limiting percent rate to %d%% because of %s</string>
|
||||
<string name="limitingpercentrate" formatted="false">Limiting max percent rate to %d%% because of %s</string>
|
||||
<string name="key_treatmentssafety_maxbolus" translatable="false">treatmentssafety_maxbolus</string>
|
||||
<string name="limitingbolus" formatted="false">Limiting bolus to %.1f U because of %s</string>
|
||||
<string name="limitingmaxiob" formatted="false">Limiting max IOB to %.1f U because of %s</string>
|
||||
|
|
Loading…
Reference in a new issue