Changeset 274 in tmcsimulator for trunk/src/atmsdriver/model/Highways.java


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.

File:
1 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 
Note: See TracChangeset for help on using the changeset viewer.