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;
|
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
||||||
|
|
||||||
import com.j256.ormlite.logger.Log;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mozilla.javascript.Callable;
|
import org.mozilla.javascript.Callable;
|
||||||
|
@ -79,6 +77,7 @@ public class DetermineBasalAdapterMAJS {
|
||||||
Object determineBasalObj = scope.get("determine_basal", scope);
|
Object determineBasalObj = scope.get("determine_basal", scope);
|
||||||
Object setTempBasalObj = scope.get("setTempBasal", scope);
|
Object setTempBasalObj = scope.get("setTempBasal", scope);
|
||||||
|
|
||||||
|
//call determine-basal
|
||||||
if (determineBasalObj instanceof Function && setTempBasalObj instanceof Function) {
|
if (determineBasalObj instanceof Function && setTempBasalObj instanceof Function) {
|
||||||
Function determineBasalJS = (Function) determineBasalObj;
|
Function determineBasalJS = (Function) determineBasalObj;
|
||||||
Function setTempBasalJS = (Function) setTempBasalObj;
|
Function setTempBasalJS = (Function) setTempBasalObj;
|
||||||
|
@ -95,7 +94,7 @@ public class DetermineBasalAdapterMAJS {
|
||||||
|
|
||||||
NativeObject jsResult = (NativeObject) determineBasalJS.call(rhino, scope, scope, params);
|
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();
|
String result = NativeJSON.stringify(rhino, scope, jsResult, null, null).toString();
|
||||||
if (Config.logAPSResult)
|
if (Config.logAPSResult)
|
||||||
log.debug("Result: " + result);
|
log.debug("Result: " + result);
|
||||||
|
@ -112,11 +111,11 @@ public class DetermineBasalAdapterMAJS {
|
||||||
} catch (RhinoException e) {
|
} catch (RhinoException e) {
|
||||||
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
|
log.error("RhinoException: (" + e.lineNumber() + "," + e.columnNumber() + ") " + e.toString());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
log.error(e.toString());
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
log.error(e.toString());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
log.error(e.toString());
|
||||||
} finally {
|
} finally {
|
||||||
Context.exit();
|
Context.exit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.OpenAPSMA;
|
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.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.mozilla.javascript.NativeObject;
|
import org.mozilla.javascript.NativeObject;
|
||||||
|
|
|
@ -233,8 +233,6 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
determineBasalResultMA.iob = iobTotal;
|
determineBasalResultMA.iob = iobTotal;
|
||||||
|
|
||||||
//determineBasalAdapterMAJS.release(); TODO: Rhinoport
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
|
determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
@ -245,8 +243,6 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
lastAPSResult = determineBasalResultMA;
|
lastAPSResult = determineBasalResultMA;
|
||||||
lastAPSRun = now;
|
lastAPSRun = now;
|
||||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||||
|
|
||||||
//deviceStatus.suggested = determineBasalResultMA.json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue