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

Revision 184, 2.8 KB checked in by jtorres, 9 years ago (diff)

highways.java: converted to immutable, removed use of FEPLineLoader and added loadLines(), loadLine(), loadStation(), and loadLoop() methods. Renamed loadHighways() to configureHighways(), renamed writeHighwaysMeta() to getHighwaysMeta() which now returns a String containing metadata instead of opening a file and writing to it, which is more flexible. FEPLineLoader.java: deleted, no longer need it. FEPLine.java: converted to immutable, removed unnecessary member variables and adjusted all methods accordingly. Station.java: MLTotVol() and OppTotVol?() are now being updated at end of updateByDirection(). ATMSDriver.java: Now using one config file: highways_fullmap.txt, as opposed to the older lds.txt and loop.txt files. config/vds_data: added highways_fullmap.txt. config/atms_driver_config.properties, atms_driver_config_local.properties: updated config to reflect use of highways_fullmap.txt instead of old loop.txt and lds.txt configuration. ATMSBatchDriver.java: conformed highways initialization in constructor to reflect use of highways_fullmap.txt

RevLine 
1package atmsdriver.model;
2
3import java.util.ArrayList;
4import java.util.List;
5import org.w3c.dom.Document;
6import org.w3c.dom.Element;
7
8/**
9 * An FEPLine is a simulated line of communication from the FEP to
10 * Stations in the highways network.
11 *
12 * An FEPLine contains static line meta data and a list of Stations. A
13 * single FEPLine contains multiple Stations.
14 *
15 * @author John A. Torres
16 * @version 09/10/2017
17 */
18final public class FEPLine
19{
20    /* Static FEPLine meta data */
21    final public int lineNum;
22    final public List<Station> stations;
23    final private int count;
24
25    /**
26     * Constructs an FEPLine from given line number, list of stations, and count.
27     *
28     * @param lineNum
29     * @param stations
30     * @param count
31     */
32    FEPLine(int lineNum, ArrayList<Station> stations, int count)
33    {
34        this.lineNum = lineNum;
35        this.stations = stations;
36        this.count = count;
37    }
38   
39    /**
40     * Returns the FEPLine meta data in string format
41     * @return FEPLine metadata
42     */
43    public String getLineMeta()
44    {
45        StringBuilder build = new StringBuilder();
46        build.append(Integer.toString(this.lineNum));
47        build.append(" ");
48        build.append(Integer.toString(this.count));
49        build.append(" ");
50        build.append(Integer.toString(this.stations.size()));
51        build.append("\n");
52        for (Station station : stations)
53        {
54            build.append(station.getStationMeta());
55        }
56        return build.toString();
57    }
58   
59    /**
60     * Returns the FEPLine data in XMLFormat
61     *
62     * @param currElem The current XML <Line> element
63     */
64    public void toXML(Element currElem)
65    {
66        Document theDoc = currElem.getOwnerDocument();
67
68        Element lineElement = theDoc.createElement(XML_TAGS.LINE.tag);
69        currElem.appendChild(lineElement);
70
71        Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag);
72        lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineNum)));
73        lineElement.appendChild(lineNumElement);
74
75        Element countElement = theDoc.createElement(XML_TAGS.COUNT.tag);
76        countElement.appendChild(theDoc.createTextNode(String.valueOf(this.count)));
77        lineElement.appendChild(countElement);
78
79        Element stationsElement = theDoc.createElement(XML_TAGS.STATIONS.tag);
80        lineElement.appendChild(stationsElement);
81        for (Station station : stations)
82        {
83            station.toXML(stationsElement);
84        }
85    }
86   
87    /**
88     * XML Tags used in toXML()
89     */
90    private static enum XML_TAGS
91    {
92
93        LINE("Line"),
94        LINE_NUM("Line_Num"),
95        STATIONS("Stations"),
96        COUNT("Count");
97
98        String tag;
99
100        private XML_TAGS(String n)
101        {
102            tag = n;
103        }
104    }
105}
Note: See TracBrowser for help on using the repository browser.