Changeset 47 in tmcsimulator for trunk/src


Ignore:
Timestamp:
06/28/2016 02:25:42 PM (10 years ago)
Author:
jdalbey
Message:

Merge 305 modifications into trunk.

Location:
trunk/src/tmcsim
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/application.properties

    r44 r47  
    1 #Thu, 23 Jun 2016 19:19:14 -0700 
     1#Tue, 28 Jun 2016 14:56:40 -0700 
    22 
    3 Application.revision=43 
     3Application.revision=44 
    44 
    5 Application.buildnumber=1 
     5Application.buildnumber=10 
  • trunk/src/tmcsim/paramicscommunicator/ParamicsCommunicator.java

    r33 r47  
    1919import java.util.logging.Level; 
    2020import java.util.logging.Logger; 
    21  
     21import javax.swing.JFrame; 
    2222import javax.swing.JOptionPane; 
    2323import javax.swing.UIManager; 
     
    140140    public ParamicsCommunicator(String propertiesFile) 
    141141    { 
     142        paramLogger.logp(Level.INFO, "ParamicsCommunicator", "Constructor", 
     143                "Entering "); 
    142144 
    143145        writers = new TreeMap<String, ParamicsFileWriter>(); 
    144146        readers = new TreeMap<String, ParamicsFileReader>(); 
    145147 
     148        theGUI = new ParamicsCommunicatorGUI(); 
     149        addObserver(theGUI); 
     150        theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    146151        try 
    147152        { 
     
    301306                        "Dropped Connection", JOptionPane.ERROR_MESSAGE); 
    302307                break; 
     308            } 
     309            try 
     310            { 
     311                Thread.sleep(2000); 
     312                paramLogger.logp(Level.INFO, "ParamicsCommunicator", 
     313                        "run", "sleeping."); 
     314            } catch (InterruptedException ex) 
     315            { 
     316                paramLogger.logp(Level.INFO, "ParamicsCommunicator", 
     317                        "run", "Exception in reading data from the socket.", ex); 
    303318            } 
    304319        } 
     
    456471            } catch (SocketTimeoutException ste) 
    457472            { 
    458                 System.out.println("...waiting for socket connection from the CAD Simulator..."); 
     473                System.out.println("...waiting..."); 
     474                try 
     475                { 
     476                    Thread.sleep(2000); 
     477                    paramLogger.logp(Level.INFO, "ParamicsCommunicator", 
     478                            "initializeSockets", "sleeping."); 
     479                } catch (InterruptedException ex) 
     480                { 
     481                    paramLogger.logp(Level.INFO, "ParamicsCommunicator", 
     482                            "initializeSockets", "Exception exiting for socket.", ex); 
     483                } 
    459484            } catch (IOException ioe) 
    460485            { 
     
    462487                        + "the receiving socket on port " + socketPort); 
    463488            } 
     489 
    464490        } 
    465491 
  • trunk/src/tmcsim/paramicscommunicator/ParamicsFileReader.java

    r40 r47  
    55import java.io.FileWriter; 
    66import java.io.IOException; 
     7import java.text.SimpleDateFormat; 
    78import java.util.Observable; 
    89import java.util.Timer; 
     
    6768     */ 
    6869    private long readerInterval; 
     70    /** 
     71     * Time formatter for diagnostic messages 
     72     */ 
     73    private SimpleDateFormat formatter; 
    6974 
    7075    /** 
     
    8085        public void run() 
    8186        { 
    82 //            paramLogger.logp(Level.INFO, 
    83 //                    "ParamicsFileReader.ReaderTimerTask", "run()", 
    84 //                    "Waiting for " + inputFile + " to be modified."); 
     87//            System.out.println( 
     88//                    "Checking last modified time on " + inputFile.getName() 
     89//                    + formatter.format(lastModified) + ":" + formatter.format(inputFile.lastModified())); 
     90 
    8591            if (lastModified < inputFile.lastModified()) 
    8692            { 
    87 //                paramLogger.logp(Level.INFO, 
    88 //                        "ParamicsFileReader.ReaderTimerTask", "run()", 
    89 //                        "Cool, " + inputFile + " has been modified, let's read it."); 
    9093 
    9194                try 
     
    101104                    Element messageElem = readerDoc.createElement(PARAMICS_COMM_TAGS.MESSAGE.tag); 
    102105                    String fileContents = readFromFile(); 
    103  //                   int stringlen = Math.min(160, fileContents.length()-1); 
    104                     // Log two lines that were read 
    105 //                    paramLogger.logp(Level.INFO, 
    106 //                            "ParamicsFileReader.ReaderTimerTask", "run()", 
    107 //                            "Nice, we read " + fileContents.length() + " bytes."); 
    108106                    messageElem.appendChild(readerDoc.createTextNode(fileContents)); 
    109107                    readerElem.appendChild(messageElem); 
     
    142140        try 
    143141        { 
     142            formatter = new SimpleDateFormat("HH:mm:ss"); 
    144143            readerID = id; 
    145144            readerInterval = interval; 
     
    159158        { 
    160159            paramLogger.logp(Level.SEVERE, "ParamicsFileReader", 
    161                     "Constructor()", "Exception in initializing file reading.", ioe); 
     160                    "Constructor()", "Exception in initializing file reading of "+workingDir + targetFile, ioe); 
    162161        } 
    163162    } 
     
    194193 
    195194        lastModified = inputFile.lastModified(); 
     195//        System.out.println( 
     196//                "Read from a file last modified at " + formatter.format(lastModified)); 
    196197 
    197198        setChanged(); 
  • trunk/src/tmcsim/paramicscommunicator/gui/ParamicsCommunicatorGUI.java

    r29 r47  
    1111import java.util.logging.LogRecord; 
    1212import java.util.logging.Logger; 
    13  
    1413import javax.swing.BorderFactory; 
    1514import javax.swing.Box; 
     
    2120import javax.swing.JTabbedPane; 
    2221import javax.swing.JTextArea; 
    23  
    2422import tmcsim.common.RevisionNumber; 
    2523import tmcsim.paramicscommunicator.FileIOUpdate; 
     
    126124                        "Exception in receiving FileIOUpdate object.", e); 
    127125            } 
    128         } else if (arg instanceof FileRegUpdate) 
     126        } 
     127        else if (arg instanceof FileRegUpdate) 
    129128        { 
    130129            try 
     
    218217                BorderFactory.createRaisedBevelBorder(), "Registered Readers "), 
    219218                BorderFactory.createEmptyBorder(5, 5, 5, 5))); 
    220          
     219 
    221220        fileWriterTabs = new JTabbedPane(); 
    222221        fileWriterTabs.setAlignmentX(Box.CENTER_ALIGNMENT); 
     
    243242        tabbedBox.add(fileReaderTabs); 
    244243        tabbedBox.add(fileWriterTabs); 
    245          
     244 
    246245        Box guiBox = new Box(BoxLayout.Y_AXIS); 
    247246        guiBox.add(tabbedBox); 
     
    255254        setResizable(false); 
    256255        pack(); 
    257         setVisible(true); 
     256        //setVisible(true); 
    258257    } 
    259258 
     
    284283 
    285284    } 
    286      
    287285    private JTabbedPane fileReaderTabs; 
    288286    private JTabbedPane fileWriterTabs; 
  • trunk/src/tmcsim/paramicslog/ParamicsLog.java

    r33 r47  
    1010import java.util.logging.Level; 
    1111import java.util.logging.Logger; 
    12  
    1312import javax.swing.JOptionPane; 
    14  
    15 import org.w3c.dom.Element; 
    16  
    1713import tmcsim.common.SimulationException; 
    1814import tmcsim.interfaces.CoordinatorInterface; 
     
    2117/** 
    2218 * Logs communication from ParamicsCommunicator to ParamicsSimulator. 
    23  *  
    24  * The system property "PARAMICS_LOG_CONFIG" should be set to the path 
    25  * where the properties file for this class is located. <br><br> 
     19 * 
     20 * The system property "PARAMICS_LOG_CONFIG" should be set to the path where the 
     21 * properties file for this class is located. <br><br> 
    2622 * The data for the properties file follows. <br> 
    2723 * <code> 
    2824 * -----------------------------------------------------------------<br> 
    29  * Log File                The file to write the communication to. 
    30  * CAD Simulator Host      The host that runs the CAD Simulator. 
    31  * CAD Simulator RMI Port  The port on the host that runs the CAD  
    32  *                         Simulator where the RMI Coordinator 
    33  *                         object is registered to.  
     25 * Log File The file to write the communication to. CAD Simulator Host The host 
     26 * that runs the CAD Simulator. CAD Simulator RMI Port The port on the host that 
     27 * runs the CAD Simulator where the RMI Coordinator object is registered to. 
    3428 * -----------------------------------------------------------------<br> 
    3529 * Example File: <br> 
    36  * LogFile=c:\\log.txt 
    37  * CADSimulatorHost=localhost 
    38  * CADSimulatorRMIPort=4445 
     30 * LogFile=c:\\log.txt CADSimulatorHost=localhost CADSimulatorRMIPort=4445 
    3931 * -----------------------------------------------------------------<br> 
    4032 * </code> 
    41  *  
     33 * 
    4234 * @author Nathaniel Lehrer 
    43  * @version  
     35 * @version 
    4436 */ 
    45 public class ParamicsLog extends Observable  
    46 {    
     37public class ParamicsLog extends Observable 
     38{ 
     39 
    4740    /** 
    4841     * Enmeration containing property names. 
     42     * 
    4943     * @author Nathaniel Lehrer 
    5044     */ 
    51     private enum PROPERTIES  
    52     { 
    53         LOG_FILE      ("LogFile"), 
    54         CAD_SIM_HOST  ("CADSimulatorHost"), 
    55         CAD_SIM_PORT  ("CADSimulatorRMIPort"); 
    56          
     45    private enum PROPERTIES 
     46    { 
     47 
     48        LOG_FILE("LogFile"), 
     49        CAD_SIM_HOST("CADSimulatorHost"), 
     50        CAD_SIM_PORT("CADSimulatorRMIPort"); 
    5751        public String name; 
    58          
     52 
    5953        private PROPERTIES(String n) 
    6054        { 
     
    6256        } 
    6357    } 
    64  
    65         private static final String CONFIG_FILE_NAME = "paramics_communicator_logging.properties"; 
    66      
    67     /** Error logger. */ 
     58    private static final String CONFIG_FILE_NAME = "paramics_communicator_logging.properties"; 
     59    /** 
     60     * Error logger. 
     61    */ 
    6862    private static Logger paramLogger = Logger.getLogger("tmcsim.paramicslog"); 
    69      
    70     /** Static instance. */ 
     63    /** 
     64     * Static instance. 
     65     */ 
    7166    private static ParamicsLog instance; 
    72      
    73     /** Properties object. */ 
     67    /** 
     68     * Properties object. 
     69     */ 
    7470    private Properties paramicsLogProp; 
    75      
    76     /** File log entries are written to */ 
     71    /** 
     72     * File log entries are written to 
     73     */ 
    7774    private File logFile; 
    78      
    79     /** Stores the log entries. This contains the same information logFile. */ 
     75    /** 
     76     * Stores the log entries. This contains the same information logFile. 
     77     */ 
    8078    private StringBuilder log; 
    81  
    82     /** Remote reference to the simulation */ 
     79    /** 
     80     * Remote reference to the simulation 
     81     */ 
    8382    private CoordinatorInterface theCoorInt; 
    84      
    85     /** Object for synchronizing IO */ 
     83    /** 
     84     * Object for synchronizing IO 
     85     */ 
    8686    Object lock; 
    87      
     87 
    8888    /** 
    8989     * Creates the singleton instance of this class. 
    9090     */ 
    91     static { 
    92         try { 
    93                 if(System.getProperty("CONFIG_DIR") == null){ 
    94                 System.setProperty("CONFIG_DIR", "config"); 
    95             } 
    96                  
    97                 instance = new ParamicsLog(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 
    98         }  
    99         catch (Exception e)  
     91    static 
     92    { 
     93        try 
     94        { 
     95            if (System.getProperty("CONFIG_DIR") == null) 
     96            { 
     97                System.setProperty("CONFIG_DIR", "config"); 
     98            } 
     99 
     100            instance = new ParamicsLog(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 
     101        } catch (Exception e) 
    100102        { 
    101103            instance = new ParamicsLog(); 
    102              
    103             paramLogger.logp(Level.WARNING, "ParamicsLog", "static initializer",  
     104 
     105            paramLogger.logp(Level.WARNING, "ParamicsLog", "static initializer", 
    104106                    "Error occured initializing application", e); 
    105107 
    106             JOptionPane.showMessageDialog(null, e.getMessage(),  
    107                     "Error - ParamicsLog will not save log to file.",  
    108                     JOptionPane.ERROR_MESSAGE);  
    109         } 
    110          
     108            JOptionPane.showMessageDialog(null, e.getMessage(), 
     109                    "Error - ParamicsLog will not save log to file.", 
     110                    JOptionPane.ERROR_MESSAGE); 
     111        } 
     112 
    111113        instance.addObserver(ParamicsLogGUI.getInstance()); 
    112114    } 
    113      
    114     /** 
    115      * Creates an instance of ParamicsLog that does not write to a file when  
     115 
     116    /** 
     117     * Creates an instance of ParamicsLog that does not write to a file when 
    116118     * writeToLog is called. 
    117119     */ 
    118     private ParamicsLog() { 
    119          
     120    private ParamicsLog() 
     121    { 
     122 
    120123        lock = new Object(); 
    121124        log = new StringBuilder(""); 
    122125    } 
    123      
    124     /** 
    125      * Creates an instance of ParamicsLog that writes to a file when writeToLog is called. 
     126 
     127    /** 
     128     * Creates an instance of ParamicsLog that writes to a file when writeToLog 
     129     * is called. 
     130     * 
    126131     * @param propertiesFile 
    127132     */ 
    128     private ParamicsLog(String propertiesFile) { 
     133    private ParamicsLog(String propertiesFile) 
     134    { 
    129135        this(); 
    130          
     136 
    131137        String logFile = null; 
    132138        String CADSIMHost = null; 
    133139        String CADSIMPort = null; 
    134          
    135         try { 
     140 
     141        try 
     142        { 
    136143            paramicsLogProp = new Properties(); 
    137144            paramicsLogProp.load(new FileInputStream(propertiesFile)); 
    138              
     145 
    139146            if ((logFile = paramicsLogProp.getProperty(PROPERTIES.LOG_FILE.name)) == null) 
    140147            { 
     
    142149            } 
    143150            else if ((CADSIMHost = paramicsLogProp.getProperty(PROPERTIES.CAD_SIM_HOST.name)) == null) 
    144             {    
     151            { 
    145152                throw new Exception("Properties file missing CAD Simulator host."); 
    146153            } 
     
    149156                throw new Exception("Properties file missing CAD Simulator RMI port."); 
    150157            } 
    151              
     158 
    152159            try 
    153160            { 
    154161                connect(CADSIMHost, CADSIMPort); 
    155             } 
    156             catch (Exception e) 
    157             { 
    158                 JOptionPane.showMessageDialog(null,  
    159                         "ParamicsLog: Could not connect to remote Coordinator object.",  
    160                         "Network Error", JOptionPane.ERROR_MESSAGE);                 
    161             } 
    162              
    163             try  
     162            } catch (Exception e) 
     163            { 
     164                JOptionPane.showMessageDialog(null, 
     165                        "ParamicsLog: Could not connect to remote Coordinator object.", 
     166                        "Network Error", JOptionPane.ERROR_MESSAGE); 
     167            } 
     168 
     169            try 
    164170            { 
    165171                createLogFile(logFile); 
    166             } 
    167             catch (Exception e) 
    168             { 
    169                 JOptionPane.showMessageDialog(null,  
    170                         "ParamicsLog: Could not create new log file.",  
     172            } catch (Exception e) 
     173            { 
     174                JOptionPane.showMessageDialog(null, 
     175                        "ParamicsLog: Could not create new log file.", 
    171176                        "File Error", JOptionPane.ERROR_MESSAGE); 
    172177            } 
    173              
    174         } catch (Exception e) { 
    175              
    176             paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor",  
     178 
     179        } catch (Exception e) 
     180        { 
     181 
     182            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor", 
    177183                    "Properties file incorrect or missing.", e); 
    178              
    179             JOptionPane.showMessageDialog(null,  
    180                     "ParamicsLog: Properties file invalid.",  
     184 
     185            JOptionPane.showMessageDialog(null, 
     186                    "ParamicsLog: Properties file invalid.", 
    181187                    "Invalid Configuration", JOptionPane.ERROR_MESSAGE); 
    182188        } 
    183189    } 
    184      
     190 
    185191    /** 
    186192     * Creates the log file. 
     193     * 
    187194     * @param filePath The path to the file including the file name. 
    188195     * @throws IOException If the log file could not be created. 
     
    190197    private void createLogFile(String filePath) throws IOException 
    191198    { 
    192         try { 
     199        try 
     200        { 
    193201            logFile = new File(filePath); 
    194              
    195             if (logFile.exists()) { 
     202 
     203            if (logFile.exists()) 
     204            { 
    196205                logFile.delete(); 
    197206            } 
    198              
     207 
    199208            logFile.createNewFile(); 
    200              
    201         } catch (Exception e) { 
    202              
     209 
     210        } catch (Exception e) 
     211        { 
     212 
    203213            logFile = null; 
    204              
    205             paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor",  
     214 
     215            paramLogger.logp(Level.WARNING, "ParamicsLog", "ParamicsLog constructor", 
    206216                    "Could not create new log file.", e); 
    207              
     217 
    208218            throw new IOException("Could not create log file."); 
    209         }                
    210     } 
    211      
     219        } 
     220    } 
     221 
    212222    /** 
    213223     * Connect to the Coordinator's RMI object. 
    214      * @param hostname Host name of the CAD Simulator.     
    215      * @param portNumber Port number of the CAD Simulator RMI communication.  
    216      * @throws SimulationException if there is an error creating the RMI connection. 
    217      */  
    218     private void connect(String hostname, String portNumber)  
    219         throws SimulationException { 
    220          
     224     * 
     225     * @param hostname Host name of the CAD Simulator. 
     226     * @param portNumber Port number of the CAD Simulator RMI communication. 
     227     * @throws SimulationException if there is an error creating the RMI 
     228     * connection. 
     229     */ 
     230    private void connect(String hostname, String portNumber) 
     231            throws SimulationException 
     232    { 
     233 
    221234        String coorIntURL = ""; 
    222          
    223         try {   
    224             coorIntURL = "rmi://" + hostname + ":" + portNumber + "/coordinator";  
    225              
    226             theCoorInt = (CoordinatorInterface)Naming.lookup(coorIntURL);            
    227         } 
    228         catch (Exception e)  
    229         { 
    230             paramLogger.logp(Level.WARNING, "ParamicsLog",  
    231                     "establishRMIConnection", "Unable to establish RMI " + 
    232                     "communication with the CAD Simulator.  URL <" + coorIntURL + ">", e); 
    233         }    
    234     } 
    235      
     235 
     236        try 
     237        { 
     238            coorIntURL = "rmi://" + hostname + ":" + portNumber + "/coordinator"; 
     239 
     240            theCoorInt = (CoordinatorInterface) Naming.lookup(coorIntURL); 
     241        } catch (Exception e) 
     242        { 
     243            paramLogger.logp(Level.WARNING, "ParamicsLog", 
     244                    "establishRMIConnection", "Unable to establish RMI " 
     245                    + "communication with the CAD Simulator.  URL <" + coorIntURL + ">", e); 
     246        } 
     247    } 
     248 
    236249    /** 
    237250     * Accessor to the entries in the log. No file IO is used. 
     251     * 
    238252     * @return The entries in the log. 
    239253     */ 
    240     public String getLog() { 
    241          
     254    public String getLog() 
     255    { 
     256 
    242257        return log.toString(); 
    243258    } 
    244      
    245     /** 
    246      * Writes an entry to the log.  
    247      * The simulator time when the message was sent is prepended to the entry. 
    248      * Entries are padded by a blank line before and after them. 
    249      * TODO: Ensure output is written in order of request. 
     259 
     260    /** 
     261     * Writes an entry to the log. The simulator time when the message was sent 
     262     * is prepended to the entry. Entries are padded by a blank line before and 
     263     * after them. TODO: Ensure output is written in order of request. 
     264     * 
    250265     * @param entry 
    251266     */ 
    252     public void writeToLog(String entry) { 
    253          
     267    public void writeToLog(String entry) 
     268    { 
     269 
    254270        String time = "?"; 
    255271        String formattedEntry; 
    256          
     272 
    257273        if (theCoorInt != null) 
    258274        { 
     
    260276            { 
    261277                time = formatTime(theCoorInt.getCurrentSimulationTime()); 
    262             } 
    263             catch (Exception e) 
    264             { 
    265                 paramLogger.logp(Level.WARNING, "ParamicsLog",  
     278            } catch (Exception e) 
     279            { 
     280                paramLogger.logp(Level.WARNING, "ParamicsLog", 
    266281                        "RMICommunication", "Unable to communicate with RMI object", e); 
    267282            } 
    268283        } 
    269          
     284 
    270285        formattedEntry = "\n" + "<!-- Time written to file: " + time + " -->\n" + entry + "\n"; 
    271286        log.append(formattedEntry); 
    272          
     287 
    273288        if (logFile != null) 
    274289        { 
    275             try  
    276             { 
    277                 synchronized(lock) 
     290            try 
     291            { 
     292                synchronized (lock) 
    278293                { 
    279294                    FileWriter writer = new FileWriter(logFile, true); 
     
    282297                    writer.close(); 
    283298                } 
    284             }  
    285             catch (IOException e)  
    286             { 
    287                 paramLogger.logp(Level.WARNING, "ParamicsLog", "writeToLog",  
     299            } catch (IOException e) 
     300            { 
     301                paramLogger.logp(Level.WARNING, "ParamicsLog", "writeToLog", 
    288302                        "Could not write to log file.", e); 
    289303            } 
    290304        } 
    291          
     305 
    292306        setChanged(); 
    293307        notifyObservers(entry); 
    294308    } 
    295      
     309 
    296310    /** 
    297311     * Formats the time given in seconds to hh:mm:ss format. 
     312     * 
    298313     * @param time The time in seconds. 
    299314     */ 
    300     private String formatTime(long time) 
     315    public String formatTime(long time) 
    301316    { 
    302317        long seconds = time % 60; 
     
    306321        return padr(hours) + ":" + padr(minutes) + ":" + padr(seconds); 
    307322    } 
    308      
     323 
    309324    private String padr(long n) 
    310325    { 
     
    317332        } 
    318333    } 
    319      
     334 
    320335    /** 
    321336     * Accessor for static instance of this class. 
     337     * 
    322338     * @return The instance of this class. 
    323339     */ 
    324     public static ParamicsLog getInstance() { 
    325          
     340    public static ParamicsLog getInstance() 
     341    { 
     342 
    326343        return instance; 
    327344    } 
  • trunk/src/tmcsim/paramicslog/gui/ParamicsLogGUI.java

    r2 r47  
    11package tmcsim.paramicslog.gui; 
    22 
    3 import javax.swing.*; 
    43import java.awt.event.WindowEvent; 
    54import java.util.*; 
     5import javax.swing.*; 
    66 
    77/** 
    8  * The UI for ParamicsLog.  
     8 * The UI for ParamicsLog. 
     9 * 
    910 * @author Nathaniel Lehrer 
    1011 * @version 
    1112 */ 
    12 public class ParamicsLogGUI extends JFrame implements Observer { 
     13public class ParamicsLogGUI extends JFrame implements Observer 
     14{ 
    1315 
    14     /** The static instance */ 
     16    /** 
     17     * The static instance 
     18     */ 
    1519    private static ParamicsLogGUI instance = new ParamicsLogGUI(); 
     20    /** 
     21     * The text area to display the log in 
     22     */ 
     23    private JTextArea textArea; 
    1624 
    17     /** The text area to display the log in */ 
    18     private JTextArea textArea; 
    19      
    20     /** Creates an instance of this class */ 
    21     public ParamicsLogGUI() { 
    22          
     25    /** 
     26     * Creates an instance of this class 
     27     */ 
     28    public ParamicsLogGUI() 
     29    { 
     30 
    2331        setupGUI(); 
    2432    } 
    25      
    26     /** Creates the UI */ 
     33 
     34    /** 
     35     * Creates the UI 
     36     */ 
    2737    private void setupGUI() 
    2838    { 
    29         try { 
     39        try 
     40        { 
    3041            UIManager.setLookAndFeel( 
    31                 UIManager.getSystemLookAndFeelClassName()); 
    32         } catch (Exception e) { 
     42                    UIManager.getSystemLookAndFeelClassName()); 
     43        } catch (Exception ex) 
     44        { 
     45            System.out.println(ex.getMessage()); 
    3346            System.err.println("Couldn't use system look and feel."); 
    3447        } 
    35          
    36         this.addWindowListener(new java.awt.event.WindowAdapter() { 
    37              
     48 
     49        this.addWindowListener(new java.awt.event.WindowAdapter() 
     50        { 
    3851            public void windowClosing(WindowEvent e) 
    3952            { 
     
    4154            } 
    4255        }); 
    43          
    44          
     56 
     57 
    4558        setTitle("Paramics Log"); 
    46          
     59 
    4760        textArea = new JTextArea(); 
    4861        textArea.setColumns(60); 
    4962        textArea.setRows(30); 
    5063        JScrollPane scrollPane = new JScrollPane(textArea); 
    51          
     64 
    5265        getContentPane().add(scrollPane); 
    53          
     66 
    5467    } 
    55      
    56     /** Shows the UI window */ 
     68 
     69    /** 
     70     * Shows the UI window 
     71     */ 
    5772    public void display() 
    5873    { 
     
    6277 
    6378    /** 
    64      * Updates the text area. If the observable class given is of type ParamicsLog then 
    65      * the log entries are displayed. 
     79     * Updates the text area. If the observable class given is of type 
     80     * ParamicsLog then the log entries are displayed. 
     81     * 
    6682     * @param o The model for this viewer. 
    6783     * @param arg An argument that is not used. 
     
    7288        { 
    7389            textArea.setText(((tmcsim.paramicslog.ParamicsLog) o).getLog()); 
    74         }  
     90        } 
    7591 
    7692        repaint(); 
    7793    } 
    78      
     94 
    7995    /** 
    8096     * Accessor for the instance of ParamicsLogGUI. 
     97     * 
    8198     * @return The instance of ParamicsLogGUI. 
    8299     */ 
    83     public static ParamicsLogGUI getInstance() { 
     100    public static ParamicsLogGUI getInstance() 
     101    { 
    84102        return instance; 
    85103    } 
    86      
    87104} 
  • trunk/src/tmcsim/simulationmanager/SimulationManager.java

    r33 r47  
    99import java.util.logging.Level; 
    1010import java.util.logging.Logger; 
    11  
    1211import javax.swing.JOptionPane; 
    1312import javax.swing.UIManager; 
    14  
    1513import tmcsim.common.CADEnums.PARAMICS_STATUS; 
     14import tmcsim.common.ScriptException; 
    1615import tmcsim.common.SimulationException; 
    1716 
     
    4847 
    4948    private static final String CONFIG_FILE_NAME = "sim_manager_config.properties"; 
    50         /** 
     49    /** 
    5150     * Error logger. 
    5251     */ 
     
    192191 
    193192    /** 
     193     * Load a simulation script from the specified file. 
     194     * 
     195     * @param scriptFile the XML file containing the simulation control script 
     196     * to be run. 
     197     * @throws ScriptException if the script throws an exception 
     198     * @throws SimulationException if the simulation throws an exception 
     199     */ 
     200    public void loadScript(File scriptFile) throws ScriptException, SimulationException 
     201    { 
     202        theSimManagerModel.loadScript(scriptFile); 
     203    } 
     204 
     205    /** 
    194206     * Main class. 
    195207     * 
    196208     * @param args Command line arguments. 
    197209     */ 
    198     static public void main(String[] args) { 
     210    static public void main(String[] args) 
     211    { 
    199212        //System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 
    200         if(System.getProperty("CONFIG_DIR") == null){ 
    201                 System.setProperty("CONFIG_DIR", "config"); 
    202         } 
    203          
    204         try {            
    205                 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
     213        if (System.getProperty("CONFIG_DIR") == null) 
     214        { 
     215            System.setProperty("CONFIG_DIR", "config"); 
     216        } 
     217 
     218        try 
     219        { 
     220            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 
    206221            new SimulationManager(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 
    207         } catch (Exception e) { 
     222        } catch (Exception e) 
     223        { 
    208224            simManLogger.logp(Level.SEVERE, "SimulationManager", "Main", 
    209225                    "Error occured initializing application", e); 
  • trunk/src/tmcsim/simulationmanager/SimulationManagerView.java

    r9 r47  
    866866        paramicsStatusLabel     = new JLabel("Status:"); 
    867867        paramicsStatusInfoLabel = new JLabel("Unknown"); 
     868        paramicsStatusInfoLabel.setName("paramicsStatusInfoLabel"); 
    868869        paramicsStatusBox.add(paramicsStatusLabel); 
    869870        paramicsStatusBox.add(Box.createHorizontalStrut(10)); 
Note: See TracChangeset for help on using the changeset viewer.