Add UAMSMB Basal Minutes with Min Bolus Increment
This commit is contained in:
parent
8f9d0269c1
commit
ff2f6a8bfb
5 changed files with 34 additions and 7 deletions
|
@ -995,8 +995,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
|
|
||||||
// eventual BG is at/above target
|
// eventual BG is at/above target
|
||||||
// if iob is over max, just cancel any temps
|
// if iob is over max, just cancel any temps
|
||||||
// if we're not here because of SMB, eventual BG is at/above target
|
if ( eventualBG >= max_bg ) {
|
||||||
if (! (microBolusAllowed && rT.COB)) {
|
|
||||||
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " >= " + convert_bg(max_bg, profile) + ", ";
|
rT.reason += "Eventual BG " + convert_bg(eventualBG, profile) + " >= " + convert_bg(max_bg, profile) + ", ";
|
||||||
}
|
}
|
||||||
if (iob_data.iob > max_iob) {
|
if (iob_data.iob > max_iob) {
|
||||||
|
@ -1047,20 +1046,27 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
||||||
// if IOB covers more than COB, limit maxBolus to 30m of basal
|
// if IOB covers more than COB, limit maxBolus to 30m of basal
|
||||||
} else if ( iob_data.iob > mealInsulinReq && iob_data.iob > 0 ) {
|
} else if ( iob_data.iob > mealInsulinReq && iob_data.iob > 0 ) {
|
||||||
console.error("IOB",iob_data.iob,"> COB",meal_data.mealCOB+"; mealInsulinReq =",mealInsulinReq);
|
console.error("IOB",iob_data.iob,"> COB",meal_data.mealCOB+"; mealInsulinReq =",mealInsulinReq);
|
||||||
|
if (profile.maxUAMSMBBasalMinutes) {
|
||||||
|
console.error("profile.maxUAMSMBBasalMinutes:",profile.maxUAMSMBBasalMinutes,"profile.current_basal:",profile.current_basal);
|
||||||
|
maxBolus = round( profile.current_basal * profile.maxUAMSMBBasalMinutes / 60 ,1);
|
||||||
|
} else {
|
||||||
|
console.error("profile.maxUAMSMBBasalMinutes undefined: defaulting to 30m");
|
||||||
maxBolus = round( profile.current_basal * 30 / 60 ,1);
|
maxBolus = round( profile.current_basal * 30 / 60 ,1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error("profile.maxSMBBasalMinutes:",profile.maxSMBBasalMinutes,"profile.current_basal:",profile.current_basal);
|
console.error("profile.maxSMBBasalMinutes:",profile.maxSMBBasalMinutes,"profile.current_basal:",profile.current_basal);
|
||||||
maxBolus = round( profile.current_basal * profile.maxSMBBasalMinutes / 60 ,1);
|
maxBolus = round( profile.current_basal * profile.maxSMBBasalMinutes / 60 ,1);
|
||||||
}
|
}
|
||||||
// bolus 1/2 the insulinReq, up to maxBolus, rounding down to nearest 0.1U
|
// bolus 1/2 the insulinReq, up to maxBolus, rounding down to nearest bolus increment
|
||||||
microBolus = Math.floor(Math.min(insulinReq/2,maxBolus)*10)/10;
|
var roundSMBTo = 1 / profile.bolus_increment;
|
||||||
|
microBolus = Math.floor(Math.min(insulinReq/2,maxBolus)*roundSMBTo)/roundSMBTo;
|
||||||
// calculate a long enough zero temp to eventually correct back up to target
|
// calculate a long enough zero temp to eventually correct back up to target
|
||||||
var smbTarget = target_bg;
|
var smbTarget = target_bg;
|
||||||
var worstCaseInsulinReq = (smbTarget - (naive_eventualBG + minIOBPredBG)/2 ) / sens;
|
var worstCaseInsulinReq = (smbTarget - (naive_eventualBG + minIOBPredBG)/2 ) / sens;
|
||||||
var durationReq = round(60*worstCaseInsulinReq / profile.current_basal);
|
var durationReq = round(60*worstCaseInsulinReq / profile.current_basal);
|
||||||
|
|
||||||
// if insulinReq > 0 but not enough for a microBolus, don't set an SMB zero temp
|
// if insulinReq > 0 but not enough for a microBolus, don't set an SMB zero temp
|
||||||
if (insulinReq > 0 && microBolus < 0.1) {
|
if (insulinReq > 0 && microBolus < profile.bolus_increment) {
|
||||||
durationReq = 0;
|
durationReq = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
private JSONObject mMealData;
|
private JSONObject mMealData;
|
||||||
private JSONObject mCurrentTemp;
|
private JSONObject mCurrentTemp;
|
||||||
private JSONObject mAutosensData = null;
|
private JSONObject mAutosensData = null;
|
||||||
|
private long mCurrentTime;
|
||||||
private boolean mMicrobolusAllowed;
|
private boolean mMicrobolusAllowed;
|
||||||
private boolean mSMBAlwaysAllowed;
|
private boolean mSMBAlwaysAllowed;
|
||||||
|
|
||||||
|
@ -255,6 +256,8 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("enableSMB_always", SP.getBoolean(R.string.key_enableSMB_always, false) && advancedFiltering);
|
mProfile.put("enableSMB_always", SP.getBoolean(R.string.key_enableSMB_always, false) && advancedFiltering);
|
||||||
mProfile.put("enableSMB_after_carbs", SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && advancedFiltering);
|
mProfile.put("enableSMB_after_carbs", SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && advancedFiltering);
|
||||||
mProfile.put("maxSMBBasalMinutes", SP.getInt("key_smbmaxminutes", SMBDefaults.maxSMBBasalMinutes));
|
mProfile.put("maxSMBBasalMinutes", SP.getInt("key_smbmaxminutes", SMBDefaults.maxSMBBasalMinutes));
|
||||||
|
mProfile.put("maxUAMSMBBasalMinutes", SP.getInt("key_uamsmbmaxminutes", SMBDefaults.maxUAMSMBBasalMinutes));
|
||||||
|
mProfile.put("bolus_increment", SMBDefaults.bolus_increment);
|
||||||
mProfile.put("carbsReqThreshold", SMBDefaults.carbsReqThreshold);
|
mProfile.put("carbsReqThreshold", SMBDefaults.carbsReqThreshold);
|
||||||
|
|
||||||
mProfile.put("current_basal", basalrate);
|
mProfile.put("current_basal", basalrate);
|
||||||
|
|
|
@ -56,9 +56,11 @@ public class SMBDefaults {
|
||||||
//public final static boolean enableSMB_after_carbs = false; // enable supermicrobolus for 6h after carbs, even with 0 COB
|
//public final static boolean enableSMB_after_carbs = false; // enable supermicrobolus for 6h after carbs, even with 0 COB
|
||||||
//public final static boolean allowSMB_with_high_temptarget = false; // allow supermicrobolus (if otherwise enabled) even with high temp targets
|
//public final static boolean allowSMB_with_high_temptarget = false; // allow supermicrobolus (if otherwise enabled) even with high temp targets
|
||||||
public final static int maxSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB with uncovered COB
|
public final static int maxSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB with uncovered COB
|
||||||
|
public final static int maxUAMSMBBasalMinutes = 30; // maximum minutes of basal that can be delivered as a single SMB when IOB exceeds COB
|
||||||
// curve:"rapid-acting" // Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp)
|
// curve:"rapid-acting" // Supported curves: "bilinear", "rapid-acting" (Novolog, Novorapid, Humalog, Apidra) and "ultra-rapid" (Fiasp)
|
||||||
// useCustomPeakTime:false // allows changing insulinPeakTime
|
// useCustomPeakTime:false // allows changing insulinPeakTime
|
||||||
// insulinPeakTime:75 // number of minutes after a bolus activity peaks. defaults to 55m for Fiasp if useCustomPeakTime: false
|
// insulinPeakTime:75 // number of minutes after a bolus activity peaks. defaults to 55m for Fiasp if useCustomPeakTime: false
|
||||||
public final static int carbsReqThreshold = 1; // grams of carbsReq to trigger a pushover
|
public final static int carbsReqThreshold = 1; // grams of carbsReq to trigger a pushover
|
||||||
// offline_hotspot:false // enabled an offline-only local wifi hotspot if no Internet available
|
// offline_hotspot:false // enabled an offline-only local wifi hotspot if no Internet available
|
||||||
|
public final static double bolus_increment = 0.1; // minimum bolus that can be delivered as an SMB
|
||||||
}
|
}
|
||||||
|
|
|
@ -802,6 +802,8 @@
|
||||||
<string name="wear_detailed_delta_summary">Show delta with one more decimal place</string>
|
<string name="wear_detailed_delta_summary">Show delta with one more decimal place</string>
|
||||||
<string name="smbmaxminutes" translatable="false">45 60 75 90 105 120</string>
|
<string name="smbmaxminutes" translatable="false">45 60 75 90 105 120</string>
|
||||||
<string name="smbmaxminutes_summary">Max minutes of basal to limit SMB to</string>
|
<string name="smbmaxminutes_summary">Max minutes of basal to limit SMB to</string>
|
||||||
|
<string name="uamsmbmaxminutes" translatable="false">45 60 75 90 105 120</string>
|
||||||
|
<string name="uamsmbmaxminutes_summary">Max minutes of basal to limit SMB to when UAM is active</string>
|
||||||
<string name="unsupportedfirmware">Unsupported pump firmware</string>
|
<string name="unsupportedfirmware">Unsupported pump firmware</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>
|
||||||
|
|
|
@ -79,6 +79,20 @@
|
||||||
validate:minNumber="15"
|
validate:minNumber="15"
|
||||||
validate:testType="numericRange" />
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
|
<com.andreabaccega.widget.ValidatingEditTextPreference
|
||||||
|
android:defaultValue="30"
|
||||||
|
android:dialogMessage="@string/uamsmbmaxminutes"
|
||||||
|
android:digits="0123456789"
|
||||||
|
android:inputType="number"
|
||||||
|
android:key="key_uamsmbmaxminutes"
|
||||||
|
android:maxLines="20"
|
||||||
|
android:selectAllOnFocus="true"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:title="@string/uamsmbmaxminutes_summary"
|
||||||
|
validate:maxNumber="120"
|
||||||
|
validate:minNumber="15"
|
||||||
|
validate:testType="numericRange" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="@string/key_use_uam"
|
android:key="@string/key_use_uam"
|
||||||
|
|
Loading…
Reference in a new issue