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

source: tmcsimulator/trunk/src/atmsdriver/model/FEPLine.java @ 103

Revision 103, 4.4 KB checked in by jtorres, 9 years ago (diff)

trunk/src/atmsdriver/ConsoleDriver.java: Created console driver for ATMSDriver, completed and very nice. Still need to apply correct vol/occ values to actually change the colors. Still need to write a JUnit test for it. trunk/src/atmsdriver/ATMSDriver.java: Refactored to run the console driver. ATMSDriver runs in thread, console driver runs, and they share the highways instance. Renamed NetworkLoader?.java to FEPLineLoader.java. trunk/src/atmsdriver/model/Highways.java: refactored loadHighways() method to conform to new undirected highway abstraction. trunk/src/atmsdriver/model/Station.java: added updateByDirection(DIRECTION dir) method and supporting utility methods. trunk/test/atmsdriver/model/LoadHighwaysTest.java: Conformed LoadHighways? test to new undirected highway abstraction. trunk/test/atmsdriver/model/StationTest.java: Conformed StationTest?.java to new changes - very minor stuff. Went through all model classes and changed any final privates with a getter method to final public, for good OOP practice and simplicity. Went through ALL FILES and commented everything very well. minor application custom configuration changes. Removed all .class or .o.d files from svn repository

RevLine 
1package atmsdriver.model;
2
3import java.util.List;
4import org.w3c.dom.Document;
5import org.w3c.dom.Element;
6
7/** An FEPLine is a simulated line of communication from the FEP to
8 *  LoopDetectorStations in the traffic network.
9 *
10 *  An FEPLine contains static meta data and a list of LoopDetectorStations.
11 *  A single FEPLine contains multiple LoopDetectorStations.
12 *
13 * @author John A. Torres
14 * @version 09/10/2017
15 */ 
16public class FEPLine {
17    /* Static FEPLine meta data */
18    final public int lineNum;
19    final public List<Station> stations;
20    final private int count;
21   
22    final private int schedule;
23    final private int lineInfo;
24    final private long systemKey;
25   
26    // THESE WILL NEED TO BE UPDATED MAYBE, NOT SURE, NOT A PRIORITY. SEE METHOD
27    // UPDATESEQUENCES()
28    private long globalSeq;
29    private long scheduleSeq;
30   
31    public FEPLine(int lineNum, List<Station> stations, int count,
32            int schedule, int lineInfo, long systemKey, long globalSeq,
33            long scheduleSeq)
34    {
35        this.lineNum = lineNum;
36        this.stations = stations;
37        this.count = count;
38        this.schedule = schedule;
39        this.lineInfo = lineInfo;
40        this.systemKey = systemKey;
41        this.globalSeq = globalSeq;
42        this.scheduleSeq = scheduleSeq;
43    }
44   
45    // NEED TO CHECK NUMBERS? DO WE EVEN NEED THIS?
46    public void updateSequences()
47    {       
48        this.scheduleSeq += 1;
49        this.globalSeq += 51;
50    }
51   
52    public String getLineMeta()
53    {
54        StringBuilder build = new StringBuilder();
55        build.append(Integer.toString(this.lineNum));
56        build.append(" ");
57        build.append(Integer.toString(this.count));
58        build.append(" ");
59        build.append(Integer.toString(this.stations.size()));
60        build.append("\n");
61        for(Station station : stations)
62        {
63            build.append(station.getStationMeta());
64        }
65        return build.toString();
66    }
67   
68    public void toXML(Element currElem)
69    {
70        Document theDoc = currElem.getOwnerDocument();
71       
72        Element lineElement = theDoc.createElement(XML_TAGS.LINE.tag);
73        currElem.appendChild(lineElement);
74       
75        Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag);
76        lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineNum)));
77        lineElement.appendChild(lineNumElement);
78       
79        Element countElement = theDoc.createElement(XML_TAGS.COUNT.tag);
80        countElement.appendChild(theDoc.createTextNode(String.valueOf(this.count)));
81        lineElement.appendChild(countElement);
82       
83        Element scheduleElement = theDoc.createElement(XML_TAGS.SCHEDULE.tag);
84        scheduleElement.appendChild(theDoc.createTextNode(String.valueOf(this.schedule)));
85        lineElement.appendChild(scheduleElement);
86       
87        Element lineInfoElement = theDoc.createElement(XML_TAGS.LINE_INFO.tag);
88        lineInfoElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineInfo)));
89        lineElement.appendChild(lineInfoElement);
90       
91        Element systemKeyElement = theDoc.createElement(XML_TAGS.SYSTEM_KEY.tag);
92        systemKeyElement.appendChild(theDoc.createTextNode(String.valueOf(this.systemKey)));
93        lineElement.appendChild(systemKeyElement);
94       
95        Element globalSeqElement = theDoc.createElement(XML_TAGS.GLOBAL_SEQ.tag);
96        globalSeqElement.appendChild(theDoc.createTextNode(String.valueOf(this.globalSeq)));
97        lineElement.appendChild(globalSeqElement);
98       
99        Element scheduleSeqElement = theDoc.createElement(XML_TAGS.SCHEDULE_SEQ.tag);
100        scheduleSeqElement.appendChild(theDoc.createTextNode(String.valueOf(this.scheduleSeq)));
101        lineElement.appendChild(scheduleSeqElement);
102       
103        Element stationsElement = theDoc.createElement(XML_TAGS.STATIONS.tag);
104        lineElement.appendChild(stationsElement);
105        for(Station station : stations)
106        {
107            station.toXML(stationsElement);
108        }
109    }
110   
111    private static enum XML_TAGS
112    {
113        LINE("Line"),
114        LINE_NUM("Line_Num"),
115        STATIONS("Stations"),
116        COUNT("Count"),
117        SCHEDULE("Schedule"),
118        LINE_INFO("Line_Info"),
119        SYSTEM_KEY("System_Key"),
120        GLOBAL_SEQ("Global_Seq"),
121        SCHEDULE_SEQ("Schedule_Seq");
122       
123        String tag;
124       
125        private XML_TAGS(String n)
126        {
127            tag = n;
128        }
129    }
130}
Note: See TracBrowser for help on using the repository browser.