Changeset 1040 for trunk


Ignore:
Timestamp:
10/18/11 21:37:33 (13 years ago)
Author:
masberg
Message:

Fix typos, warnings, and formatting

File:
1 edited

Legend:

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

    r692 r1040  
    103103public class OMCProxy implements IModelicaCompiler
    104104{
    105    
     105
    106106    /* the CORBA object */
    107107    private  OmcCommunication omcc;
    108108
    109109    enum osType { WINDOWS, UNIX };
    110    
     110
    111111    private String corbaSession = "mdt";
    112112
     
    123123    /* number of compiler errors to show */
    124124    private int numberOfErrors = 0;
    125    
     125
    126126
    127127    /* indicates if the Modelica System Library has been loaded */
     
    129129
    130130    private ArrayList<String> standardLibraryPackages = null;
    131    
     131
    132132    /* should we trace the calls to sendExpression? */
    133133    private  boolean traceOMCCalls  = false;
    134134    private  boolean traceOMCStatus = true;
    135    
     135
    136136    private  boolean traceStatusPreferences = false;
    137137    private  boolean traceCommandsPreferences = false;
    138138    private  boolean traceErrorPreferences = false;
    139139    private  boolean traceReplyPrefereces = false; 
    140    
     140
    141141    {
    142142        /* load debug options and set debug flag variables accordingly */
     
    154154        }
    155155    }
    156    
     156
    157157    private  OutputStream consoleOutput = null;
    158    
     158
    159159    private OMCThread fOMCThread = null;
    160160    private boolean fOMCThreadHasBeenScheduled = false;
    161    
     161
    162162    //private ILock fOMCLock = null;
    163163
     
    245245     * With the help of voodoo magic determines the path to the
    246246     * omc binary that user (probably) wants to use and the working
    247      * direcoty of where that binary (most likely) should be started in
     247     * directory of where that binary (most likely) should be started in
    248248     *
    249249     * This will returns for example 'c:\openmodelica132\omc.exe'
     
    272272             * user specified that standard path to omc should be used,
    273273             * try to determine the omc path via the OPENMODELICAHOME and
    274              * by checking in it's varius subdirectory for the omc binary file
     274             * by checking in it's various subdirectory for the omc binary file
    275275             */
    276276            logOMCStatus("Using OPENMODELICAHOME environment variable to find omc-binary", true);
     
    285285                final String m = "Environment variable OPENMODELICAHOME not set";
    286286                logOMCStatus("Environment variable OPENMODELICAHOME not set,"+
    287                 " don't know how to start OMC from standard path.", true);
     287                        " don't know how to start OMC from standard path.", true);
    288288                throw new ConnectException(m);
    289289            }
     
    330330                logOMCStatus("file '" + omcBinary.getAbsolutePath() + "' does not exist", true);
    331331                throw new ConnectException("Specified omc-binary '" + omcBinary.getAbsolutePath() +
    332                 "' does not exist");
     332                        "' does not exist");
    333333            }
    334334
     
    350350
    351351            if (parent.getName().equalsIgnoreCase("bin") ||
    352                 parent.getName().equalsIgnoreCase("compiler"))
     352                    parent.getName().equalsIgnoreCase("compiler"))
    353353            {
    354354                omcWorkingDirectory = parent.getParentFile();
     
    406406        String args[] = {null};
    407407
    408         /* set the CORBA read timeout to a larger value as we send huge ammounts of data
     408        /* set the CORBA read timeout to a larger value as we send huge amounts of data
    409409         * from OMC to MDT
    410410         */
    411411        System.setProperty("com.sun.CORBA.transport.ORBTCPReadTimeouts", "1:60000:300:1");
    412        
     412
    413413        ORB orb;
    414414        orb = ORB.init(args, null);     
     
    531531    // communication with OMC
    532532    // old synchronization aka 'private synchronized String sendExpression(String command)'
    533     // doesnt work when there is possibility of multiple instances of OMCProxy objects
     533    // doesn't work when there is possibility of multiple instances of OMCProxy objects
    534534    public ICompilerResult sendExpression(String command, boolean showInConsole) throws ConnectException
    535535    {   
     
    541541            return CompilerResult.makeResult(retval, error);
    542542        }
    543        
     543
    544544        if (numberOfErrors > showMaxErrors) return CompilerResult.makeResult(retval, error);
    545        
     545
    546546        // trim the start and end spaces
    547547        command = command.trim();
     
    553553            return CompilerResult.makeResult(retval, error);
    554554        }
    555        
     555
    556556        if(hasInitialized == false)
    557557        {
    558558            init();
    559559        }
    560        
     560
    561561        if (command.equalsIgnoreCase("quit()"))
    562562            hasInitialized = false;
     
    591591                else
    592592                    System.out.println("");
    593                 */
     593                 */
    594594                return CompilerResult.makeResult(retval, error);               
    595595            }           
     
    623623            }
    624624        }
    625            
     625
    626626        if (!traceOMCCalls)
    627627        {
     
    630630        System.out.println(">> " + expression);
    631631    }
    632    
     632
    633633    public void setConsoleOutputStream(OutputStream outputStream)
    634634    {
    635635        consoleOutput = outputStream;
    636636    }
    637    
     637
    638638
    639639    /**
     
    653653            }
    654654        }
    655        
     655
    656656        if(!traceOMCCalls)
    657657        {
     
    662662
    663663    /**
    664      * loggs the message conserning OMC status if the
     664     * logs the message concerning OMC status if the
    665665     * tracing flag traceOMCStatus is set
    666666     * @param message the message to log
     
    677677            }
    678678        }
    679        
     679
    680680        if (!traceOMCStatus)
    681681        {
     
    689689     * the tracing flag (traceOMCCalls) is set
    690690     *
    691      * @param reply the reply recieved from the OMC
     691     * @param reply the reply received from the OMC
    692692     */
    693693    private  void logOMCReply(String reply, boolean showInConsole)
     
    702702            }
    703703        }
    704        
     704
    705705        if (!traceOMCCalls)
    706706        {
     
    756756     */
    757757    public IModelicaClass.Restriction getRestriction(String className)
    758     throws ConnectException, UnexpectedReplyException
    759     {
     758            throws ConnectException, UnexpectedReplyException
     759            {
    760760        ICompilerResult result = sendExpression("getClassRestriction(" + className + ")", true);
    761761
     
    782782
    783783        return type;
    784     }
     784            }
    785785
    786786    /**
     
    796796         */     
    797797        return
    798         (retval.toLowerCase().contains("error") /* &&
     798                (retval.toLowerCase().contains("error") /* &&
    799799                !retval.startsWith("{")) ||
    800800                retval.equals("{}"*/);
     
    805805        ParseResults results;
    806806        long lastModification;
    807        
     807
    808808        public LazyLoadResult(ParseResults results, long lastModification)
    809809        {
     
    813813    }
    814814    private static Map<IPath, LazyLoadResult> lazyLoadList = new HashMap<IPath, LazyLoadResult>();
    815    
     815
    816816    public static Map<IPath, LazyLoadResult> getLazyLoadList()
    817817    {
    818818        return lazyLoadList;
    819819    }
    820    
     820
    821821    /**
    822822     * Tries to load file into OMC which causes it to be parsed and the syntax
     
    900900                long lastModification = file.getModificationStamp();
    901901                if (lastModification != IFile.NULL_STAMP)               
    902                 getLazyLoadList().put(file.getFullPath(), new LazyLoadResult(res, lastModification));
     902                    getLazyLoadList().put(file.getFullPath(), new LazyLoadResult(res, lastModification));
    903903            }
    904904        }       
     
    917917     */
    918918    public DefinitionLocation getClassLocation(String className)
    919     throws ConnectException, UnexpectedReplyException, InvocationError
    920     {
     919            throws ConnectException, UnexpectedReplyException, InvocationError
     920            {
    921921        ICompilerResult res = sendExpression("getCrefInfo(" + className + ")", true);
    922922
     
    967967            throw new
    968968            UnexpectedReplyException("Can't parse getCrefInfo() reply, "+
    969             "unexpected format");
     969                    "unexpected format");
    970970        }
    971971
    972972        return new DefinitionLocation(filePath, startLine, startColumn, endLine, endColumn);
    973     }
     973            }
    974974
    975975    /**
     
    997997     */
    998998    public Collection<ElementInfo> getElements(String className)
    999     throws ConnectException, InvocationError, UnexpectedReplyException
    1000     {       
     999            throws ConnectException, InvocationError, UnexpectedReplyException
     1000            {       
    10011001        ICompilerResult res = sendExpression("getElementsInfo("+ className +")", true);
    10021002        String retval = res.getFirstResult();
     
    10101010            {
    10111011                /*
    1012                  * we found the begining of the list, send it to parser and
     1012                 * we found the beginning of the list, send it to parser and
    10131013                 * hope for the best
    10141014                 */
     
    10521052        /* we have no idea what OMC returned */
    10531053        throw new UnexpectedReplyException("getElementsInfo("+ className +")" + "replies:'" + retval + "'");
    1054     }
     1054            }
    10551055
    10561056    public IClassInfo getClassInfo(String className)
    1057     throws ConnectException, UnexpectedReplyException
    1058     {
     1057            throws ConnectException, UnexpectedReplyException
     1058            {
    10591059        ICompilerResult res = sendExpression("getClassInformation("+ className +")", true);
    10601060        String retval = res.getFirstResult();
     
    10761076
    10771077        return  ci;
    1078     }
     1078            }
    10791079
    10801080
     
    11391139            {
    11401140                sendExpression("loadModel("+(String)lib+")", true);
    1141                
     1141
    11421142            }
    11431143
     
    11541154     * the server
    11551155     */
    1156     public ICompilerResult getClassString(String className)
    1157     throws ConnectException, UnexpectedReplyException
    1158     {
     1156    public ICompilerResult getClassString(String className) throws ConnectException, UnexpectedReplyException {
    11591157        ICompilerResult res = sendExpression("list("+ className +")", true);
    11601158
     
    11631161        return res;
    11641162    }
    1165    
     1163
    11661164    /**
    11671165     *
     
    11741172        private String message = null;
    11751173        private String prefix = null;
    1176        
     1174
    11771175        public ConsoleWriter(OutputStream output, String prefix)
    11781176        {
     
    11841182            this.prefix = prefix;
    11851183        }
    1186        
     1184
    11871185        public synchronized void setMessage(String what)
    11881186        {
    11891187            message = what;
    11901188        }
    1191        
     1189
    11921190        public synchronized void run()
    11931191        {
     
    12041202        }
    12051203    }
    1206    
     1204
    12071205    /**
    12081206     * Evaluate command locally, don't sent it to OpenModelica Compiler
     
    12171215        {
    12181216            retval =
    1219                 "All the MDT Console local commands start with '!'.\n" +
    1220                 "All commands not starting with '!' will be sent to the OpenModelica compiler.\n" +
    1221                 "For a list of OpenModelica commands available type help().\n" +
    1222                 "NOTE: The !trace* commands display traces of all OpenModelica<->MDT\n" +
    1223                 "      communication except the commands send from the console!\n" +
    1224                 "Available local commands are:\n" +
    1225                 "!help         - toggle display help on local commands.\n" +
    1226                 "!traceStatus  - toggle display the status of the OpenModelica compiler.\n" +
    1227                 "!traceError   - toggle display errors talking with the OpenModelica compiler.\n" +
    1228                 "!traceReply   - toggle display the reply of the OpenModelica compiler.\n" +
    1229                 "!traceCommand - toggle display the commands send to the OpenModelica compiler.\n" +
    1230                 "!traceAll     - toggle on the display of all the traces available.\n" +
    1231                 "!traceNone    - toggle off the display of all the traces available.\n";
    1232         }
    1233        
     1217                    "All the MDT Console local commands start with '!'.\n" +
     1218                            "All commands not starting with '!' will be sent to the OpenModelica compiler.\n" +
     1219                            "For a list of OpenModelica commands available type help().\n" +
     1220                            "NOTE: The !trace* commands display traces of all OpenModelica<->MDT\n" +
     1221                            "      communication except the commands send from the console!\n" +
     1222                            "Available local commands are:\n" +
     1223                            "!help         - toggle display help on local commands.\n" +
     1224                            "!traceStatus  - toggle display the status of the OpenModelica compiler.\n" +
     1225                            "!traceError   - toggle display errors talking with the OpenModelica compiler.\n" +
     1226                            "!traceReply   - toggle display the reply of the OpenModelica compiler.\n" +
     1227                            "!traceCommand - toggle display the commands send to the OpenModelica compiler.\n" +
     1228                            "!traceAll     - toggle on the display of all the traces available.\n" +
     1229                            "!traceNone    - toggle off the display of all the traces available.\n";
     1230        }
     1231
    12341232        if (command.equals("traceStatus"))
    12351233        {
     
    12371235            retval = "Tracing of OpenModelica status is set to: " + traceStatusPreferences;
    12381236        }
    1239        
     1237
    12401238        if (command.equals("traceError"))
    12411239        {
    12421240            traceErrorPreferences = traceErrorPreferences ? false : true;
    12431241            retval =
    1244                 "Tracing of errors while talking with OpenModelica is set to: " + traceErrorPreferences;
     1242                    "Tracing of errors while talking with OpenModelica is set to: " + traceErrorPreferences;
    12451243        }       
    1246        
     1244
    12471245        if (command.equals("traceReply"))
    12481246        {
     
    12561254            retval = "Tracing of commands sent to OpenModelica is set to: " + traceCommandsPreferences;
    12571255        }
    1258        
     1256
    12591257        if (command.equals("traceAll"))
    12601258        {
     
    12651263            retval = "All tracing is now enabled!";         
    12661264        }
    1267        
     1265
    12681266        if (command.equals("traceNone"))
    12691267        {
     
    12741272            retval = "All tracing is now disabled!";           
    12751273        }       
    1276        
     1274
    12771275        return "\n" + retval;
    12781276    }
    1279    
     1277
    12801278    class OMCThread extends Thread
    12811279    {
    1282        
     1280
    12831281        public OMCThread()
    12841282        {
     
    13101308             */
    13111309            long lastModified = 0;
    1312             if(f.exists())
    1313             {
    1314                 logOMCStatus("Remember the creation time for old OMC object reference file.", true);
    1315                 lastModified = f.lastModified();
    1316             }
    1317            
     1310            if(f.exists())
     1311            {
     1312                logOMCStatus("Remember the creation time for old OMC object reference file.", true);
     1313                lastModified = f.lastModified();
     1314            }
     1315
    13181316            Process proc = null;
    13191317            StreamReaderThread outThread = null;
     
    13221320            String command[] = { omcBinary.getAbsolutePath(), "+c="+corbaSession, "+d=interactiveCorba"};
    13231321            String extraCmds[] = PreferenceManager.getOMCCommandLineParametersArray();
    1324             ArrayList both = new ArrayList(command.length + extraCmds.length);
    1325             Collections.addAll(both, command);
    1326             Collections.addAll(both, extraCmds);
    1327             String cmd[] = new String[both.size()];
    1328             int nonNull = 0;
    1329             for (int i=0; i < both.size(); i++)
    1330             {
    1331                 String str = (String) both.get(i);
    1332                 if (str != null)
    1333                 {
    1334                     cmd[nonNull] = str;
    1335                     nonNull++;
    1336                 }
    1337             }
    1338             String fullCMD = "";
    1339             for (int i=0; i < nonNull; i++)
    1340                 fullCMD += cmd[i] + " ";
     1322            ArrayList<String> both = new ArrayList<String>(command.length + extraCmds.length);
     1323            Collections.addAll(both, command);
     1324            Collections.addAll(both, extraCmds);
     1325            String cmd[] = new String[both.size()];
     1326            int nonNull = 0;
     1327            for (int i=0; i < both.size(); i++)
     1328            {
     1329                String str = (String) both.get(i);
     1330                if (str != null)
     1331                {
     1332                    cmd[nonNull] = str;
     1333                    nonNull++;
     1334                }
     1335            }
     1336            String fullCMD = "";
     1337            for (int i=0; i < nonNull; i++)
     1338                fullCMD += cmd[i] + " ";
    13411339            logOMCStatus("Running command: " + fullCMD, true);
    13421340            logOMCStatus("Setting working directory to: " + workingDirectory.getAbsolutePath(), true);             
     
    13741372                    if (lastModified == 0 || (lastModified != 0 && f.lastModified() != lastModified))
    13751373                        break;
    1376                
     1374
    13771375                try
    13781376                {
     
    14161414        }
    14171415    }
    1418    
     1416
    14191417    public boolean isRunning()
    14201418    {
Note: See TracChangeset for help on using the changeset viewer.