Skip to content
Merged
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
11 changes: 9 additions & 2 deletions bin/oref0-pump-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ smb_main() {
))
fi
) \
&& ( refresh_profile; refresh_pumphistory_24h; true ) \
&& ( refresh_profile 15; refresh_pumphistory_24h; true ) \
&& refresh_after_bolus_or_enact \
&& echo Completed supermicrobolus pump-loop at $(date): \
&& touch monitor/pump_loop_completed -r monitor/pump_loop_enacted \
Expand Down Expand Up @@ -224,6 +224,8 @@ function smb_bolus {

function refresh_after_bolus_or_enact {
if (find enact/ -mmin -2 -size +5c | grep -q bolused.json || (cat monitor/temp_basal.json | json -c "this.duration > 28" | grep -q duration)); then
# refresh profile if >5m old to give SMB a chance to deliver
refresh_profile 3
gather || ( wait_for_silence 10 && gather ) || ( wait_for_silence 20 && gather )
true
fi
Expand Down Expand Up @@ -504,7 +506,12 @@ function refresh_pumphistory_and_enact {
}

function refresh_profile {
find settings/ -mmin -10 -size +5c | grep -q settings.json && echo Settings less than 10m old \
if [ -z $1 ]; then
profileage=10
else
profileage=$1
fi
find settings/ -mmin -$profileage -size +5c | grep -q settings.json && echo Settings less than $profileage minutes old \
|| (echo -n Settings refresh && openaps get-settings 2>/dev/null >/dev/null && echo ed)
}

Expand Down