show constraints on LoopFragment
This commit is contained in:
parent
661595792f
commit
30f09dc416
|
@ -20,6 +20,7 @@ import butterknife.ButterKnife;
|
|||
import butterknife.OnClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||
|
@ -40,6 +41,8 @@ public class LoopFragment extends SubscriberFragment {
|
|||
TextView requestView;
|
||||
@BindView(R.id.loop_constraintsprocessed)
|
||||
TextView constraintsProcessedView;
|
||||
@BindView(R.id.loop_constraints)
|
||||
TextView constraintsView;
|
||||
@BindView(R.id.loop_tbrsetbypump)
|
||||
TextView tbrSetByPumpView;
|
||||
@BindView(R.id.loop_smbsetbypump)
|
||||
|
@ -85,14 +88,26 @@ public class LoopFragment extends SubscriberFragment {
|
|||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
if (LoopPlugin.lastRun != null) {
|
||||
requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : "");
|
||||
constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : "");
|
||||
sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : "");
|
||||
lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : "");
|
||||
lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : "");
|
||||
tbrSetByPumpView.setText(LoopPlugin.lastRun.tbrSetByPump != null ? LoopPlugin.lastRun.tbrSetByPump.toSpanned() : "");
|
||||
smbSetByPumpView.setText(LoopPlugin.lastRun.smbSetByPump != null ? LoopPlugin.lastRun.smbSetByPump.toSpanned() : "");
|
||||
LoopPlugin.LastRun lastRun = LoopPlugin.lastRun;
|
||||
if (lastRun != null) {
|
||||
requestView.setText(lastRun.request != null ? lastRun.request.toSpanned() : "");
|
||||
constraintsProcessedView.setText(lastRun.constraintsProcessed != null ? lastRun.constraintsProcessed.toSpanned() : "");
|
||||
sourceView.setText(lastRun.source != null ? lastRun.source : "");
|
||||
lastRunView.setText(lastRun.lastAPSRun != null && lastRun.lastAPSRun.getTime() != 0 ? lastRun.lastAPSRun.toLocaleString() : "");
|
||||
lastEnactView.setText(lastRun.lastEnact != null && lastRun.lastEnact.getTime() != 0 ? lastRun.lastEnact.toLocaleString() : "");
|
||||
tbrSetByPumpView.setText(lastRun.tbrSetByPump != null ? lastRun.tbrSetByPump.toSpanned() : "");
|
||||
smbSetByPumpView.setText(lastRun.smbSetByPump != null ? lastRun.smbSetByPump.toSpanned() : "");
|
||||
|
||||
String constraints = "";
|
||||
if (lastRun.constraintsProcessed != null) {
|
||||
Constraint<Double> allConstraints = new Constraint<>(0d);
|
||||
if (lastRun.constraintsProcessed.rateConstraint != null)
|
||||
allConstraints.copyReasons(lastRun.constraintsProcessed.rateConstraint);
|
||||
if (lastRun.constraintsProcessed.smbConstraint != null)
|
||||
allConstraints.copyReasons(lastRun.constraintsProcessed.smbConstraint);
|
||||
constraints = allConstraints.getMostLimitedReasons();
|
||||
}
|
||||
constraintsView.setText(constraints);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -236,6 +236,51 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<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/loop_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="2dip"
|
||||
|
|
Loading…
Reference in a new issue