Changeset 422 in tmcsimulator for trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
- Timestamp:
- 06/23/2019 10:27:35 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
r407 r422 2 2 3 3 import atmsdriver.GoogleMapAnimator; 4 import atmsdriver.model.Highways;5 import atmsdriver.model.LoopDetector;6 import atmsdriver.model.TrafficEvent;4 import tmcsim.highwaymodel.Highways; 5 import tmcsim.highwaymodel.LoopDetector; 6 import tmcsim.highwaymodel.TrafficEvent; 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; … … 129 129 incidents = new HashMap<String, List<TrafficEvent>>(); 130 130 highways = new Highways( 131 props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name), 132 props.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name), 133 8080); 131 props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name)); 134 132 this.theCoordinator = theCoordinator; 135 133 } … … 211 209 timer.start(); 212 210 213 if (props.getProperty(PROPERTIES.OUTPUT_DEST.name).equals("FEP"))214 {215 // Start the FEP thread (to update ATMS every 30 sec). (See class def below)216 Thread wtfep = new WriteToFEPThread();217 wtfep.start();218 }219 else220 {221 Thread wtConsole = new WriteToConsoleThread();222 wtConsole.start();223 }224 211 // Always write to json for google map display 225 212 Thread wtJson = new WriteToJsonThread(); … … 411 398 } 412 399 413 class WriteToConsoleThread extends Thread414 {415 416 public void run()417 {418 System.out.println("WriteToConsole Thread starting.");419 // Run indefinitely420 while (true)421 {422 // Write the highway network status to the Console423 System.out.println(highways.toString());424 // Pause the thread425 try426 {427 Thread.sleep(10000);428 }429 catch (InterruptedException ie)430 {431 ie.printStackTrace();432 }433 }434 435 }436 }437 400 /** Writes the highway model to a GeoJson file for reading 438 401 * by Google Maps. … … 475 438 } 476 439 477 class WriteToFEPThread extends Thread 478 { 479 480 public void run() 481 { 482 System.out.println("WriteToFEP Thread starting."); 483 // Run indefinitely 484 boolean running = true; 485 while (running) 486 { 487 try 488 { 489 // Write the highway network status to the FEP Simulator 490 highways.writeToFEP(); 491 } 492 catch (SimulationException ex) 493 { 494 // Ask user if they want to proceed without FEP Sim connection 495 // int reply = JOptionPane.showConfirmDialog(null, "Failed to connect to FEP Sim, proceed anyway?", "Network Failure", JOptionPane.YES_NO_OPTION); 496 // if (reply == JOptionPane.NO_OPTION) 497 // { 498 // System.exit(0); 499 // } 500 System.out.println("Skipping writeToFEP..."); 501 running = false; 502 } 503 504 // Wait for FEP Sim to process the data we just sent 505 try 506 { 507 Thread.sleep(FEPSIM_INTERVAL); 508 } 509 catch (InterruptedException ie) 510 { 511 ie.printStackTrace(); 512 } 513 } 514 515 } 516 } 440 517 441 }
Note: See TracChangeset
for help on using the changeset viewer.
