Changeset 422 in tmcsimulator for trunk/src/tmcsim/highwaymodel/Station.java


Ignore:
Timestamp:
06/23/2019 10:27:35 AM (7 years ago)
Author:
jdalbey
Message:

Remove ATMS functionality. Reworked and simplified the Highway model to use only VDS data from PeMS. Updated all unit tests.

Location:
trunk/src/tmcsim/highwaymodel
Files:
1 added
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/tmcsim/highwaymodel/Station.java

    r343 r422  
    1 package atmsdriver.model; 
    2  
    3 import atmsdriver.model.LoopDetector.DOTCOLOR; 
     1package tmcsim.highwaymodel; 
     2 
     3import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
    44import java.util.ArrayList; 
    55import java.util.List; 
     
    99/** 
    1010 * 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 
     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 
     
    194194            outputUpdateMessage(dotColor, direction.toString()); 
    195195 
     196            // Set the values for all lanes at this station 
    196197            for (LoopDetector loop : loops) 
    197198            { 
    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     //            } 
     199                // Set loop detector attributes given the desired color 
     200                loop.setAttributes(dotColor); 
    205201            } 
    206202 
     
    210206    } 
    211207    /** 
    212      * Return the color for the lanes in a given direction. 
    213      * @return character representing color of this station's traffic flow 
    214      * '@' = red, '+' = yellow, '-' = green 
    215      */ 
    216     public char getColor() 
     208     * Compute the color for the lanes in a given direction. 
     209     * @return DOTCOLOR of this station's traffic flow 
     210     */ 
     211    public DOTCOLOR getColor() 
    217212    { 
    218213        /* For now just use the color of the first lane.  
    219          * TODO: Average the color in ALL the lanes for the given direction */ 
     214         * TODO: Average the color in ALL the lanes */ 
    220215 
    221216        String laneDir = ""; 
    222217         
    223             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    224             // creates a highway map based on VDS instead of Controller (LDS). 
    225 //        if (direction.equals(this.direction)) 
    226 //        { 
    227 //            laneDir = "ML"; 
    228 //        } 
    229 //        else if (direction.equals(this.direction.getOpposite())) 
    230 //        { 
    231 //            laneDir = "OS"; 
    232 //        } 
    233         // Search lanes to find specified direction 
    234         for (LoopDetector loop : loops) 
    235         { 
    236             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    237             // creates a highway map based on VDS instead of Controller (LDS). 
    238 //            if (loop.loopLocation.substring(0,2).equals(laneDir)) 
    239 //            { 
    240                 // Return color according to loop volume of first matching lane 
    241                 if (loop.vol == 1) 
    242                 { 
    243                     return '@'; 
    244                 } 
    245                 if (loop.vol == 3) 
    246                 { 
    247                     return '+'; 
    248                 } 
    249                 if (loop.vol == 0) 
    250                 { 
    251                     return '-'; 
    252                 } 
    253 //            } 
    254         } 
    255         // Default case for when the route is not on this direction 
    256         return ' '; 
    257     } 
    258     /** 
    259      * Return the color name for the traffic volume of this station. 
    260      */ 
    261     public String getColorName() 
    262     { 
    263         String colorName = ""; 
    264         switch (this.getColor()) 
    265         { 
    266             case '@': colorName = "red";break; 
    267             case '+': colorName = "yellow"; break; 
    268             case '-': colorName = "lime";break; 
    269             case ' ': colorName = "lime";break; 
    270         } 
    271         return colorName; 
    272     } 
     218        // FOR FUTURE USE we will need to examine all detectors for this station 
     219        // and perform an average 
     220        // for (LoopDetector loop : loops) 
     221        { 
     222            // for now, Return color according to loop volume of first lane 
     223            if (loops.get(0).vol == 1) 
     224            { 
     225                return DOTCOLOR.RED; 
     226            } 
     227            if (loops.get(0).vol == 3) 
     228            { 
     229                return DOTCOLOR.YELLOW; 
     230            } 
     231            if (loops.get(0).vol == 0) 
     232            { 
     233                return DOTCOLOR.GREEN; 
     234            } 
     235        } 
     236         
     237        // Default case for invalid data 
     238        return DOTCOLOR.GREEN; 
     239    } 
     240 
    273241    /** 
    274242     * Output for updateByDirection. Logs the update to the console. 
Note: See TracChangeset for help on using the changeset viewer.