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
35 changes: 29 additions & 6 deletions bin/oref0-meal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,37 @@ if (!module.parent) {
}

var fs = require('fs');
var pumphistory_data;
var profile_data;
var clock_data;
var basalprofile_data;

try {
var pumphistory_data = JSON.parse(fs.readFileSync(pumphistory_input, 'utf8'));
var profile_data = JSON.parse(fs.readFileSync(profile_input, 'utf8'));
var clock_data = JSON.parse(fs.readFileSync(clock_input, 'utf8'));
var basalprofile_data = JSON.parse(fs.readFileSync(basalprofile_input, 'utf8'));
pumphistory_data = JSON.parse(fs.readFileSync(pumphistory_input, 'utf8'));
} catch (e) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "Could not parse input data" }');
return console.error("Could not parse input data: ", e);
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "Could not parse pumphistory data" }');
return console.error("Could not parse pumphistory data: ", e);
}

try {
profile_data = JSON.parse(fs.readFileSync(profile_input, 'utf8'));
} catch (e) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "Could not parse profile data" }');
return console.error("Could not parse profile data: ", e);
}

try {
clock_data = JSON.parse(fs.readFileSync(clock_input, 'utf8'));
} catch (e) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "Could not parse clock data" }');
return console.error("Could not parse clock data: ", e);
}

try {
basalprofile_data = JSON.parse(fs.readFileSync(basalprofile_input, 'utf8'));
} catch (e) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "Could not parse basalprofile data" }');
return console.error("Could not parse basalprofile data: ", e);
}

// disallow impossibly low carbRatios due to bad decoding
Expand Down