diff --git a/bin/oref0-autotune-core.js b/bin/oref0-autotune-core.js index 0de06491f..ee924c4a8 100755 --- a/bin/oref0-autotune-core.js +++ b/bin/oref0-autotune-core.js @@ -47,6 +47,14 @@ if (!module.parent) { return console.error("Could not parse input data: ", e); } + // Pump profile has an up to date copy of useCustomPeakTime from preferences + // If the preferences file has useCustomPeakTime use the previous autotune dia and PeakTime. + // Otherwise, use data from pump profile. + if (!pumpprofile_data.useCustomPeakTime) { + previous_autotune_data.dia = pumpprofile_data.dia; + previous_autotune_data.insulinPeakTime = pumpprofile_data.insulinPeakTime; + } + var inputs = { preppedGlucose: prepped_glucose_data , previousAutotune: previous_autotune_data diff --git a/bin/oref0-autotune-prep.js b/bin/oref0-autotune-prep.js index 2372d7953..406166e6e 100755 --- a/bin/oref0-autotune-prep.js +++ b/bin/oref0-autotune-prep.js @@ -84,6 +84,17 @@ if (!module.parent) { } } + // get insulin curve from pump profile that is maintained + profile_data.curve = pumpprofile_data.curve; + + // Pump profile has an up to date copy of useCustomPeakTime from preferences + // If the preferences file has useCustomPeakTime use the previous autotune dia and PeakTime. + // Otherwise, use data from pump profile. + if (!pumpprofile_data.useCustomPeakTime) { + profile_data.dia = pumpprofile_data.dia; + profile_data.insulinPeakTime = pumpprofile_data.insulinPeakTime; + } + try { var glucose_data = JSON.parse(fs.readFileSync(glucose_input, 'utf8')); } catch (e) { diff --git a/tests/command-behavior.tests.sh b/tests/command-behavior.tests.sh index 0b9038194..cb7228e81 100755 --- a/tests/command-behavior.tests.sh +++ b/tests/command-behavior.tests.sh @@ -104,14 +104,15 @@ test-ns-status () { test-autotune-core () { # Run autotune-core and capture output - ../bin/oref0-autotune-core.js autotune.data.json profile.json profile.json 2>stderr_output 1>stdout_output + ../bin/oref0-autotune-core.js autotune.data.json profile.json pumpprofile.json 2>stderr_output 1>stdout_output ERROR_LINE_COUNT=$( cat stderr_output | wc -l ) ERROR_LINES=$( cat stderr_output ) cat stderr_output | grep -q CRTotalCarbs || fail_test "oref0-autotune-core didn't contain expected stderr output" # Make sure output has accurate carb ratio data - cat stdout_output | jq .carb_ratio | grep -q 22.142 || fail_test "oref0-autotune-core didn't contain expected carb_ratio output" + cat stdout_output | jq .dia | grep -q 7 || fail_test "oref0-autotune-core didn't contain expected dia output" + cat stdout_output | jq .insulinPeakTime | grep -q 85 || fail_test "oref0-autotune-core didn't contain expected insulinPeakTime output" # If we made it here, the test passed echo "oref0-autotune-core test passed" @@ -582,6 +583,111 @@ EOT "useCustomPeakTime": true, "wide_bg_target_range": false } +EOT + + # Make a dummy pumpprofile.json + cat >pumpprofile.json <