rhino some more cleanups

This commit is contained in:
AdrianLxM 2017-10-15 16:19:29 +02:00
parent d32a874baa
commit 564c882754
3 changed files with 8 additions and 18 deletions

View file

@ -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;
@ -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);
@ -112,11 +111,11 @@ public class DetermineBasalAdapterMAJS {
} 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();
}

View file

@ -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;

View file

@ -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;
}