Skip to content

Commit

Permalink
Formatting fixes in sens logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tim2000s committed Feb 20, 2022
1 parent 035e974 commit 304edd8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js
Expand Up @@ -284,9 +284,11 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
else {
console.error("Time now is "+now+"; ");
}
console.error(" ");
console.error("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
console.error("++ Dynamic ISF Beta 1.3 - Based on rolling 24 hours ++");
console.error("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
console.error(" ");

if (meal_data.TDDAIMI7){
var tdd7 = meal_data.TDDAIMI7;
Expand All @@ -295,7 +297,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
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;
Expand All @@ -307,7 +309,9 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
var TDD = (tdd7 * 0.3) + (tdd_24 * 0.7);

console.error("Rolling 24 hour TDD = "+tdd_24+"; ");
console.error(" ");
console.error("Weighted Average TDD = "+TDD+"; ");
console.error(" ");
//if (tdd7 > 0){
/*if ( tdd_pump > tdd7 && now < 5 || now < 7 && TDD < ( 0.8 * tdd7 ) ){
TDD = ( 0.8 * tdd7 );
Expand Down Expand Up @@ -336,6 +340,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
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 ) {
Expand Down Expand Up @@ -403,7 +408,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
if (iob_data.iob > 0) {
var naive_eventualBG = round( bg - (iob_data.iob * sens) );
} else { // if IOB is negative, be more conservative and use the lower of sens, profile.sens
naive_eventualBG = round( bg - (iob_data.iob * Math.min(sens, profile.sens) ) );
naive_eventualBG = round( bg - (iob_data.iob * sens ) );
}
// and adjust it for the deviation above
var eventualBG = naive_eventualBG + deviation;
Expand Down

0 comments on commit 304edd8

Please sign in to comment.