Changeset 836
- Timestamp:
- 06/23/11 16:49:16 (13 years ago)
- Location:
- trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling/RunInteractiveSimulationRuntimeEnvironment.java
r768 r836 5 5 6 6 import java.io.File; 7 import java. io.IOException;7 import java.util.Map; 8 8 import java.util.Scanner; 9 9 … … 53 53 try { 54 54 ProcessBuilder builder = new ProcessBuilder(command); 55 56 Map<String, String> env = builder.environment(); 57 String pathFromEnv = ""; 58 59 if(env.get("Path") != null){ 60 pathFromEnv = "Path"; 61 } else if(env.get("PATH") != null){ 62 pathFromEnv = "PATH"; 63 } else if(env.get("path") != null){ 64 pathFromEnv = "path"; 65 } else 66 throw new Exception("path variable not available"); 67 68 env.put(pathFromEnv, env.get(pathFromEnv) + ";" + env.get("OPENMODELICAHOME") + "/bin/"); 69 55 70 builder.directory(new File(pathToExecutable + "/")); 56 71 p = builder.start(); … … 60 75 } 61 76 // p.waitFor(); 62 } catch (IOException e) { 63 System.err.println("IOException starting process!"); 77 } catch (Exception e) { 78 // System.err.println("IOException starting process!"); 79 e.getStackTrace(); 64 80 } 65 81 } -
trunk/modelicaml/org.openmodelica.simulation.environment/src/org/openmodelica/simulation/environment/filehandling/RunNonInteractiveSimulationRuntimeEnvironment.java
r641 r836 1 /*2 *3 */4 1 package org.openmodelica.simulation.environment.filehandling; 5 2 6 3 import java.io.File; 7 import java. io.IOException;4 import java.util.Map; 8 5 9 // TODO: Auto-generated Javadoc10 6 /** 11 * The Class RunNonInteractiveSimulationRuntimeEnvironment. 7 * 8 * @author EADS Innovation Works, Parham Vasaiely, Parham.Vasaiely@gmx.de 12 9 * 13 * @author EADS Innovation Works, Parham Vasaiely, Parham.Vasaiely@gmx.de14 10 */ 15 11 public class RunNonInteractiveSimulationRuntimeEnvironment implements Runnable{ 16 12 17 /** The path to executable. */18 13 String pathToExecutable; 19 20 /** The runtime name. */21 14 String runtimeName; 22 15 23 /**24 * Instantiates a new run non interactive simulation runtime environment.25 */26 16 public RunNonInteractiveSimulationRuntimeEnvironment(){ 27 17 super(); … … 29 19 30 20 /** 31 * A Runnable thread to execute the simulation runtime. 32 * 33 * @param pathToExecutable The folder path to the executable runtime NOTE: complete the 34 * string without a last slash 35 * @param runtimeName name of the runtime 21 * A Runnable thread to execute the simulation runtime 22 * 23 * @param pathToExecutable 24 * The folder path to the executable runtime NOTE: complete the 25 * string without a last slash 26 * @param runtimeName 27 * name of the runtime 28 36 29 */ 37 30 public RunNonInteractiveSimulationRuntimeEnvironment(String pathToExecutable, … … 42 35 } 43 36 44 /* (non-Javadoc)45 * @see java.lang.Runnable#run()46 */47 37 public void run() { 48 38 … … 50 40 try 51 41 { 52 ProcessBuilder builder = new ProcessBuilder(command); 42 ProcessBuilder builder = new ProcessBuilder(command); 43 44 Map<String, String> env = builder.environment(); 45 String pathFromEnv = ""; 46 47 if(env.get("Path") != null){ 48 pathFromEnv = "Path"; 49 } else if(env.get("PATH") != null){ 50 pathFromEnv = "PATH"; 51 } else if(env.get("path") != null){ 52 pathFromEnv = "path"; 53 } else 54 throw new Exception("path variable not available"); 55 56 env.put(pathFromEnv, env.get(pathFromEnv) + ";" + env.get("OPENMODELICAHOME") + "/bin/"); 57 53 58 builder.directory(new File(pathToExecutable + "/")); 54 59 Process p = builder.start(); 55 60 p.waitFor(); 56 61 } 57 catch(IOException e) 58 { 59 System.err.println("IOException starting process!"); 60 } 61 catch(InterruptedException e) 62 { 63 System.err.println("Interrupted waiting for process!"); 64 } 62 catch (Exception e) { 63 // System.err.println("IOException starting process!"); 64 e.getStackTrace(); 65 } 65 66 } 66 67 67 68 /** 68 * The main method. 69 * 70 * @param args the arguments 69 * @param args 71 70 */ 72 71 public static void main(String[] args) {
Note: See TracChangeset
for help on using the changeset viewer.