Changeset 47 in tmcsimulator for trunk/src/tmcsim/paramicscommunicator


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

Merge 305 modifications into trunk.

Location:
trunk/src/tmcsim/paramicscommunicator
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.