Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into empty-target-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleibrand committed Jun 24, 2019
2 parents a4d7cdd + 29f6b99 commit 482dc6b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
9 changes: 6 additions & 3 deletions bin/oref0-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1279,14 +1279,17 @@ if prompt_yn "" N; then
# Install Golang
mkdir -p $HOME/go
source $HOME/.bash_profile
if go version | grep go1.11.; then
golangversion=1.12.5
if go version | grep go${golangversion}.; then
echo Go already installed
else
echo "Removing possible old go install..."
rm -rf /usr/local/go/*
echo "Installing Golang..."
if uname -m | grep armv; then
cd /tmp && wget -c https://storage.googleapis.com/golang/go1.11.linux-armv6l.tar.gz && tar -C /usr/local -xzvf /tmp/go1.11.linux-armv6l.tar.gz
cd /tmp && wget -c https://storage.googleapis.com/golang/go${golangversion}.linux-armv6l.tar.gz && tar -C /usr/local -xzvf /tmp/go${golangversion}.linux-armv6l.tar.gz
elif uname -m | grep i686; then
cd /tmp && wget -c https://dl.google.com/go/go1.11.linux-386.tar.gz && tar -C /usr/local -xzvf /tmp/go1.11.linux-386.tar.gz
cd /tmp && wget -c https://dl.google.com/go/go${golangversion}.linux-386.tar.gz && tar -C /usr/local -xzvf /tmp/go${golangversion}.linux-386.tar.gz
fi
fi
if ! grep GOROOT $HOME/.bash_profile; then
Expand Down
14 changes: 7 additions & 7 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,21 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
}
if (minAgo > 12 || minAgo < -5) { // Dexcom data is too old, or way in the future
rT.reason = "If current system time "+systemTime+" is correct, then BG data is too old. The last BG data was read "+minAgo+"m ago at "+bgTime;
// if BG is too old/noisy, or is completely unchanging, cancel any high temps and shorten any long zero temps
} else if ( glucose_status.short_avgdelta === 0 && glucose_status.long_avgdelta === 0 ) {
// if BG is too old/noisy, or is changing less than 1 mg/dL/5m for 45m, cancel any high temps and shorten any long zero temps
} else if ( bg > 60 && glucose_status == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) {
if ( glucose_status.last_cal && glucose_status.last_cal < 3 ) {
rT.reason = "CGM was just calibrated";
} else {
rT.reason = "Error: CGM data is unchanged for the past ~45m";
}
}
if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || ( glucose_status.short_avgdelta === 0 && glucose_status.long_avgdelta === 0 ) ) {
if (currenttemp.rate >= basal) { // high temp is running
rT.reason += ". Canceling high temp basal of "+currenttemp.rate;
if (bg <= 10 || bg === 38 || noise >= 3 || minAgo > 12 || minAgo < -5 || ( bg > 60 && glucose_status == 0 && glucose_status.short_avgdelta > -1 && glucose_status.short_avgdelta < 1 && glucose_status.long_avgdelta > -1 && glucose_status.long_avgdelta < 1 ) ) {
if (currenttemp.rate > basal) { // high temp is running
rT.reason += ". Replacing high temp basal of "+currenttemp.rate+" with neutral temp of "+basal;
rT.deliverAt = deliverAt;
rT.temp = 'absolute';
rT.duration = 0;
rT.rate = 0;
rT.duration = 30;
rT.rate = basal;
return rT;
//return tempBasalFunctions.setTempBasal(basal, 30, profile, rT, currenttemp);
} else if ( currenttemp.rate === 0 && currenttemp.duration > 30 ) { //shorten long zero temps to 30m
Expand Down
17 changes: 11 additions & 6 deletions tests/determine-basal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('determine-basal', function ( ) {
//function determine_basal(glucose_status, currenttemp, iob_data, profile)

// standard initial conditions for all determine-basal test cases unless overridden
var glucose_status = {"delta":0,"glucose":115,"long_avgdelta":0.1,"short_avgdelta":0};
var glucose_status = {"delta":0,"glucose":115,"long_avgdelta":1.1,"short_avgdelta":0};
var currenttemp = {"duration":0,"rate":0,"temp":"absolute"};
var iob_data = {"iob":0,"activity":0,"bolussnooze":0};
var autosens = {"ratio":1.0};
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('determine-basal', function ( ) {
it('should do nothing when low and rising w/o IOB', function () {
var glucose_status = {"delta":6,"glucose":75,"long_avgdelta":6,"short_avgdelta":6};
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
console.log(output);
//console.log(output);
output.rate.should.equal(0.9);
output.duration.should.equal(30);
//output.reason.should.match(/75<80.*setting current basal/);
Expand Down Expand Up @@ -248,27 +248,30 @@ describe('determine-basal', function ( ) {
});

it('should temp to 0 when LOW w/ positive IOB', function () {
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":0.1,"short_avgdelta":0};
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":-1.1,"short_avgdelta":0};
var iob_data = {"iob":1,"activity":0.01,"bolussnooze":0.5};
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
output.rate.should.equal(0);
output.duration.should.be.above(29);
//output.reason.should.match(/BG 39<80/);
});

it('should low temp when LOW w/ negative IOB', function () {
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":0.1,"short_avgdelta":0};
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":-1.1,"short_avgdelta":0};
var iob_data = {"iob":-2.5,"activity":-0.03,"bolussnooze":0};
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
output.rate.should.be.below(0.8);
output.duration.should.be.above(29);
//output.reason.should.match(/BG 39<80/);
});

it('should temp to 0 when LOW w/ no IOB', function () {
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":0.1,"short_avgdelta":0};
var glucose_status = {"delta":0,"glucose":39,"long_avgdelta":-1.1,"short_avgdelta":0};
var iob_data = {"iob":0,"activity":0,"bolussnooze":0};
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
output.rate.should.equal(0);
output.duration.should.be.above(29);
//output.reason.should.match(/BG 39<80/);
Expand Down Expand Up @@ -476,7 +479,7 @@ describe('determine-basal', function ( ) {
var output = determine_basal({glucose:10},currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
output.rate.should.be.below(1);
output.reason.should.match(/Canceling high temp/);
output.reason.should.match(/Replacing high temp/);
});

it('profile should contain min_bg,max_bg', function () {
Expand Down Expand Up @@ -725,6 +728,7 @@ describe('determine-basal', function ( ) {
profile.current_basal = 0.825;
profile.model = "523";
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
//output.rate.should.equal(0);
//output.duration.should.equal(0);
output.rate.should.equal(0.825);
Expand All @@ -738,6 +742,7 @@ describe('determine-basal', function ( ) {
profile.current_basal = 0.875;
profile.model = "522";
var output = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens, meal_data, tempBasalFunctions);
//console.log(output);
//output.rate.should.equal(0);
//output.duration.should.equal(0);
output.rate.should.equal(0.9);
Expand Down

0 comments on commit 482dc6b

Please sign in to comment.