rhinoAMA first full run
This commit is contained in:
parent
1494b7f5b3
commit
1c49362415
3 changed files with 11 additions and 6 deletions
|
@ -89,15 +89,16 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
|
|
||||||
//set module parent
|
//set module parent
|
||||||
rhino.evaluateString(scope, "var module = {\"parent\":Boolean(1)};", "JavaScript", 0, null);
|
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"
|
//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);
|
rhino.evaluateString(scope, readFile("OpenAPSAMA/basal-set-temp.js"), "setTempBasal.js", 0, null);
|
||||||
Object determineBasalObj = scope.get("determine_basal", scope);
|
Object determineBasalObj = scope.get("determine_basal", scope);
|
||||||
Object setTempBasalFunctionsObj = scope.get("tempBasalFunctions", scope);
|
Object setTempBasalFunctionsObj = scope.get("tempBasalFunctions", scope);
|
||||||
|
|
||||||
Object testParam = makeParam(null, rhino, scope);
|
Object testParam = makeParamArray(mIobData, rhino, scope);
|
||||||
|
|
||||||
//call determine-basal
|
//call determine-basal
|
||||||
if (determineBasalObj instanceof Function && setTempBasalFunctionsObj instanceof NativeObject) {
|
if (determineBasalObj instanceof Function && setTempBasalFunctionsObj instanceof NativeObject) {
|
||||||
|
@ -271,6 +272,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
|
public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
|
||||||
|
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
|
||||||
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
|
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
|
||||||
@Override
|
@Override
|
||||||
public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
|
public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
|
||||||
|
|
|
@ -230,7 +230,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
|
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
|
||||||
);
|
);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.debug(e.toString());
|
log.error("Unable to set data: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,9 @@ public class DetermineBasalAdapterMAJS {
|
||||||
Function determineBasalJS = (Function) determineBasalObj;
|
Function determineBasalJS = (Function) determineBasalObj;
|
||||||
Function setTempBasalJS = (Function) setTempBasalObj;
|
Function setTempBasalJS = (Function) setTempBasalObj;
|
||||||
|
|
||||||
|
Object testParam = makeParam(mIobData, rhino, scope);
|
||||||
|
|
||||||
|
|
||||||
//prepare parameters
|
//prepare parameters
|
||||||
Object[] params = new Object[]{
|
Object[] params = new Object[]{
|
||||||
makeParam(mGlucoseStatus, rhino, scope),
|
makeParam(mGlucoseStatus, rhino, scope),
|
||||||
|
|
Loading…
Reference in a new issue