Changeset 343 in tmcsimulator for trunk/src/atmsdriver/model/Station.java


Ignore:
Timestamp:
03/23/2019 05:40:52 PM (7 years ago)
Author:
jdalbey
Message:

Fix defect #117. Update HighwaysTest?.java for new highway model.

File:
1 edited

Legend:

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

    r285 r343  
    88 
    99/** 
    10  * A Station (LDS or Loop Detector Station) represents a group of lane detectors 
    11  * across all lanes at a particular point on a highway. A station is identified 
     10 * A Station (VDS or Vehicle Detector Station) represents a group of lane detectors 
     11 * across all lanes in one direction at a particular point on a highway. A station is identified 
    1212 * by its highway number and postmile. A station has an associated direction 
    1313 * used to establish which direction is Main and which is Opposite. The MLTotVol 
    1414 * and OppTotVol for a station can be dynamically updated. A station has other 
    15  * attributes: lineNum, ldsID, drop, and location which are used by the FEP. A 
     15 * attributes: lineNum, vdsID, drop, and location which are used by the FEP. A 
    1616 * station can be compared to other stations by its postmile. 
    1717 * 
    18  * @author John A. Torres 
    19  * @version 9/10/2017 
     18 * @author John A. Torres, jdalbey 
     19 * @version 9/10/2017, 3/22/2019 
    2020 */ 
    21 public class Station implements Comparable 
     21public final class Station implements Comparable 
    2222{ 
    2323 
    2424    /* Static Station meta data */ 
    2525    final public int lineID; 
    26     final public int ldsID; // double check 
     26    final public int vdsID; // double check 
    2727    final public int drop; 
    2828    final public String location; 
     
    3737 
    3838    /* Constructor */ 
    39     public Station(int lineID, int ldsID, int drop, 
     39    public Station(int lineID, int vdsID, int drop, 
    4040            String location, List<LoopDetector> loops, int hwy, 
    4141            DIRECTION direction, double postmile) 
    4242    { 
    4343        this.lineID = lineID; 
    44         this.ldsID = ldsID; 
     44        this.vdsID = vdsID; 
    4545        this.drop = drop; 
    4646        this.loops = loops; 
     
    109109    { 
    110110        StringBuilder build = new StringBuilder(); 
    111         build.append(Integer.toString(this.ldsID)); 
     111        build.append(Integer.toString(this.vdsID)); 
    112112        build.append(" "); 
    113113        build.append(Integer.toString(this.drop)); 
     
    170170 
    171171    /** 
     172     * See if this station matches the specified attributes. 
     173     * @param dir 
     174     * @param postmile 
     175     * @return true if this station's attributes match the given ones. 
     176     */ 
     177    public boolean matches(DIRECTION dir, double postmile) 
     178    { 
     179        double val = this.postmile - postmile; 
     180        return (Math.abs(val) < 0.01) && this.direction.equals(dir); 
     181    } 
     182    /** 
    172183     * Determine which lane fields to update based on given direction and update 
    173184     * all the loop detectors with the given color. 
     
    178189    public void updateByDirection(DIRECTION direction, DOTCOLOR dotColor) 
    179190    { 
    180         String laneDir = "OS"; 
     191        // Is this station going in the desired direction? 
    181192        if (direction.equals(this.direction)) 
    182193        { 
    183             laneDir = "ML"; 
    184         } 
    185         outputUpdateMessage(dotColor, laneDir); 
    186  
    187         for (LoopDetector loop : loops) 
    188         { 
    189             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    190             // creates a highway map based on VDS instead of Controller (LDS). 
    191 //            if (loop.loopLocation.startsWith(laneDir)) 
    192 //            { 
    193                 // UPDATE LOOP WITH VALUES 
    194                 loop.updateLoop(dotColor.volume(), dotColor.occupancy()); 
    195 //            } 
    196         } 
    197  
    198         this.MLTotVol = getMLTotVol(); 
    199         this.OppTotVol = getOPPTotVol(); 
    200     } 
    201      
     194            outputUpdateMessage(dotColor, direction.toString()); 
     195 
     196            for (LoopDetector loop : loops) 
     197            { 
     198                // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
     199                // creates a highway map based on VDS instead of Controller (LDS). 
     200    //            if (loop.loopLocation.startsWith(laneDir)) 
     201    //            { 
     202                    // UPDATE LOOP WITH VALUES 
     203                    loop.updateLoop(dotColor.volume(), dotColor.occupancy()); 
     204    //            } 
     205            } 
     206 
     207            this.MLTotVol = getMLTotVol(); 
     208            this.OppTotVol = getOPPTotVol(); 
     209        } 
     210    } 
    202211    /** 
    203212     * Return the color for the lanes in a given direction. 
     
    316325 
    317326        Element ldsIDElement = theDoc.createElement(XML_TAGS.LDS_ID.tag); 
    318         ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.ldsID))); 
     327        ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.vdsID))); 
    319328        stationElement.appendChild(ldsIDElement); 
    320329 
     
    422431    public String toString() 
    423432    { 
    424         return Integer.toString(this.ldsID); 
     433        return Integer.toString(this.vdsID)+this.getColor(); 
    425434    } 
    426435} 
Note: See TracChangeset for help on using the changeset viewer.