Changeset 363 for trunk/org.modelica.mdt.omc/src/org
- Timestamp:
- 02/23/06 15:06:51 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.omc/src/org/modelica/mdt/omc/OMCProxy.java
r340 r363 53 53 import org.eclipse.core.runtime.Platform; 54 54 import org.modelica.mdt.core.IModelicaClass; 55 import org.modelica.mdt.core.IllegalTypeException; 55 56 import org.modelica.mdt.core.List; 56 57 import org.modelica.mdt.core.ListElement; … … 178 179 } 179 180 180 logOMCStatus(" will look for OMC object reference in '"181 + fileName + "' ");181 logOMCStatus("Will look for OMC object reference in '" 182 + fileName + "'."); 182 183 183 184 return fileName; … … 200 201 final String m = "Environment variable OPENMODELICAHOME not set"; 201 202 logOMCStatus("Environment variable OPENMODELICAHOME not set,"+ 202 " don't know how to start OMC ");203 " don't know how to start OMC."); 203 204 throw new ConnectException(m); 204 205 } … … 221 222 if(f.exists()) 222 223 { 223 logOMCStatus(" removing old OMC object reference file");224 logOMCStatus("Removing old OMC object reference file."); 224 225 f.delete(); 225 226 } … … 228 229 try 229 230 { 230 logOMCStatus(" running command " + command[0] + " " + command[1]);231 logOMCStatus("Running command " + command[0] + " " + command[1]); 231 232 Runtime.getRuntime().exec(command); 232 logOMCStatus(" command run successfully");233 logOMCStatus("Command run successfully."); 233 234 } 234 235 catch(IOException e) … … 239 240 * source). Try starting OMC from this secondary location. 240 241 */ 241 logOMCStatus(" error running command " + e.getMessage()242 + " \ntrying allternative path to the binary");242 logOMCStatus("Error running command " + e.getMessage() 243 + ", trying alternative path to the binary."); 243 244 String secondaryPathToOmc = null; 244 245 try … … 255 256 command = 256 257 new String[]{secondaryPathToOmc, "+d=interactiveCorba"}; 257 logOMCStatus(" running command "258 logOMCStatus("Running command " 258 259 + command[0] + " " + command[1]); 259 260 Runtime.getRuntime().exec(command); 260 logOMCStatus(" command run successfully");261 logOMCStatus("Command run successfully."); 261 262 } 262 263 catch(IOException ex) 263 264 { 264 logOMCStatus(" error running command, giving up");265 logOMCStatus("Unable to start OMC, giving up."); 265 266 throw new ConnectException 266 ("Unable to start OpenModelica Compiler. "267 ("Unable to start the OpenModelica Compiler. " 267 268 + "Tried starting " + pathToOmc 268 269 + " and " + secondaryPathToOmc); … … 270 271 } 271 272 273 logOMCStatus("Wait for OMC CORBA object reference to appear on disk."); 274 272 275 /* 273 276 * Wait until the object exists on disk, but if it takes longer than … … 290 293 if(ticks > 50) 291 294 { 292 logOMCStatus("no OMC object reference file created after " + 293 "approximatly 5 seconds\n" + 294 "it seems OMC does not want to come up, giving up"); 295 logOMCStatus("No OMC object reference file created after " + 296 "approximately 5 seconds."); 297 logOMCStatus("It seems OMC does not want to come up, giving " + 298 "up."); 295 299 throw new ConnectException 296 300 ("Unable to start the Open Modelica Compiler. Waited for 5" … … 298 302 } 299 303 } 304 logOMCStatus("OMC object reference found."); 300 305 } 301 306 … … 363 368 { 364 369 /* If a server isn't running, start it */ 365 logOMCStatus(" no OMC object reference found");370 logOMCStatus("No OMC object reference found, starting server."); 366 371 startServer(); 367 372 } 368 373 else 369 374 { 370 logOMCStatus("O MCobject reference present," +371 " assuming OMC is running ");375 logOMCStatus("Old OMC CORBA object reference present," + 376 " assuming OMC is running."); 372 377 } 373 378 … … 389 394 * catch an exception and try starting a server. 390 395 */ 391 logOMCStatus(" trying to send expression to OMC");396 logOMCStatus("Trying to send expression to OMC."); 392 397 omcc.sendExpression("1+1"); 393 logOMCStatus(" expression send successfully");398 logOMCStatus("Expression sent successfully."); 394 399 } 395 400 catch(org.omg.CORBA.COMM_FAILURE e) 396 401 { 397 402 /* Start server and set up omcc */ 398 logOMCStatus(" failed sending expression");403 logOMCStatus("Failed sending expression, will try to start OMC."); 399 404 startServer(); 400 405 stringifiedObjectReference = readObjectFromFile(); … … 406 411 * time it's time to send back an exception to the caller of 407 412 * this function. */ 408 logOMCStatus(" trying to send expression to OMC");413 logOMCStatus("Trying to send expression to OMC."); 409 414 omcc.sendExpression("1+1"); 410 logOMCStatus(" expression send successfully");415 logOMCStatus("Expression sent successfully."); 411 416 } 412 417 catch(org.omg.CORBA.COMM_FAILURE x) 413 418 { 414 logOMCStatus(" failed sending expression, giving up");419 logOMCStatus("Failed sending expression, giving up."); 415 420 throw new ConnectException("Unable to start the OpenModelica" 416 421 +" Compiler."); … … 450 455 catch(org.omg.CORBA.COMM_FAILURE x) 451 456 { 457 logOMCCallError("Error while sending expression " + exp + " ["+x+"]"); 452 458 /* lost connection to OMC or something */ 453 459 throw new ConnectException("Couldn't send expression to the "+ … … 471 477 } 472 478 System.out.println(">> " + expression); 479 } 480 481 /** 482 * outputs the message about a call error that occured 483 * when communicating with omc 484 * @param message the message to log 485 */ 486 private static void logOMCCallError(String message) 487 { 488 if(!traceOMCCalls) 489 { 490 return; 491 } 492 System.out.println(message); 473 493 } 474 494 … … 542 562 */ 543 563 public IModelicaClass.Type getRestrictionType(String className) 544 throws ConnectException 564 throws ConnectException, UnexpectedReplyException 545 565 { 546 566 String reply = 547 567 sendExpression("getClassRestriction(" + className + ")"); 548 568 549 569 /* remove " around the reply */ 550 570 reply = reply.trim(); 571 572 if(reply.equals("")) 573 { 574 throw new UnexpectedReplyException("getClassRestriction("+className 575 +") returned an empty result"); 576 } 577 551 578 reply = reply.substring(1, reply.length()-1); 552 579 … … 554 581 getErrorString(); 555 582 556 return IModelicaClass.Type.parse(reply); 583 IModelicaClass.Type type = null; 584 try 585 { 586 type = IModelicaClass.Type.parse(reply); 587 } 588 catch(IllegalTypeException e) 589 { 590 throw new UnexpectedReplyException("Illegal type: " 591 + e.getMessage()); 592 } 593 594 return type; 557 595 } 558 596 … … 604 642 if(retval.toLowerCase().contains("error") || retval.equals("{}")) 605 643 { 606 res.setCompileErrors 607 (OMCParser.parseErrorString(getErrorString())); 644 res.setCompileErrors(OMCParser.parseErrorString(getErrorString())); 608 645 res.setClassNames(new List()); 609 646 }
Note: See TracChangeset
for help on using the changeset viewer.