determine-basal-prepare.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //для enact/smb-suggested.json параметры: monitor/iob.json monitor/temp_basal.json monitor/glucose.json settings/profile.json settings/autosens.json --meal monitor/meal.json --microbolus --reservoir monitor/reservoir.json
  2. function generate(iob, currenttemp, glucose, profile, autosens = null, meal = null, microbolusAllowed = false, reservoir = null, clock = new Date(), pump_history, preferences, basalProfile, trio_custom_oref_variables) {
  3. // We pass in the clock when we're replaying
  4. //var clock = new Date();
  5. var middleware_was_used = "";
  6. try {
  7. var middlewareReason = middleware(iob, currenttemp, glucose, profile, autosens, meal, reservoir, clock, pump_history, preferences, basalProfile, trio_custom_oref_variables);
  8. middleware_was_used = (middlewareReason || "Nothing changed");
  9. console.log("Middleware reason: " + middleware_was_used);
  10. } catch (error) {
  11. console.log("Invalid middleware: " + error);
  12. };
  13. var glucose_status = trio_glucoseGetLast(glucose);
  14. var autosens_data = null;
  15. if (autosens) {
  16. autosens_data = autosens;
  17. }
  18. var reservoir_data = null;
  19. if (reservoir) {
  20. reservoir_data = reservoir;
  21. }
  22. var meal_data = {};
  23. if (meal) {
  24. meal_data = meal;
  25. }
  26. var pumphistory = {};
  27. if (pump_history) {
  28. pumphistory = pump_history;
  29. }
  30. var basalprofile = {};
  31. if (basalProfile) {
  32. basalprofile = basalProfile;
  33. }
  34. var trio_custom_oref_variables_temp = {};
  35. if (trio_custom_oref_variables) {
  36. trio_custom_oref_variables_temp = trio_custom_oref_variables;
  37. }
  38. return trio_determineBasal(glucose_status, currenttemp, iob, profile, autosens_data, meal_data, trio_basalSetTemp, microbolusAllowed, reservoir_data, clock, pumphistory, preferences, basalprofile, trio_custom_oref_variables_temp, middleware_was_used);
  39. }