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


Ignore:
Timestamp:
10/30/2017 01:35:05 PM (9 years ago)
Author:
jdalbey
Message:

Highways.java: Added toString() method. Station.java: Added getColorByDirection method. Added testToString to HighwaysTest?.

File:
1 edited

Legend:

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

    r190 r191  
    195195     
    196196    /** 
     197     * Return the color for the lanes in a given direction. 
     198     * @param direction 
     199     * @return character representing color of lanes in given direction 
     200     * '@' = red,  '+' = yellow, '-' = green 
     201     */ 
     202    public char getColorByDirection(DIRECTION direction) 
     203    { 
     204        /* For now just use the color of the first lane.  
     205         * TODO: Average the color in all the lanes for the given direction */ 
     206 
     207        String laneDir = "OS"; 
     208        if(direction.equals(this.direction)) 
     209        { 
     210            laneDir = "ML"; 
     211        } 
     212        // Examine all the lanes in a given direction 
     213        for(LoopDetector loop : loops) 
     214        { 
     215            if(loop.loopLocation.startsWith(laneDir)) 
     216            { 
     217                // Return color according to loop volume 
     218                if (loop.vol == 1) return '@'; 
     219                if (loop.vol == 3) return '+'; 
     220            } 
     221        } 
     222        // Default case 
     223        return '-'; 
     224                 
     225    } 
     226     
     227    /** 
    197228     * Output for updateByDirection. Logs the update to the console. 
    198229     *  
Note: See TracChangeset for help on using the changeset viewer.