Changeset 424 in tmcsimulator for trunk/src


Ignore:
Timestamp:
06/23/2019 01:08:58 PM (7 years ago)
Author:
jdalbey
Message:

Station.java removed obsolete toXML method.

Location:
trunk/src/tmcsim
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/application.properties

    r422 r424  
    1 #Sun, 23 Jun 2019 11:49:46 -0700 
     1#Sun, 23 Jun 2019 14:38:34 -0700 
    22 
    3 Application.revision=419 
     3Application.revision=423 
    44 
    55Application.buildnumber=140 
  • trunk/src/tmcsim/highwaymodel/Station.java

    r422 r424  
    2121public final class Station implements Comparable 
    2222{ 
    23  
    2423    /* Static Station meta data */ 
    2524    final public int lineID; 
     
    3332 
    3433    /* Dynamic Station data */ 
    35     private int MLTotVol; 
    36     private int OppTotVol; 
     34    private int totalVolume; 
    3735 
    3836    /* Constructor */ 
     
    5048        this.routeNumber = hwy; 
    5149 
    52         this.MLTotVol = getMLTotVol(); 
    53         this.OppTotVol = getOPPTotVol(); 
    54     } 
    55  
    56     /** 
    57      * Calculates the total ML Volume. 
    58      * 
    59      * @return total ML volume. 
    60      */ 
    61     private int getMLTotVol() 
     50        this.totalVolume = calcTotalVolume(); 
     51    } 
     52 
     53    /** 
     54     * Calculates the total lane Volume. 
     55     * Reserved for future use. 
     56     * @return total lane volume. 
     57     */ 
     58    private int calcTotalVolume() 
    6259    { 
    6360        int mlTotVol = 0; 
    6461        for (LoopDetector loop : loops) 
    6562        { 
    66             if (loop.loopLocation.startsWith("ML")) 
    67             { 
    6863                mlTotVol += loop.vol; 
    69             } 
    7064        } 
    7165        return mlTotVol; 
    72     } 
    73  
    74     /** 
    75      * Calculates the total OPP Volume 
    76      * 
    77      * @return total OPP volume. 
    78      */ 
    79     private int getOPPTotVol() 
    80     { 
    81         int oppTotVol = 0; 
    82         for (LoopDetector loop : loops) 
    83         { 
    84             if (loop.loopLocation.startsWith("OS")) 
    85             { 
    86                 oppTotVol += loop.vol; 
    87             } 
    88         } 
    89         return oppTotVol; 
    90     } 
    91  
    92     /** 
    93      * Returns a string of highways data. If MetaDataOnly is true, you get a 
    94      * full dump of the highways meta data, which does not include dynamic loop 
    95      * values, and does include the string location names. If MetaDataOnly is 
    96      * false, dynamic loop values are included, and unnecessary information like 
    97      * string location values are included. 
    98      * 
    99      * The FEPSimulator takes in the toCondensedFormat() output, with a 
    100      * MetaDataOnly value of false, over the socket. 
    101      * 
    102      * The MetaDataOnly flag should be used to get a full dump of the highways 
    103      * information. This was used to get the highways_fullmap.txt output. 
    104      * 
    105      * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 
    106      * @return String, highways data in condensed format 
    107      */ 
    108     public String toCondensedFormat(boolean MetaDataOnly) 
    109     { 
    110         StringBuilder build = new StringBuilder(); 
    111         build.append(Integer.toString(this.vdsID)); 
    112         build.append(" "); 
    113         build.append(Integer.toString(this.drop)); 
    114         build.append(" "); 
    115         build.append(Integer.toString(this.routeNumber)); 
    116         build.append(" "); 
    117         build.append(this.direction.getLetter()); 
    118         build.append(" "); 
    119         build.append(Double.toString(this.postmile)); 
    120         build.append(" "); 
    121         build.append(Integer.toString(loops.size())); 
    122         build.append(" "); 
    123         if (MetaDataOnly) 
    124         { 
    125             build.append(this.location); 
    126         } 
    127         build.append("\n"); 
    128         for (LoopDetector loop : loops) 
    129         { 
    130             build.append(loop.toCondensedFormat(MetaDataOnly)); 
    131         } 
    132         return build.toString(); 
    13366    } 
    13467 
     
    201134            } 
    202135 
    203             this.MLTotVol = getMLTotVol(); 
    204             this.OppTotVol = getOPPTotVol(); 
     136            this.totalVolume = calcTotalVolume(); 
    205137        } 
    206138    } 
     
    252184                OPP_ML, this.location, Double.toString(this.postmile), 
    253185                dotcolor.name()); 
    254     } 
    255  
    256     /** 
    257      * XML tags used for toXML() method. 
    258      */ 
    259     private static enum XML_TAGS 
    260     { 
    261  
    262         STATION("Station"), 
    263         LDS_ID("LDS_ID"), 
    264         LINE_NUM("Line_Num"), 
    265         DROP("Drop"), 
    266         LOOPS("Loops"), 
    267         LOCATION("Location"), 
    268         POST_MILE("Post_Mile"), 
    269         DIRECTION("Direction"), 
    270         FREEWAY("Freeway"), 
    271         ML_TOT_VOL("ML_Tot_Vol"), 
    272         OPP_TOT_VOL("Opp_Tot_Vol"); 
    273  
    274         String tag; 
    275  
    276         private XML_TAGS(String n) 
    277         { 
    278             tag = n; 
    279         } 
    280     } 
    281  
    282     /** 
    283      * Returns the Station data in XMLFormat. 
    284      * 
    285      * @param currElem The current XML <Station> element 
    286      */ 
    287     public void toXML(Element currElem) 
    288     { 
    289         Document theDoc = currElem.getOwnerDocument(); 
    290  
    291         Element stationElement = theDoc.createElement(XML_TAGS.STATION.tag); 
    292         currElem.appendChild(stationElement); 
    293  
    294         Element ldsIDElement = theDoc.createElement(XML_TAGS.LDS_ID.tag); 
    295         ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.vdsID))); 
    296         stationElement.appendChild(ldsIDElement); 
    297  
    298         Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag); 
    299         lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineID))); 
    300         stationElement.appendChild(lineNumElement); 
    301  
    302         Element dropElement = theDoc.createElement(XML_TAGS.DROP.tag); 
    303         dropElement.appendChild(theDoc.createTextNode(String.valueOf(this.drop))); 
    304         stationElement.appendChild(dropElement); 
    305  
    306         Element locationElement = theDoc.createElement(XML_TAGS.LOCATION.tag); 
    307         locationElement.appendChild(theDoc.createTextNode(this.location)); 
    308         stationElement.appendChild(locationElement); 
    309  
    310         Element postMileElement = theDoc.createElement(XML_TAGS.POST_MILE.tag); 
    311         postMileElement.appendChild(theDoc.createTextNode(String.valueOf(this.postmile))); 
    312         stationElement.appendChild(postMileElement); 
    313  
    314         Element directionElement = theDoc.createElement(XML_TAGS.DIRECTION.tag); 
    315         directionElement.appendChild(theDoc.createTextNode("" + this.direction.getLetter())); 
    316         stationElement.appendChild(directionElement); 
    317  
    318         Element freewayElement = theDoc.createElement(XML_TAGS.FREEWAY.tag); 
    319         freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.routeNumber))); 
    320         stationElement.appendChild(freewayElement); 
    321  
    322         Element mlElement = theDoc.createElement(XML_TAGS.ML_TOT_VOL.tag); 
    323         mlElement.appendChild(theDoc.createTextNode(String.valueOf(this.MLTotVol))); 
    324         stationElement.appendChild(mlElement); 
    325  
    326         Element oppElement = theDoc.createElement(XML_TAGS.OPP_TOT_VOL.tag); 
    327         oppElement.appendChild(theDoc.createTextNode(String.valueOf(this.OppTotVol))); 
    328         stationElement.appendChild(oppElement); 
    329  
    330         Element loopsElement = theDoc.createElement(XML_TAGS.LOOPS.tag); 
    331         stationElement.appendChild(loopsElement); 
    332  
    333         for (LoopDetector loop : loops) 
    334         { 
    335             loop.toXML(loopsElement); 
    336         } 
    337186    } 
    338187 
Note: See TracChangeset for help on using the changeset viewer.