Changeset 64 in tmcsimulator
- Timestamp:
- 03/16/2017 07:28:12 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
- 2 moved
-
IDE_metadata/NetBeans/TMCSim/build.xml (modified) (9 diffs)
-
src/tmcsim/application.properties (modified) (1 diff)
-
src/tmcsim/client/ClockClient.java (moved) (moved from trunk/src/tmcsim/client/CADClockDisplay.java) (10 diffs)
-
src/tmcsim/client/ClockView.java (moved) (moved from trunk/src/tmcsim/client/CADClockView.java) (3 diffs)
-
src/tmcsim/client/cadclientgui/screens/AssignedIncidents.java (modified) (3 diffs)
-
src/tmcsim/client/cadclientgui/screens/UnitStatus.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/IDE_metadata/NetBeans/TMCSim/build.xml
r59 r64 89 89 <!-- 90 90 ================= 91 LOC counter 91 LOC counter 92 92 ================= 93 93 --> … … 96 96 classpath="${workdir}/lib/JavaLOC.jar"> 97 97 <arg line="-r -d ${workdir}/src"/> 98 </java> 99 </target> 98 </java> 99 </target> 100 100 <!-- 101 101 ================= … … 143 143 ================= 144 144 --> 145 <target description="Build separate jar files for each component of the TMC system." 145 <target description="Build separate jar files for each component of the TMC system." 146 146 name="package-jars" depends="jar"> 147 147 … … 211 211 </manifest> 212 212 </jar> 213 <!-- Remove the following line when we get CADClient to run 213 <!-- Remove the following line when we get CADClient to run 214 214 <delete file="${deploy.dir}/CADClient.jar"/>--> 215 215 216 <!-- *** Build Clock Client Only Jar *** --> 217 <jar destfile="${deploy.dir}/ClockClient.jar" 218 basedir="${build.dir}/classes" 219 includes="tmcsim/client/ClockClient*.class, tmcsim/client/ClockView.class, 220 tmcsim/interfaces/**, tmcsim/cadmodels/**, tmcsim/common/**, tmcsim/client/**"> 221 <zipgroupfileset dir="dist/lib" includes="xercesImpl.jar"/> 222 <manifest> 223 <attribute name="Main-Class" value="tmcsim.client.ClockClient"/> 224 <attribute name="Implementation-Version" value="${TODAY}"/> 225 </manifest> 226 </jar> 227 216 228 <!-- *** Build Paramics Communicator Only Jar *** --> 217 229 <jar destfile="${deploy.dir}/ParamicsCommunicator.jar" … … 227 239 </target> 228 240 229 <target description="Build separate jar files for each component of the TMC system." 241 <target description="Build separate jar files for each component of the TMC system." 230 242 name="ZipForInstall" depends="package-jars"> 231 243 <!-- Notes: Create a zip file with jars and all external resources for distributing … … 240 252 <!-- 241 253 242 There exist several targets which are by default empty and which can be 243 used for execution of your tasks. These targets are usually executed 244 before and after some main targets. They are: 254 There exist several targets which are by default empty and which can be 255 used for execution of your tasks. These targets are usually executed 256 before and after some main targets. They are: 245 257 246 258 -pre-init: called before initialization of project properties … … 268 280 </target> 269 281 270 For list of available properties check the imported 271 nbproject/build-impl.xml file. 282 For list of available properties check the imported 283 nbproject/build-impl.xml file. 272 284 273 285 274 286 Another way to customize the build is by overriding existing main targets. 275 The targets of interest are: 287 The targets of interest are: 276 288 277 289 -init-macrodef-javac: defines macro for javac compilation … … 281 293 -do-jar-with-manifest: JAR building (if you are using a manifest) 282 294 -do-jar-without-manifest: JAR building (if you are not using a manifest) 283 run: execution of project 295 run: execution of project 284 296 -javadoc-build: Javadoc generation 285 297 test-report: JUnit report generation … … 293 305 </target> 294 306 295 Notice that the overridden target depends on the jar target and not only on 296 the compile target as the regular run target does. Again, for a list of available 307 Notice that the overridden target depends on the jar target and not only on 308 the compile target as the regular run target does. Again, for a list of available 297 309 properties which you can use, check the target you are overriding in the 298 nbproject/build-impl.xml file. 310 nbproject/build-impl.xml file. 299 311 300 312 --> -
trunk/src/tmcsim/application.properties
r59 r64 1 # Wed, 15 Mar 2017 11:18:58-07001 #Thu, 16 Mar 2017 08:26:10 -0700 2 2 3 Application.revision= 583 Application.revision=63 4 4 5 Application.buildnumber= 335 Application.buildnumber=44 -
trunk/src/tmcsim/client/ClockClient.java
r62 r64 4 4 import java.awt.event.ActionListener; 5 5 import java.io.FileInputStream; 6 import java.io.FileOutputStream;7 import java.io.IOException;8 6 import java.rmi.Naming; 9 7 import java.rmi.RemoteException; 10 8 import java.rmi.server.UnicastRemoteObject; 11 9 import java.util.Properties; 12 import java.util.Vector;13 10 import java.util.concurrent.TimeUnit; 14 11 import java.util.logging.Level; … … 18 15 import javax.swing.Timer; 19 16 import javax.swing.UIManager; 20 import tmcsim.client.cadclientgui.CADClientGUI;21 17 import tmcsim.common.SimulationException; 22 18 import tmcsim.interfaces.CADClientInterface; … … 24 20 25 21 /** 26 * C ADClockDisplay shows the simulation clock time. It operates as a client of27 * theCAD server, using RMI to poll the server every second for the current22 * ClockClient shows the simulation clock time. It operates as a client of the 23 * CAD server, using RMI to poll the server every second for the current 28 24 * simulation clock time. 25 * 26 * @author jdalbey 29 27 */ 30 public class C ADClockDisplayextends UnicastRemoteObject implements28 public class ClockClient extends UnicastRemoteObject implements 31 29 CADClientInterface 32 30 { … … 35 33 */ 36 34 private static Logger cadClientLogger = Logger.getLogger("tmcsim.client"); 35 36 @Override 37 public void refresh() throws RemoteException 38 { 39 throw new UnsupportedOperationException("Not supported yet."); 40 } 37 41 38 42 /** … … 62 66 private CADClientSocket theClientSocket; 63 67 /** 64 * Instance of the CADClientModel. 65 */ 66 private CADClientModel theClientScreenModel; 67 /** 68 * Instance of the CADClockView. 69 */ 70 private CADClockView theClientScreenView; 71 /** 72 * Instance of the CADCLientGUI Replaces CADClockView 73 */ 74 private CADClientGUI theClientGUI; 68 * Instance of the ClockView. 69 */ 70 private ClockView theView; 75 71 /** 76 72 * Properties object for the CADClient class. … … 95 91 * file containing configuration data. 96 92 */ 97 public C ADClockDisplay(String propertiesFile) throws SimulationException,93 public ClockClient(String propertiesFile) throws SimulationException, 98 94 RemoteException 99 95 { … … 106 102 cadClientProp.getProperty(PROPERTIES.CAD_RMI_PORT.name).trim()); 107 103 108 the ClientScreenView = new CADClockView();109 the ClientScreenView.setVisible(true);104 theView = new ClockView(); 105 theView.setVisible(true); 110 106 111 107 // Create a timer that fetches the simulation time every second. … … 117 113 { 118 114 long simtime = theCoorInt.getCurrentSimulationTime(); 119 the ClientScreenView.updateTime("" + formatInterval(simtime));115 theView.updateTime("" + formatInterval(simtime)); 120 116 } catch (RemoteException ex) 121 117 { 122 Logger.getLogger(C ADClockDisplay.class.getName()).log(Level.SEVERE, null, ex);118 Logger.getLogger(ClockClient.class.getName()).log(Level.SEVERE, null, ex); 123 119 } 124 120 } … … 199 195 } 200 196 201 try202 {203 // If the properties file does not specify a CAD position, prompt204 // the205 // user to select one. If the user selects a position, write the206 // new properties values to the file. If the user cancels, else207 // throw an exception.208 if (cadClientProp.getProperty(PROPERTIES.CLIENT_CAD_POS.name) == null)209 {210 if (getCADPosition())211 {212 cadClientProp.store(new FileOutputStream(propertiesFile),213 "");214 }215 else216 {217 throw new SimulationException(218 SimulationException.INITIALIZE_ERROR);219 }220 }221 222 // If the properties file does not specifiy a CAD User ID, prompt223 // the224 // user to enter a value. If the user enters a valid ID, write the225 // new properties values to the file. If the user cancels, else226 // throw an exception.227 if (cadClientProp.getProperty(PROPERTIES.CLIENT_USER_ID.name) == null)228 {229 if (getUserID())230 {231 cadClientProp.store(new FileOutputStream(propertiesFile),232 "");233 }234 else235 {236 throw new SimulationException(237 SimulationException.INITIALIZE_ERROR);238 }239 }240 } catch (IOException ioe)241 {242 cadClientLogger.logp(Level.SEVERE, "SimulationManager",243 "Constructor",244 "Exception in writing to the properties file.");245 throw new SimulationException(SimulationException.INITIALIZE_ERROR);246 }247 248 // Ensure that the properties file has a valid display type249 if (cadClientProp.getProperty(PROPERTIES.DISPLAY_TYPE.name) == null250 || (!cadClientProp.getProperty(PROPERTIES.DISPLAY_TYPE.name)251 .equals("FULL_SCREEN") && !cadClientProp.getProperty(252 PROPERTIES.DISPLAY_TYPE.name).equals("FRAME")))253 {254 cadClientLogger.logp(Level.SEVERE, "SimulationManager",255 "Constructor", "Invalid display type.");256 throw new SimulationException(SimulationException.INITIALIZE_ERROR);257 }258 259 197 return true; 260 198 } 261 199 262 200 /** 263 * This method prompts the user to select a value for the CAD position. If 264 * the user cancels the method returns false, else the Properties object is 265 * updated and true is returned. 266 * 267 * @return True if the user successfully selected a CAD position, false if 268 * not. 269 */ 270 private boolean getCADPosition() 271 { 272 273 Vector<Integer> positions = new Vector<Integer>(); 274 for (int i = 0; i < 10; i++) 275 { 276 positions.add(i); 277 } 278 279 Object cadPos = null; 280 281 while (true) 282 { 283 cadPos = JOptionPane.showInputDialog(null, 284 "Please assign this workstation a CAD position number.", 285 "CAD Position Asignment", JOptionPane.QUESTION_MESSAGE, 286 null, positions.toArray(), positions.get(0)); 287 288 // If the user pressed cancel, confirm the exit and return false. 289 if (cadPos == null) 290 { 291 if (JOptionPane 292 .showConfirmDialog( 293 null, 294 "CAD Client cannot load until a valid CAD " 295 + "position has been selected. Do you wish to " 296 + "cancel loading the CAD Client?", 297 "Confirm Exit", JOptionPane.YES_NO_OPTION, 298 JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) 299 { 300 return false; 301 } 302 } // Else the user selected a CAD position, exit the loop. 303 else 304 { 305 break; 306 } 307 } 308 309 cadClientProp.setProperty(PROPERTIES.CLIENT_CAD_POS.name, 310 cadPos.toString()); 311 return true; 312 } 313 314 /** 315 * This method prompts the user to enter a 5-character User ID. If the user 316 * cancels the method returns false, else the Properties object is updated 317 * and true is returned. 318 * 319 * @return True if the user successfully selected a CAD position, false if 320 * not. 321 */ 322 private boolean getUserID() 323 { 324 String cadUID = null; 325 326 while (true) 327 { 328 cadUID = JOptionPane.showInputDialog(null, 329 "Please assign this workstation a 6-character CAD " 330 + "User ID.", "CAD User ID Asignment", 331 JOptionPane.QUESTION_MESSAGE); 332 333 // /If the user pressed cancel, confirm the exit and return false. 334 if (cadUID == null) 335 { 336 if (JOptionPane.showConfirmDialog(null, 337 "CAD Client cannot load until a valid User ID " 338 + "has been entered. Do you wish to " 339 + "cancel loading the CAD Client?", 340 "Confirm Exit", JOptionPane.YES_NO_OPTION, 341 JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) 342 { 343 return false; 344 } 345 } // If the user does not enter a valid User ID, notify and reprompt. 346 else if (cadUID.length() != 6) 347 { 348 JOptionPane.showMessageDialog(null, 349 "The User ID must be 6 characters.", "Invalid User ID", 350 JOptionPane.WARNING_MESSAGE); 351 } // Else the user entered a valid value, exit the loop. 352 else 353 { 354 break; 355 } 356 } 357 358 cadClientProp.setProperty(PROPERTIES.CLIENT_USER_ID.name, cadUID); 359 return true; 360 } 361 362 /** 363 * Construct the CADClient with the properties file path, either from the 364 * command line arguments or default. 365 * 366 * @param args Command line arguments. 367 */ 368 public static void main(String[] args) 369 { 370 if (System.getProperty("CONFIG_DIR") == null) 371 { 372 System.setProperty("CONFIG_DIR", "config"); 373 } 374 375 try 376 { 377 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 378 new CADClockDisplay(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 379 380 } catch (Exception e) 381 { 382 cadClientLogger.logp(Level.SEVERE, "SimulationManager", "Main", 383 "Error initializing application."); 384 385 JOptionPane.showMessageDialog(new JWindow(), e.getMessage(), 386 "Error - Program Exiting", JOptionPane.ERROR_MESSAGE); 387 388 System.exit(-1); 389 } 390 391 } 392 393 public void refresh() 394 { 395 theClientGUI.screen.refreshScreens(); 201 * Format a time in seconds as HH:MM:SS 202 * 203 * @param l 204 * @return 205 */ 206 private String formatInterval(final long l) 207 { 208 final long hr = TimeUnit.SECONDS.toHours(l); 209 final long min = TimeUnit.SECONDS.toMinutes(l - TimeUnit.HOURS.toSeconds(hr)); 210 final long sec = TimeUnit.SECONDS.toSeconds(l - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min)); 211 return String.format("%02d:%02d:%02d", hr, min, sec); 396 212 } 397 213 … … 414 230 415 231 /** 416 * Format a time in seconds as HH:MM:SS 417 * 418 * @param l 419 * @return 420 */ 421 private String formatInterval(final long l) 422 { 423 final long hr = TimeUnit.SECONDS.toHours(l); 424 final long min = TimeUnit.SECONDS.toMinutes(l - TimeUnit.HOURS.toSeconds(hr)); 425 final long sec = TimeUnit.SECONDS.toSeconds(l - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min)); 426 return String.format("%02d:%02d:%02d", hr, min, sec); 232 * Construct the CADClient with the properties file path, either from the 233 * command line arguments or default. 234 * 235 * @param args Command line arguments. 236 */ 237 public static void main(String[] args) 238 { 239 if (System.getProperty("CONFIG_DIR") == null) 240 { 241 System.setProperty("CONFIG_DIR", "config"); 242 } 243 244 try 245 { 246 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 247 new ClockClient(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME); 248 249 } catch (Exception e) 250 { 251 cadClientLogger.logp(Level.SEVERE, "SimulationManager", "Main", 252 "Error initializing application."); 253 254 JOptionPane.showMessageDialog(new JWindow(), e.getMessage(), 255 "Error - Program Exiting", JOptionPane.ERROR_MESSAGE); 256 257 System.exit(-1); 258 } 259 427 260 } 428 261 } -
trunk/src/tmcsim/client/ClockView.java
r62 r64 16 16 * The CADClientView class is the view component to the CAD Client application. 17 17 * 18 * @author jdalbey 18 19 */ 19 20 @SuppressWarnings("serial") 20 public class C ADClockView extends JFrame21 public class ClockView extends JFrame 21 22 { 22 23 /** … … 26 27 private JPanel mainPane; 27 28 private JLabel currentTime; 29 private final static Dimension SCREEN_SIZE = new Dimension(1100, 255); 28 30 29 31 /** 30 32 * Constructor. Build panes, add key listeners, and set up observer 31 * relationship between the footer and main panes. 32 * 33 * @param position The CAD position for this client terminal. 33 * relationship between the footer and main panes. TODO: Consider having 34 * screen size and font size in properties file. 34 35 */ 35 public C ADClockView()36 public ClockView() 36 37 { 37 38 super("Simulation Clock"); … … 41 42 currentTime.setFont(new Font("Geneva", Font.BOLD, 200)); 42 43 mainPane = new JPanel(); 43 setSize( new Dimension(1100, 255));44 setMaximumSize( new Dimension(1100, 255));45 setMinimumSize( new Dimension(1100, 255));44 setSize(SCREEN_SIZE); 45 setMaximumSize(SCREEN_SIZE); 46 setMinimumSize(SCREEN_SIZE); 46 47 mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS)); 47 48 mainPane.setBorder(BorderFactory.createLineBorder(Color.black)); -
trunk/src/tmcsim/client/cadclientgui/screens/AssignedIncidents.java
r63 r64 15 15 import java.rmi.RemoteException; 16 16 import java.util.List; 17 import java.util.logging.Level; 18 import java.util.logging.Logger; 17 19 import javax.swing.Box; 18 20 import javax.swing.BoxLayout; … … 62 64 // labels for the drop down menu 63 65 private JLabel[] dropDownLabels = new JLabel[LABELS.length]; 66 private static Logger clientLogger = Logger.getLogger("tmcsim.client"); 64 67 private long lastLeftClick;// used for double clicking feature 65 68 … … 110 113 { 111 114 comp = super.prepareRenderer(renderer, row, column); 112 } catch (ArrayIndexOutOfBoundsException ex) 113 { 114 // our workaround is to just return a dummy value 115 // all will be redrawn in the next one second interval 115 } catch (Exception ex) 116 { 117 clientLogger.logp(Level.INFO, "AssignedIncidents", 118 "prepareRenderer", "row=" + row + " col=" + column, ex); 119 120 // Our workaround is to just return a dummy value. 121 // It will be erased in the next one second refresh 116 122 return new JLabel("?"); 117 123 } -
trunk/src/tmcsim/client/cadclientgui/screens/UnitStatus.java
r63 r64 18 18 import java.rmi.RemoteException; 19 19 import java.util.List; 20 import java.util.logging.Level; 21 import java.util.logging.Logger; 20 22 import javax.swing.Box; 21 23 import javax.swing.BoxLayout; … … 48 50 public class UnitStatus extends JFrame 49 51 { 50 private final int ONE_SECOND = 1000; 52 private final static int ONE_SECOND = 1000; 53 private static Logger clientLogger = Logger.getLogger("tmcsim.client"); 51 54 private final String SCREEN_TITLE = "(Shift + F4) Unit Status"; 52 55 private final Dimension SCREEN_DIMENSIONS = new Dimension(1400, 250); … … 152 155 { 153 156 comp = super.prepareRenderer(renderer, row, column); 154 } catch (ArrayIndexOutOfBoundsException ex) 155 { 156 // our workaround is to just return a dummy value 157 // all will be redrawn in the next one second interval 157 } catch (Exception ex) 158 { 159 clientLogger.logp(Level.INFO, "UnitStatus", 160 "prepareRenderer", "row=" + row + " col=" + column, ex); 161 // Our workaround is to just return a dummy value. 162 // It will be erased in the next one second refresh 158 163 return new JLabel("?"); 159 164 }
Note: See TracChangeset
for help on using the changeset viewer.
