public DetermineBasalAdapterJS(ScriptReader scriptReader) throws IOException {
    mV8rt = V8.createV8Runtime();
    mScriptReader = scriptReader;

    initProfile();
    initGlucoseStatus();
    initIobData();
    initCurrentTemp();

    initLogCallback();

    initProcessExitCallback();

    initModuleParent();

    mV8rt.executeVoidScript(
        readFile("oref0/lib/round-basal.js"), "oref0/lib/determine-basal/round-basal.js", 0);
    mV8rt.executeVoidScript("var round_basal = module.exports;");

    mV8rt.executeVoidScript("require = function() {return round_basal;};");

    mV8rt.executeVoidScript(
        readFile("oref0/lib/basal-set-temp.js"), "oref0/lib/determine-basal/basal-set-temp.js ", 0);
    mV8rt.executeVoidScript("var tempBasalFunctions = module.exports;");

    mCobData = new V8Object(mV8rt);
    mCobData.add("mealCOB", 0.0);
    mV8rt.add("meal_data", mCobData);

    // V8Object autosens_data = new V8Object(mV8rt);
    // runtime.add("autosens_data", autosens_data);
    mV8rt.executeVoidScript("autosens_data = undefined");

    loadScript();
  }
Exemple #2
0
 public J2V8Testing() {
   V8 runtime = V8.createV8Runtime();
   runtime.registerJavaMethod(this::test, "test");
   runtime.registerJavaMethod(this::print, "print");
   runtime.executeVoidScript("test(function() { print('Hello World!'); });");
   runtime.release();
 }