Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look ahead dev #1371

Open
wants to merge 2 commits into
base: floating-carbs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/autotune/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ function tuneAllTheThings (inputs) {
} //else { console.error("newCR",newCR,"is close enough to",pumpCarbRatio); }
}
// only adjust by 20%
var newCR = ( 0.8 * carbRatio ) + ( 0.2 * fullNewCR );
var newCR = ( 0.6 * carbRatio ) + ( 0.4 * fullNewCR );
// safety cap newCR
if (typeof(pumpCarbRatio) !== 'undefined') {
if (newCR > maxCR) {
Expand Down
16 changes: 11 additions & 5 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,11 +617,17 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
}
UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + predBGI + Math.min(0, predDev) + predUCI;
//console.error(predBGI, predCI, predUCI);
// truncate all BG predictions at 4 hours
if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); }
if ( COBpredBGs.length < 48) { COBpredBGs.push(COBpredBG); }
if ( UAMpredBGs.length < 48) { UAMpredBGs.push(UAMpredBG); }
if ( ZTpredBGs.length < 48) { ZTpredBGs.push(ZTpredBG); }
// truncate all BG predictions at lookahead_int hours in 5min segments

if (typeof profile.lookahead_5mins === 'undefined') {
var lookahead_int = 48; }
else if (profile.lookahead_5mins) {
var lookahead_int = Math.max(profile.lookahead_5mins, 27); }

if ( IOBpredBGs.length < lookahead_int) { IOBpredBGs.push(IOBpredBG); }
if ( COBpredBGs.length < lookahead_int) { COBpredBGs.push(COBpredBG); }
if ( UAMpredBGs.length < lookahead_int) { UAMpredBGs.push(UAMpredBG); }
if ( ZTpredBGs.length < lookahead_int) { ZTpredBGs.push(ZTpredBG); }
// calculate minGuardBGs without a wait from COB, UAM, IOB predBGs
if ( COBpredBG < minCOBGuardBG ) { minCOBGuardBG = round(COBpredBG); }
if ( UAMpredBG < minUAMGuardBG ) { minUAMGuardBG = round(UAMpredBG); }
Expand Down
2 changes: 2 additions & 0 deletions lib/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function defaults ( ) {
// TODO: make maxRaw a preference here usable by oref0-raw in myopenaps-cgm-loop
//, maxRaw: 200 // highest raw/noisy CGM value considered safe to use for looping
, calc_glucose_noise: false
, lookahead_5mins: 48 // prediction truncation in hours x 12
};
}

Expand All @@ -92,6 +93,7 @@ function displayedDefaults () {
profile.enableUAM = allDefaults.enableUAM;
profile.curve = allDefaults.curve;
profile.offline_hotspot = allDefaults.offline_hotspot;
profile.lookahead_5mins = allDefaults.lookahead_5mins;

console.error(profile);
return profile
Expand Down