Changeset 180 in tmcsimulator for trunk/src/atmsdriver/model/LoopDetector.java


Ignore:
Timestamp:
10/27/2017 01:38:13 PM (9 years ago)
Author:
jdalbey
Message:

ATMSDriver.java Refactored for cleaner design. DotColor? enum moved to LoopDetector? class. ConsoleDriver? renamed ConsoleTrafficDriver? (and associated project configurations updated), build.xml package-jars target updated, ConsoleTrafficDriver? logic improved to allow more user control, runtraffic.bash script created for automating traffic display tests.

File:
1 edited

Legend:

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

    r176 r180  
    121121        loopElement.appendChild(spdElement); 
    122122    } 
     123     
     124    /** 
     125     * Enum for highway status dot colors. Each color has associated volume 
     126     * and occupancy constants. 
     127     * 
     128     * @author John A. Torres, jdalbey 
     129     * @version 10/11/2017 
     130     */ 
     131    public static enum DOTCOLOR { 
     132 
     133        RED(1, 0.06f),    // "Stopped" is less than 25mph 
     134        YELLOW(3,0.059f), // speed = 26 
     135        GREEN(0,0); 
     136         
     137        // All the first letters of the values, in order. 
     138        public static String allLetters = "RYG"; 
     139         
     140        private int vol;  /* volume */ 
     141        private float occ;  /* occupancy */       
     142         
     143        private DOTCOLOR(int v, float o) 
     144        { 
     145            vol = v; 
     146            occ = o; 
     147        } 
     148        /** 
     149         * Return the first letter of this enum. 
     150         * 
     151         * @return String first letter of this enum. 
     152         */ 
     153        public String getLetter() { 
     154            return this.toString().substring(0, 1); 
     155        } 
     156 
     157        public int volume() 
     158        { 
     159            return vol; 
     160        } 
     161        public float occupancy() 
     162        { 
     163            return occ; 
     164        } 
     165        /** 
     166         * Returns a dot color given its first character. 
     167         * 
     168         * @param letter the first character of a dot color 
     169         * @return dot color corresponding to letter 
     170         * @pre letter must be one of allLetters 
     171         */ 
     172        public static DOTCOLOR toDotColor(String letter) { 
     173            return values()[allLetters.indexOf(letter.charAt(0))]; 
     174        } 
     175    }   
     176     
    123177} 
Note: See TracChangeset for help on using the changeset viewer.