
com.neuronrobotics.bowlerstudio.BowlerKernel Maven / Gradle / Ivy
package com.neuronrobotics.bowlerstudio;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
import jline.ConsoleReader;
import jline.History;
import jline.Terminal;
import com.neuronrobotics.bowlerstudio.scripting.ScriptingEngine;
import com.neuronrobotics.imageprovider.OpenCVJNILoader;
import com.sun.speech.freetts.ProcessException;
import com.sun.speech.freetts.VoiceManager;
import com.sun.speech.freetts.en.us.FeatureProcessors.WordNumSyls;
import eu.mihosoft.vrl.v3d.*;
public class BowlerKernel {
private static final String CSG = null;
private static File historyFile= new File(ScriptingEngine.getWorkspace().getAbsolutePath()+"/bowler.history");
static{
historyFile= new File(ScriptingEngine.getWorkspace().getAbsolutePath()+"/bowler.history");
ArrayList history=new ArrayList<>();
if(!historyFile.exists()){
try {
historyFile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
history.add("println SDKBuildInfo.getVersion()");
history.add("for(int i=0;i<1000000;i++) { println dyio.getValue(0) }");
history.add("dyio.setValue(0,128)");
history.add("println dyio.getValue(0)");
history.add("ScriptingEngine.inlineGistScriptRun(\"d4312a0787456ec27a2a\", \"helloWorld.groovy\" , null)");
history.add("DeviceManager.addConnection(new DyIO(ConnectionDialog.promptConnection()),\"dyio\")");
history.add("DeviceManager.addConnection(new DyIO(new SerialConnection(\"/dev/DyIO0\")),\"dyio\")");
history.add("shellType Clojure #Switches shell to Clojure");
history.add("shellType Jython #Switches shell to Python");
history.add("shellType Groovy #Switches shell to Groovy/Java");
history.add("println \"Hello world!\"");
writeHistory(history);
}
}
private static void fail() {
System.err
.println("Usage: \r\njava -jar BowlerScriptKernel.jar -s .. # This will load one script after the next ");
System.err
.println("java -jar BowlerScriptKernel.jar -p .. # This will load one script then take the list of objects returned and pss them to the next script as its 'args' variable ");
System.err
.println("java -jar BowlerScriptKernel.jar -r (Optional)(-s or -p) .. # This will start a shell in the requested langauge and run the files provided. ");
System.exit(1);
}
/**
* @param args
* the command line arguments
* @throws Exception
*/
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
if (args.length == 0) {
fail();
}
OpenCVJNILoader.load(); // Loads the OpenCV JNI (java native interface)
// File servo = ScriptingEngine.fileFromGit("https://github.com/NeuronRobotics/BowlerStudioVitamins.git",
// "BowlerStudioVitamins/stl/servo/smallservo.stl");
//
// ArrayList cad = (ArrayList )ScriptingEngine.inlineGistScriptRun("4814b39ee72e9f590757", "javaCad.groovy" , null);
// System.out.println(servo.exists()+" exists: "+servo);
boolean startLoadingScripts = false;
Object ret = null;
for (String s : args) {
if (startLoadingScripts) {
try {
ret = ScriptingEngine
.inlineFileScriptRun(new File(s), null);
} catch (Error e) {
e.printStackTrace();
fail();
}
}
if (s.contains("script") || s.contains("-s")) {
startLoadingScripts = true;
}
}
startLoadingScripts = false;
for (String s : args) {
if (startLoadingScripts) {
try {
ret = ScriptingEngine.inlineFileScriptRun(new File(s),
(ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy