rhinoAMA first full run

This commit is contained in:
AdrianLxM 2017-10-15 20:42:36 +02:00
parent 1494b7f5b3
commit 1c49362415
3 changed files with 11 additions and 6 deletions

View file

@ -89,15 +89,16 @@ public class DetermineBasalAdapterAMAJS {
//set module parent
rhino.evaluateString(scope, "var module = {\"parent\":Boolean(1)};", "JavaScript", 0, null);
rhino.evaluateString(scope, "var round_basal = function round_basal(basal, profile) { return basal; };", "JavaScript", 0, null);
rhino.evaluateString(scope, "require = function() {return round_basal;};", "JavaScript", 0, null);
//generate functions "determine_basal" and "setTempBasal"
rhino.evaluateString(scope, readFile("OpenAPSMA/determine-basal.js"), "JavaScript", 0, null);
rhino.evaluateString(scope, readFile("OpenAPSAMA/determine-basal.js"), "JavaScript", 0, null);
rhino.evaluateString(scope, readFile("OpenAPSAMA/basal-set-temp.js"), "setTempBasal.js", 0, null);
Object determineBasalObj = scope.get("determine_basal", scope);
Object setTempBasalFunctionsObj = scope.get("tempBasalFunctions", scope);
Object testParam = makeParam(null, rhino, scope);
Object testParam = makeParamArray(mIobData, rhino, scope);
//call determine-basal
if (determineBasalObj instanceof Function && setTempBasalFunctionsObj instanceof NativeObject) {
@ -271,7 +272,8 @@ public class DetermineBasalAdapterAMAJS {
}
public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
@Override
public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
return objects[1];

View file

@ -230,7 +230,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
);
} catch (JSONException e) {
log.debug(e.toString());
log.error("Unable to set data: " + e.toString());
}

View file

@ -82,7 +82,10 @@ public class DetermineBasalAdapterMAJS {
Function determineBasalJS = (Function) determineBasalObj;
Function setTempBasalJS = (Function) setTempBasalObj;
//prepare parameters
Object testParam = makeParam(mIobData, rhino, scope);
//prepare parameters
Object[] params = new Object[]{
makeParam(mGlucoseStatus, rhino, scope),
makeParam(mCurrentTemp, rhino, scope),