- Timestamp:
- 10/14/2017 01:33:24 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
-
atmsdriver/ConsoleDriver.java (modified) (1 diff)
-
tmcsim/client/ATMSBatchDriver.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/ConsoleDriver.java
r119 r121 275 275 System.out.println(""); 276 276 System.out.println("Enter a direction:"); 277 directionInput = sc.next() ;277 directionInput = sc.next().toUpperCase(); 278 278 System.out.println(""); 279 279 -
trunk/src/tmcsim/client/ATMSBatchDriver.java
r120 r121 1 1 package tmcsim.client; 2 2 3 import atmsdriver.ATMSDriver; 3 4 import atmsdriver.ConsoleDriver; 5 import atmsdriver.ExchangeInfo; 4 6 import atmsdriver.model.Highways; 5 7 import atmsdriver.model.Station; … … 48 50 private static final String CONFIG_FILE_NAME = "cad_client_config.properties"; 49 51 private final static int ONE_SECOND = 1000; 52 private static final int FEPSIM_INTERVAL = 30000; 50 53 private final static SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); 51 54 /** … … 98 101 */ 99 102 private CADClientInterface client = this; 103 104 /** 105 * Highways in traffic network 106 */ 107 final private Highways highways; 100 108 101 109 /** … … 121 129 System.exit(0); 122 130 } 123 Highwayshighways = new Highways(131 highways = new Highways( 124 132 "config/vds_data/lds.txt", 125 133 "config/vds_data/loop.txt", 126 134 "config/vds_data/highwaysMeta.txt", 127 135 "localhost", 8080); 136 // Create console driver but don't start run() method 128 137 console = new ConsoleDriver(highways); 129 138 … … 133 142 // READ THE BATCH FILE OF COMMANDS and put in a queue 134 143 readBatchFile(); 135 136 144 // Create a timer that fetches the simulation time every second. 137 145 Timer timer = new Timer(ONE_SECOND, new ActionListener() 138 146 { 147 // Every second, see if an event should be launched 139 148 public void actionPerformed(ActionEvent e) 140 149 { … … 205 214 timer.start(); 206 215 216 // Start the FEP thread (to update ATMS every 30 sec) 217 new WriteToFEPThread().run(); 218 207 219 ensureProperShutdown(); 208 220 } … … 222 234 Logger.getLogger(ATMSBatchDriver.class.getName()).log(Level.SEVERE, null, ex); 223 235 } 236 System.out.println("Events file read, " + eventQueue.size() + " events queued."); 224 237 } 225 238 … … 358 371 359 372 } 373 374 class WriteToFEPThread extends Thread 375 { 376 377 public void run() 378 { 379 System.out.println("WriteToFEP Thread starting."); 380 // Run indefinitely 381 while (true) 382 { 383 // Write the highway network status to the FEP Simulator 384 highways.writeToFEP(); 385 386 // Wait for FEP Sim to process the data we just sent 387 try 388 { 389 Thread.sleep(FEPSIM_INTERVAL); 390 } 391 catch (InterruptedException ie) 392 { 393 ie.printStackTrace(); 394 } 395 } 396 397 } 398 } 360 399 }
Note: See TracChangeset
for help on using the changeset viewer.
