Changeset 47 in tmcsimulator for trunk/src/tmcsim/paramicscommunicator
- Timestamp:
- 06/28/2016 02:25:42 PM (10 years ago)
- Location:
- trunk/src/tmcsim/paramicscommunicator
- Files:
-
- 1 added
- 3 edited
-
PComm.java (added)
-
ParamicsCommunicator.java (modified) (5 diffs)
-
ParamicsFileReader.java (modified) (7 diffs)
-
gui/ParamicsCommunicatorGUI.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/paramicscommunicator/ParamicsCommunicator.java
r33 r47 19 19 import java.util.logging.Level; 20 20 import java.util.logging.Logger; 21 21 import javax.swing.JFrame; 22 22 import javax.swing.JOptionPane; 23 23 import javax.swing.UIManager; … … 140 140 public ParamicsCommunicator(String propertiesFile) 141 141 { 142 paramLogger.logp(Level.INFO, "ParamicsCommunicator", "Constructor", 143 "Entering "); 142 144 143 145 writers = new TreeMap<String, ParamicsFileWriter>(); 144 146 readers = new TreeMap<String, ParamicsFileReader>(); 145 147 148 theGUI = new ParamicsCommunicatorGUI(); 149 addObserver(theGUI); 150 theGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 146 151 try 147 152 { … … 301 306 "Dropped Connection", JOptionPane.ERROR_MESSAGE); 302 307 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); 303 318 } 304 319 } … … 456 471 } catch (SocketTimeoutException ste) 457 472 { 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 } 459 484 } catch (IOException ioe) 460 485 { … … 462 487 + "the receiving socket on port " + socketPort); 463 488 } 489 464 490 } 465 491 -
trunk/src/tmcsim/paramicscommunicator/ParamicsFileReader.java
r40 r47 5 5 import java.io.FileWriter; 6 6 import java.io.IOException; 7 import java.text.SimpleDateFormat; 7 8 import java.util.Observable; 8 9 import java.util.Timer; … … 67 68 */ 68 69 private long readerInterval; 70 /** 71 * Time formatter for diagnostic messages 72 */ 73 private SimpleDateFormat formatter; 69 74 70 75 /** … … 80 85 public void run() 81 86 { 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 85 91 if (lastModified < inputFile.lastModified()) 86 92 { 87 // paramLogger.logp(Level.INFO,88 // "ParamicsFileReader.ReaderTimerTask", "run()",89 // "Cool, " + inputFile + " has been modified, let's read it.");90 93 91 94 try … … 101 104 Element messageElem = readerDoc.createElement(PARAMICS_COMM_TAGS.MESSAGE.tag); 102 105 String fileContents = readFromFile(); 103 // int stringlen = Math.min(160, fileContents.length()-1);104 // Log two lines that were read105 // paramLogger.logp(Level.INFO,106 // "ParamicsFileReader.ReaderTimerTask", "run()",107 // "Nice, we read " + fileContents.length() + " bytes.");108 106 messageElem.appendChild(readerDoc.createTextNode(fileContents)); 109 107 readerElem.appendChild(messageElem); … … 142 140 try 143 141 { 142 formatter = new SimpleDateFormat("HH:mm:ss"); 144 143 readerID = id; 145 144 readerInterval = interval; … … 159 158 { 160 159 paramLogger.logp(Level.SEVERE, "ParamicsFileReader", 161 "Constructor()", "Exception in initializing file reading .", ioe);160 "Constructor()", "Exception in initializing file reading of "+workingDir + targetFile, ioe); 162 161 } 163 162 } … … 194 193 195 194 lastModified = inputFile.lastModified(); 195 // System.out.println( 196 // "Read from a file last modified at " + formatter.format(lastModified)); 196 197 197 198 setChanged(); -
trunk/src/tmcsim/paramicscommunicator/gui/ParamicsCommunicatorGUI.java
r29 r47 11 11 import java.util.logging.LogRecord; 12 12 import java.util.logging.Logger; 13 14 13 import javax.swing.BorderFactory; 15 14 import javax.swing.Box; … … 21 20 import javax.swing.JTabbedPane; 22 21 import javax.swing.JTextArea; 23 24 22 import tmcsim.common.RevisionNumber; 25 23 import tmcsim.paramicscommunicator.FileIOUpdate; … … 126 124 "Exception in receiving FileIOUpdate object.", e); 127 125 } 128 } else if (arg instanceof FileRegUpdate) 126 } 127 else if (arg instanceof FileRegUpdate) 129 128 { 130 129 try … … 218 217 BorderFactory.createRaisedBevelBorder(), "Registered Readers "), 219 218 BorderFactory.createEmptyBorder(5, 5, 5, 5))); 220 219 221 220 fileWriterTabs = new JTabbedPane(); 222 221 fileWriterTabs.setAlignmentX(Box.CENTER_ALIGNMENT); … … 243 242 tabbedBox.add(fileReaderTabs); 244 243 tabbedBox.add(fileWriterTabs); 245 244 246 245 Box guiBox = new Box(BoxLayout.Y_AXIS); 247 246 guiBox.add(tabbedBox); … … 255 254 setResizable(false); 256 255 pack(); 257 setVisible(true);256 //setVisible(true); 258 257 } 259 258 … … 284 283 285 284 } 286 287 285 private JTabbedPane fileReaderTabs; 288 286 private JTabbedPane fileWriterTabs;
Note: See TracChangeset
for help on using the changeset viewer.
