Changeset 129 in tmcsimulator for trunk/src/tmcsim
- Timestamp:
- 10/17/2017 10:38:23 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/client/ATMSBatchDriver.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/ATMSBatchDriver.java
r128 r129 15 15 import java.text.ParseException; 16 16 import java.text.SimpleDateFormat; 17 import java.util.ArrayList; 17 18 import java.util.Date; 19 import java.util.HashMap; 18 20 import java.util.InputMismatchException; 19 21 import java.util.LinkedList; 22 import java.util.List; 23 import java.util.Map; 20 24 import java.util.Properties; 21 25 import java.util.Queue; … … 111 115 */ 112 116 private Queue<String> eventQueue; 117 /** 118 * Map of incidents to events 119 */ 120 private Map<String, List<String>> incidents; 113 121 114 122 /** Instance of ConsoleDriver that contains the highway model */ … … 132 140 System.exit(0); 133 141 } 142 incidents = new HashMap<String, List<String>> (); 134 143 highways = new Highways( 135 144 "config/vds_data/lds.txt", … … 179 188 // Get the time to launch the next event 180 189 String nextEvent = eventQueue.peek(); 181 String eventTimeField = nextEvent.substring(0,8); 190 // String eventTimeField = nextEvent.substring(0,8); 191 Scanner evtScan = new Scanner(nextEvent); 192 String inci = evtScan.next(); 193 String eventTimeField = evtScan.next(); 182 194 Date eventTime = new Date(); 183 195 try { … … 200 212 try 201 213 { 214 lineScan.next(); // skip incident number field 202 215 lineScan.next(); // skip time field 203 216 int routeNumber = lineScan.nextInt(); … … 233 246 try { 234 247 fis = new FileInputStream("config/vds_data/atmsBatchEvents.txt"); 248 eventQueue = new LinkedList<String>(); 249 // Read all lines from the file of events 235 250 Scanner scan = new Scanner(fis); 236 eventQueue = new LinkedList<String>();237 251 while (scan.hasNext()) 238 252 { 239 eventQueue.add(scan.nextLine()); 253 // Read a line and add it to the event queue 254 String line = scan.nextLine(); 255 eventQueue.add(line); 256 // Parse the incident from the line 257 Scanner lineScan = new Scanner(line); 258 String incident = lineScan.next(); 259 // Add the line to the list for the corresponding incident 260 List evtList; 261 if (incidents.containsKey(incident)) 262 { 263 evtList = incidents.get(incident); 264 } 265 else 266 { 267 evtList = new ArrayList<String>(); 268 } 269 evtList.add(line); 270 // and put it back in the map 271 incidents.put(incident, evtList); 240 272 } 241 273 } catch (FileNotFoundException ex) {
Note: See TracChangeset
for help on using the changeset viewer.
