- Timestamp:
- 09/24/11 22:52:30 (13 years ago)
- Location:
- trunk/modelicaml/org.openmodelica.modelicaml.simulation/src/org/openmodelica/modelicaml/simulation/execution
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/modelicaml/org.openmodelica.modelicaml.simulation/src/org/openmodelica/modelicaml/simulation/execution/ExecuteSimulation.java
r996 r1004 1 package org.openmodelica.modelicaml.simulation. simulationexecution;1 package org.openmodelica.modelicaml.simulation.execution; 2 2 import java.io.File; 3 3 4 import org.openmodelica.modelicaml.simulation.filehandling.cp; 4 5 import org.openmodelica.modelicaml.simulation.omc.OpenModelicaCompilerCommunication; 5 6 import org.openmodelica.modelicaml.simulation.xml.TestSession; … … 10 11 11 12 /** 12 * Compiling the model code using OMC13 * Compiling and simulating the model code using OMC 13 14 * Error Handling : Syntax, Semantic check by OMC. 14 15 * 15 * @return the string16 * @return the omc return string, if the string is empty there was no error otherwise the error string is included 16 17 */ 17 p rivate static String compileModel(File sessionFolder, File tempSimulationFolder, TestSession testSessionObj){18 public static String executeAllModels(File sessionFolder, String omcTempWorkingFolder, TestSession testSessionObj){ 18 19 OpenModelicaCompilerCommunication omcc = new OpenModelicaCompilerCommunication(); 19 20 String omcReturnString = ""; 20 String pathForOMC = tempSimulationFolder.getAbsolutePath();21 21 22 while( pathForOMC.contains("\\")){23 pathForOMC = pathForOMC.replace('\\', '/');22 while(omcTempWorkingFolder.contains("\\")){ 23 omcTempWorkingFolder = omcTempWorkingFolder.replace('\\', '/'); 24 24 } 25 25 … … 27 27 omcc.clear(); 28 28 29 // Change directory30 omcReturnString = omcc.cd( );29 //OMC is working in the eclipse project folder, therefore the folder must been changed to the OM installation folder where a tmp folder can be created. 30 omcReturnString = omcc.cd(omcTempWorkingFolder); 31 31 if(omcReturnString.contains("Error")){ 32 32 String errorString = omcc.getErrorString(); … … 34 34 return "cd: " + omcReturnString + "\nErrorString: " + errorString; 35 35 } 36 else{ 37 File omcWorkingDirectory = new File(omcReturnString); 38 // omcReturnString = ""; //TODO cd muss hier raus und nach oben gepackt werden! 39 } 36 else 37 omcReturnString = ""; 40 38 41 39 //Load package.mo … … 46 44 packageMO = packageMO.replace('\\', '/'); 47 45 } 48 //TODO [20110224] Check for true or false46 49 47 if(new File(packageMO).isDirectory()){ 50 48 omcReturnString = omcc.loadFile(packageMO.replaceAll("%20", " ") + "/package.mo"); //If the file is a directory the whole contained model will be loaded … … 85 83 //Simulate model 86 84 for(TestModel model : testSessionObj.testModels){ 87 omcReturnString = omcc. buildModel(model.qualifiedName, model.start, model.stop, model.numberOfIntervals, model.tolerance, model.solver, model.outputFormat);85 omcReturnString = omcc.simulate(model.qualifiedName, model.start, model.stop, model.numberOfIntervals, model.tolerance, model.solver, model.outputFormat); 88 86 89 87 if(omcReturnString.contains("{\"\",\"\"}") || omcReturnString.contains("Error")){ … … 107 105 */ 108 106 public static void main(String[] args) { 109 String sessionFolderPath = "C:\\Projects\\ModelicaML\\runtime-New_configuration\\modelicaml.example.potableWaterSystem_v2 5\\test-gen\\test-session_20110922235427\\";107 String sessionFolderPath = "C:\\Projects\\ModelicaML\\runtime-New_configuration\\modelicaml.example.potableWaterSystem_v26\\test-gen\\test-session_20110924175101\\"; 110 108 111 109 TestSession testSessionObj = TestSessionXML_Reader.readFromXML(sessionFolderPath + "test_session.xml"); 112 110 String omcTempWorkingFolder = System.getenv().get("OPENMODELICAHOME") + "/tmp"; 113 111 File sessionFolder = new File(sessionFolderPath); 114 112 File tempSimulationFolder = new File(sessionFolderPath + "tmp"); 115 116 117 String omcMessage = compileModel(sessionFolder, tempSimulationFolder, testSessionObj);113 tempSimulationFolder.mkdir(); 114 tempSimulationFolder.canWrite(); 115 String omcMessage = executeAllModels(sessionFolder, omcTempWorkingFolder, testSessionObj); 118 116 if(omcMessage.isEmpty()){ 119 117 … … 121 119 else 122 120 System.out.println("OMC Message: /n" + omcMessage); 121 122 for(TestModel model : testSessionObj.testModels){ 123 cp.copyFile(omcTempWorkingFolder + "/" + model.qualifiedName + ".exe", tempSimulationFolder + "/" + model.qualifiedName + ".exe"); 124 cp.copyFile(omcTempWorkingFolder + "/" + model.qualifiedName + "_init.xml", tempSimulationFolder + "/" + model.qualifiedName + "_init.xml"); 125 cp.copyFile(omcTempWorkingFolder + "/" + model.qualifiedName + "_res.plt", tempSimulationFolder + "/" + model.qualifiedName + "_res.plt"); 126 } 123 127 } 124 128
Note: See TracChangeset
for help on using the changeset viewer.