Changeset 191 in tmcsimulator for trunk/src/atmsdriver
- Timestamp:
- 10/30/2017 01:35:05 PM (9 years ago)
- Location:
- trunk/src/atmsdriver/model
- Files:
-
- 2 edited
-
Highways.java (modified) (3 diffs)
-
Station.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/atmsdriver/model/Highways.java
r190 r191 198 198 { 199 199 Scanner sc = new Scanner(new File(highwaysMapFileName)); 200 // first line of file contains number of FEP Lines 200 201 String firstLine = sc.nextLine(); 201 202 202 Scanner linesc = new Scanner(firstLine); 203 203 int numLines = linesc.nextInt(); 204 204 linesc.close(); 205 205 // FOR each FEP Line 206 206 for (int i = 0; i < numLines; i++) 207 207 { … … 227 227 String line = sc.nextLine(); 228 228 Scanner scline = new Scanner(line); 229 229 // Get the attribute of this FEP Line 230 230 int lineNum = scline.nextInt(); 231 231 int count = scline.nextInt(); 232 232 int numStations = scline.nextInt(); 233 233 ArrayList<Station> stations = new ArrayList<>(); 234 // Read all the stations for thie FEP Line 234 235 for (int i = 0; i < numStations; i++) 235 236 { … … 473 474 } 474 475 476 /** Return a string representation of the Highways */ 477 public String toString() 478 { 479 StringBuilder result = new StringBuilder(); 480 for (Highway hwy: highways) 481 { 482 result.append(""+String.format("%3s ",hwy.routeNumber)); 483 for (Station stat: hwy.stations) 484 { 485 result.append(stat.getColorByDirection(stat.direction)); 486 } 487 result.append("\n"); 488 } 489 return result.toString(); 490 } 475 491 /** 476 492 * XML tags used in writeToXML() -
trunk/src/atmsdriver/model/Station.java
r190 r191 195 195 196 196 /** 197 * Return the color for the lanes in a given direction. 198 * @param direction 199 * @return character representing color of lanes in given direction 200 * '@' = red, '+' = yellow, '-' = green 201 */ 202 public char getColorByDirection(DIRECTION direction) 203 { 204 /* For now just use the color of the first lane. 205 * TODO: Average the color in all the lanes for the given direction */ 206 207 String laneDir = "OS"; 208 if(direction.equals(this.direction)) 209 { 210 laneDir = "ML"; 211 } 212 // Examine all the lanes in a given direction 213 for(LoopDetector loop : loops) 214 { 215 if(loop.loopLocation.startsWith(laneDir)) 216 { 217 // Return color according to loop volume 218 if (loop.vol == 1) return '@'; 219 if (loop.vol == 3) return '+'; 220 } 221 } 222 // Default case 223 return '-'; 224 225 } 226 227 /** 197 228 * Output for updateByDirection. Logs the update to the console. 198 229 *
Note: See TracChangeset
for help on using the changeset viewer.
