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 @ 87

Revision 87, 4.3 KB checked in by jtorres, 9 years ago (diff)

merged branches/trunk into regular tmcsim/trunk. Changed Network.java to Highways.java. Highways.java: added writeToFEP(), updateSequences(), loadHighways(), and writeHighwaysMeta(). writeToFEP() is a socket client that communicates with FEPSimulator socket server. updateSequences() updates global and schedule sequences per the existing UCI plugin code and may not be necessary. loadHighways() loads the ArrayList? of Highways used in highways class, in sorted order. Stations are now implementing comparable to sort by postmile. writeHighwaysMeta() is an attempt at writing the highways meta data in condensed form, because loading time in NetworkLoader? is super long. We will eventually get rid of NetworkLoader? and do it within the Highways class for good OOP practice. There are new properties in atms_driver_properties.properties in config to support all these changes. Highway.java: new class, represents a highway which is a sorted ArrayList? of stations. This is a good checkpoint, for persistent green dots and all is working within the triangle. There is much commented out code in Highways.java which does not quite work. This commented code is an attempt at writing the condensed form highway meta data to improve loading times as described above.

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