Changeset 274 in tmcsimulator for trunk/src/atmsdriver
- Timestamp:
- 02/25/2019 04:36:04 PM (7 years ago)
- Location:
- trunk/src/atmsdriver/model
- Files:
-
- 3 edited
-
Highways.java (modified) (10 diffs)
-
PostmileCoords.java (modified) (1 diff)
-
Station.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/Highways.java
r266 r274 63 63 // load FEP Lines 64 64 lines = loadLines(highwaysMapFileName); 65 // configure and load highways66 this.highways = configureHighways();65 // build highways data structure 66 this.highways = buildHighways(); 67 67 68 68 // write to FEP host and port number … … 71 71 } 72 72 73 private ArrayList<Highway> configureHighways()74 { 75 System.out.println(" Loading highways...");73 private ArrayList<Highway> buildHighways() 74 { 75 System.out.println("Building highways..."); 76 76 // The list of highways to return 77 77 ArrayList<Highway> highways = new ArrayList<Highway>(); … … 89 89 { 90 90 Integer hwyNum = station.routeNumber; 91 92 91 // if the map does not contain an entry for the highway, create 93 92 // a new entry (key/value pair) for the highway and instantiate … … 116 115 ArrayList<Station> hwyStations = highwayMap.get(hwyKey); 117 116 Collections.sort(hwyStations); 118 System.out.println("Loaded highway " + hwyKey + "..."); 117 System.out.println("Loaded highway " + hwyKey + " with " + 118 hwyStations.size() + " stations."); 119 119 highways.add(new Highway(hwyKey, 120 120 hwyStations)); … … 159 159 startPost = postmile; 160 160 endPost = postmile + range; 161 161 //TODO: Catch NPE exception for situation when the events file 162 // specifies a highway that doesn't exist in the network. 163 // Also the case where a desired postmile to color isn't in 164 // the network. 162 165 // iterate through the stations, if within the specified highway 163 166 // stretch, update the station by direction and apply dot color … … 222 225 223 226 /** 224 * Load sa single FEP Line from the highways map file.227 * Load all the stations for a single FEP Line from the highways map file. 225 228 * 226 229 * @param sc scanner at the current FEPLine line … … 348 351 // Print the number of bytes the highways data message contains 349 352 System.out.println("Highways sending " + this.toCondensedFormat(false).toCharArray().length + 1 + "bytes to FEPSIM."); 350 353 String outMsg = this.toCondensedFormat(false); 351 354 // Write the highways data over the socket 352 out.println( this.toCondensedFormat(false));355 out.println(outMsg); 353 356 354 357 // close the socket … … 371 374 * and does include the string location names. If MetaDataOnly is false, 372 375 * dynamic loop values are included, and unnecessary information like string 373 * location values are included.376 * location values are not included. 374 377 * 375 378 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly … … 526 529 public String toJson() 527 530 { 531 // TODO: move loading this file to init method so it doesn't get 532 // called every time. 528 533 PostmileCoords pmList = new PostmileCoords(); 529 534 FileInputStream fis = null; … … 545 550 for (Highway hwy: highways) 546 551 { 547 // For json output we don't care about listing all the stations548 // in order by direction because we are just outputting points not lines.552 // Consider each route direction 553 for (DIRECTION dir: DIRECTION.values()) 549 554 { 550 555 // Examine every station on this highway and direction -
trunk/src/atmsdriver/model/PostmileCoords.java
r269 r274 119 119 public boolean nameEquals(String target) 120 120 { 121 // remove .0 for comparing strings 122 if (target.endsWith(".0")) 123 { 124 String truncTarget = target.substring(0,target.length()-2); 125 return this.name.equals(truncTarget); 126 } 121 127 return this.name.equals(target); 122 128 } -
trunk/src/atmsdriver/model/Station.java
r237 r274 208 208 { 209 209 /* For now just use the color of the first lane. 210 * TODO: Average the color in allthe lanes for the given direction */210 * TODO: Average the color in ALL the lanes for the given direction */ 211 211 212 212 String laneDir = ""; … … 219 219 laneDir = "OS"; 220 220 } 221 // Examine all the lanes in a givendirection221 // Search lanes to find specified direction 222 222 for (LoopDetector loop : loops) 223 223 { 224 224 if (loop.loopLocation.substring(0,2).equals(laneDir)) 225 225 { 226 // Return color according to loop volume 226 // Return color according to loop volume of first matching lane 227 227 if (loop.vol == 1) 228 228 {
Note: See TracChangeset
for help on using the changeset viewer.
