Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use original oref0 profile script #805

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ fastlane/FastlaneRunner

ConfigOverride.xcconfig

branch.txt
branch.txt
package-lock.json
node_modules
oref0
3 changes: 1 addition & 2 deletions FreeAPS/Resources/javascript/bundle/profile.js

Large diffs are not rendered by default.

39 changes: 38 additions & 1 deletion FreeAPS/Resources/javascript/prepare/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,42 @@ function generate(pumpsettings_data, bgtargets_data, isf_data, basalprofile_data
if (autotune_data.carb_ratio) { inputs.carbratio.schedule[0].ratio = autotune_data.carb_ratio; }
}
}
return freeaps_profile(inputs);

// merge oref0 defaults with iAPS ones
const defaults = Object.assign(
{},
freeaps_profile.defaults(),
{
type: 'iAPS', // attribute to override defaults
// +++++ iAPS settings
// smb_delivery_ratio: included in the current oref0 PR (https://github.com/openaps/oref0/pull/1465/files)
smb_delivery_ratio: 0.5,
adjustmentFactor: 1,
useNewFormula: false,
enableDynamicCR: false,
sigmoid: false,
weightPercentage: 0.65,
tddAdjBasal: false,
// threshold_setting: temporary fix to test thomasvargiu/iAPS#original-oref0 branch before build.
// We can remove it after merged and after build the new original bundles
// because it's included in the current oref0 PR (https://github.com/openaps/oref0/pull/1465/files)
// currently (2024-08-09) this settings probably doesn't work in the current iAPS main/dev branch
threshold_setting: 60
}
)

var logs = { err: '', stdout: '', return_val: 0 };
var profile = freeaps_profile(logs, inputs, defaults);
if (logs.err.length > 0) {
console.error(logs.err);
}
if (logs.stdout.length > 0) {
console.error(logs.stdout);
}

if (typeof profile !== 'object') {
return;
}

return profile;
}
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"scripts": {
"build": "webpack --config ./scripts/webpack.config.js"
},
"devDependencies": {
"webpack-cli": "^5.1.4"
}
}
38 changes: 25 additions & 13 deletions scripts/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,43 @@
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");

const libPath = process.env['OREF0_DIST_PATH'] || './lib'

module.exports = {
mode: 'production',
entry: {
iob: './lib/iob/index.js',
meal: './lib/meal/index.js',
"determineBasal": './lib/determine-basal/determine-basal.js',
"glucoseGetLast": './lib/glucose-get-last.js',
"basalSetTemp": './lib/basal-set-temp.js',
autosens: './lib/determine-basal/autosens.js',
profile: './lib/profile/index.js',
"autotunePrep": './lib/autotune-prep/index.js',
"autotuneCore": './lib/autotune/index.js'
iob: path.resolve(libPath, 'iob/index.js'),
meal: path.resolve(libPath, 'meal/index.js'),
determineBasal: path.resolve(libPath, 'determine-basal/determine-basal.js'),
glucoseGetLast: path.resolve(libPath, 'glucose-get-last.js'),
basalSetTemp: path.resolve(libPath, 'basal-set-temp.js'),
autosens: path.resolve(libPath, 'determine-basal/autosens.js'),
profile: path.resolve(libPath, 'profile/index.js'),
autotunePrep: path.resolve(libPath, 'autotune-prep/index.js'),
autotuneCore: path.resolve(libPath, 'autotune/index.js')
},
output: {
path: path.resolve(__dirname, 'dist'),
path: path.resolve(__dirname, '..', 'FreeAPS', 'Resources', 'javascript', 'bundle'),
filename: (pathData) => {
return pathData.chunk.name.replace(/[A-Z]/g, function(match) {
return '-' + match.toLowerCase();
}) + '.js';
},
libraryTarget: 'var',
library: 'freeaps_[name]'
library: {
type: 'var',
name: 'freeaps_[name]'
}
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
minimizer: [new TerserPlugin({
extractComments: false,
parallel: true,
terserOptions: {
format: {
comments: false,
},
},
})],
},
};