Merge pull request #1474 from tim2000s/dev
Update Dynamic ISF Beta 1.5 into nightscout-dev
This commit is contained in:
commit
48d516c2f2
|
@ -202,161 +202,194 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
|||
halfBasalTarget = 160; // when temptarget is 160 mg/dL, run 50% basal (120 = 75%; 140 = 60%)
|
||||
// 80 mg/dL with low_temptarget_lowers_sensitivity would give 1.5x basal, but is limited to autosens_max (1.2x by default)
|
||||
}
|
||||
if ( high_temptarget_raises_sensitivity && profile.temptargetSet && target_bg > normalTarget
|
||||
|| profile.low_temptarget_lowers_sensitivity && profile.temptargetSet && target_bg < normalTarget ) {
|
||||
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||
//sensitivityRatio = 2/(2+(target_bg-normalTarget)/40);
|
||||
var c = halfBasalTarget - normalTarget;
|
||||
sensitivityRatio = c/(c+target_bg-normalTarget);
|
||||
// limit sensitivityRatio to profile.autosens_max (1.2x by default)
|
||||
sensitivityRatio = Math.min(sensitivityRatio, profile.autosens_max);
|
||||
sensitivityRatio = round(sensitivityRatio,2);
|
||||
console.log("Sensitivity ratio set to "+sensitivityRatio+" based on temp target of "+target_bg+"; ");
|
||||
} else if (typeof autosens_data !== 'undefined' && autosens_data) {
|
||||
sensitivityRatio = autosens_data.ratio;
|
||||
console.log("Autosens ratio: "+sensitivityRatio+"; ");
|
||||
}
|
||||
if (sensitivityRatio) {
|
||||
basal = profile.current_basal * sensitivityRatio;
|
||||
basal = round_basal(basal, profile);
|
||||
if (basal !== profile_current_basal) {
|
||||
console.log("Adjusting basal from "+profile_current_basal+" to "+basal+"; ");
|
||||
} else {
|
||||
console.log("Basal unchanged: "+basal+"; ");
|
||||
}
|
||||
}
|
||||
|
||||
// adjust min, max, and target BG for sensitivity, such that 50% increase in ISF raises target from 100 to 120
|
||||
if (profile.temptargetSet) {
|
||||
//console.log("Temp Target set, not adjusting with autosens; ");
|
||||
} else if (typeof autosens_data !== 'undefined' && autosens_data) {
|
||||
if ( profile.sensitivity_raises_target && autosens_data.ratio < 1 || profile.resistance_lowers_target && autosens_data.ratio > 1 ) {
|
||||
// with a target of 100, default 0.7-1.2 autosens min/max range would allow a 93-117 target range
|
||||
min_bg = round((min_bg - 60) / autosens_data.ratio) + 60;
|
||||
max_bg = round((max_bg - 60) / autosens_data.ratio) + 60;
|
||||
var new_target_bg = round((target_bg - 60) / autosens_data.ratio) + 60;
|
||||
// don't allow target_bg below 80
|
||||
new_target_bg = Math.max(80, new_target_bg);
|
||||
if (target_bg === new_target_bg) {
|
||||
console.log("target_bg unchanged: "+new_target_bg+"; ");
|
||||
} else {
|
||||
console.log("target_bg from "+target_bg+" to "+new_target_bg+"; ");
|
||||
}
|
||||
target_bg = new_target_bg;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof iob_data === 'undefined' ) {
|
||||
rT.error ='Error: iob_data undefined. ';
|
||||
return rT;
|
||||
}
|
||||
|
||||
var iobArray = iob_data;
|
||||
if (typeof(iob_data.length) && iob_data.length > 1) {
|
||||
iob_data = iobArray[0];
|
||||
//console.error(JSON.stringify(iob_data[0]));
|
||||
}
|
||||
|
||||
if (typeof iob_data.activity === 'undefined' || typeof iob_data.iob === 'undefined' ) {
|
||||
rT.error ='Error: iob_data missing some property. ';
|
||||
return rT;
|
||||
}
|
||||
|
||||
var tick;
|
||||
|
||||
if (glucose_status.delta > -0.5) {
|
||||
tick = "+" + round(glucose_status.delta,0);
|
||||
} else {
|
||||
tick = round(glucose_status.delta,0);
|
||||
}
|
||||
//var minDelta = Math.min(glucose_status.delta, glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
var minDelta = Math.min(glucose_status.delta, glucose_status.short_avgdelta);
|
||||
var minAvgDelta = Math.min(glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
var maxDelta = Math.max(glucose_status.delta, glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
|
||||
var profile_sens = round(profile.sens,1)
|
||||
var sens = profile.sens;
|
||||
|
||||
var now = new Date().getHours();
|
||||
if (now < 1){
|
||||
now = 1;}
|
||||
else {
|
||||
console.error("Time now is "+now+"; ");
|
||||
}
|
||||
console.error(" ");
|
||||
console.error("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
console.error("++ Dynamic ISF Beta 1.4 - Linear Extrapolation/TDD7 ++");
|
||||
console.error("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
|
||||
console.error(" ");
|
||||
if (now < 1){
|
||||
now = 1;}
|
||||
else {
|
||||
console.error("Time now is "+now+"; ");
|
||||
}
|
||||
//*********************************************************************************
|
||||
//** Start of Dynamic ISF code for predictions **
|
||||
//*********************************************************************************
|
||||
|
||||
if (meal_data.TDDAIMI7){
|
||||
var tdd7 = meal_data.TDDAIMI7;
|
||||
console.error("---------------------------------------------------------");
|
||||
console.error( " Dynamic ISF version Beta 1.5 ");
|
||||
console.error("---------------------------------------------------------");
|
||||
|
||||
|
||||
if (meal_data.TDDAIMI7){
|
||||
var tdd7 = meal_data.TDDAIMI7;
|
||||
}
|
||||
else{
|
||||
var tdd7 = ((basal * 12)*100)/21;
|
||||
}
|
||||
console.error("7-day average TDD is: " +tdd7+ "; ");
|
||||
console.error(" ");
|
||||
|
||||
if (meal_data.TDDLast24){
|
||||
var tdd_24 = meal_data.TDDLast24;
|
||||
if (meal_data.TDDLast24){
|
||||
var tdd_24 = meal_data.TDDLast24;
|
||||
}
|
||||
else {
|
||||
var tdd_24 = (( basal * 24 ) * 2.8);
|
||||
}
|
||||
|
||||
if (meal_data.TDDPUMP){
|
||||
var tdd_pump = ( (meal_data.TDDPUMP / now ) * 24);
|
||||
}
|
||||
else {
|
||||
var tdd_pump = (( basal * 24 ) * 2.8);
|
||||
}
|
||||
console.log("Rolling TDD for last 24 hours is: "+tdd_24+"; ");
|
||||
|
||||
/*var tdd_pump_now = meal_data.TDDPUMP;
|
||||
var tdd_pump = ( tdd_pump_now / (now / 24));*/
|
||||
var TDD = (tdd7 * 0.4) + (tdd_pump * 0.6);
|
||||
|
||||
console.error("Pump extrapolated TDD = "+tdd_pump+"; ");
|
||||
//if (tdd7 > 0){
|
||||
if ( tdd_pump > tdd7 && now < 5 || now < 7 && TDD < ( 0.8 * tdd7 ) ){
|
||||
TDD = ( 0.8 * tdd7 );
|
||||
console.log("Excess or too low insulin from pump so TDD set to "+TDD+" based on 75% of TDD7; ");
|
||||
rT.reason += "TDD: " +TDD+ " due to low or high tdd from pump; ";
|
||||
}
|
||||
|
||||
else if (tdd_pump > (1.75 * tdd7)){
|
||||
TDD = tdd7;
|
||||
console.error("TDD set to TDD7 due to high pump usage reported. TDD = "+TDD+"; ");
|
||||
rT.reason += "TDD set to TDD7 due to high pump usage reported. TDD = "+TDD+"; ";
|
||||
}
|
||||
|
||||
|
||||
else if (tdd_pump < (0.33 * tdd7)){
|
||||
TDD = (tdd7 * 0.25) + (tdd_pump * 0.75);
|
||||
console.error("TDD weighted to pump due to low insulin usage. TDD = "+TDD+"; ");
|
||||
rT.reason += "TDD weighted to pump due to low insulin usage. TDD = "+TDD+"; ";
|
||||
}
|
||||
|
||||
else {
|
||||
console.log("TDD = " +TDD+ " based on standard pump 60/tdd7 40 split; ");
|
||||
rT.reason += "TDD: " +TDD+ " based on standard pump 60/tdd7 40 split; ";
|
||||
}
|
||||
|
||||
var dynISFadjust = profile.DynISFAdjust;
|
||||
var dynISFadjust = ( dynISFadjust / 100 );
|
||||
var TDD = (dynISFadjust * TDD);
|
||||
var variable_sens = (277700 / ( TDD * bg));
|
||||
variable_sens = round(variable_sens,1);
|
||||
if (dynISFadjust > 1 ) {
|
||||
console.log("TDD adjustment factor is: " +dynISFadjust+"; ");
|
||||
console.log("TDD adjusted to "+TDD+" using adjustment factor of "+dynISFadjust+"; ");
|
||||
console.log("Current sensitivity for predictions is " +variable_sens+" based on current bg");
|
||||
}
|
||||
else {
|
||||
var tdd_24 = (( basal * 24 ) * 2.8);
|
||||
else if (dynISFadjust < 1 ){
|
||||
console.log("TDD adjustment factor is: " +dynISFadjust+"; ");
|
||||
console.log("TDD adjusted to "+TDD+" using adjustment factor of "+dynISFadjust+"; ");
|
||||
console.log("Current sensitivity for predictions is " +variable_sens+" based on current bg");
|
||||
} else {
|
||||
console.log("Current sensitivity for predictions is " +variable_sens+" based on current bg");
|
||||
}
|
||||
sens = variable_sens;
|
||||
|
||||
//*********************************************************************************
|
||||
//** End of Dynamic ISF code for predictions **
|
||||
//*********************************************************************************
|
||||
|
||||
|
||||
if ( high_temptarget_raises_sensitivity && profile.temptargetSet && target_bg > normalTarget || profile.low_temptarget_lowers_sensitivity && profile.temptargetSet && target_bg < normalTarget ) {
|
||||
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||
//sensitivityRatio = 2/(2+(target_bg-normalTarget)/40);
|
||||
var c = halfBasalTarget - normalTarget;
|
||||
sensitivityRatio = c/(c+target_bg-normalTarget);
|
||||
// limit sensitivityRatio to profile.autosens_max (1.2x by default)
|
||||
sensitivityRatio = Math.min(sensitivityRatio, profile.autosens_max);
|
||||
sensitivityRatio = round(sensitivityRatio,2);
|
||||
console.log("Sensitivity ratio set to "+sensitivityRatio+" based on temp target of "+target_bg+"; ");
|
||||
sens = sens / sensitivityRatio ;
|
||||
sens = round(sens, 1);
|
||||
console.log("ISF from "+variable_sens+" to "+sens+ "due to temp target; ");
|
||||
}
|
||||
else {
|
||||
sensitivityRatio = ( tdd_24 / tdd7 );
|
||||
}
|
||||
if (sensitivityRatio > 1) {
|
||||
sensitivityRatio = Math.min(sensitivityRatio, profile.autosens_max);
|
||||
sensitivityRatio = round(sensitivityRatio,2);
|
||||
console.log("Sensitivity ratio: "+sensitivityRatio+"; ");
|
||||
}
|
||||
else if( sensitivityRatio < 1) {
|
||||
sensitivityRatio = Math.max(sensitivityRatio, profile.autosens_min);
|
||||
sensitivityRatio = round(sensitivityRatio,2);
|
||||
console.log("Sensitivity ratio: "+sensitivityRatio+"; ");
|
||||
}
|
||||
else {
|
||||
console.log("Sensitivity ratio: "+sensitivityRatio+"; ");
|
||||
}
|
||||
|
||||
|
||||
if (sensitivityRatio && profile.openapsama_useautosens === true) {
|
||||
basal = profile.current_basal * sensitivityRatio;
|
||||
basal = round_basal(basal, profile);
|
||||
if (basal !== profile_current_basal) {
|
||||
console.log("Adjusting basal from "+profile_current_basal+" to "+basal+"; ");
|
||||
} else {
|
||||
console.log("Autosens disabled. Basal unchanged: "+basal+"; ");
|
||||
}
|
||||
}
|
||||
|
||||
if (meal_data.TDDPUMP){
|
||||
var tdd_pump = ( (meal_data.TDDPUMP / now ) * 24);
|
||||
// adjust min, max, and target BG for sensitivity, such that 50% increase in ISF raises target from 100 to 120
|
||||
if (profile.temptargetSet) {
|
||||
//console.log("Temp Target set, not adjusting with autosens; ");
|
||||
} else {
|
||||
if ( profile.sensitivity_raises_target && sensitivityRatio < 1 && profile.openapsama_useautosens === true || profile.resistance_lowers_target && sensitivityRatio > 1 && profile.openapsama_useautosens === true) {
|
||||
// with a target of 100, default 0.7-1.2 autosens min/max range would allow a 93-117 target range
|
||||
min_bg = round((min_bg - 60) / sensitivityRatio) + 60;
|
||||
max_bg = round((max_bg - 60) / sensitivityRatio) + 60;
|
||||
var new_target_bg = round((target_bg - 60) / sensitivityRatio) + 60;
|
||||
// don't allow target_bg below 80
|
||||
new_target_bg = Math.max(80, new_target_bg);
|
||||
if (target_bg === new_target_bg) {
|
||||
console.log("target_bg unchanged: "+new_target_bg+"; ");
|
||||
} else {
|
||||
console.log("target_bg from "+target_bg+" to "+new_target_bg+"; ");
|
||||
}
|
||||
target_bg = new_target_bg;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var tdd_pump = (( basal * 24 ) * 2.8);
|
||||
|
||||
|
||||
if (typeof iob_data === 'undefined' ) {
|
||||
rT.error ='Error: iob_data undefined. ';
|
||||
return rT;
|
||||
}
|
||||
var TDD = (tdd7 * 0.4) + (tdd_pump * 0.6);
|
||||
|
||||
console.error("Pump extrapolated TDD = "+tdd_pump+"; ");
|
||||
//if (tdd7 > 0){
|
||||
if ( tdd_pump > tdd7 && now < 5 || now < 7 && TDD < ( 0.8 * tdd7 ) ){
|
||||
TDD = ( 0.8 * tdd7 );
|
||||
console.log("Excess or too low insulin from pump so TDD set to "+TDD+" based on 75% of TDD7; ");
|
||||
rT.reason += "TDD: " +TDD+ " due to low or high tdd from pump; ";
|
||||
}
|
||||
var iobArray = iob_data;
|
||||
if (typeof(iob_data.length) && iob_data.length > 1) {
|
||||
iob_data = iobArray[0];
|
||||
//console.error(JSON.stringify(iob_data[0]));
|
||||
}
|
||||
|
||||
else if (tdd_pump > (1.75 * tdd7)){
|
||||
TDD = tdd7;
|
||||
console.error("TDD set to TDD7 due to high pump usage reported. TDD = "+TDD+"; ");
|
||||
rT.reason += "TDD set to TDD7 due to high pump usage reported. TDD = "+TDD+"; ";
|
||||
}
|
||||
if (typeof iob_data.activity === 'undefined' || typeof iob_data.iob === 'undefined' ) {
|
||||
rT.error ='Error: iob_data missing some property. ';
|
||||
return rT;
|
||||
}
|
||||
|
||||
var tick;
|
||||
|
||||
else if (tdd_pump < (0.33 * tdd7)){
|
||||
TDD = (tdd7 * 0.25) + (tdd_pump * 0.75);
|
||||
console.error("TDD weighted to pump due to low insulin usage. TDD = "+TDD+"; ");
|
||||
rT.reason += "TDD weighted to pump due to low insulin usage. TDD = "+TDD+"; ";
|
||||
}
|
||||
if (glucose_status.delta > -0.5) {
|
||||
tick = "+" + round(glucose_status.delta,0);
|
||||
} else {
|
||||
tick = round(glucose_status.delta,0);
|
||||
}
|
||||
//var minDelta = Math.min(glucose_status.delta, glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
var minDelta = Math.min(glucose_status.delta, glucose_status.short_avgdelta);
|
||||
var minAvgDelta = Math.min(glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
var maxDelta = Math.max(glucose_status.delta, glucose_status.short_avgdelta, glucose_status.long_avgdelta);
|
||||
|
||||
else {
|
||||
console.log("TDD = " +TDD+ " based on standard pump 60/tdd7 40 split; ");
|
||||
rT.reason += "TDD: " +TDD+ " based on standard pump 60/tdd7 40 split; ";
|
||||
}
|
||||
|
||||
console.error(" ");
|
||||
|
||||
|
||||
var variable_sens = (277700 / (TDD * bg));
|
||||
variable_sens = round(variable_sens,1);
|
||||
console.log("Current sensitivity for predictions is " +variable_sens+" based on current bg");
|
||||
console.error(" ");
|
||||
|
||||
sens = variable_sens;
|
||||
if ( high_temptarget_raises_sensitivity && profile.temptargetSet && target_bg > normalTarget || profile.low_temptarget_lowers_sensitivity && profile.temptargetSet && target_bg < normalTarget ) {
|
||||
sens = sens / sensitivityRatio ;
|
||||
sens = round(sens, 1);
|
||||
console.log("ISF from "+variable_sens+" to "+sens+ "due to temp target; ");
|
||||
} else {
|
||||
sens = sens;
|
||||
sens = round(sens, 1);
|
||||
}
|
||||
|
||||
console.error("; CR:",profile.carb_ratio);
|
||||
|
||||
|
@ -772,19 +805,27 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
|
|||
|
||||
console.error("UAM Impact:",uci,"mg/dL per 5m; UAM Duration:",UAMduration,"hours");
|
||||
|
||||
console.log("EventualBG is" +eventualBG+" ;");
|
||||
console.log("EventualBG is" +eventualBG+" ;");
|
||||
|
||||
if (bg > target_bg && glucose_status.delta < 3 && glucose_status.delta > -3 && glucose_status.short_avgdelta > -3 && glucose_status.short_avgdelta < 3 && eventualBG > target_bg && eventualBG < bg ) {
|
||||
var future_sens = ( 277700 / (TDD * ((eventualBG * 0.5) + (bg * 0.5) ) ) );
|
||||
console.log("Future state sensitivity is " +future_sens+" based on eventual and current bg due to flat glucose level above target");
|
||||
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
|
||||
}
|
||||
|
||||
else if( glucose_status.delta > 0 && eventualBG > target_bg ) {
|
||||
var future_sens = ( 277700 / (TDD * bg) );
|
||||
console.log("Future state sensitivity is " +future_sens+" using current bg due to small delta or variation");
|
||||
rT.reason += "Dosing sensitivity: " +future_sens+" using current BG;";
|
||||
}
|
||||
|
||||
else {
|
||||
var future_sens = ( 277700 / (TDD * eventualBG) );
|
||||
console.log("Future state sensitivity is " +future_sens+" based on eventual bg due to -ve delta");
|
||||
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
|
||||
}
|
||||
var future_sens = round(future_sens,1);
|
||||
|
||||
if( glucose_status.delta >= 0 || bg > 60 && glucose_status.delta < 2 && glucose_status.delta > -2 && glucose_status.short_avgdelta > -2 && glucose_status.short_avgdelta < 2 || eventualBG > target_bg && glucose_status.delta < 0 ) {
|
||||
var future_sens = ( 277700 / (TDD * bg) );
|
||||
console.log("Future state sensitivity is " +future_sens+" using current bg due to no COB & small delta or variation");
|
||||
rT.reason += "Dosing sensitivity: " +future_sens+" using current BG;";
|
||||
}
|
||||
else {
|
||||
var future_sens = ( 277700 / (TDD * eventualBG));
|
||||
console.log("Future state sensitivity is " +future_sens+" based on eventual bg due to -ve delta");
|
||||
rT.reason += "Dosing sensitivity: " +future_sens+" using eventual BG;";
|
||||
}
|
||||
var future_sens = round(future_sens,1);
|
||||
|
||||
|
||||
minIOBPredBG = Math.max(39,minIOBPredBG);
|
||||
|
|
|
@ -194,9 +194,9 @@ class DetermineBasalAdapterSMBDynamicISFJS internal constructor(private val scri
|
|||
this.profile.put("current_basal_safety_multiplier", sp.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4.0))
|
||||
|
||||
//mProfile.put("high_temptarget_raises_sensitivity", SP.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity));
|
||||
this.profile.put("high_temptarget_raises_sensitivity", false)
|
||||
this.profile.put("high_temptarget_raises_sensitivity", sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity))
|
||||
//mProfile.put("low_temptarget_lowers_sensitivity", SP.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity));
|
||||
this.profile.put("low_temptarget_lowers_sensitivity", false)
|
||||
this.profile.put("low_temptarget_lowers_sensitivity", sp.getBoolean(R.string.key_low_temptarget_lowers_sensitivity, SMBDefaults.low_temptarget_lowers_sensitivity))
|
||||
this.profile.put("sensitivity_raises_target", sp.getBoolean(R.string.key_sensitivity_raises_target, SMBDefaults.sensitivity_raises_target))
|
||||
this.profile.put("resistance_lowers_target", sp.getBoolean(R.string.key_resistance_lowers_target, SMBDefaults.resistance_lowers_target))
|
||||
this.profile.put("adv_target_adjustments", SMBDefaults.adv_target_adjustments)
|
||||
|
@ -222,12 +222,17 @@ class DetermineBasalAdapterSMBDynamicISFJS internal constructor(private val scri
|
|||
this.profile.put("enableSMB_after_carbs", smbEnabled && sp.getBoolean(R.string.key_enableSMB_after_carbs, false) && advancedFiltering)
|
||||
this.profile.put("maxSMBBasalMinutes", sp.getInt(R.string.key_smbmaxminutes, SMBDefaults.maxSMBBasalMinutes))
|
||||
this.profile.put("maxUAMSMBBasalMinutes", sp.getInt(R.string.key_uamsmbmaxminutes, SMBDefaults.maxUAMSMBBasalMinutes))
|
||||
this.profile.put("DynISFAdjust", SafeParse.stringToDouble(sp.getString(R.string.key_DynISFAdjust,"100")))
|
||||
this.profile.put("maxUAMSMBBasalMinutes", sp.getInt(R.string.key_uamsmbmaxminutes, SMBDefaults.maxUAMSMBBasalMinutes))
|
||||
//set the min SMB amount to be the amount set by the pump.
|
||||
this.profile.put("bolus_increment", pumpBolusStep)
|
||||
this.profile.put("carbsReqThreshold", sp.getInt(R.string.key_carbsReqThreshold, SMBDefaults.carbsReqThreshold))
|
||||
this.profile.put("current_basal", basalRate)
|
||||
this.profile.put("temptargetSet", tempTargetSet)
|
||||
this.profile.put("autosens_max", SafeParse.stringToDouble(sp.getString(R.string.key_openapsama_autosens_max, "1.2")))
|
||||
this.profile.put("autosens_min", SafeParse.stringToDouble(sp.getString(R.string.key_openapsama_autosens_min, "0.8")))
|
||||
this.profile.put("openapsama_useautosens", sp.getBoolean(R.string.key_openapsama_useautosens, false))
|
||||
//set the min SMB amount to be the amount set by the pump.
|
||||
if (profileFunction.getUnits() == GlucoseUnit.MMOL) {
|
||||
this.profile.put("out_units", "mmol/L")
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ class OpenAPSSMBDynamicISFPlugin @Inject constructor(
|
|||
.pluginName(R.string.openaps_smb_dynamic_isf)
|
||||
.description(R.string.description_smb_dynamic_isf)
|
||||
.shortName(R.string.dynisf_shortname)
|
||||
.preferencesId(R.xml.pref_openapssmbdynamicisf)
|
||||
.setDefault(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,6 @@
|
|||
<string name="treatments">Treatments</string>
|
||||
<string name="virtualpump">Virtual Pump</string>
|
||||
|
||||
|
||||
<string name="configbuilder_pump">Pump</string>
|
||||
<string name="configbuilder_pump_description">Which pump would you like to use with AndroidAPS?</string>
|
||||
<string name="configbuilder_profile">Profile</string>
|
||||
|
@ -228,6 +227,7 @@
|
|||
<string name="end_user_license_agreement">End User License Agreement</string>
|
||||
<string name="end_user_license_agreement_text">MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</string>
|
||||
<string name="end_user_license_agreement_i_understand">I UNDERSTAND AND AGREE</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="reloadprofile">Reload profile</string>
|
||||
<string name="smscommunicator">SMS Communicator</string>
|
||||
<string name="smscommunicator_allowednumbers">Allowed phone numbers</string>
|
||||
|
@ -535,6 +535,10 @@
|
|||
<string name="ns_localbroadcasts_title">Enable local Broadcasts.</string>
|
||||
<string name="openapssmb">OpenAPS SMB</string>
|
||||
<string name="openaps_smb_dynamic_isf">Dynamic ISF</string>
|
||||
<string name="key_DynISFAdjust" translatable="false">DynISFAdjust</string>
|
||||
<string name="DynISFAdjust_title">DynamicISF Adjustment Factor %</string>
|
||||
<string name="DynISFAdjust_summary">Adjustment factor for DynamicISF. Set more than 100% for more aggressive correction doses, and less than 100% for less aggressive corrections.</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>
|
||||
|
|
223
app/src/main/res/xml/pref_openapssmbdynamicisf.xml
Normal file
223
app/src/main/res/xml/pref_openapssmbdynamicisf.xml
Normal file
|
@ -0,0 +1,223 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:validate="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="@string/key_openapssmb_settings"
|
||||
android:title="@string/openapssmb"
|
||||
app:initialExpandedChildrenCount="0">
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="1"
|
||||
android:dialogMessage="@string/openapsma_maxbasal_summary"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="@string/key_openapsma_max_basal"
|
||||
android:title="@string/openapsma_maxbasal_title"
|
||||
validate:floatmaxNumber="25.0"
|
||||
validate:floatminNumber="0.1"
|
||||
validate:testType="floatNumericRange" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="3"
|
||||
android:dialogMessage="@string/openapssmb_maxiob_summary"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="@string/key_openapssmb_max_iob"
|
||||
android:title="@string/openapssmb_maxiob_title"
|
||||
validate:floatmaxNumber="70.0"
|
||||
validate:floatminNumber="0"
|
||||
validate:testType="floatNumericRange" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="100"
|
||||
android:enabled="true"
|
||||
android:dialogMessage="@string/DynISFAdjust_summary"
|
||||
android:inputType="numberDecimal"
|
||||
android:key="@string/key_DynISFAdjust"
|
||||
android:title="@string/DynISFAdjust_title"
|
||||
validate:floatmaxNumber="300"
|
||||
validate:floatminNumber="1"
|
||||
validate:testType="floatNumericRange" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="openapsama_useautosens"
|
||||
android:title="@string/openapsama_useautosens" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_use_smb"
|
||||
android:summary="@string/enablesmb_summary"
|
||||
android:title="@string/enablesmb" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_use_smb"
|
||||
android:key="@string/key_allowSMB_with_high_temptarget"
|
||||
android:summary="@string/enablesmbwithhightemptarget_summary"
|
||||
android:title="@string/enablesmbwithhightemptarget" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_use_smb"
|
||||
android:key="@string/key_enableSMB_always"
|
||||
android:summary="@string/enablesmbalways_summary"
|
||||
android:title="@string/enablesmbalways" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_use_smb"
|
||||
android:key="@string/key_enableSMB_with_COB"
|
||||
android:summary="@string/enablesmbwithcob_summary"
|
||||
android:title="@string/enablesmbwithcob" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_use_smb"
|
||||
android:key="@string/key_enableSMB_with_temptarget"
|
||||
android:summary="@string/enablesmbwithtemptarget_summary"
|
||||
android:title="@string/enablesmbwithtemptarget" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:dependency="@string/key_use_smb"
|
||||
android:key="@string/key_enableSMB_after_carbs"
|
||||
android:summary="@string/enablesmbaftercarbs_summary"
|
||||
android:title="@string/enablesmbaftercarbs" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="3"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_smbinterval"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/smbinterval_summary"
|
||||
validate:maxNumber="10"
|
||||
validate:minNumber="1"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="30"
|
||||
android:digits="0123456789"
|
||||
android:entries="@array/smbMaxMinutes"
|
||||
android:entryValues="@array/smbMaxMinutes"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_smbmaxminutes"
|
||||
android:title="@string/smbmaxminutes_summary"
|
||||
validate:maxNumber="120"
|
||||
validate:minNumber="15"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="30"
|
||||
android:dialogMessage="@string/uamsmbmaxminutes"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/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
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_use_uam"
|
||||
android:summary="@string/enableuam_summary"
|
||||
android:title="@string/enableuam" />
|
||||
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="true"
|
||||
android:key="@string/key_sensitivity_raises_target"
|
||||
android:summary="@string/sensitivity_raises_target_summary"
|
||||
android:title="@string/sensitivity_raises_target_title" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_resistance_lowers_target"
|
||||
android:summary="@string/resistance_lowers_target_summary"
|
||||
android:title="@string/resistance_lowers_target_title" />
|
||||
<!-- TODO AS-FIX -->
|
||||
<!--<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="false"
|
||||
android:key="@string/key_high_temptarget_raises_sensitivity"
|
||||
android:summary="@string/high_temptarget_raises_sensitivity_summary"
|
||||
android:title="@string/high_temptarget_raises_sensitivity_title" />
|
||||
|
||||
<- TODO AS-FIX -->
|
||||
<!--<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:enabled="false"
|
||||
android:key="@string/key_low_temptarget_lowers_sensitivity"
|
||||
android:summary="@string/low_temptarget_lowers_sensitivity_summary"
|
||||
android:title="@string/low_temptarget_lowers_sensitivity_title" />-->
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="1"
|
||||
android:dialogMessage="@string/carbsReqThreshold_summary"
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_carbsReqThreshold"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:summary="@string/carbsReqThreshold_summary"
|
||||
android:title="@string/carbsReqThreshold"
|
||||
validate:maxNumber="10"
|
||||
validate:minNumber="1"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<androidx.preference.PreferenceScreen
|
||||
android:key="absorption_smb_advanced"
|
||||
android:title="@string/advancedsettings_title">
|
||||
|
||||
<Preference android:summary="@string/openapsama_link_to_preferncejson_doc_txt">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="@string/openapsama_link_to_preferncejson_doc" />
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_always_use_shortavg"
|
||||
android:summary="@string/always_use_shortavg_summary"
|
||||
android:title="@string/always_use_shortavg" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="3"
|
||||
android:dialogMessage="@string/openapsama_max_daily_safety_multiplier_summary"
|
||||
android:digits="0123456789.,"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_openapsama_max_daily_safety_multiplier"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:title="@string/openapsama_max_daily_safety_multiplier"
|
||||
validate:maxNumber="10"
|
||||
validate:minNumber="1"
|
||||
validate:testType="numericRange" />
|
||||
|
||||
<info.nightscout.androidaps.utils.textValidator.ValidatingEditTextPreference
|
||||
android:defaultValue="4"
|
||||
android:dialogMessage="@string/openapsama_current_basal_safety_multiplier_summary"
|
||||
android:digits="0123456789.,"
|
||||
android:inputType="number"
|
||||
android:key="@string/key_openapsama_current_basal_safety_multiplier"
|
||||
android:maxLines="20"
|
||||
android:selectAllOnFocus="true"
|
||||
android:singleLine="true"
|
||||
android:title="@string/openapsama_current_basal_safety_multiplier"
|
||||
validate:floatmaxNumber="10"
|
||||
validate:floatminNumber="1"
|
||||
validate:testType="floatNumericRange" />
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
|
@ -22,8 +22,9 @@ object SMBDefaults {
|
|||
// const val remainingCarbsFraction = 1.0 // fraction of carbs we'll assume will absorb over 4h if we don't yet see carb absorption
|
||||
|
||||
// USED IN DETERMINE_BASAL
|
||||
// const val low_temptarget_lowers_sensitivity = false // lower sensitivity for temptargets <= 99.
|
||||
const val low_temptarget_lowers_sensitivity = false // lower sensitivity for temptargets <= 99.
|
||||
const val high_temptarget_raises_sensitivity = false // raise sensitivity for temptargets >= 111. synonym for exercise_mode
|
||||
|
||||
const val sensitivity_raises_target = true // raise BG target when autosens detects sensitivity
|
||||
const val resistance_lowers_target = false // lower BG target when autosens detects resistance
|
||||
const val adv_target_adjustments = false // lower target automatically when BG and eventualBG are high
|
||||
|
|
Loading…
Reference in a new issue