Merge pull request #2614 from Tornado-Tim/carbs-required

Show Carbs required - Updated from #1974
This commit is contained in:
Milos Kozak 2020-06-11 20:42:43 +02:00 committed by GitHub
commit b5c72cb4a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 281 additions and 45 deletions

View file

@ -105,6 +105,9 @@
<!-- Receiver keepalive, scheduled every 30 min -->
<receiver android:name=".receivers.KeepAliveReceiver" />
<!-- Receive ignore 5m, 15m, 30m requests for carb notifications -->
<receiver android:name=".plugins.aps.loop.CarbSuggestionReceiver"></receiver>
<!-- Auto start -->
<receiver
android:name=".receivers.AutoStartReceiver"

View file

@ -878,8 +878,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
console.error("naive_eventualBG:",naive_eventualBG,"bgUndershoot:",bgUndershoot,"zeroTempDuration:",zeroTempDuration,"zeroTempEffect:",zeroTempEffect,"carbsReq:",carbsReq);
if ( carbsReq >= profile.carbsReqThreshold && minutesAboveThreshold <= 45 ) {
rT.carbsReq = carbsReq;
rT.carbsReqWithin = minutesAboveThreshold;
rT.reason += carbsReq + " add'l carbs req w/in " + minutesAboveThreshold + "m; ";
}
// don't low glucose suspend if IOB is already super negative and BG is rising faster than predicted
if (bg < threshold && iob_data.iob < -profile.current_basal*20/60 && minDelta > 0 && minDelta > expectedDelta) {
rT.reason += "IOB "+iob_data.iob+" < " + round(-profile.current_basal*20/60,2);

View file

@ -4,8 +4,10 @@ import dagger.Module
import dagger.android.ContributesAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver
import info.nightscout.androidaps.plugins.aps.loop.CarbSuggestionReceiver
import info.nightscout.androidaps.receivers.*
@Module
@Suppress("unused")
abstract class ReceiversModule {
@ -17,6 +19,6 @@ abstract class ReceiversModule {
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
@ContributesAndroidInjector abstract fun contributesCarbSuggestionReceiver(): CarbSuggestionReceiver
@ContributesAndroidInjector abstract fun contributesRileyLinkBroadcastReceiver(): RileyLinkBroadcastReceiver
}

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.plugins.aps.loop
import android.content.Context
import android.content.Intent
import dagger.android.DaggerBroadcastReceiver
import javax.inject.Inject
class CarbSuggestionReceiver : DaggerBroadcastReceiver() {
@Inject lateinit var loopPlugin: LoopPlugin
override fun onReceive(context: Context, intent: Intent) {
super.onReceive(context, intent)
val duration = intent.getIntExtra("ignoreDuration", 5)
loopPlugin.disableCarbSuggestions(duration)
}
}

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.aps.loop;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
@ -56,6 +55,9 @@ import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui;
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
@ -93,6 +95,7 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
private final FabricPrivacy fabricPrivacy;
private final NSUpload nsUpload;
private final HardLimits hardLimits;
private Notification notification;
private CompositeDisposable disposable = new CompositeDisposable();
@ -104,6 +107,8 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
private boolean isSuperBolus;
private boolean isDisconnected;
private long carbsSuggestionsSuspendedUntil = 0;
@Nullable private LastRun lastRun = null;
@Nullable @Override public LastRun getLastRun() {
@ -332,6 +337,14 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
}
return isDisconnected;
}
public boolean treatmentTimethreshold(int duartionMinutes) {
long threshold = System.currentTimeMillis() + (duartionMinutes*60*1000);
boolean bool = false;
if (treatmentsPlugin.getLastBolusTime() > threshold || treatmentsPlugin.getLastCarbTime() > threshold)
bool = true;
return bool;
}
public synchronized void invoke(String initiator, boolean allowNotification) {
invoke(initiator, allowNotification, false);
@ -430,6 +443,66 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
if (closedLoopEnabled.value()) {
if (allowNotification) {
if (resultAfterConstraints.isCarbsRequired()
&& resultAfterConstraints.carbsReq >= sp.getInt(R.string.key_smb_enable_carbs_suggestions_threshold, 0)
&& carbsSuggestionsSuspendedUntil < System.currentTimeMillis() && !treatmentTimethreshold(-15)) {
if (sp.getBoolean(R.string.key_enable_carbs_required_alert_local,true) && !sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false)) {
Notification carbreqlocal = new Notification(Notification.CARBS_REQUIRED, resultAfterConstraints.getCarbsRequiredText(), Notification.NORMAL);
rxBus.send(new EventNewNotification(carbreqlocal));
}
if (sp.getBoolean(R.string.key_ns_create_announcements_from_carbs_req, false)) {
nsUpload.uploadError(resultAfterConstraints.getCarbsRequiredText());
}
if (sp.getBoolean(R.string.key_enable_carbs_required_alert_local,true) && sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, false)){
Intent intentAction5m = new Intent(context, CarbSuggestionReceiver.class);
intentAction5m.putExtra("ignoreDuration", 5);
PendingIntent pendingIntent5m = PendingIntent.getBroadcast(context, 1, intentAction5m, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action actionIgnore5m = new
NotificationCompat.Action(R.drawable.ic_notif_aaps, resourceHelper.gs(R.string.ignore5m,"Ignore 5m"), pendingIntent5m);
Intent intentAction15m = new Intent(context, CarbSuggestionReceiver.class);
intentAction15m.putExtra("ignoreDuration", 15);
PendingIntent pendingIntent15m = PendingIntent.getBroadcast(context, 1, intentAction15m, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action actionIgnore15m = new
NotificationCompat.Action(R.drawable.ic_notif_aaps, resourceHelper.gs(R.string.ignore15m,"Ignore 15m"), pendingIntent15m);
Intent intentAction30m = new Intent(context, CarbSuggestionReceiver.class);
intentAction30m.putExtra("ignoreDuration", 30);
PendingIntent pendingIntent30m = PendingIntent.getBroadcast(context, 1, intentAction30m, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action actionIgnore30m = new
NotificationCompat.Action(R.drawable.ic_notif_aaps, resourceHelper.gs(R.string.ignore30m,"Ignore 30m"), pendingIntent30m);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, CHANNEL_ID);
builder.setSmallIcon(R.drawable.notif_icon)
.setContentTitle(resourceHelper.gs(R.string.carbssuggestion))
.setContentText(resultAfterConstraints.getCarbsRequiredText())
.setAutoCancel(true)
.setPriority(Notification.IMPORTANCE_HIGH)
.setCategory(Notification.CATEGORY_ALARM)
.addAction(actionIgnore5m)
.addAction(actionIgnore15m)
.addAction(actionIgnore30m)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setVibrate(new long[]{1000, 1000, 1000, 1000, 1000});
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(Constants.notificationID, builder.build());
rxBus.send(new EventNewOpenLoopNotification());
// Send to Wear
actionStringHandler.get().handleInitiate("changeRequest");
}
} else {
dismissSuggestion();
}
}
if (resultAfterConstraints.isChangeRequested()
&& !commandQueue.bolusInQueue()
&& !commandQueue.isRunning(Command.CommandType.BOLUS)) {
@ -482,13 +555,30 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
.setContentTitle(resourceHelper.gs(R.string.openloop_newsuggestion))
.setContentText(resultAfterConstraints.toString())
.setAutoCancel(true)
.setPriority(Notification.PRIORITY_HIGH)
.setPriority(Notification.IMPORTANCE_HIGH)
.setCategory(Notification.CATEGORY_ALARM)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
if (sp.getBoolean("wearcontrol", false)) {
builder.setLocalOnly(true);
}
presentSuggestion(builder);
} else if (allowNotification) {
dismissSuggestion();
}
}
rxBus.send(new EventLoopUpdateGui());
} finally {
getAapsLogger().debug(LTag.APS, "invoke end");
}
}
public void disableCarbSuggestions(int duartionMinutes) {
carbsSuggestionsSuspendedUntil = System.currentTimeMillis() + (duartionMinutes*60*1000);
dismissSuggestion();
}
private void presentSuggestion(NotificationCompat.Builder builder) {
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context, MainActivity.class);
@ -512,20 +602,15 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
// Send to Wear
actionStringHandler.get().handleInitiate("changeRequest");
} else if (allowNotification) {
}
private void dismissSuggestion() {
// dismiss notifications
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(Constants.notificationID);
actionStringHandler.get().handleInitiate("cancelChangeRequest");
}
}
rxBus.send(new EventLoopUpdateGui());
} finally {
getAapsLogger().debug(LTag.APS, "invoke end");
}
}
public void acceptChangeRequest() {
Profile profile = profileFunction.getProfile();

View file

@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB;
import org.json.JSONException;
import org.json.JSONObject;
import javax.inject.Inject;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class DetermineBasalResultSMB extends APSResult {
@Inject SP sp;
private double eventualBG;
private double snoozeBG;
@ -33,7 +37,10 @@ public class DetermineBasalResultSMB extends APSResult {
if (result.has("eventualBG")) eventualBG = result.getDouble("eventualBG");
if (result.has("snoozeBG")) snoozeBG = result.getDouble("snoozeBG");
//if (result.has("insulinReq")) insulinReq = result.getDouble("insulinReq");
//if (result.has("carbsReq")) carbsReq = result.getDouble("carbsReq");
if (result.has("carbsReq")) carbsReq = result.getInt("carbsReq");
if (result.has("carbsReqWithin")) carbsReqWithin = result.getInt("carbsReqWithin");
if (result.has("rate") && result.has("duration")) {
tempBasalRequested = true;

View file

@ -7,6 +7,7 @@ import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.os.Handler
import android.util.DisplayMetrics
@ -157,6 +158,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
private val secondaryGraphs = ArrayList<GraphView>()
private val secondaryGraphsLabel = ArrayList<TextView>()
private lateinit var carbAnimation: AnimationDrawable
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
@ -187,6 +190,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight)
carbAnimation = overview_carbs_icon.background as AnimationDrawable
carbAnimation.setEnterFadeDuration(1200)
carbAnimation.setExitFadeDuration(1200)
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
overview_bggraph?.setOnLongClickListener {
@ -736,7 +743,19 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
}
if (config.APS && lastRun?.constraintsProcessed != null) {
if (lastRun.constraintsProcessed!!.carbsReq > 0) {
overview_cob?.text = cobText + " | " + lastRun.constraintsProcessed!!.carbsReq + " " + resourceHelper.gs(R.string.required)
if (!carbAnimation.isRunning)
carbAnimation.start()
} else {
overview_cob?.text = cobText
if (carbAnimation.isRunning)
carbAnimation.stop()
carbAnimation.selectDrawable(0);
}
}
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT

View file

@ -729,7 +729,6 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
result.boluses += treatment.insulin;
}
}
if (t > absorptionTime_ago && t <= now) {
if (treatment.carbs >= 1) {
result.carbs += treatment.carbs;

View file

@ -613,6 +613,29 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
}
}
/**
* Returns the newest record with carbs > 0
*/
@Nullable
public Treatment getLastCarb() {
try {
QueryBuilder<Treatment, Long> queryBuilder = getDao().queryBuilder();
Where where = queryBuilder.where();
where.gt("carbs", 0);
where.and().le("date", DateUtil.now());
where.and().eq("isValid", true);
queryBuilder.orderBy("date", false);
queryBuilder.limit(1L);
List<Treatment> result = getDao().query(queryBuilder.prepare());
if (result.isEmpty())
return null;
return result.get(0);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public void deleteNS(JSONObject json) {
String _id = JsonHelper.safeGetString(json, "_id");
if (_id != null && !_id.isEmpty())

View file

@ -358,6 +358,19 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
}
}
public long getLastCarbTime() {
Treatment last = getService().getLastCarb();
if (last == null) {
getAapsLogger().debug(LTag.DATATREATMENTS, "Last Carb time: NOTHING FOUND");
return 0;
}
else {
getAapsLogger().debug(LTag.DATATREATMENTS, "Last Carb time: " + dateUtil.dateAndTimeString(last.date));
return last.date;
}
}
@Override
public boolean isInHistoryRealTempBasalInProgress() {
return getRealTempBasalFromHistory(System.currentTimeMillis()) != null;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/icon_cp_bolus_carbs" android:duration="1200" />
<item android:drawable="@drawable/icon_cp_bolus_carbs_red" android:duration="1200" />
</animation-list>

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

View file

@ -140,7 +140,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/icon_cp_bolus_carbs" />
android:id="@+id/overview_carbs_icon"
android:background="@drawable/anim_carbs" />
<TextView
android:id="@+id/overview_cob"

View file

@ -166,6 +166,7 @@
<string name="enableloop">Enable loop</string>
<string name="openloop_newsuggestion">New suggestion available</string>
<string name="carbssuggestion">Carbs Suggestion</string>
<string name="unsupportednsversion">Unsupported version of Nightscout</string>
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
@ -617,6 +618,7 @@
<string name="openapssmb">OpenAPS SMB</string>
<string name="key_use_smb" translatable="false">use_smb</string>
<string name="key_use_uam" translatable="false">use_uam</string>
<string name="key_smb_enable_carbs_suggestions_threshold" translatable="false">smb_enable_carbs_suggestions_threshold</string>
<string name="enableuam">Enable UAM</string>
<string name="enablesmb">Enable SMB</string>
<string name="enablesmb_summary">Use Super Micro Boluses instead of temp basal for faster action</string>
@ -659,10 +661,12 @@
<string name="raise_notifications_as_android_notifications">Use system notifications for alerts and notifications</string>
<string name="key_enable_pump_unreachable_alert" translatable="false">enable_pump_unreachable_alert</string>
<string name="key_enable_missed_bg_readings_alert" translatable="false">enable_missed_bg_readings</string>
<string name="key_enable_carbs_required_alert_local" translatable="false">enable_carbs_required_alert_local</string>
<string name="localalertsettings_title">Local alerts</string>
<string name="enable_missed_bg_readings_alert">Alert if no BG data is received</string>
<string name="enable_pump_unreachable_alert">Alert if pump is unreachable</string>
<string name="pump_unreachable_threshold">Pump unreachable threshold [min]</string>
<string name="enable_carbs_req_alert">Alert if carbs are required</string>
<string name="key_pump_unreachable_threshold" translatable="false">pump_unreachable_threshold</string>
<string name="key_missed_bg_readings_threshold" translatable="false">missed_bg_readings_threshold</string>
<string name="urgent_alarm">Urgent Alarm</string>
@ -680,8 +684,8 @@
<string name="uamsmbmaxminutes">UAM SMB max minutes</string>
<string name="uamsmbmaxminutes_summary">Max minutes of basal to limit SMB to for UAM</string>
<string name="key_carbsReqThreshold" translatable="false">carbsReqThreshold</string>
<string name="carbsReqThreshold">Carb suggestion threshold</string>
<string name="carbsReqThreshold_summary">When Carbs are suggested, how many carbs will prompt a notification</string>
<string name="carbsReqThreshold">Minimum Carbs Required For Suggestion</string>
<string name="carbsReqThreshold_summary">Minimum grams of carbs to display a carbs suggestion alert. Carbs suggestions below this number will not trigger a notification.</string>
<string name="dexcomg5_xdripupload_title">Send BG data to xDrip+</string>
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
<string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</string>
@ -781,11 +785,18 @@
<string name="insulin_increment_button_message">Amount of insulin to add when button is pressed</string>
<string name="error_starting_cgm">Could not launch CGM application. Make sure it is installed.</string>
<string name="overview_cgm">CGM</string>
<string name="ignore5m">Ignore 5m</string>
<string name="ignore15m">Ignore 15m</string>
<string name="ignore30m">Ignore 30m</string>
<string name="required">req</string>
<string name="nav_historybrowser">History browser</string>
<string name="wear_notifysmb_title">Notify on SMB</string>
<string name="wear_notifysmb_summary">Show SMB on the watch like a standard bolus.</string>
<string name="ns_create_announcements_from_errors_title">Create announcements from errors</string>
<string name="ns_create_announcements_from_carbs_req_title">Create announcements from carbs required alerts</string>
<string name="ns_create_announcements_from_errors_summary">Create Nightscout announcement for error dialogs and local alerts (also viewable in Careportal under Treatments)</string>
<string name="ns_create_announcements_from_carbs_req_summary">Create Nightscout announcements for carbs required alerts</string>
<string name="key_ns_create_announcements_from_carbs_req" translatable="false">ns_create_announcements_from_carbs_req</string>
<string name="eversense_shortname" translatable="false">EVR</string>
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
<string name="wear_predictions_title">Predictions</string>

View file

@ -27,6 +27,11 @@
android:key="@string/key_enable_pump_unreachable_alert"
android:title="@string/enable_pump_unreachable_alert" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_enable_carbs_required_alert_local"
android:title="@string/enable_carbs_req_alert" />
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:defaultValue="30"
android:dependency="@string/key_enable_pump_unreachable_alert"

View file

@ -122,6 +122,12 @@
android:summary="@string/ns_create_announcements_from_errors_summary"
android:title="@string/ns_create_announcements_from_errors_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_create_announcements_from_carbs_req"
android:summary="@string/ns_create_announcements_from_carbs_req_summary"
android:title="@string/ns_create_announcements_from_carbs_req_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_nsclient_localbroadcasts"

View file

@ -146,6 +146,7 @@
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
android:key="@string/key_carbsReqThreshold"
android:title="@string/carbsReqThreshold"
android:summary="@string/carbsReqThreshold_summary"
android:defaultValue="1"
android:dialogMessage="@string/carbsReqThreshold_summary"
android:digits="0123456789"

View file

@ -64,6 +64,9 @@ public class APSResult {
public long deliverAt = 0;
public double targetBG = 0d;
public int carbsReq = 0;
public int carbsReqWithin = 0;
public Constraint<Double> inputConstraints;
public Constraint<Double> rateConstraint;
@ -100,6 +103,10 @@ public class APSResult {
return this;
}
public String getCarbsRequiredText() {
return String.format(resourceHelper.gs(R.string.carbsreq), carbsReq, carbsReqWithin);
}
@Override
public String toString() {
final PumpInterface pump = activePlugin.getActivePump();
@ -123,10 +130,19 @@ public class APSResult {
if (smb != 0)
ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U\n");
if (isCarbsRequired()) {
ret += getCarbsRequiredText()+"\n";
}
// reason
ret += resourceHelper.gs(R.string.reason) + ": " + reason;
return ret;
} else
}
if (isCarbsRequired()) {
return getCarbsRequiredText();
}
return resourceHelper.gs(R.string.nochangerequested);
}
@ -152,10 +168,19 @@ public class APSResult {
if (smb != 0)
ret += ("<b>" + "SMB" + "</b>: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U<br>");
if (isCarbsRequired()) {
ret += getCarbsRequiredText()+"<br>";
}
// reason
ret += "<b>" + resourceHelper.gs(R.string.reason) + "</b>: " + reason.replace("<", "&lt;").replace(">", "&gt;");
return HtmlHelper.INSTANCE.fromHtml(ret);
} else
}
if (isCarbsRequired()) {
return HtmlHelper.INSTANCE.fromHtml(getCarbsRequiredText());
}
return HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.nochangerequested));
}
@ -185,6 +210,8 @@ public class APSResult {
newResult.smbConstraint = smbConstraint;
newResult.percent = percent;
newResult.usePercent = usePercent;
newResult.carbsReq = carbsReq;
newResult.carbsReqWithin = carbsReqWithin;
newResult.targetBG = targetBG;
}
@ -300,6 +327,10 @@ public class APSResult {
return latest;
}
public boolean isCarbsRequired() {
return carbsReq > 0;
}
public boolean isChangeRequested() {
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
// closed loop mode: handle change at driver level

View file

@ -70,6 +70,10 @@ public class Notification {
public static final int OMNIPOD_PUMP_ALARM = 57;
public static final int TIME_OR_TIMEZONE_CHANGE = 58;
public static final int OMNIPOD_POD_NOT_ATTACHED = 59;
public static final int CARBS_REQUIRED = 60;
public static final int IMPORTANCE_HIGH = 2;
public static final String CATEGORY_ALARM = "alarm";
public static final int USERMESSAGE = 1000;

View file

@ -199,6 +199,9 @@
<string name="waitingforpumpresult">Waiting for result</string>
<string name="smb_shortname">SMB</string>
<!-- CarbsReq-->
<string name="carbsreq">"%dg Additional Carbs Required Within %d Minutes</string>
<!-- TDDStatsActivity-->
<string name="stats">Stats</string>
<string name="cumulative_tdd">Cumulative TDD</string>