rhino some more cleanups
This commit is contained in:
parent
d32a874baa
commit
564c882754
3 changed files with 8 additions and 18 deletions
|
@ -1,7 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
||||
|
||||
import com.j256.ormlite.logger.Log;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.javascript.Callable;
|
||||
|
@ -70,7 +68,7 @@ public class DetermineBasalAdapterMAJS {
|
|||
//generate functions "determine_basal" and "setTempBasal"
|
||||
rhino.evaluateString(scope, readFile("OpenAPSMA/determine-basal.js"), "JavaScript", 0, null);
|
||||
|
||||
String setTempBasalCode= "var setTempBasal = function (rate, duration, profile, rT, offline) {" +
|
||||
String setTempBasalCode = "var setTempBasal = function (rate, duration, profile, rT, offline) {" +
|
||||
"rT.duration = duration;\n" +
|
||||
" rT.rate = rate;" +
|
||||
"return rT;" +
|
||||
|
@ -79,6 +77,7 @@ public class DetermineBasalAdapterMAJS {
|
|||
Object determineBasalObj = scope.get("determine_basal", scope);
|
||||
Object setTempBasalObj = scope.get("setTempBasal", scope);
|
||||
|
||||
//call determine-basal
|
||||
if (determineBasalObj instanceof Function && setTempBasalObj instanceof Function) {
|
||||
Function determineBasalJS = (Function) determineBasalObj;
|
||||
Function setTempBasalJS = (Function) setTempBasalObj;
|
||||
|
@ -95,7 +94,7 @@ public class DetermineBasalAdapterMAJS {
|
|||
|
||||
NativeObject jsResult = (NativeObject) determineBasalJS.call(rhino, scope, scope, params);
|
||||
|
||||
// Parse the jsResult object to a String
|
||||
// Parse the jsResult object to a JSON-String
|
||||
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
|
||||
if (Config.logAPSResult)
|
||||
log.debug("Result: " + result);
|
||||
|
@ -109,14 +108,14 @@ public class DetermineBasalAdapterMAJS {
|
|||
}
|
||||
} catch (IOException e) {
|
||||
log.debug("IOException");
|
||||
} catch (RhinoException e){
|
||||
log.error("RhinoException: (" + e.lineNumber() + ","+ e.columnNumber() + ") " + e.toString());
|
||||
} catch (RhinoException e) {
|
||||
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.toString());
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.toString());
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.toString());
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.eclipsesource.v8.V8Object;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.javascript.NativeObject;
|
||||
|
|
|
@ -233,8 +233,6 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
determineBasalResultMA.iob = iobTotal;
|
||||
|
||||
//determineBasalAdapterMAJS.release(); TODO: Rhinoport
|
||||
|
||||
try {
|
||||
determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
|
||||
} catch (JSONException e) {
|
||||
|
@ -245,8 +243,6 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
lastAPSResult = determineBasalResultMA;
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
|
||||
//deviceStatus.suggested = determineBasalResultMA.json;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue