Changeset 248 in tmcsimulator
- Timestamp:
- 02/09/2019 08:18:35 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
src/atmsdriver/ATMSDriver.java (modified) (1 diff)
-
src/atmsdriver/GoogleMapAnimator.java (modified) (2 diffs)
-
src/atmsdriver/model/Highways.java (modified) (3 diffs)
-
src/atmsdriver/model/PostmileCoords.java (modified) (2 diffs)
-
src/tmcsim/application.properties (modified) (1 diff)
-
src/tmcsim/cadsimulator/managers/TrafficModelManager.java (modified) (4 diffs)
-
test/atmsdriver/model/HighwaysTest.java (modified) (2 diffs)
-
test/atmsdriver/model/PostmileCoordsTest.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/ATMSDriver.java
r190 r248 8 8 import tmcsim.common.SimulationException; 9 9 10 /** 10 /** "Super Old" 11 11 * ATMS Driver reads the current simulation traffic conditions from the 12 12 * EXCHANGE.XML file and constructs the Highway Network status info in the -
trunk/src/atmsdriver/GoogleMapAnimator.java
r245 r248 33 33 * Error logger. 34 34 */ 35 private final static Logger logger = Logger.getLogger(" trafficmodeleventdriver");35 private final static Logger logger = Logger.getLogger("mapanimator"); 36 36 37 37 /** … … 195 195 public static void main(String[] args) throws RemoteException, SimulationException 196 196 { 197 JFrame frame = new JFrame(" Traffic EventsAnimator");197 JFrame frame = new JFrame("Google Map Animator"); 198 198 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 199 199 frame.setSize(1050,450); -
trunk/src/atmsdriver/model/Highways.java
r243 r248 545 545 for (Highway hwy: highways) 546 546 { 547 // Consider each route direction 548 //for (DIRECTION dir: DIRECTION.values()) 549 // TODO: Needs fixing so proper direction is displayed 550 Station.DIRECTION dir = Station.DIRECTION.SOUTH; 551 if (hwy.routeNumber == 55) 552 dir = Station.DIRECTION.SOUTH; 553 if (hwy.routeNumber == 405) 554 dir = Station.DIRECTION.NORTH; 555 { 556 String rowLabel = ""+String.format("%3s ",hwy.routeNumber)+dir.getLetter()+' '; 547 // For json output we don't care about listing all the stations 548 // in order by direction because we are just outputting points not lines. 549 { 550 // Examine every station on this highway and direction 557 551 StringBuilder lineout = new StringBuilder(); 558 // Examine every station on this highway and direction559 552 for (Station stat: hwy.stations) 560 553 { 561 String pmID = "" + hwy.routeNumber + " " + stat.postmile; 554 String pmID = "" + hwy.routeNumber + " " 555 + stat.direction.getLetter() + " " 556 + stat.postmile; 562 557 PostmileCoords.Postmile currentPM = pmList.find(pmID); 563 558 if (currentPM != null) … … 566 561 //lineout.append(stat.getColorByDirection(dir)); 567 562 String outString = currentPM.toJson(); 563 // replace the color code with the color name 568 564 String colorName=""; 569 switch (stat.getColorByDirection( dir))565 switch (stat.getColorByDirection(stat.direction)) 570 566 { 571 567 case '@': colorName = "red";break; … … 579 575 } 580 576 } 581 // See if there were stations for this direction 582 String checkMe = lineout.toString().trim(); 583 // if any stations were colored, output the line 584 if (checkMe.length() > 1) 585 { 586 //result.append(rowLabel); 587 result.append(lineout + "\n"); 588 } 577 //result.append(rowLabel); 578 result.append(lineout + "\n"); 589 579 590 580 } -
trunk/src/atmsdriver/model/PostmileCoords.java
r244 r248 54 54 { 55 55 String[] fields = item.split(","); 56 Postmile pm = new Postmile(fields[0],fields[1],fields[2]); 56 String[] nameparts = fields[0].split(" "); 57 String statepm = nameparts[2]; 58 // some postmiles come with a prefix, which we ignore 59 if (Character.isLetter(statepm.charAt(0))) 60 { 61 statepm = statepm.substring(1); 62 } 63 String revisedpm = nameparts[0] + " " + nameparts[1] + " " + statepm; 64 Postmile pm = new Postmile(revisedpm,fields[1],fields[2]); 57 65 postmileList.add(pm); 58 66 } … … 69 77 final static class Postmile 70 78 { 71 String name; // the postmile name or id79 String name; // the postmile name (Route,Direction,State postmile) 72 80 String latitude; // the latitude coordinate for this postmile 73 81 String longitude; // the longitude coordinate for this postmile -
trunk/src/tmcsim/application.properties
r246 r248 1 # Thu, 07 Feb 2019 15:47:33-08001 #Sat, 09 Feb 2019 09:41:52 -0800 2 2 3 Application.revision=24 23 Application.revision=247 4 4 5 5 Application.buildnumber=91 -
trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java
r228 r248 1 1 package tmcsim.cadsimulator.managers; 2 2 3 import atmsdriver.GoogleMapAnimator; 3 4 import atmsdriver.model.Highways; 4 5 import atmsdriver.model.LoopDetector; … … 8 9 import java.io.FileInputStream; 9 10 import java.io.FileNotFoundException; 11 import java.io.PrintWriter; 10 12 import java.rmi.RemoteException; 11 13 import java.text.ParseException; … … 208 210 wtConsole.start(); 209 211 } 212 // Always write to json for google map display 213 Thread wtJson = new WriteToJsonThread(); 214 wtJson.start(); 210 215 } 211 216 /** Accessor to event queue … … 403 408 while (true) 404 409 { 405 // Write the highway network status to the FEP Simulator410 // Write the highway network status to the Console 406 411 System.out.println(highways.toString()); 407 408 // Wait for FEP Sim to process the data we just sent 412 // Output the highway model 413 String geojson = highways.toJson(); 414 //System.out.println(geojson); // diagnostic 415 PrintWriter out; 416 try 417 { 418 out = new PrintWriter("highways.json"); 419 out.print(geojson); 420 out.close(); 421 } 422 catch (FileNotFoundException ex) 423 { 424 Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex); 425 } 426 // Wait for Google Map to process the data we just sent 409 427 try 410 428 { 411 429 Thread.sleep(5000); 430 } 431 catch (InterruptedException ie) 432 { 433 ie.printStackTrace(); 434 } 435 } 436 437 } 438 } 439 /** Writes the highway model to a GeoJson file for reading 440 * by Google Maps. 441 */ 442 class WriteToJsonThread extends Thread 443 { 444 445 public void run() 446 { 447 System.out.println("WriteToJson Thread starting."); 448 // Run indefinitely 449 while (true) 450 { 451 // Write the highway network status to Json 452 String geojson = highways.toJson(); 453 PrintWriter out; 454 try 455 { 456 // currently writes to local file 457 out = new PrintWriter("highways.json"); 458 out.print(geojson); 459 out.close(); 460 } 461 catch (FileNotFoundException ex) 462 { 463 Logger.getLogger(GoogleMapAnimator.class.getName()).log(Level.SEVERE, null, ex); 464 } 465 // Wait for Google Map to process the data we just sent 466 try 467 { 468 Thread.sleep(30000); 412 469 } 413 470 catch (InterruptedException ie) -
trunk/test/atmsdriver/model/HighwaysTest.java
r243 r248 29 29 writer.println("32 0 2"); 30 30 writer.println("1210831 1 5 S 0.9 8 CALAFIA"); 31 writer.println("1210832 ML _1");32 writer.println("1210833 ML _2");33 writer.println("1210834 ML _3");34 writer.println("1210835 ML _4");35 writer.println("1210836 PA SSAGE");36 writer.println("1210837 D EMAND");37 writer.println("1210838 QU EUE");38 writer.println("1210839 RAMP_OFF");31 writer.println("1210832 ML ML_1"); 32 writer.println("1210833 ML ML_2"); 33 writer.println("1210834 ML ML_3"); 34 writer.println("1210835 ML ML_4"); 35 writer.println("1210836 PA PASSAGE"); 36 writer.println("1210837 DM DEMAND"); 37 writer.println("1210838 QU QUEUE"); 38 writer.println("1210839 FR RAMP_OFF"); 39 39 writer.println("1210845 2 5 S 1.49 9 EL CAMINO REAL"); 40 writer.println("1210846 ML _1");41 writer.println("1210847 ML _2");42 writer.println("1210848 ML _3");43 writer.println("1210849 ML _4");44 writer.println("1210850 RAMP_ON");45 writer.println("1210851 PA SSAGE");46 writer.println("1210853 D EMAND");47 writer.println("1210854 QU EUE");48 writer.println("1210855 RAMP_OFF");40 writer.println("1210846 ML ML_1"); 41 writer.println("1210847 ML ML_2"); 42 writer.println("1210848 ML ML_3"); 43 writer.println("1210849 ML ML_4"); 44 writer.println("1210850 OR RAMP_ON"); 45 writer.println("1210851 PA PASSAGE"); 46 writer.println("1210853 DM DEMAND"); 47 writer.println("1210854 QU QUEUE"); 48 writer.println("1210855 FR RAMP_OFF"); 49 49 writer.println("74 0 1"); 50 50 writer.println("1204203 2 5 N 1.26 13 MAGDALENA"); 51 writer.println("1204205 RAMP_ON");52 writer.println("1204206 QU EUE");53 writer.println("1204207 D EMAND");54 writer.println("1204208 PA SSAGE");55 writer.println("1204210 RAMP_OFF");56 writer.println("1204212 ML _1");57 writer.println("1204213 ML _2");58 writer.println("1204214 ML _3");59 writer.println("1204215 ML _4");60 writer.println("1204217 OS _1");61 writer.println("1204218 OS _2");62 writer.println("1204219 OS _3");63 writer.println("1204220 OS _4");51 writer.println("1204205 OR RAMP_ON"); 52 writer.println("1204206 QU QUEUE"); 53 writer.println("1204207 DM DEMAND"); 54 writer.println("1204208 PA PASSAGE"); 55 writer.println("1204210 FR RAMP_OFF"); 56 writer.println("1204212 ML ML_1"); 57 writer.println("1204213 ML ML_2"); 58 writer.println("1204214 ML ML_3"); 59 writer.println("1204215 ML ML_4"); 60 writer.println("1204217 OS OS_1"); 61 writer.println("1204218 OS OS_2"); 62 writer.println("1204219 OS OS_3"); 63 writer.println("1204220 OS OS_4"); 64 64 writer.close(); 65 65 } catch (Exception e) { … … 97 97 System.out.println("toJson"); 98 98 Highways highways = new Highways( 99 " config/vds_data/highways_fullmap.txt",99 "test/atmsdriver/model/ldssample.txt", 100 100 "localhost", 8080); 101 highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1;101 //highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1; 102 102 String result = highways.toJson(); 103 103 System.out.println(result); 104 assertTrue(result.startsWith(expToJson1)); 105 } 106 String expToJson1 = ""; 104 assertTrue(result.indexOf("33.416348") > 0); 105 } 107 106 108 107 -
trunk/test/atmsdriver/model/PostmileCoordsTest.java
r244 r248 37 37 38 38 System.out.println("load"); 39 String line1 = " ORA 4 5.55, 33.33, -117.117\nORA 4 6.66, 33.33, -117.117";39 String line1 = "5 N 4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117"; 40 40 Scanner scan = new Scanner(line1).useDelimiter("\\A"); 41 41 pmc = new PostmileCoords(); 42 42 pmc.load(scan); 43 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("ORA 4 5.55", "33.33", "-117.117"); 44 assertEquals(pmc.get(0),pm); 43 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 44 "-117.117"); 45 assertEquals(pm,pmc.get(0)); 46 assert(pmc.size() == 2); 47 } 48 public void testLoadwithPrefix() throws FileNotFoundException 49 { 50 51 System.out.println("load"); 52 String line1 = "5 N R4.02, 33.33, -117.117\n5 S 3.56, 33.33, -117.117"; 53 Scanner scan = new Scanner(line1).useDelimiter("\\A"); 54 pmc = new PostmileCoords(); 55 pmc.load(scan); 56 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", 57 "-117.117"); 58 assertEquals(pm,pmc.get(0)); 45 59 assert(pmc.size() == 2); 46 60 } … … 60 74 System.out.println("find"); 61 75 testLoad(); 62 PostmileCoords.Postmile result = pmc.find(" ORA 4 6.66");76 PostmileCoords.Postmile result = pmc.find("5 N 4.02"); 63 77 assertNotNull(result); 64 PostmileCoords.Postmile pm = new PostmileCoords.Postmile(" ORA 4 6.66", "33.33", "-117.117");78 PostmileCoords.Postmile pm = new PostmileCoords.Postmile("5 N 4.02", "33.33", "-117.117"); 65 79 assertEquals(pm,result); 66 80 PostmileCoords.Postmile result2 = pmc.find("X");
Note: See TracChangeset
for help on using the changeset viewer.
