Changeset 188 in tmcsimulator
- Timestamp:
- 10/29/2017 03:13:25 PM (9 years ago)
- Location:
- trunk/src/tmcsim/cadsimulator
- Files:
-
- 4 edited
-
CADServer.java (modified) (4 diffs)
-
managers/TrafficModelManager.java (modified) (9 diffs)
-
managers/TrafficModelViewer.form (modified) (1 diff)
-
managers/TrafficModelViewer.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/CADServer.java
r123 r188 20 20 import tmcsim.cadsimulator.managers.ParamicsSimulationManager; 21 21 import tmcsim.cadsimulator.managers.SimulationClockManager; 22 import tmcsim.cadsimulator.managers.TrafficModelManager; 22 23 import tmcsim.cadsimulator.viewer.model.CADSimulatorState; 23 24 import tmcsim.common.SimulationException; … … 122 123 ATMS_PROP_FILE("ATMSProperties"), 123 124 /** 125 * Filepath for the properties file to initialize the traffic manager. 126 */ 127 TRAFFICMGR_PROP_FILE("TrafficMgrProperties"), 128 /** 124 129 * Class name of desired user interface. 125 130 */ … … 168 173 */ 169 174 protected static ATMSManager theATMSMgr = null; 175 /** 176 * Traffic Model Manager instance 177 */ 178 protected static TrafficModelManager theTrafficMgr = null; 170 179 /** 171 180 * Properties file for the CADSimulator. … … 242 251 cadSimulatorProperties.getProperty( 243 252 CAD_PROPERTIES.ATMS_PROP_FILE.name)); 253 254 theTrafficMgr = new TrafficModelManager( 255 cadSimulatorProperties.getProperty( 256 CAD_PROPERTIES.TRAFFICMGR_PROP_FILE.name), 257 theCoordinator); 244 258 245 259 theMediaMgr = new MediaManager( -
trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
r187 r188 26 26 import java.util.logging.Logger; 27 27 import javax.swing.JOptionPane; 28 import javax.swing.JWindow; 28 29 import javax.swing.Timer; 30 import javax.swing.UIManager; 29 31 import tmcsim.cadsimulator.Coordinator; 32 import tmcsim.cadsimulator.viewer.model.CADSimulatorState; 30 33 import tmcsim.client.ATMSBatchDriver; 31 34 import tmcsim.client.ATMSBatchViewer; … … 39 42 * @version 2.0 40 43 */ 41 public class TrafficModelManager extends Observable44 public class TrafficModelManager 42 45 { 43 46 private final static int ONE_SECOND = 1000; … … 78 81 }; 79 82 80 /**81 * Reference to the simulation Coordinator from whom we get simulation82 * elapsed time.83 */84 private Coordinator theCoordinator;85 83 86 84 /** … … 112 110 * 113 111 * @param propertiesFile Target file path of properties file. 114 */ 115 public TrafficModelManager(String propertiesFile) throws SimulationException 112 * @param theCoordinator Reference to the simulation Coordinator from whom we get simulation 113 * elapsed time. 114 */ 115 public TrafficModelManager(String propertiesFile, final Coordinator theCoordinator) 116 throws SimulationException 116 117 { 117 118 if (!loadProperties(propertiesFile)) … … 119 120 System.exit(0); 120 121 } 121 122 // final Coordinator theCoordinator = theCoordinator; 122 123 // Initialize the highway model 123 124 incidents = new HashMap<String, List<TrafficEvent>>(); 124 125 highways = new Highways( 125 "config/vds_data/highways_fullmap.txt", 126 atmsProperties.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name), 127 //"config/vds_data/highways_fullmap.txt", 126 128 // "192.168.251.46", 8080); //IP address of FEP Sim Linux VM 127 "localhost", 8080); 129 atmsProperties.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name), 130 8080); 128 131 129 132 // READ THE BATCH FILE OF COMMANDS and put in a queue 130 readBatchFile();133 eventQueue = readBatchFile(); 131 134 // Launch the display 132 135 theView = new TrafficModelViewer(this, new ArrayList<String>(incidents.keySet())); … … 245 248 return true; 246 249 } 247 private void readBatchFile() 250 /** 251 * Read a file of traffic events. 252 * @return the chronologically ordered list of events 253 */ 254 // Method is package private to facilitate unit testing. 255 LinkedList<TrafficEvent> readBatchFile() 248 256 { 249 257 FileInputStream fis; 258 LinkedList<TrafficEvent> eventList = new LinkedList<TrafficEvent>(); 250 259 try 251 260 { 252 fis = new FileInputStream("config/vds_data/atmsBatchEvents.txt"); 253 eventQueue = new LinkedList<TrafficEvent>(); 261 fis = new FileInputStream( 262 //"config/vds_data/atmsBatchEvents.txt"); 263 atmsProperties.getProperty(PROPERTIES.EVENTS_FILE.name)); 254 264 // Read all lines from the file of events 255 265 Scanner scan = new Scanner(fis); … … 264 274 { 265 275 evt = new TrafficEvent(line); 266 event Queue.add(evt);276 eventList.add(evt); 267 277 String incident = evt.incident; 268 278 // Add the line to the list for the corresponding incident … … 293 303 Logger.getLogger(ATMSBatchDriver.class.getName()).log(Level.SEVERE, null, ex); 294 304 } 295 System.out.println("Events file read, " + event Queue.size() + " events queued.");305 System.out.println("Events file read, " + eventList.size() + " events queued."); 296 306 // Put the events in chronological order 297 Collections.sort(eventQueue); 307 Collections.sort(eventList); 308 return eventList; 298 309 } 299 310 … … 343 354 } 344 355 356 /** 357 * Construct the CADClient with the properties file path, either from the 358 * command line arguments or default. 359 * 360 * @param args Command line arguments. 361 */ 362 public static void main(String[] args) throws RemoteException 363 { 364 final String CONFIG_FILE_NAME = "traffic_model_config.properties"; 365 if (System.getProperty("CONFIG_DIR") == null) 366 { 367 System.setProperty("CONFIG_DIR", "config"); 368 } 369 CADSimulatorState theModel = new CADSimulatorState(); 370 Coordinator theCoordinator = new Coordinator(theModel); 371 try 372 { 373 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 374 new TrafficModelManager(System.getProperty("CONFIG_DIR") + System.getProperty("file.separator") + CONFIG_FILE_NAME, 375 theCoordinator); 376 377 } 378 catch (Exception e) 379 { 380 atmsLogger.logp(Level.SEVERE, "SimulationManager", "Main", 381 "Error initializing application."); 382 383 JOptionPane.showMessageDialog(new JWindow(), e.getMessage(), 384 "Error - Program Exiting", JOptionPane.ERROR_MESSAGE); 385 386 System.exit(-1); 387 } 388 389 } 345 390 class WriteToFEPThread extends Thread 346 391 { -
trunk/src/tmcsim/cadsimulator/managers/TrafficModelViewer.form
r187 r188 4 4 <Properties> 5 5 <Property name="defaultCloseOperation" type="int" value="3"/> 6 <Property name="title" type="java.lang.String" value=" ATMS Batch Driver"/>6 <Property name="title" type="java.lang.String" value="Traffic Modeler"/> 7 7 </Properties> 8 8 <SyntheticProperties> -
trunk/src/tmcsim/cadsimulator/managers/TrafficModelViewer.java
r187 r188 96 96 97 97 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 98 setTitle(" ATMS Batch Driver");98 setTitle("Traffic Modeler"); 99 99 100 100 lstEvents.setFont(new java.awt.Font("Noto Mono", 0, 12)); // NOI18N
Note: See TracChangeset
for help on using the changeset viewer.
