Changeset 135 in tmcsimulator for trunk/src/tmcsim/client/ATMSBatchDriver.java
- Timestamp:
- 10/17/2017 05:10:07 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/tmcsim/client/ATMSBatchDriver.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/client/ATMSBatchDriver.java
r129 r135 155 155 readBatchFile(); 156 156 // Launch the display 157 theView = new ATMSBatchViewer( );157 theView = new ATMSBatchViewer(this, new ArrayList<String>(incidents.keySet())); 158 158 theView.setVisible(true); 159 theView.update("0:00", eventQueue); 159 theView.update("0:00", eventQueue); 160 160 161 // Create a timer that fetches the simulation time every second. 161 162 Timer timer = new Timer(ONE_SECOND, new ActionListener() … … 201 202 } 202 203 //System.out.println("Next event will be launched at: " + formatter.format(eventTime)); 203 theView.update(currentClock, eventQueue);204 204 // Check the queue of events to see if the first 205 205 // item should be launched. IF so, … … 230 230 } 231 231 } 232 theView.update(currentClock, eventQueue); 232 233 } 233 234 } … … 236 237 237 238 // Start the FEP thread (to update ATMS every 30 sec). (See class def below) 238 new WriteToFEPThread().run(); 239 Thread wtfep = new WriteToFEPThread(); 240 wtfep.start(); 239 241 240 242 ensureProperShutdown(); … … 277 279 } 278 280 281 /** Clear an incident. For each event associated with an incident, 282 * turn the dots in its range Green and remove it from the event queue. 283 * @param incidentNumber incident to be cleared. 284 */ 285 public void clearIncident(String incidentNumber) 286 { 287 boolean ok = incidents.containsKey(incidentNumber); 288 if (!ok) 289 { 290 System.out.println("Sorry, that incident number isn't found."); 291 return; 292 } 293 System.out.println("Clearing incident " + incidentNumber); 294 List<String> events = incidents.get(incidentNumber); 295 // Process each event associated with this incident 296 for (String event: events) 297 { 298 System.out.println("Event: " + event + " cleared."); 299 eventQueue.remove(event); 300 // Extract fields from event and prepare them 301 Scanner lineScan = new Scanner(event); 302 try 303 { 304 lineScan.next(); // skip incident number field 305 lineScan.next(); // skip time field 306 int routeNumber = lineScan.nextInt(); 307 Station.DIRECTION dir = Station.DIRECTION.toDirection(lineScan.next()); 308 double postmile = lineScan.nextDouble(); 309 int range = lineScan.nextInt(); 310 // apply colorization to highways, forcing to green, indicating cleared 311 console.applyColorToHighwayStretch(routeNumber, dir, postmile, range, ConsoleDriver.DOTCOLOR.GREEN); 312 } 313 catch (InputMismatchException ex) 314 { 315 System.out.println("Internal error, please report to programmers." + event); 316 } 317 318 } 319 // Now refresh the view with the updated queue of events 320 theView.update("0:00", eventQueue); 321 } 322 279 323 /** 280 324 * Connect to the Coordinator's RMI object, and register this object for
Note: See TracChangeset
for help on using the changeset viewer.
