Changeset 274 in tmcsimulator


Ignore:
Timestamp:
02/25/2019 04:36:04 PM (7 years ago)
Author:
jdalbey
Message:

Multi file commit: adding and elaborating on comments and javadoc.

Location:
trunk/src
Files:
6 edited

Legend:

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

    r266 r274  
    6363        // load FEP Lines 
    6464        lines = loadLines(highwaysMapFileName); 
    65         // configure and load highways 
    66         this.highways = configureHighways(); 
     65        // build highways data structure 
     66        this.highways = buildHighways(); 
    6767 
    6868        // write to FEP host and port number 
     
    7171    } 
    7272 
    73     private ArrayList<Highway> configureHighways() 
    74     { 
    75         System.out.println("Loading highways..."); 
     73    private ArrayList<Highway> buildHighways() 
     74    { 
     75        System.out.println("Building highways..."); 
    7676        // The list of highways to return 
    7777        ArrayList<Highway> highways = new ArrayList<Highway>(); 
     
    8989            { 
    9090                Integer hwyNum = station.routeNumber; 
    91                  
    9291                // if the map does not contain an entry for the highway, create 
    9392                // a new entry (key/value pair) for the highway and instantiate 
     
    116115            ArrayList<Station> hwyStations = highwayMap.get(hwyKey); 
    117116            Collections.sort(hwyStations); 
    118             System.out.println("Loaded highway " + hwyKey + "..."); 
     117            System.out.println("Loaded highway " + hwyKey + " with " + 
     118                    hwyStations.size() + " stations."); 
    119119            highways.add(new Highway(hwyKey, 
    120120                    hwyStations)); 
     
    159159            startPost = postmile; 
    160160            endPost = postmile + range; 
    161  
     161            //TODO: Catch NPE exception for situation when the events file  
     162            //   specifies a highway that doesn't exist in the network. 
     163            //   Also the case where a desired postmile to color isn't in 
     164            //   the network. 
    162165            // iterate through the stations, if within the specified highway 
    163166            // stretch, update the station by direction and apply dot color 
     
    222225     
    223226    /** 
    224      * Loads a single FEP Line from the highways map file. 
     227     * Load all the stations for a single FEP Line from the highways map file. 
    225228     *  
    226229     * @param sc scanner at the current FEPLine line 
     
    348351            // Print the number of bytes the highways data message contains 
    349352            System.out.println("Highways sending " + this.toCondensedFormat(false).toCharArray().length + 1 + "bytes to FEPSIM."); 
    350              
     353            String outMsg = this.toCondensedFormat(false); 
    351354            // Write the highways data over the socket 
    352             out.println(this.toCondensedFormat(false)); 
     355            out.println(outMsg); 
    353356             
    354357            // close the socket 
     
    371374     *  and does include the string location names. If MetaDataOnly is false, 
    372375     *  dynamic loop values are included, and unnecessary information like string 
    373      *  location values are included. 
     376     *  location values are not included. 
    374377     *  
    375378     *  The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 
     
    526529    public String toJson() 
    527530    { 
     531        // TODO: move loading this file to init method so it doesn't get  
     532        // called every time. 
    528533        PostmileCoords pmList = new PostmileCoords(); 
    529534        FileInputStream fis = null; 
     
    545550        for (Highway hwy: highways) 
    546551        { 
    547             // For json output we don't care about listing all the stations 
    548             // in order by direction because we are just outputting points not lines. 
     552            // Consider each route direction 
     553            for (DIRECTION dir: DIRECTION.values()) 
    549554            { 
    550555                // Examine every station on this highway and direction 
  • trunk/src/atmsdriver/model/PostmileCoords.java

    r269 r274  
    119119        public boolean nameEquals(String target) 
    120120        { 
     121            // remove .0 for comparing strings 
     122            if (target.endsWith(".0")) 
     123            { 
     124                String truncTarget = target.substring(0,target.length()-2); 
     125                return this.name.equals(truncTarget); 
     126            } 
    121127            return this.name.equals(target); 
    122128        } 
  • trunk/src/atmsdriver/model/Station.java

    r237 r274  
    208208    { 
    209209        /* For now just use the color of the first lane.  
    210          * TODO: Average the color in all the lanes for the given direction */ 
     210         * TODO: Average the color in ALL the lanes for the given direction */ 
    211211 
    212212        String laneDir = ""; 
     
    219219            laneDir = "OS"; 
    220220        } 
    221         // Examine all the lanes in a given direction 
     221        // Search lanes to find specified direction 
    222222        for (LoopDetector loop : loops) 
    223223        { 
    224224            if (loop.loopLocation.substring(0,2).equals(laneDir)) 
    225225            { 
    226                 // Return color according to loop volume 
     226                // Return color according to loop volume of first matching lane 
    227227                if (loop.vol == 1) 
    228228                { 
  • trunk/src/tmcsim/application.properties

    r269 r274  
    1 #Thu, 21 Feb 2019 15:22:00 -0800 
     1#Mon, 25 Feb 2019 17:13:55 -0800 
    22 
    3 Application.revision=268 
     3Application.revision=273 
    44 
    5 Application.buildnumber=95 
     5Application.buildnumber=97 
  • trunk/src/tmcsim/utilities/BuildHighwayFile.java

    r272 r274  
    1 /* 
    2  * To change this license header, choose License Headers in Project Properties. 
    3  * To change this template file, choose Tools | Templates 
    4  * and open the template in the editor. 
    5  */ 
    61package tmcsim.utilities; 
    72 
     
    3025 *      3. LDS file that has the fep line number for each LDS. 
    3126 * Output: 1. The highway map file that lists VDS info and the lanes it governs. 
    32  *      2. A slightly reformatted loop file. 
     27 *      2. A slightly reformatted loop file.  (Not sure what this is for.) 
    3328 * @author jdalbey, jtorres 
    3429 */ 
     
    157152                else 
    158153                { 
    159                     if (shortLoc.equals("ML") && !missingVDS.contains(vdsID)) 
     154                    boolean desiredType = shortLoc.equals("ML") || shortLoc.equals("OS"); 
     155                    if (desiredType && !missingVDS.contains(vdsID)) 
    160156                    { 
    161157                        System.out.println("createLaneLookup(): vdsID: "+vdsID+ 
    162                                 " of type ML not found. "+ String.format("%3s %s %5s",fwy,dir,postmile)); 
     158                                " of type "+shortLoc+" not found. "+ String.format("%3s %s %5s",fwy,dir,postmile)); 
    163159                        missingVDS.add(vdsID); 
    164160                    } 
  • trunk/src/tmcsim/utilities/VehicleDetectionStation.java

    r272 r274  
    88 
    99/** 
    10  * Represent a single VDS. 
     10 * Represent a single VDS, "a logical grouping of detectors" at a particular  
     11 * location in one direction. 
    1112 * @author jdalbey 
    1213 */ 
     
    3334        lineScanner.next(); // skip City 
    3435        String raw_pm = lineScanner.next().trim(); 
    35         if (raw_pm.startsWith("R")) 
     36        // remove any postmile prefix, if it exists. 
     37        if (Character.isAlphabetic(raw_pm.charAt(0))) 
    3638        { 
    3739            raw_pm = raw_pm.substring(1); 
Note: See TracChangeset for help on using the changeset viewer.