Skip to content

Commit

Permalink
Merge branch 'master' into oref0-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
scottleibrand committed Dec 3, 2016
2 parents 71aa0cf + 0e05f7e commit fbcdf98
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 9 deletions.
14 changes: 14 additions & 0 deletions bin/nightscout.sh
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ ns)
lsgaps --minutes 5 --after now --date dateString -


;;
mm-format-ns-glucose)
#Format Medtronic glucose data into something acceptable to Nightscout.
HISTORY=$1
cat $HISTORY | \
json -E "this.sgv = this.sgv ? this.sgv : this.glucose" | \
json -E "this.medtronic = this._type;" | \
json -E "this.dateString = this.dateString ? this.dateString : this.display_time" | \
json -E "this.dateString = this.dateString ? this.dateString : (this.date + '$(date +%z)')" | \
json -E "this.date = new Date(this.dateString).getTime();" | \
json -E "this.type = (this.name == 'GlucoseSensorData') ? 'sgv' : 'pumpdata'" | \
json -E "this.device = 'openaps://medtronic/pump/cgm'" | (
json -E "$NSONLY"
)
;;
format-recent-type)
ZONE=${1-'tz'}
Expand Down
4 changes: 2 additions & 2 deletions bin/oref0-get-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ if (!module.parent) {
errors.push({msg: "Carb ratio data should have an array called schedule with a start and ratio fields.", file: carbratio_input, data: carbratio_data});
} else {
}
if (carbratio_data.units != 'grams') {
errors.push({msg: "Carb ratio should have units field set to 'grams'.", file: carbratio_input, data: carbratio_data});
if (carbratio_data.units != 'grams' && carbratio_data.units != 'exchanges') {
errors.push({msg: "Carb ratio should have units field set to 'grams' or 'exchanges'.", file: carbratio_input, data: carbratio_data});
}
if (errors.length) {

Expand Down
5 changes: 2 additions & 3 deletions bin/oref0-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ esac
done

if ! [[ ${CGM,,} =~ "g4" || ${CGM,,} =~ "g5" || ${CGM,,} =~ "mdt" || ${CGM,,} =~ "shareble" ]]; then
echo "Unsupported CGM. Please select (Dexcom) G4 (default), shareble, G5, or MDT."
echo "If you'd like to help add Medtronic CGM support, please contact @scottleibrand on Gitter"
echo "Unsupported CGM. Please select (Dexcom) G4 (default), ShareBLE, G5, or MDT."
echo
DIR="" # to force a Usage prompt
fi
Expand Down Expand Up @@ -113,7 +112,7 @@ if [[ -z "$DIR" || -z "$serial" ]]; then
read -p "What is your pump serial number (numbers only)? " -r
serial=$REPLY
echo "Ok, $serial it is."
read -p "What kind of CGM are you using? (i.e. G4, shareble, G5, MDT) " -r
read -p "What kind of CGM are you using? (i.e. G4, ShareBLE, G5, MDT) " -r
CGM=$REPLY
echo "Ok, $CGM it is."
if [[ ${CGM,,} =~ "shareble" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion lib/iob/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function iobCalc(treatment, time, dia) {
var y = (minAgo-peak)/5;
iobContrib = treatment.insulin * (0.001323 * y * y - .054233 * y + .55556);
//activityContrib=sens*treatment.insulin*(2/dia/60-(minAgo-peak)*2/dia/60/(60*dia-peak));
activityContrib = treatment.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * dia - peak));
activityContrib = treatment.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
}

results = {
Expand Down
74 changes: 73 additions & 1 deletion lib/oref0-setup/mdt-cgm.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,77 @@
},
"type": "alias",
"name": "pump-loop"
}
},
{
"type": "report",
"name": "monitor/glucose.json",
"monitor/glucose.json": {
"use": "rezone",
"reporter": "JSON",
"astimezone": "False",
"date": "timestamp dateString start_at end_at created_at display_time",
"adjust": "missing",
"input": "monitor/glucose-unzoned.json",
"device": "tz",
"timezone": ""
}
},
{
"type": "report",
"nightscout/recent-missing-entries.json": {
"oper": "format-recent-type",
"use": "shell",
"reporter": "JSON",
"device": "ns",
"remainder": "tz entries nightscout/glucose.json",
"json_default": "True"
},
"name": "nightscout/recent-missing-entries.json"
},
{
"type": "report",
"nightscout/uploaded-entries.json": {
"oper": "upload",
"use": "shell",
"reporter": "JSON",
"device": "ns",
"remainder": "entries.json nightscout/recent-missing-entries.json",
"json_default": "True"
},
"name": "nightscout/uploaded-entries.json"
},
{
"type": "report",
"nightscout/glucose.json": {
"oper": "mm-format-ns-glucose",
"use": "shell",
"reporter": "JSON",
"device": "ns",
"remainder": "monitor/glucose.json",
"json_default": "True"
},
"name": "nightscout/glucose.json"
},
{
"get-bg": {
"command": "! bash -c \"openaps monitor-cgm 2>/dev/null | tail -1 && grep -q glucose cgm/cgm-glucose.json && cp -pu cgm/cgm-glucose.json cgm/glucose.json; cp -pu cgm/glucose.json monitor/glucose-unzoned.json; openaps report invoke monitor/glucose.json\""
},
"type": "alias",
"name": "get-bg"
},
{
"type": "alias",
"upload-bg": {
"command": "report invoke nightscout/glucose.json nightscout/recent-missing-entries.json nightscout/uploaded-entries.json"
},
"name": "upload-bg"
},
{
"type": "alias",
"name": "upload",
"upload": {
"command": "! bash -c \"echo -n Upload && ( openaps upload-bg; openaps upload-ns-status; openaps upload-pumphistory-entries; openaps upload-recent-treatments ) 2>/dev/null >/dev/null && echo ed\""
}
},
{"type": "alias", "first-upload": {"command": "! bash -c \"cat nightscout/glucose.json | json 1 > nightscout/recent-missing-entries.json && openaps report invoke nightscout/uploaded-entries.json\""}, "name": "first-upload"}
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oref0",
"version": "0.2.1",
"version": "0.3.0",
"description": "openaps oref0 reference implementation of the reference design",
"scripts": {
"test": "make test",
Expand Down
2 changes: 1 addition & 1 deletion release-master.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
git checkout master && \
git pull master && \
git pull origin master && \
npm version patch && \
git tag -l && \
npm publish && \
Expand Down

0 comments on commit fbcdf98

Please sign in to comment.