Merge pull request #2614 from Tornado-Tim/carbs-required
Show Carbs required - Updated from #1974
This commit is contained in:
commit
b5c72cb4a9
25 changed files with 281 additions and 45 deletions
|
@ -105,6 +105,9 @@
|
||||||
<!-- Receiver keepalive, scheduled every 30 min -->
|
<!-- Receiver keepalive, scheduled every 30 min -->
|
||||||
<receiver android:name=".receivers.KeepAliveReceiver" />
|
<receiver android:name=".receivers.KeepAliveReceiver" />
|
||||||
|
|
||||||
|
<!-- Receive ignore 5m, 15m, 30m requests for carb notifications -->
|
||||||
|
<receiver android:name=".plugins.aps.loop.CarbSuggestionReceiver"></receiver>
|
||||||
|
|
||||||
<!-- Auto start -->
|
<!-- Auto start -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".receivers.AutoStartReceiver"
|
android:name=".receivers.AutoStartReceiver"
|
||||||
|
|
|
@ -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);
|
console.error("naive_eventualBG:",naive_eventualBG,"bgUndershoot:",bgUndershoot,"zeroTempDuration:",zeroTempDuration,"zeroTempEffect:",zeroTempEffect,"carbsReq:",carbsReq);
|
||||||
if ( carbsReq >= profile.carbsReqThreshold && minutesAboveThreshold <= 45 ) {
|
if ( carbsReq >= profile.carbsReqThreshold && minutesAboveThreshold <= 45 ) {
|
||||||
rT.carbsReq = carbsReq;
|
rT.carbsReq = carbsReq;
|
||||||
|
rT.carbsReqWithin = minutesAboveThreshold;
|
||||||
rT.reason += carbsReq + " add'l carbs req w/in " + minutesAboveThreshold + "m; ";
|
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
|
// 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) {
|
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);
|
rT.reason += "IOB "+iob_data.iob+" < " + round(-profile.current_basal*20/60,2);
|
||||||
|
|
|
@ -4,8 +4,10 @@ import dagger.Module
|
||||||
import dagger.android.ContributesAndroidInjector
|
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.RileyLinkBluetoothStateReceiver
|
||||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.CarbSuggestionReceiver
|
||||||
import info.nightscout.androidaps.receivers.*
|
import info.nightscout.androidaps.receivers.*
|
||||||
|
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
abstract class ReceiversModule {
|
abstract class ReceiversModule {
|
||||||
|
@ -17,6 +19,6 @@ abstract class ReceiversModule {
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
|
@ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
|
@ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
@ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver
|
||||||
|
@ContributesAndroidInjector abstract fun contributesCarbSuggestionReceiver(): CarbSuggestionReceiver
|
||||||
@ContributesAndroidInjector abstract fun contributesRileyLinkBroadcastReceiver(): RileyLinkBroadcastReceiver
|
@ContributesAndroidInjector abstract fun contributesRileyLinkBroadcastReceiver(): RileyLinkBroadcastReceiver
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.aps.loop;
|
package info.nightscout.androidaps.plugins.aps.loop;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.NotificationChannel;
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
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.aps.loop.events.EventNewOpenLoopNotification;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
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.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
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 FabricPrivacy fabricPrivacy;
|
||||||
private final NSUpload nsUpload;
|
private final NSUpload nsUpload;
|
||||||
private final HardLimits hardLimits;
|
private final HardLimits hardLimits;
|
||||||
|
private Notification notification;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
|
@ -104,6 +107,8 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
private boolean isSuperBolus;
|
private boolean isSuperBolus;
|
||||||
private boolean isDisconnected;
|
private boolean isDisconnected;
|
||||||
|
|
||||||
|
private long carbsSuggestionsSuspendedUntil = 0;
|
||||||
|
|
||||||
@Nullable private LastRun lastRun = null;
|
@Nullable private LastRun lastRun = null;
|
||||||
|
|
||||||
@Nullable @Override public LastRun getLastRun() {
|
@Nullable @Override public LastRun getLastRun() {
|
||||||
|
@ -332,6 +337,14 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
return isDisconnected;
|
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) {
|
public synchronized void invoke(String initiator, boolean allowNotification) {
|
||||||
invoke(initiator, allowNotification, false);
|
invoke(initiator, allowNotification, false);
|
||||||
|
@ -430,6 +443,66 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
||||||
|
|
||||||
if (closedLoopEnabled.value()) {
|
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()
|
if (resultAfterConstraints.isChangeRequested()
|
||||||
&& !commandQueue.bolusInQueue()
|
&& !commandQueue.bolusInQueue()
|
||||||
&& !commandQueue.isRunning(Command.CommandType.BOLUS)) {
|
&& !commandQueue.isRunning(Command.CommandType.BOLUS)) {
|
||||||
|
@ -482,42 +555,15 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
.setContentTitle(resourceHelper.gs(R.string.openloop_newsuggestion))
|
.setContentTitle(resourceHelper.gs(R.string.openloop_newsuggestion))
|
||||||
.setContentText(resultAfterConstraints.toString())
|
.setContentText(resultAfterConstraints.toString())
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setPriority(Notification.PRIORITY_HIGH)
|
.setPriority(Notification.IMPORTANCE_HIGH)
|
||||||
.setCategory(Notification.CATEGORY_ALARM)
|
.setCategory(Notification.CATEGORY_ALARM)
|
||||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
if (sp.getBoolean("wearcontrol", false)) {
|
if (sp.getBoolean("wearcontrol", false)) {
|
||||||
builder.setLocalOnly(true);
|
builder.setLocalOnly(true);
|
||||||
}
|
}
|
||||||
|
presentSuggestion(builder);
|
||||||
// Creates an explicit intent for an Activity in your app
|
|
||||||
Intent resultIntent = new Intent(context, MainActivity.class);
|
|
||||||
|
|
||||||
// The stack builder object will contain an artificial back stack for the
|
|
||||||
// started Activity.
|
|
||||||
// This ensures that navigating backward from the Activity leads out of
|
|
||||||
// your application to the Home screen.
|
|
||||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
|
|
||||||
stackBuilder.addParentStack(MainActivity.class);
|
|
||||||
// Adds the Intent that starts the Activity to the top of the stack
|
|
||||||
stackBuilder.addNextIntent(resultIntent);
|
|
||||||
PendingIntent resultPendingIntent =
|
|
||||||
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
||||||
builder.setContentIntent(resultPendingIntent);
|
|
||||||
builder.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 if (allowNotification) {
|
} else if (allowNotification) {
|
||||||
// dismiss notifications
|
dismissSuggestion();
|
||||||
NotificationManager notificationManager =
|
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
notificationManager.cancel(Constants.notificationID);
|
|
||||||
actionStringHandler.get().handleInitiate("cancelChangeRequest");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +573,45 @@ public class LoopPlugin extends PluginBase implements LoopInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// The stack builder object will contain an artificial back stack for the
|
||||||
|
// started Activity.
|
||||||
|
// This ensures that navigating backward from the Activity leads out of
|
||||||
|
// your application to the Home screen.
|
||||||
|
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
|
||||||
|
stackBuilder.addParentStack(MainActivity.class);
|
||||||
|
// Adds the Intent that starts the Activity to the top of the stack
|
||||||
|
stackBuilder.addNextIntent(resultIntent);
|
||||||
|
PendingIntent resultPendingIntent =
|
||||||
|
stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||||
|
builder.setContentIntent(resultPendingIntent);
|
||||||
|
builder.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");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dismissSuggestion() {
|
||||||
|
// dismiss notifications
|
||||||
|
NotificationManager notificationManager =
|
||||||
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
notificationManager.cancel(Constants.notificationID);
|
||||||
|
actionStringHandler.get().handleInitiate("cancelChangeRequest");
|
||||||
|
}
|
||||||
|
|
||||||
public void acceptChangeRequest() {
|
public void acceptChangeRequest() {
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
final LoopPlugin lp = this;
|
final LoopPlugin lp = this;
|
||||||
|
|
|
@ -3,13 +3,17 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger;
|
|
||||||
import info.nightscout.androidaps.logging.LTag;
|
import info.nightscout.androidaps.logging.LTag;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
public class DetermineBasalResultSMB extends APSResult {
|
public class DetermineBasalResultSMB extends APSResult {
|
||||||
|
@Inject SP sp;
|
||||||
|
|
||||||
private double eventualBG;
|
private double eventualBG;
|
||||||
private double snoozeBG;
|
private double snoozeBG;
|
||||||
|
@ -33,7 +37,10 @@ public class DetermineBasalResultSMB extends APSResult {
|
||||||
if (result.has("eventualBG")) eventualBG = result.getDouble("eventualBG");
|
if (result.has("eventualBG")) eventualBG = result.getDouble("eventualBG");
|
||||||
if (result.has("snoozeBG")) snoozeBG = result.getDouble("snoozeBG");
|
if (result.has("snoozeBG")) snoozeBG = result.getDouble("snoozeBG");
|
||||||
//if (result.has("insulinReq")) insulinReq = result.getDouble("insulinReq");
|
//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")) {
|
if (result.has("rate") && result.has("duration")) {
|
||||||
tempBasalRequested = true;
|
tempBasalRequested = true;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
|
import android.graphics.drawable.AnimationDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
|
@ -157,6 +158,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
private val secondaryGraphs = ArrayList<GraphView>()
|
private val secondaryGraphs = ArrayList<GraphView>()
|
||||||
private val secondaryGraphsLabel = ArrayList<TextView>()
|
private val secondaryGraphsLabel = ArrayList<TextView>()
|
||||||
|
|
||||||
|
private lateinit var carbAnimation: AnimationDrawable
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?): View? {
|
savedInstanceState: Bundle?): View? {
|
||||||
|
|
||||||
|
@ -187,6 +190,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
overview_bggraph?.gridLabelRenderer?.labelVerticalWidth = axisWidth
|
||||||
overview_bggraph?.layoutParams?.height = resourceHelper.dpToPx(skinProvider.activeSkin().mainGraphHeight)
|
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)
|
rangeToDisplay = sp.getInt(R.string.key_rangetodisplay, 6)
|
||||||
|
|
||||||
overview_bggraph?.setOnLongClickListener {
|
overview_bggraph?.setOnLongClickListener {
|
||||||
|
@ -736,7 +743,19 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
|
cobText = resourceHelper.gs(R.string.format_carbs, cobInfo.displayCob.toInt())
|
||||||
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
|
if (cobInfo.futureCarbs > 0) cobText += "(" + DecimalFormatter.to0Decimal(cobInfo.futureCarbs) + ")"
|
||||||
}
|
}
|
||||||
overview_cob?.text = cobText
|
|
||||||
|
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
|
val predictionsAvailable = if (config.APS) lastRun?.request?.hasPredictions == true else config.NSCLIENT
|
||||||
|
|
||||||
|
|
|
@ -729,7 +729,6 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
result.boluses += treatment.insulin;
|
result.boluses += treatment.insulin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > absorptionTime_ago && t <= now) {
|
if (t > absorptionTime_ago && t <= now) {
|
||||||
if (treatment.carbs >= 1) {
|
if (treatment.carbs >= 1) {
|
||||||
result.carbs += treatment.carbs;
|
result.carbs += treatment.carbs;
|
||||||
|
|
|
@ -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) {
|
public void deleteNS(JSONObject json) {
|
||||||
String _id = JsonHelper.safeGetString(json, "_id");
|
String _id = JsonHelper.safeGetString(json, "_id");
|
||||||
if (_id != null && !_id.isEmpty())
|
if (_id != null && !_id.isEmpty())
|
||||||
|
|
|
@ -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
|
@Override
|
||||||
public boolean isInHistoryRealTempBasalInProgress() {
|
public boolean isInHistoryRealTempBasalInProgress() {
|
||||||
return getRealTempBasalFromHistory(System.currentTimeMillis()) != null;
|
return getRealTempBasalFromHistory(System.currentTimeMillis()) != null;
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable-hdpi/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
app/src/main/res/drawable-mdpi/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable-mdpi/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 905 B |
BIN
app/src/main/res/drawable-xhdpi/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
6
app/src/main/res/drawable/anim_carbs.xml
Normal file
6
app/src/main/res/drawable/anim_carbs.xml
Normal 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>
|
BIN
app/src/main/res/drawable/icon_cp_bolus_carbs_red.png
Normal file
BIN
app/src/main/res/drawable/icon_cp_bolus_carbs_red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 905 B |
|
@ -140,7 +140,8 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:src="@drawable/icon_cp_bolus_carbs" />
|
android:id="@+id/overview_carbs_icon"
|
||||||
|
android:background="@drawable/anim_carbs" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/overview_cob"
|
android:id="@+id/overview_cob"
|
||||||
|
|
|
@ -166,6 +166,7 @@
|
||||||
<string name="enableloop">Enable loop</string>
|
<string name="enableloop">Enable loop</string>
|
||||||
|
|
||||||
<string name="openloop_newsuggestion">New suggestion available</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="unsupportednsversion">Unsupported version of Nightscout</string>
|
||||||
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
<string name="loopdisabled">LOOP DISABLED BY CONSTRAINTS</string>
|
||||||
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
|
<string name="treatments_wizard_basaliob_label">Basal IOB</string>
|
||||||
|
@ -617,6 +618,7 @@
|
||||||
<string name="openapssmb">OpenAPS SMB</string>
|
<string name="openapssmb">OpenAPS SMB</string>
|
||||||
<string name="key_use_smb" translatable="false">use_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_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="enableuam">Enable UAM</string>
|
||||||
<string name="enablesmb">Enable SMB</string>
|
<string name="enablesmb">Enable SMB</string>
|
||||||
<string name="enablesmb_summary">Use Super Micro Boluses instead of temp basal for faster action</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="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_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_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="localalertsettings_title">Local alerts</string>
|
||||||
<string name="enable_missed_bg_readings_alert">Alert if no BG data is received</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="enable_pump_unreachable_alert">Alert if pump is unreachable</string>
|
||||||
<string name="pump_unreachable_threshold">Pump unreachable threshold [min]</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_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="key_missed_bg_readings_threshold" translatable="false">missed_bg_readings_threshold</string>
|
||||||
<string name="urgent_alarm">Urgent Alarm</string>
|
<string name="urgent_alarm">Urgent Alarm</string>
|
||||||
|
@ -680,8 +684,8 @@
|
||||||
<string name="uamsmbmaxminutes">UAM SMB max minutes</string>
|
<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="uamsmbmaxminutes_summary">Max minutes of basal to limit SMB to for UAM</string>
|
||||||
<string name="key_carbsReqThreshold" translatable="false">carbsReqThreshold</string>
|
<string name="key_carbsReqThreshold" translatable="false">carbsReqThreshold</string>
|
||||||
<string name="carbsReqThreshold">Carb suggestion threshold</string>
|
<string name="carbsReqThreshold">Minimum Carbs Required For Suggestion</string>
|
||||||
<string name="carbsReqThreshold_summary">When Carbs are suggested, how many carbs will prompt a notification</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="dexcomg5_xdripupload_title">Send BG data to xDrip+</string>
|
||||||
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
|
<string name="key_dexcomg5_xdripupload" translatable="false">dexcomg5_xdripupload</string>
|
||||||
<string name="dexcomg5_xdripupload_summary">In xDrip+ select 640g/Eversense data source</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="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="error_starting_cgm">Could not launch CGM application. Make sure it is installed.</string>
|
||||||
<string name="overview_cgm">CGM</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="nav_historybrowser">History browser</string>
|
||||||
<string name="wear_notifysmb_title">Notify on SMB</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="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_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_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="eversense_shortname" translatable="false">EVR</string>
|
||||||
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
|
<string name="wear_predictions_summary">Show the predictions on the watchface.</string>
|
||||||
<string name="wear_predictions_title">Predictions</string>
|
<string name="wear_predictions_title">Predictions</string>
|
||||||
|
|
|
@ -27,6 +27,11 @@
|
||||||
android:key="@string/key_enable_pump_unreachable_alert"
|
android:key="@string/key_enable_pump_unreachable_alert"
|
||||||
android:title="@string/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
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:defaultValue="30"
|
android:defaultValue="30"
|
||||||
android:dependency="@string/key_enable_pump_unreachable_alert"
|
android:dependency="@string/key_enable_pump_unreachable_alert"
|
||||||
|
|
|
@ -122,6 +122,12 @@
|
||||||
android:summary="@string/ns_create_announcements_from_errors_summary"
|
android:summary="@string/ns_create_announcements_from_errors_summary"
|
||||||
android:title="@string/ns_create_announcements_from_errors_title" />
|
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
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/key_nsclient_localbroadcasts"
|
android:key="@string/key_nsclient_localbroadcasts"
|
||||||
|
|
|
@ -142,10 +142,11 @@
|
||||||
android:key="@string/key_low_temptarget_lowers_sensitivity"
|
android:key="@string/key_low_temptarget_lowers_sensitivity"
|
||||||
android:summary="@string/low_temptarget_lowers_sensitivity_summary"
|
android:summary="@string/low_temptarget_lowers_sensitivity_summary"
|
||||||
android:title="@string/low_temptarget_lowers_sensitivity_title" />
|
android:title="@string/low_temptarget_lowers_sensitivity_title" />
|
||||||
|
|
||||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||||
android:key="@string/key_carbsReqThreshold"
|
android:key="@string/key_carbsReqThreshold"
|
||||||
android:title="@string/carbsReqThreshold"
|
android:title="@string/carbsReqThreshold"
|
||||||
|
android:summary="@string/carbsReqThreshold_summary"
|
||||||
android:defaultValue="1"
|
android:defaultValue="1"
|
||||||
android:dialogMessage="@string/carbsReqThreshold_summary"
|
android:dialogMessage="@string/carbsReqThreshold_summary"
|
||||||
android:digits="0123456789"
|
android:digits="0123456789"
|
||||||
|
|
|
@ -64,6 +64,9 @@ public class APSResult {
|
||||||
public long deliverAt = 0;
|
public long deliverAt = 0;
|
||||||
public double targetBG = 0d;
|
public double targetBG = 0d;
|
||||||
|
|
||||||
|
public int carbsReq = 0;
|
||||||
|
public int carbsReqWithin = 0;
|
||||||
|
|
||||||
public Constraint<Double> inputConstraints;
|
public Constraint<Double> inputConstraints;
|
||||||
|
|
||||||
public Constraint<Double> rateConstraint;
|
public Constraint<Double> rateConstraint;
|
||||||
|
@ -100,6 +103,10 @@ public class APSResult {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCarbsRequiredText() {
|
||||||
|
return String.format(resourceHelper.gs(R.string.carbsreq), carbsReq, carbsReqWithin);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final PumpInterface pump = activePlugin.getActivePump();
|
final PumpInterface pump = activePlugin.getActivePump();
|
||||||
|
@ -123,11 +130,20 @@ public class APSResult {
|
||||||
if (smb != 0)
|
if (smb != 0)
|
||||||
ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U\n");
|
ret += ("SMB: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U\n");
|
||||||
|
|
||||||
|
if (isCarbsRequired()) {
|
||||||
|
ret += getCarbsRequiredText()+"\n";
|
||||||
|
}
|
||||||
|
|
||||||
// reason
|
// reason
|
||||||
ret += resourceHelper.gs(R.string.reason) + ": " + reason;
|
ret += resourceHelper.gs(R.string.reason) + ": " + reason;
|
||||||
return ret;
|
return ret;
|
||||||
} else
|
}
|
||||||
return resourceHelper.gs(R.string.nochangerequested);
|
|
||||||
|
if (isCarbsRequired()) {
|
||||||
|
return getCarbsRequiredText();
|
||||||
|
}
|
||||||
|
|
||||||
|
return resourceHelper.gs(R.string.nochangerequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Spanned toSpanned() {
|
public Spanned toSpanned() {
|
||||||
|
@ -152,11 +168,20 @@ public class APSResult {
|
||||||
if (smb != 0)
|
if (smb != 0)
|
||||||
ret += ("<b>" + "SMB" + "</b>: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U<br>");
|
ret += ("<b>" + "SMB" + "</b>: " + DecimalFormatter.toPumpSupportedBolus(smb, activePlugin.getActivePump()) + " U<br>");
|
||||||
|
|
||||||
|
if (isCarbsRequired()) {
|
||||||
|
ret += getCarbsRequiredText()+"<br>";
|
||||||
|
}
|
||||||
|
|
||||||
// reason
|
// reason
|
||||||
ret += "<b>" + resourceHelper.gs(R.string.reason) + "</b>: " + reason.replace("<", "<").replace(">", ">");
|
ret += "<b>" + resourceHelper.gs(R.string.reason) + "</b>: " + reason.replace("<", "<").replace(">", ">");
|
||||||
return HtmlHelper.INSTANCE.fromHtml(ret);
|
return HtmlHelper.INSTANCE.fromHtml(ret);
|
||||||
} else
|
}
|
||||||
return HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.nochangerequested));
|
|
||||||
|
if (isCarbsRequired()) {
|
||||||
|
return HtmlHelper.INSTANCE.fromHtml(getCarbsRequiredText());
|
||||||
|
}
|
||||||
|
|
||||||
|
return HtmlHelper.INSTANCE.fromHtml(resourceHelper.gs(R.string.nochangerequested));
|
||||||
}
|
}
|
||||||
|
|
||||||
public APSResult newAndClone(HasAndroidInjector injector) {
|
public APSResult newAndClone(HasAndroidInjector injector) {
|
||||||
|
@ -185,6 +210,8 @@ public class APSResult {
|
||||||
newResult.smbConstraint = smbConstraint;
|
newResult.smbConstraint = smbConstraint;
|
||||||
newResult.percent = percent;
|
newResult.percent = percent;
|
||||||
newResult.usePercent = usePercent;
|
newResult.usePercent = usePercent;
|
||||||
|
newResult.carbsReq = carbsReq;
|
||||||
|
newResult.carbsReqWithin = carbsReqWithin;
|
||||||
newResult.targetBG = targetBG;
|
newResult.targetBG = targetBG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +327,10 @@ public class APSResult {
|
||||||
return latest;
|
return latest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCarbsRequired() {
|
||||||
|
return carbsReq > 0;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isChangeRequested() {
|
public boolean isChangeRequested() {
|
||||||
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
|
||||||
// closed loop mode: handle change at driver level
|
// closed loop mode: handle change at driver level
|
||||||
|
|
|
@ -70,6 +70,10 @@ public class Notification {
|
||||||
public static final int OMNIPOD_PUMP_ALARM = 57;
|
public static final int OMNIPOD_PUMP_ALARM = 57;
|
||||||
public static final int TIME_OR_TIMEZONE_CHANGE = 58;
|
public static final int TIME_OR_TIMEZONE_CHANGE = 58;
|
||||||
public static final int OMNIPOD_POD_NOT_ATTACHED = 59;
|
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;
|
public static final int USERMESSAGE = 1000;
|
||||||
|
|
||||||
|
|
|
@ -199,6 +199,9 @@
|
||||||
<string name="waitingforpumpresult">Waiting for result</string>
|
<string name="waitingforpumpresult">Waiting for result</string>
|
||||||
<string name="smb_shortname">SMB</string>
|
<string name="smb_shortname">SMB</string>
|
||||||
|
|
||||||
|
<!-- CarbsReq-->
|
||||||
|
<string name="carbsreq">"%dg Additional Carbs Required Within %d Minutes</string>
|
||||||
|
|
||||||
<!-- TDDStatsActivity-->
|
<!-- TDDStatsActivity-->
|
||||||
<string name="stats">Stats</string>
|
<string name="stats">Stats</string>
|
||||||
<string name="cumulative_tdd">Cumulative TDD</string>
|
<string name="cumulative_tdd">Cumulative TDD</string>
|
||||||
|
|
Loading…
Reference in a new issue