return new String(buffer);\r
}\r
\r
- protected static void printProcessOutput(Process process) throws IOException {\r
+ protected static void printProcessOutput(Process process, IModelicaMonitor monitor) throws IOException {\r
InputStream stream = process.getInputStream();\r
while(true) {\r
int c = stream.read();\r
if(c <= 0)\r
break;\r
- System.out.print((char)c);\r
+ monitor.message(new String(new char[] {(char)c}));\r
}\r
}\r
\r
);\r
}\r
\r
- public static SimulationResult runModelica(String modelName, String modelText, Double startTime, Double stopTime) throws IOException {\r
+ public static SimulationResult runModelica(String modelName, String modelText,\r
+ IModelicaMonitor monitor, Double startTime, Double stopTime) throws IOException {\r
SimulationLocation simulationLocation = \r
createInputFiles(modelName, modelText, startTime, stopTime);\r
\r
.directory(simulationLocation.simulationDir.getAbsoluteFile())\r
.redirectErrorStream(true)\r
.start();\r
- printProcessOutput(process);\r
+ printProcessOutput(process, monitor);\r
\r
SimulationResult result = new SimulationResult();\r
result.read(simulationLocation.outputFile);\r
} \r
return null;\r
}\r
- \r
- public static void main(String[] args) {\r
- try {\r
- runModelica("Testi2", "model Testi2 end Testi2;", 0.0, 10.0);\r
- } catch (IOException e) {\r
- // TODO Auto-generated catch block\r
- e.printStackTrace();\r
- }\r
- }\r
\r
}\r