Ignore:
Timestamp:
03/01/06 17:13:31 (19 years ago)
Author:
remar
Message:
  • IModelicaClass now provides an ISignature of its inputs and outputs
  • OMCProxy now tries three (3) different paths to omc
  • Context Information now takes imports and the Standard Library in consideration
  • ModelicaImport? now works better on Standard Library items
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/org.modelica.mdt.omc/src/org/modelica/mdt/omc/OMCProxy.java

    r380 r393  
    190190    private static void startServer() throws ConnectException
    191191    {
    192         String pathToOmc = null;
     192        String[] pathsToOmc = new String[3];
    193193        File workingDirectory;
    194194
     
    208208        if(os.equals("Unix"))
    209209        {
    210             pathToOmc = omHome + "/bin/omc";
     210            pathsToOmc[0] = omHome + "/bin/omc";
     211            pathsToOmc[1] = omHome + "/omc";
     212            pathsToOmc[2] = omHome + "/Compiler/omc";
    211213        }
    212214        else if(os.equals("Windows"))
    213215        {
    214             pathToOmc = omHome + "\\bin\\omc.exe";
     216            pathsToOmc[0] = omHome + "\\bin\\omc.exe";
     217            pathsToOmc[1] = omHome + "\\omc.exe";
     218            pathsToOmc[2] = omHome + "\\Compiler\\omc.exe";
    215219        }
    216220       
     
    230234        }
    231235       
    232         String command[] = { pathToOmc, "+d=interactiveCorba" };
    233         try
    234         {
    235             logOMCStatus("Running command " + command[0] + " " + command[1]);
    236             Runtime.getRuntime().exec(command, null, workingDirectory);
    237             logOMCStatus("Command run successfully.");
    238         }
    239         catch(IOException e)
    240         {
    241             /*
    242              * If we fail to start the compiler, maybe the executable is in
    243              * the Compiler directory (if we've compiled the compiler from
    244              * source). Try starting OMC from this secondary location.
    245              */
    246             logOMCStatus("Error running command " + e.getMessage()
    247                     + ", trying alternative path to the binary.");
    248             String secondaryPathToOmc = null;
     236        for(int i = 0;i < 3;i++)
     237        {
     238            String command[] = { pathsToOmc[i], "+d=interactiveCorba" };
    249239            try
    250240            {
    251                 if(os.equals("Unix"))
    252                 {
    253                     secondaryPathToOmc = omHome + "/build/bin/omc";
    254                 }
    255                 else if(os.equals("Windows"))
    256                 {
    257                     secondaryPathToOmc = omHome + "\\build\\bin\\omc.exe";
    258                 }
    259 
    260                 command =
    261                     new String[]{secondaryPathToOmc, "+d=interactiveCorba"};
    262                 logOMCStatus("Running command "
    263                         + command[0] + " " + command[1]);
     241                logOMCStatus("Running command " + command[0] + " " + command[1]);
    264242                Runtime.getRuntime().exec(command, null, workingDirectory);
    265243                logOMCStatus("Command run successfully.");
    266             }
    267             catch(IOException ex)
    268             {
    269                 logOMCStatus("Unable to start OMC, giving up.");
    270                 throw new ConnectException
    271                     ("Unable to start the OpenModelica Compiler. "
    272                      + "Tried starting " + pathToOmc
    273                      + " and " + secondaryPathToOmc);
    274             }
     244               
     245                break; /* exit the for loop, we've started OMC */
     246            }
     247            catch(IOException e)
     248            {
     249                if(i < 2)
     250                {
     251                    logOMCStatus("Error running command " + e.getMessage()
     252                            + ", trying alternative path to the binary.");
     253                   
     254                    /* If the call failed, try another path to the compiler */
     255                }
     256                else
     257                {
     258                    /* If all the paths to OMC were wrong, throw an exception */
     259                   
     260                    logOMCStatus("Unable to start OMC, giving up.");
     261                    throw new ConnectException
     262                        ("Unable to start the OpenModelica Compiler. "
     263                         + "Tried starting " + pathsToOmc[0] + ", "
     264                         + pathsToOmc[1] + " and " + pathsToOmc[2]);
     265                }
     266            }           
    275267        }
    276268
Note: See TracChangeset for help on using the changeset viewer.