Warning: Can't use blame annotator:
svn blame failed on trunk/src/atmsdriver/model/TrafficEvent.java: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/trunk/src/atmsdriver/model/TrafficEvent.java @ 197

Revision 197, 2.1 KB checked in by jdalbey, 9 years ago (diff)

Deleted ATMSBatchDriver from clients folder. This is now obsolete since it's been integrated as a CAD Server Manager.

RevLine 
1
2package atmsdriver.model;
3
4import java.text.ParseException;
5import java.text.SimpleDateFormat;
6import java.util.Date;
7import java.util.Scanner;
8
9/**
10 * Traffic Event represents some occurrence in the traffic on
11 * a highway network.  A traffic event occurs at a particular time
12 * and belongs to a unique simulation incident.  The event occurs on
13 * a specified section of a given highway route.  Each event specifies
14 * the level of traffic congestion by a color.  Events are comparable
15 * by the time of their occurrence.
16 * @author jdalbey
17 */
18public final class TrafficEvent implements Comparable<TrafficEvent>
19{
20    public final String incident;
21    public final String eventTime;
22    public final Date eventDate;  // for convenience
23    public final int routeNumber;
24    public final LoopDetector.DOTCOLOR color;
25    public final Station.DIRECTION dir;
26    public final double postmile;
27    public final double range;
28    public final String rawString;
29    private final static SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
30
31    /** Create an event from a string as in this example:
32     * 181 00:12:30 405 S 0.6 11.0 G
33     * @param eventString
34     * @return traffic event
35     * @throws Scanner exception if string improperly formatted
36     */
37    public TrafficEvent(String eventString) throws ParseException
38    {
39        this.rawString = eventString;
40        Scanner lineScan = new Scanner(eventString);
41        this.incident = lineScan.next();
42        this.eventTime = lineScan.next(); // time field
43        // may throw parseexception
44        this.eventDate = formatter.parse(eventTime);
45        this.routeNumber = lineScan.nextInt();
46        this.dir = Station.DIRECTION.toDirection(lineScan.next());
47        this.postmile = lineScan.nextDouble();
48        this.range = lineScan.nextDouble();
49        this.color = LoopDetector.DOTCOLOR.toDotColor(lineScan.next());   
50    }
51
52    @Override
53    public int compareTo(TrafficEvent o)
54    {
55        return eventDate.compareTo(o.eventDate);
56    }
57   
58    @Override
59    public String toString()
60    {
61        return rawString;
62    }
63}
Note: See TracBrowser for help on using the repository browser.