Allow EB in open loop mode

This commit is contained in:
Milos Kozak 2020-01-13 22:16:13 +01:00
parent 6e40c2ebc6
commit 94dd843825
8 changed files with 90 additions and 32 deletions

View file

@ -325,8 +325,8 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
}
public String toStringMedium() {
return "E " + DecimalFormatter.to2Decimal(absoluteRate()) + "U/h ("
+ getRealDuration() + "/" + durationInMinutes + ") ";
return DecimalFormatter.to2Decimal(absoluteRate()) + "U/h "
+ getRealDuration() + "/" + durationInMinutes + "'";
}
public String toStringTotal() {

View file

@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DecimalFormatter;
import info.nightscout.androidaps.utils.HardLimits;
import info.nightscout.androidaps.utils.Round;
@ -74,6 +75,9 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
value.set(false, MainApp.gs(R.string.closed_loop_disabled_on_dev_branch), this);
}
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
value.set(false, MainApp.gs(R.string.closed_loop_disabled_with_eb), this);
}
return value;
}

View file

@ -29,11 +29,7 @@ import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.dialogs.TempTargetDialog
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.SP
import info.nightscout.androidaps.utils.SingleClickButton
import info.nightscout.androidaps.utils.plusAssign
import info.nightscout.androidaps.utils.toVisibility
import info.nightscout.androidaps.utils.*
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import kotlinx.android.synthetic.main.actions_fragment.*
@ -62,7 +58,12 @@ class ActionsFragment : Fragment() {
fragmentManager?.let { TempTargetDialog().show(it, "Actions") }
}
actions_extendedbolus.setOnClickListener {
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
context?.let { context ->
OKDialog.showConfirmation(context, MainApp.gs(R.string.extended_bolus), MainApp.gs(R.string.ebstopsloop),
Runnable {
fragmentManager?.let { ExtendedBolusDialog().show(it, "Actions") }
}, null)
}
}
actions_extendedbolus_cancel.setOnClickListener {
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress) {
@ -178,7 +179,7 @@ class ActionsFragment : Fragment() {
actions_profileswitch?.visibility = if (!basalProfileEnabled || !pump.isInitialized || pump.isSuspended) View.GONE else View.VISIBLE
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses || Config.APS) {
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized || pump.isSuspended || pump.isFakingTempsByExtendedBoluses) {
actions_extendedbolus?.visibility = View.GONE
actions_extendedbolus_cancel?.visibility = View.GONE
} else {
@ -186,7 +187,7 @@ class ActionsFragment : Fragment() {
if (activeExtendedBolus != null) {
actions_extendedbolus?.visibility = View.GONE
actions_extendedbolus_cancel?.visibility = View.VISIBLE
actions_extendedbolus_cancel?.text = MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toString()
actions_extendedbolus_cancel?.text = MainApp.gs(R.string.cancel) + " " + activeExtendedBolus.toStringMedium()
} else {
actions_extendedbolus?.visibility = View.VISIBLE
actions_extendedbolus_cancel?.visibility = View.GONE

View file

@ -137,6 +137,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
TextView avgdeltaView;
TextView baseBasalView;
TextView extendedBolusView;
LinearLayout extendedBolusLayout;
TextView activeProfileView;
TextView iobView;
TextView cobView;
@ -240,6 +241,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
extendedBolusLayout = view.findViewById(R.id.overview_extendedbolus_layout);
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
@ -1187,15 +1189,18 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
} else {
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
extendedBolusText = extendedBolus.toString();
extendedBolusText = extendedBolus.toStringMedium();
}
}
extendedBolusView.setText(extendedBolusText);
extendedBolusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.extended_bolus), extendedBolus.toString()));
if (extendedBolusText.equals(""))
extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE);
else
if (extendedBolusText.equals("")) {
extendedBolusLayout.setVisibility(View.GONE);
if (extendedBolusLayout != null) extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE);
} else {
extendedBolusView.setVisibility(View.VISIBLE);
if (extendedBolusLayout != null) extendedBolusLayout.setVisibility(View.VISIBLE);
}
}
activeProfileView.setText(ProfileFunctions.getInstance().getProfileNameWithDuration());

View file

@ -9,6 +9,7 @@ import android.telephony.SmsManager
import android.telephony.SmsMessage
import android.text.TextUtils
import com.andreabaccega.widget.ValidatingEditTextPreference
import info.nightscout.androidaps.Config
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R
@ -597,6 +598,7 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
override fun run() {
if (result.success) {
var replyText = String.format(MainApp.gs(R.string.smscommunicator_extendedset), aDouble, duration)
if (Config.APS) replyText += "\n" + MainApp.gs(R.string.loopsuspended)
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
} else {

View file

@ -270,6 +270,37 @@
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/overview_extendedbolus_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short"
android:textSize="16sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:text=":"
android:textSize="16sp" />
<TextView
android:id="@+id/overview_extendedbolus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="16sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -356,15 +387,6 @@
</LinearLayout>
<TextView
android:id="@+id/overview_extendedbolus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/mdtp_white" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"

View file

@ -273,6 +273,36 @@
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/overview_extendedbolus_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginEnd="1dp"
android:text="@string/extended_bolus_short"
android:textSize="14sp" />
<TextView
android:layout_width="5dp"
android:layout_height="wrap_content"
android:text=":"
android:textSize="14sp" />
<TextView
android:id="@+id/overview_extendedbolus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:text="0.50U/h @17:35 1/30min - 0.40U/h"
android:textSize="14sp"
android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -359,15 +389,6 @@
</LinearLayout>
<TextView
android:id="@+id/overview_extendedbolus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/mdtp_white" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="200dp">

View file

@ -1687,5 +1687,8 @@
<string name="alreadyset">Already set</string>
<string name="message">Message</string>
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
<string name="ebstopsloop">Use of Extended bolus feature will stop closed loop mode for the time of running extended bolus. Do you really want it?</string>
<string name="closed_loop_disabled_with_eb">Closed loop disabled because of running Extended bolus</string>
<string name="extended_bolus_short">EB</string>
</resources>