Changeset 184 in tmcsimulator for trunk/src/atmsdriver/model/FEPLine.java


Ignore:
Timestamp:
10/28/2017 05:24:02 PM (9 years ago)
Author:
jtorres
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/model/FEPLine.java

    r103 r184  
    11package atmsdriver.model; 
    22 
     3import java.util.ArrayList; 
    34import java.util.List; 
    45import org.w3c.dom.Document; 
    56import org.w3c.dom.Element; 
    67 
    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. 
     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. 
    1214 * 
    1315 * @author John A. Torres 
    1416 * @version 09/10/2017 
    15  */  
    16 public class FEPLine { 
     17 */ 
     18final public class FEPLine 
     19{ 
    1720    /* Static FEPLine meta data */ 
    1821    final public int lineNum; 
    1922    final public List<Station> stations; 
    2023    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) 
     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) 
    3433    { 
    3534        this.lineNum = lineNum; 
    3635        this.stations = stations; 
    3736        this.count = count; 
    38         this.schedule = schedule; 
    39         this.lineInfo = lineInfo; 
    40         this.systemKey = systemKey; 
    41         this.globalSeq = globalSeq; 
    42         this.scheduleSeq = scheduleSeq; 
    4337    } 
    4438     
    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      
     39    /** 
     40     * Returns the FEPLine meta data in string format 
     41     * @return FEPLine metadata 
     42     */ 
    5243    public String getLineMeta() 
    5344    { 
     
    5950        build.append(Integer.toString(this.stations.size())); 
    6051        build.append("\n"); 
    61         for(Station station : stations) 
     52        for (Station station : stations) 
    6253        { 
    6354            build.append(station.getStationMeta()); 
     
    6657    } 
    6758     
     59    /** 
     60     * Returns the FEPLine data in XMLFormat 
     61     *  
     62     * @param currElem The current XML <Line> element 
     63     */ 
    6864    public void toXML(Element currElem) 
    6965    { 
    7066        Document theDoc = currElem.getOwnerDocument(); 
    71          
     67 
    7268        Element lineElement = theDoc.createElement(XML_TAGS.LINE.tag); 
    7369        currElem.appendChild(lineElement); 
    74          
     70 
    7571        Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag); 
    7672        lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineNum))); 
    7773        lineElement.appendChild(lineNumElement); 
    78          
     74 
    7975        Element countElement = theDoc.createElement(XML_TAGS.COUNT.tag); 
    8076        countElement.appendChild(theDoc.createTextNode(String.valueOf(this.count))); 
    8177        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          
     78 
    10379        Element stationsElement = theDoc.createElement(XML_TAGS.STATIONS.tag); 
    10480        lineElement.appendChild(stationsElement); 
    105         for(Station station : stations) 
     81        for (Station station : stations) 
    10682        { 
    10783            station.toXML(stationsElement); 
     
    10985    } 
    11086     
     87    /** 
     88     * XML Tags used in toXML() 
     89     */ 
    11190    private static enum XML_TAGS 
    11291    { 
     92 
    11393        LINE("Line"), 
    11494        LINE_NUM("Line_Num"), 
    11595        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          
     96        COUNT("Count"); 
     97 
    12398        String tag; 
    124          
     99 
    125100        private XML_TAGS(String n) 
    126101        { 
Note: See TracChangeset for help on using the changeset viewer.