Skip to content

Commit

Permalink
target_bg preference (#1358)
Browse files Browse the repository at this point in the history
* deprecate/remove support for max_bg and wide_bg_target_range

* support target_bg in preferences.json

* populate target_bg from preferences.json to profile.json

* allow target_bg to override profile schedule in simulator
  • Loading branch information
scottleibrand committed Feb 14, 2020
1 parent 7571845 commit 38732f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/oref0-simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ function init {
function main {

# look up the currently active bg_target based on the current clock.json
target=$((cat profile.json | jq -r '.bg_targets.targets[] | [.start, .min_bg] | @csv'; echo -n \"; cat clock.json | awk -F T '{print $2}') | sort | grep -B1 '\"$' | head -1 | awk -F , '{print $2}')
if grep target_bg profile.json; then
target=$(jq .target_bg profile.json)
else
target=$((cat profile.json | jq -r '.bg_targets.targets[] | [.start, .min_bg] | @csv'; echo -n \"; cat clock.json | awk -F T '{print $2}') | sort | grep -B1 '\"$' | head -1 | awk -F , '{print $2}')
fi
if ! [ -z "$target" ]; then
cat profile.json | jq ". | .min_bg=$target | .max_bg=$target" > profile.json.new
echo setting target to $target
Expand Down
1 change: 1 addition & 0 deletions lib/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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
, target_bg: false // set to an integer value in mg/dL to override pump min_bg
};
}

Expand Down
4 changes: 4 additions & 0 deletions lib/profile/targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ function lookup (inputs, profile) {
}
}

if (profile.target_bg) {
bgTargets.low = profile.target_bg;
}

bgTargets.high = bgTargets.low;

var tempTargets = bgTargets;
Expand Down

0 comments on commit 38732f8

Please sign in to comment.