diff --git a/lib/determine-basal/determine-basal.js b/lib/determine-basal/determine-basal.js index a5923eaf9..002a07ea3 100644 --- a/lib/determine-basal/determine-basal.js +++ b/lib/determine-basal/determine-basal.js @@ -414,12 +414,10 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // generate predicted future BGs based on IOB, COB, and current absorption rate var COBpredBGs = []; - var aCOBpredBGs = []; var IOBpredBGs = []; var UAMpredBGs = []; var ZTpredBGs = []; COBpredBGs.push(bg); - aCOBpredBGs.push(bg); IOBpredBGs.push(bg); ZTpredBGs.push(bg); UAMpredBGs.push(bg); @@ -527,10 +525,9 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } else { cid = Math.min(remainingCATime*60/5/2,Math.max(0, meal_data.mealCOB * csf / ci )); } - var acid = Math.max(0, meal_data.mealCOB * csf / aci ); // duration (hours) = duration (5m) * 5 / 60 * 2 (to account for linear decay) console.error("Carb Impact:",ci,"mg/dL per 5m; CI Duration:",round(cid*5/60*2,1),"hours; remaining CI (~2h peak):",round(remainingCIpeak,1),"mg/dL per 5m"); - //console.error("Accel. Carb Impact:",aci,"mg/dL per 5m; ACI Duration:",round(acid*5/60*2,1),"hours"); + //console.error("Accel. Carb Impact:",aci,"mg/dL per 5m; ACI Duration:",round(aci*5/60*2,1),"hours"); var minIOBPredBG = 999; var minCOBPredBG = 999; var minUAMPredBG = 999; @@ -569,7 +566,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // for COBpredBGs, predicted carb impact drops linearly from current carb impact down to zero // eventually accounting for all carbs (if they can be absorbed over DIA) var predCI = Math.max(0, Math.max(0,ci) * ( 1 - COBpredBGs.length/Math.max(cid*2,1) ) ); - var predACI = Math.max(0, Math.max(0,aci) * ( 1 - COBpredBGs.length/Math.max(acid*2,1) ) ); // if any carbs aren't absorbed after remainingCATime hours, assume they'll absorb in a /\ shaped // bilinear curve peaking at remainingCIpeak at remainingCATime/2 hours (remainingCATime/2*12 * 5m) // and ending at remainingCATime h (remainingCATime*12 * 5m intervals) @@ -580,7 +576,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ predCIs.push(round(predCI,0)); //process.stderr.write(round(predCI,1)+"+"+round(remainingCI,1)+" "); COBpredBG = COBpredBGs[COBpredBGs.length-1] + predBGI + Math.min(0,predDev) + predCI + remainingCI; - var aCOBpredBG = aCOBpredBGs[aCOBpredBGs.length-1] + predBGI + Math.min(0,predDev) + predACI; // for UAMpredBGs, predicted carb impact drops at slopeFromDeviations // calculate predicted CI from UAM based on slopeFromDeviations var predUCIslope = Math.max(0, uci + ( UAMpredBGs.length*slopeFromDeviations ) ); @@ -599,7 +594,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // truncate all BG predictions at 4 hours if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); } if ( COBpredBGs.length < 48) { COBpredBGs.push(COBpredBG); } - if ( aCOBpredBGs.length < 48) { aCOBpredBGs.push(aCOBpredBG); } if ( UAMpredBGs.length < 48) { UAMpredBGs.push(UAMpredBG); } if ( ZTpredBGs.length < 48) { ZTpredBGs.push(ZTpredBG); } // calculate minGuardBGs without a wait from COB, UAM, IOB predBGs @@ -654,15 +648,6 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ } rT.predBGs.ZT = ZTpredBGs; lastZTpredBG=round(ZTpredBGs[ZTpredBGs.length-1]); - if (meal_data.mealCOB > 0) { - aCOBpredBGs.forEach(function(p, i, theArray) { - theArray[i] = round(Math.min(401,Math.max(39,p))); - }); - for (i=aCOBpredBGs.length-1; i > 12; i--) { - if (aCOBpredBGs[i-1] !== aCOBpredBGs[i]) { break; } - else { aCOBpredBGs.pop(); } - } - } if (meal_data.mealCOB > 0 && ( ci > 0 || remainingCIpeak > 0 )) { COBpredBGs.forEach(function(p, i, theArray) { theArray[i] = round(Math.min(401,Math.max(39,p)));