Changeset 343 in tmcsimulator for trunk


Ignore:
Timestamp:
03/23/2019 05:40:52 PM (7 years ago)
Author:
jdalbey
Message:

Fix defect #117. Update HighwaysTest?.java for new highway model.

Location:
trunk
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/IDE_metadata/NetBeans/TMCSim/nbproject/project.properties

    r257 r343  
    11#Fri Oct 06 15:14:08 PDT 2017 
    22excludes= 
     3file.reference.json-simple-1.1.jar=../../../lib/json-simple-1.1.jar 
    34file.reference.SimTimeSelector_r28.jar=../../../lib/SimTimeSelector_r28.jar 
    45file.reference.xercesImpl.jar=../../../lib/xercesImpl.jar 
     
    5253    ${build.classes.dir}:\ 
    5354    ${libs.junit_4.classpath}:\ 
    54     ${libs.hamcrest.classpath} 
     55    ${libs.hamcrest.classpath}:\ 
     56    ${file.reference.json-simple-1.1.jar} 
    5557build.generated.dir=${build.dir}/generated 
    5658jar.compress=false 
  • trunk/src/atmsdriver/model/Highway.java

    r237 r343  
    33import atmsdriver.model.Station.DIRECTION; 
    44import java.util.ArrayList; 
     5import java.util.HashSet; 
    56import java.util.List; 
     7import java.util.Set; 
     8import java.util.SortedSet; 
     9import java.util.TreeSet; 
    610 
    711/** 
     
    1822    /** The ordered list of stations (lane detector stations) on this highway */ 
    1923    public final List<Station> stations; 
    20          
     24    /** The directions for this highway, either N/S or E/W */ 
     25    public final Set<DIRECTION> availDirs = new TreeSet<DIRECTION>(); 
     26     
    2127    /** Construct a highway  
    2228     *  
     
    2834        this.routeNumber = routeNumber; 
    2935        this.stations = stations; 
    30     } 
    31      
    32     /** 
    33      *  
    34      */ 
    35     public List<DIRECTION> getDirections() 
    36     { 
    37                     // Get available directions for route 
    38             ArrayList<DIRECTION> availDirs = new ArrayList<>(); 
     36        // Get available directions for route 
     37        if (stations != null) 
     38        { 
    3939            for(Station stn : stations) 
    4040            { 
    41                 if(!availDirs.contains(stn.direction)) 
    42                 { 
    43                     availDirs.add(stn.direction); 
    44                 } 
     41                availDirs.add(stn.direction); 
    4542            } 
    46             return availDirs; 
     43        } 
    4744    } 
    4845     
  • trunk/src/atmsdriver/model/Highways.java

    r306 r343  
    4343 * FEP Simulator. 
    4444 * 
    45  * Currently, there is no driving logic within the highways class. It is only 
    46  * done through an instance of the ConsoleDriver.java class. Eventually, it will 
    47  * receive incident data (from exchange.xml or better yet, directly from the 
    48  * TMCSimulator itself) and drive the highways using resident logic. 
    4945 * 
    5046 * @author John A. Torres 
     
    124120    } 
    125121 
     122    /** Search for a station with the given attributes  
     123     *  
     124     * @param routeNumber 
     125     * @param direction 
     126     * @param postmile 
     127     * @return the desired station, or null if not found. 
     128     */ 
     129    public Station findStation(Integer routeNumber, Station.DIRECTION direction, 
     130            Double postmile) 
     131    { 
     132        // Get the highway by route number 
     133        Highway highway = getHighwayByRouteNumber(routeNumber); 
     134        if (highway == null) 
     135        { 
     136            Logger.getLogger(Highways.class.getName()).log(Level.SEVERE,   
     137                    "Highway "+routeNumber+" not found in findStation()", ""); 
     138            return null; 
     139        } 
     140        //Search the stations on this highway for a match 
     141        for (Station station : highway.stations) 
     142        { 
     143            if (station.matches(direction, postmile)) 
     144            { 
     145                return station; 
     146            } 
     147        } 
     148        return null; 
     149    } 
    126150    /** 
    127151     * Applies specified color to the specified highway stretch. Route number 
     
    158182        // postmiles increase from s to n and w to e 
    159183        // if the direction is south or west 
    160         if (direction.equals(Station.DIRECTION.SOUTH) || direction.equals(Station.DIRECTION.WEST)) 
     184        if (direction.equals(Station.DIRECTION.NORTH) || direction.equals(Station.DIRECTION.EAST)) 
    161185        { 
    162186            // add range value to startPost to get 
     
    440464    /** 
    441465     * Returns the Highways model data in XML format. 
    442      *  
     466     * Probably obsolete, since we aren't using exchange.xml any longer. 
    443467     * @return highways data in XML format 
    444468     */ 
     
    507531        { 
    508532            // Consider each route direction 
    509             for (DIRECTION dir: DIRECTION.values()) 
     533            for (DIRECTION dir: hwy.availDirs) 
    510534            { 
    511535                String rowLabel = ""+String.format("%3s ",hwy.routeNumber)+dir.getLetter()+' '; 
     
    514538                for (Station stat: hwy.stations) 
    515539                { 
     540                    if (stat.direction.equals(dir)) 
     541                    { 
    516542                    //lineout.append("" + dir.getLetter() + stat.postmile); 
    517543                    lineout.append(stat.getColor()); 
    518544                    //lineout.append("  "); 
     545                    } 
     546                    else  
     547                    { 
     548                        lineout.append("."); 
     549                    } 
    519550                } 
    520551                // See if there were stations for this direction 
  • trunk/src/atmsdriver/model/LoopDetector.java

    r242 r343  
    9494        { 
    9595            build.append(this.loopLocationID); 
     96            build.append(" "); 
    9697        } 
    9798        build.append(this.loopLocation); 
  • trunk/src/atmsdriver/model/Station.java

    r285 r343  
    88 
    99/** 
    10  * A Station (LDS or Loop Detector Station) represents a group of lane detectors 
    11  * across all lanes at a particular point on a highway. A station is identified 
     10 * 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 
    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 
    1414 * and OppTotVol for a station can be dynamically updated. A station has other 
    15  * attributes: lineNum, ldsID, drop, and location which are used by the FEP. A 
     15 * attributes: lineNum, vdsID, drop, and location which are used by the FEP. A 
    1616 * station can be compared to other stations by its postmile. 
    1717 * 
    18  * @author John A. Torres 
    19  * @version 9/10/2017 
     18 * @author John A. Torres, jdalbey 
     19 * @version 9/10/2017, 3/22/2019 
    2020 */ 
    21 public class Station implements Comparable 
     21public final class Station implements Comparable 
    2222{ 
    2323 
    2424    /* Static Station meta data */ 
    2525    final public int lineID; 
    26     final public int ldsID; // double check 
     26    final public int vdsID; // double check 
    2727    final public int drop; 
    2828    final public String location; 
     
    3737 
    3838    /* Constructor */ 
    39     public Station(int lineID, int ldsID, int drop, 
     39    public Station(int lineID, int vdsID, int drop, 
    4040            String location, List<LoopDetector> loops, int hwy, 
    4141            DIRECTION direction, double postmile) 
    4242    { 
    4343        this.lineID = lineID; 
    44         this.ldsID = ldsID; 
     44        this.vdsID = vdsID; 
    4545        this.drop = drop; 
    4646        this.loops = loops; 
     
    109109    { 
    110110        StringBuilder build = new StringBuilder(); 
    111         build.append(Integer.toString(this.ldsID)); 
     111        build.append(Integer.toString(this.vdsID)); 
    112112        build.append(" "); 
    113113        build.append(Integer.toString(this.drop)); 
     
    170170 
    171171    /** 
     172     * See if this station matches the specified attributes. 
     173     * @param dir 
     174     * @param postmile 
     175     * @return true if this station's attributes match the given ones. 
     176     */ 
     177    public boolean matches(DIRECTION dir, double postmile) 
     178    { 
     179        double val = this.postmile - postmile; 
     180        return (Math.abs(val) < 0.01) && this.direction.equals(dir); 
     181    } 
     182    /** 
    172183     * Determine which lane fields to update based on given direction and update 
    173184     * all the loop detectors with the given color. 
     
    178189    public void updateByDirection(DIRECTION direction, DOTCOLOR dotColor) 
    179190    { 
    180         String laneDir = "OS"; 
     191        // Is this station going in the desired direction? 
    181192        if (direction.equals(this.direction)) 
    182193        { 
    183             laneDir = "ML"; 
    184         } 
    185         outputUpdateMessage(dotColor, laneDir); 
    186  
    187         for (LoopDetector loop : loops) 
    188         { 
    189             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    190             // creates a highway map based on VDS instead of Controller (LDS). 
    191 //            if (loop.loopLocation.startsWith(laneDir)) 
    192 //            { 
    193                 // UPDATE LOOP WITH VALUES 
    194                 loop.updateLoop(dotColor.volume(), dotColor.occupancy()); 
    195 //            } 
    196         } 
    197  
    198         this.MLTotVol = getMLTotVol(); 
    199         this.OppTotVol = getOPPTotVol(); 
    200     } 
    201      
     194            outputUpdateMessage(dotColor, direction.toString()); 
     195 
     196            for (LoopDetector loop : loops) 
     197            { 
     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    //            } 
     205            } 
     206 
     207            this.MLTotVol = getMLTotVol(); 
     208            this.OppTotVol = getOPPTotVol(); 
     209        } 
     210    } 
    202211    /** 
    203212     * Return the color for the lanes in a given direction. 
     
    316325 
    317326        Element ldsIDElement = theDoc.createElement(XML_TAGS.LDS_ID.tag); 
    318         ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.ldsID))); 
     327        ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.vdsID))); 
    319328        stationElement.appendChild(ldsIDElement); 
    320329 
     
    422431    public String toString() 
    423432    { 
    424         return Integer.toString(this.ldsID); 
     433        return Integer.toString(this.vdsID)+this.getColor(); 
    425434    } 
    426435} 
  • trunk/src/atmsdriver/trafficeventseditor/TrafficEventsEditor.java

    r257 r343  
    9090                TrafficLaneEvent currEvent = currFrame.events.get(i); 
    9191                data[i][0] = Integer.toString(currEvent.routeNum); 
    92                 data[i][1] = Integer.toString(currEvent.station.ldsID); 
     92                data[i][1] = Integer.toString(currEvent.station.vdsID); 
    9393                data[i][2] = Double.toString(currEvent.station.postmile); 
    9494                data[i][3] = Integer.toString(currEvent.loopDetector.loopID); 
     
    285285            for(int i = 0; i < rows; i++) 
    286286            { 
    287                 data[i][0] = Integer.toString(hwy.stations.get(i).ldsID); 
     287                data[i][0] = Integer.toString(hwy.stations.get(i).vdsID); 
    288288                data[i][1] = hwy.stations.get(i).direction.getLetter(); 
    289289                data[i][2] = Double.toString(hwy.stations.get(i).postmile); 
  • trunk/src/tmcsim/application.properties

    r340 r343  
    1 #Sat, 23 Mar 2019 09:47:19 -0700 
     1#Sat, 23 Mar 2019 19:09:36 -0700 
    22 
    3 Application.revision=339 
     3Application.revision=342 
    44 
    55Application.buildnumber=108 
  • trunk/test/atmsdriver/TrafficModelEventDriver.java

    r204 r343  
    2020 
    2121/** 
     22 * OBSOLETE: An interactive version is now available: 
     23 *    atmsdriver.TrafficEventsAnimator.java 
    2224 * Read and process all Traffic Events in a file and show 
    2325 * resulting highway network.  
  • trunk/test/atmsdriver/model/HighwaysTest.java

    r340 r343  
    22 
    33import archive.ATMSDriver; 
     4import atmsdriver.model.LoopDetector.DOTCOLOR; 
     5import atmsdriver.model.Station.DIRECTION; 
    46import java.io.File; 
    57import java.io.FileWriter; 
     
    911import java.nio.file.Path; 
    1012import junit.framework.TestCase; 
     13import org.json.simple.JSONArray; 
     14import org.json.simple.JSONObject; 
     15import org.json.simple.parser.JSONParser; 
     16import org.json.simple.parser.ParseException; 
    1117 
    1218/** 
     
    2834            writer.println("2"); 
    2935            writer.println("32 0 2"); 
    30             writer.println("1210831 1 5 S 0.9 8 CALAFIA"); 
     36            writer.println("1210831 1 5 S 0.9 4 CALAFIA"); 
    3137            writer.println("1210832 ML ML_1"); 
    3238            writer.println("1210833 ML ML_2"); 
    3339            writer.println("1210834 ML ML_3"); 
    3440            writer.println("1210835 ML ML_4"); 
    35             writer.println("1210836 PA PASSAGE"); 
    36             writer.println("1210837 DM DEMAND"); 
    37             writer.println("1210838 QU QUEUE"); 
    38             writer.println("1210839 FR RAMP_OFF"); 
    39             writer.println("1210845 2 5 S 1.49 9 EL CAMINO REAL"); 
     41            writer.println("1210845 2 5 S 1.49 4 EL CAMINO REAL"); 
    4042            writer.println("1210846 ML ML_1"); 
    4143            writer.println("1210847 ML ML_2"); 
    4244            writer.println("1210848 ML ML_3"); 
    4345            writer.println("1210849 ML ML_4"); 
    44             writer.println("1210850 OR RAMP_ON"); 
    45             writer.println("1210851 PA PASSAGE"); 
    46             writer.println("1210853 DM DEMAND"); 
    47             writer.println("1210854 QU QUEUE"); 
    48             writer.println("1210855 FR RAMP_OFF"); 
    4946            writer.println("74 0 1"); 
    50             writer.println("1204203 2 5 N 1.26 13 MAGDALENA"); 
    51             writer.println("1204205 OR RAMP_ON"); 
    52             writer.println("1204206 QU QUEUE"); 
    53             writer.println("1204207 DM DEMAND"); 
    54             writer.println("1204208 PA PASSAGE"); 
    55             writer.println("1204210 FR RAMP_OFF"); 
     47            writer.println("1204203 2 5 N 1.26 4 MAGDALENA"); 
    5648            writer.println("1204212 ML ML_1"); 
    5749            writer.println("1204213 ML ML_2"); 
    5850            writer.println("1204214 ML ML_3"); 
    5951            writer.println("1204215 ML ML_4"); 
    60             writer.println("1204217 OS OS_1"); 
    61             writer.println("1204218 OS OS_2"); 
    62             writer.println("1204219 OS OS_3"); 
    63             writer.println("1204220 OS OS_4"); 
    6452            writer.close(); 
    6553        } catch (Exception e) { 
     
    7563    } 
    7664 
     65    public void testFindStation() 
     66    { 
     67        System.out.println("test FindStation()"); 
     68        Highways highways = new Highways( 
     69                "test/atmsdriver/model/ldssample.txt", 
     70                "localhost", 8080); 
     71        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 0.9)); 
     72        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 1.49)); 
     73        assertTrue(null != highways.findStation(5, DIRECTION.NORTH, 1.26)); 
     74        assertTrue(null == highways.findStation(5, DIRECTION.SOUTH, 1.1)); 
     75    } 
    7776    /** 
    7877     * Test of toString method 
     
    8685        String result = highways.toString(); 
    8786        System.out.println(result); 
    88         assertTrue(result.startsWith(expToString1)); 
    89         highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 20.13, 4.0, LoopDetector.DOTCOLOR.RED); 
    90         result = highways.toString(); 
    91         assertEquals("241 N @@ @@@@@-",result.substring(0,15)); 
    92     } 
    93     String expToString1 =  
    94     "241 N -- ------ -- ------- -------------------------------------  \n" + 
    95 "241 S   - --- --  --------- ------------------------------------  \n" + 
    96 "  5 N  - - ------ ---  --- -- --- ----  - -- - -  -- - - -    -- -- - ---- -- -- --- - - -- -  ----- ----- --- -  - -- --  - - ---- - - - ------- \n" + 
    97 "  5 S @--"; 
    98  
    99     public void testToJson() { 
     87        String[] resultLines = result.split("\n"); 
     88        String actual = resultLines[3].substring(0,9); 
     89        assertEquals("  5 S @.-",actual); 
     90        highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 18.08, 1.0,  
     91                LoopDetector.DOTCOLOR.RED); 
     92        result = highways.toString(); 
     93        System.out.println("bravo:\n"+result); 
     94        assertEquals("241 N -@.@@.-",result.substring(0,13)); 
     95        highways.applyColorToHighwayStretch(241, Station.DIRECTION.SOUTH, 20.13, 2.0,  
     96                LoopDetector.DOTCOLOR.YELLOW); 
     97        result = highways.toString(); 
     98        System.out.println("charly:\n"+result); 
     99        resultLines = result.split("\n"); 
     100        actual = resultLines[1].substring(0,16); 
     101        assertEquals("241 S ..+..+.++.",actual); 
     102    } 
     103 
     104 
     105    public void testToJson() throws ParseException { 
    100106        System.out.println("toJson"); 
    101107        Highways highways = new Highways( 
     
    105111        System.out.println(result); 
    106112        assertTrue(result.indexOf("33.416348") > 0); 
     113        JSONParser parser = new JSONParser(); 
     114        JSONObject obj = (JSONObject) parser.parse(result); 
     115        System.out.println(obj); 
     116        JSONArray array = (JSONArray)obj.get("features"); 
     117        JSONObject item1 = (JSONObject)array.get(0); 
     118        String id1 = (String) item1.get("id"); 
     119        assertEquals("5 S 0.9", id1); 
     120        JSONObject item2 = (JSONObject)array.get(1); 
     121        String id2 = (String) item2.get("id"); 
     122        assertEquals("5 N 1.26", id2); 
     123        JSONObject item3 = (JSONObject)array.get(2); 
     124        String id3 = (String) item3.get("id"); 
     125        assertEquals("5 S 1.49", id3); 
    107126    } 
    108127    
     
    113132            "test/atmsdriver/model/ldssample.txt", 
    114133            "localhost", 8080); 
    115         highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0, LoopDetector.DOTCOLOR.RED); 
     134        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0,  
     135                LoopDetector.DOTCOLOR.RED); 
     136        Station target = highways.findStation(5, DIRECTION.SOUTH, 0.9); 
     137        assertEquals('@',target.getColor()); 
    116138        String result = highways.toString(); 
    117         assertEquals("5 N @@@", result.trim().substring(0,7)); 
    118         highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 20.13, 4.0, LoopDetector.DOTCOLOR.RED); 
    119         result = highways.toString(); 
    120         assertTrue(result.length()>0); //"241 N @@ @@@@@-",result.substring(0,15)); 
     139        System.out.println("applyto:\n"+result); 
     140        assertEquals("5 N .-.\n  5 S @.-", result.trim()); 
     141         
     142        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 2.0,  
     143                LoopDetector.DOTCOLOR.YELLOW); 
     144        result = highways.toString(); 
     145        assertEquals("5 N .-.\n  5 S +.+", result.trim()); 
     146         
     147        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 0.59,  
     148                LoopDetector.DOTCOLOR.GREEN); 
     149        result = highways.toString(); 
     150        assertEquals("5 N .-.\n  5 S -.-", result.trim()); 
     151 
     152        highways.applyColorToHighwayStretch(5, Station.DIRECTION.NORTH, 0.1, 2.0,  
     153                LoopDetector.DOTCOLOR.RED); 
     154        result = highways.toString(); 
     155        assertEquals("5 N .@.\n  5 S -.-", result.trim()); 
     156         
     157        //highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 20.13, 4.0, LoopDetector.DOTCOLOR.RED); 
     158        //result = highways.toString(); 
     159        //assertTrue(result.length()>0); //"241 N @@ @@@@@-",result.substring(0,15)); 
    121160 
    122161    }             
     
    131170        String actualCondensedFormatMeta = highways.toCondensedFormat(true); 
    132171        String actualCondensedFormatFEP = highways.toCondensedFormat(false); 
     172        System.out.println(actualCondensedFormatMeta); 
    133173         
    134174        assertEquals(expectedCondensedFormatFEP, actualCondensedFormatFEP); 
     
    138178            "2\n" + 
    139179            "32 0 2\n" + 
    140             "1210831 1 5 S 0.9 8 CALAFIA\n" + 
    141             "1210832 ML_1\n" + 
    142             "1210833 ML_2\n" + 
    143             "1210834 ML_3\n" + 
    144             "1210835 ML_4\n" + 
    145             "1210836 PASSAGE\n" + 
    146             "1210837 DEMAND\n" + 
    147             "1210838 QUEUE\n" + 
    148             "1210839 RAMP_OFF\n" + 
    149             "1210845 2 5 S 1.49 9 EL CAMINO REAL\n" + 
    150             "1210846 ML_1\n" + 
    151             "1210847 ML_2\n" + 
    152             "1210848 ML_3\n" + 
    153             "1210849 ML_4\n" + 
    154             "1210850 RAMP_ON\n" + 
    155             "1210851 PASSAGE\n" + 
    156             "1210853 DEMAND\n" + 
    157             "1210854 QUEUE\n" + 
    158             "1210855 RAMP_OFF\n" + 
     180            "1210831 1 5 S 0.9 4 CALAFIA\n" + 
     181            "1210832 ML ML_1\n" + 
     182            "1210833 ML ML_2\n" + 
     183            "1210834 ML ML_3\n" + 
     184            "1210835 ML ML_4\n" + 
     185            "1210845 2 5 S 1.49 4 EL CAMINO REAL\n" + 
     186            "1210846 ML ML_1\n" + 
     187            "1210847 ML ML_2\n" + 
     188            "1210848 ML ML_3\n" + 
     189            "1210849 ML ML_4\n" + 
    159190            "74 0 1\n" + 
    160             "1204203 2 5 N 1.26 13 MAGDALENA\n" + 
    161             "1204205 RAMP_ON\n" + 
    162             "1204206 QUEUE\n" + 
    163             "1204207 DEMAND\n" + 
    164             "1204208 PASSAGE\n" + 
    165             "1204210 RAMP_OFF\n" + 
    166             "1204212 ML_1\n" + 
    167             "1204213 ML_2\n" + 
    168             "1204214 ML_3\n" + 
    169             "1204215 ML_4\n" + 
    170             "1204217 OS_1\n" + 
    171             "1204218 OS_2\n" + 
    172             "1204219 OS_3\n" + 
    173             "1204220 OS_4\n"; 
     191            "1204203 2 5 N 1.26 4 MAGDALENA\n" + 
     192            "1204212 ML ML_1\n" + 
     193            "1204213 ML ML_2\n" + 
     194            "1204214 ML ML_3\n" + 
     195            "1204215 ML ML_4\n"; 
    174196    String expectedCondensedFormatFEP =  
    175197            "2\n" + 
    176198            "32 0 2\n" + 
    177             "1210831 1 5 S 0.9 8 \n" + 
     199            "1210831 1 5 S 0.9 4 \n" + 
    178200            "1210832  0.0 0 ML_1\n" + 
    179201            "1210833  0.0 0 ML_2\n" + 
    180202            "1210834  0.0 0 ML_3\n" + 
    181203            "1210835  0.0 0 ML_4\n" + 
    182             "1210836  0.0 0 PASSAGE\n" + 
    183             "1210837  0.0 0 DEMAND\n" + 
    184             "1210838  0.0 0 QUEUE\n" + 
    185             "1210839  0.0 0 RAMP_OFF\n" + 
    186             "1210845 2 5 S 1.49 9 \n" + 
     204            "1210845 2 5 S 1.49 4 \n" + 
    187205            "1210846  0.0 0 ML_1\n" + 
    188206            "1210847  0.0 0 ML_2\n" + 
    189207            "1210848  0.0 0 ML_3\n" + 
    190208            "1210849  0.0 0 ML_4\n" + 
    191             "1210850  0.0 0 RAMP_ON\n" + 
    192             "1210851  0.0 0 PASSAGE\n" + 
    193             "1210853  0.0 0 DEMAND\n" + 
    194             "1210854  0.0 0 QUEUE\n" + 
    195             "1210855  0.0 0 RAMP_OFF\n" + 
    196209            "74 0 1\n" + 
    197             "1204203 2 5 N 1.26 13 \n" + 
    198             "1204205  0.0 0 RAMP_ON\n" + 
    199             "1204206  0.0 0 QUEUE\n" + 
    200             "1204207  0.0 0 DEMAND\n" + 
    201             "1204208  0.0 0 PASSAGE\n" + 
    202             "1204210  0.0 0 RAMP_OFF\n" + 
     210            "1204203 2 5 N 1.26 4 \n" + 
    203211            "1204212  0.0 0 ML_1\n" + 
    204212            "1204213  0.0 0 ML_2\n" + 
    205213            "1204214  0.0 0 ML_3\n" + 
    206             "1204215  0.0 0 ML_4\n" + 
    207             "1204217  0.0 0 OS_1\n" + 
    208             "1204218  0.0 0 OS_2\n" + 
    209             "1204219  0.0 0 OS_3\n" + 
    210             "1204220  0.0 0 OS_4\n"; 
     214            "1204215  0.0 0 ML_4\n"; 
    211215     
    212     /** 
    213      * Test of toXML method 
    214      */ 
    215     public void testToXML() { 
    216         System.out.println("toXML"); 
    217         Highways highways = new Highways( 
    218                 "test/atmsdriver/model/ldssample.txt", 
    219                 "localhost", 8080); 
    220         String result = highways.toXML(); 
    221         assertEquals(expXMLResult, result); 
    222     } 
    223 String expXMLResult = 
    224 "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" + 
    225 "<Network>\n" + 
    226 "  <Line>\n" + 
    227 "    <Line_Num>32</Line_Num>\n" + 
    228 "    <Count>0</Count>\n" + 
    229 "    <Stations>\n" + 
    230 "      <Station>\n" + 
    231 "        <LDS_ID>1210831</LDS_ID>\n" + 
    232 "        <Line_Num>32</Line_Num>\n" + 
    233 "        <Drop>1</Drop>\n" + 
    234 "        <Location>CALAFIA</Location>\n" + 
    235 "        <Post_Mile>0.9</Post_Mile>\n" + 
    236 "        <Direction>S</Direction>\n" + 
    237 "        <Freeway>5</Freeway>\n" + 
    238 "        <ML_Tot_Vol>0</ML_Tot_Vol>\n" + 
    239 "        <Opp_Tot_Vol>0</Opp_Tot_Vol>\n" + 
    240 "        <Loops>\n" + 
    241 "          <Loop>\n" + 
    242 "            <Loop_ID>1210832</Loop_ID>\n" + 
    243 "            <Loop_Location>ML_1</Loop_Location>\n" + 
    244 "            <Vol>0</Vol>\n" + 
    245 "            <Occ>0.0</Occ>\n" + 
    246 "          </Loop>\n" + 
    247 "          <Loop>\n" + 
    248 "            <Loop_ID>1210833</Loop_ID>\n" + 
    249 "            <Loop_Location>ML_2</Loop_Location>\n" + 
    250 "            <Vol>0</Vol>\n" + 
    251 "            <Occ>0.0</Occ>\n" + 
    252 "          </Loop>\n" + 
    253 "          <Loop>\n" + 
    254 "            <Loop_ID>1210834</Loop_ID>\n" + 
    255 "            <Loop_Location>ML_3</Loop_Location>\n" + 
    256 "            <Vol>0</Vol>\n" + 
    257 "            <Occ>0.0</Occ>\n" + 
    258 "          </Loop>\n" + 
    259 "          <Loop>\n" + 
    260 "            <Loop_ID>1210835</Loop_ID>\n" + 
    261 "            <Loop_Location>ML_4</Loop_Location>\n" + 
    262 "            <Vol>0</Vol>\n" + 
    263 "            <Occ>0.0</Occ>\n" + 
    264 "          </Loop>\n" + 
    265 "          <Loop>\n" + 
    266 "            <Loop_ID>1210836</Loop_ID>\n" + 
    267 "            <Loop_Location>PASSAGE</Loop_Location>\n" + 
    268 "            <Vol>0</Vol>\n" + 
    269 "            <Occ>0.0</Occ>\n" + 
    270 "          </Loop>\n" + 
    271 "          <Loop>\n" + 
    272 "            <Loop_ID>1210837</Loop_ID>\n" + 
    273 "            <Loop_Location>DEMAND</Loop_Location>\n" + 
    274 "            <Vol>0</Vol>\n" + 
    275 "            <Occ>0.0</Occ>\n" + 
    276 "          </Loop>\n" + 
    277 "          <Loop>\n" + 
    278 "            <Loop_ID>1210838</Loop_ID>\n" + 
    279 "            <Loop_Location>QUEUE</Loop_Location>\n" + 
    280 "            <Vol>0</Vol>\n" + 
    281 "            <Occ>0.0</Occ>\n" + 
    282 "          </Loop>\n" + 
    283 "          <Loop>\n" + 
    284 "            <Loop_ID>1210839</Loop_ID>\n" + 
    285 "            <Loop_Location>RAMP_OFF</Loop_Location>\n" + 
    286 "            <Vol>0</Vol>\n" + 
    287 "            <Occ>0.0</Occ>\n" + 
    288 "          </Loop>\n" + 
    289 "        </Loops>\n" + 
    290 "      </Station>\n" + 
    291 "      <Station>\n" + 
    292 "        <LDS_ID>1210845</LDS_ID>\n" + 
    293 "        <Line_Num>32</Line_Num>\n" + 
    294 "        <Drop>2</Drop>\n" + 
    295 "        <Location>EL CAMINO REAL</Location>\n" + 
    296 "        <Post_Mile>1.49</Post_Mile>\n" + 
    297 "        <Direction>S</Direction>\n" + 
    298 "        <Freeway>5</Freeway>\n" + 
    299 "        <ML_Tot_Vol>0</ML_Tot_Vol>\n" + 
    300 "        <Opp_Tot_Vol>0</Opp_Tot_Vol>\n" + 
    301 "        <Loops>\n" + 
    302 "          <Loop>\n" + 
    303 "            <Loop_ID>1210846</Loop_ID>\n" + 
    304 "            <Loop_Location>ML_1</Loop_Location>\n" + 
    305 "            <Vol>0</Vol>\n" + 
    306 "            <Occ>0.0</Occ>\n" + 
    307 "          </Loop>\n" + 
    308 "          <Loop>\n" + 
    309 "            <Loop_ID>1210847</Loop_ID>\n" + 
    310 "            <Loop_Location>ML_2</Loop_Location>\n" + 
    311 "            <Vol>0</Vol>\n" + 
    312 "            <Occ>0.0</Occ>\n" + 
    313 "          </Loop>\n" + 
    314 "          <Loop>\n" + 
    315 "            <Loop_ID>1210848</Loop_ID>\n" + 
    316 "            <Loop_Location>ML_3</Loop_Location>\n" + 
    317 "            <Vol>0</Vol>\n" + 
    318 "            <Occ>0.0</Occ>\n" + 
    319 "          </Loop>\n" + 
    320 "          <Loop>\n" + 
    321 "            <Loop_ID>1210849</Loop_ID>\n" + 
    322 "            <Loop_Location>ML_4</Loop_Location>\n" + 
    323 "            <Vol>0</Vol>\n" + 
    324 "            <Occ>0.0</Occ>\n" + 
    325 "          </Loop>\n" + 
    326 "          <Loop>\n" + 
    327 "            <Loop_ID>1210850</Loop_ID>\n" + 
    328 "            <Loop_Location>RAMP_ON</Loop_Location>\n" + 
    329 "            <Vol>0</Vol>\n" + 
    330 "            <Occ>0.0</Occ>\n" + 
    331 "          </Loop>\n" + 
    332 "          <Loop>\n" + 
    333 "            <Loop_ID>1210851</Loop_ID>\n" + 
    334 "            <Loop_Location>PASSAGE</Loop_Location>\n" + 
    335 "            <Vol>0</Vol>\n" + 
    336 "            <Occ>0.0</Occ>\n" + 
    337 "          </Loop>\n" + 
    338 "          <Loop>\n" + 
    339 "            <Loop_ID>1210853</Loop_ID>\n" + 
    340 "            <Loop_Location>DEMAND</Loop_Location>\n" + 
    341 "            <Vol>0</Vol>\n" + 
    342 "            <Occ>0.0</Occ>\n" + 
    343 "          </Loop>\n" + 
    344 "          <Loop>\n" + 
    345 "            <Loop_ID>1210854</Loop_ID>\n" + 
    346 "            <Loop_Location>QUEUE</Loop_Location>\n" + 
    347 "            <Vol>0</Vol>\n" + 
    348 "            <Occ>0.0</Occ>\n" + 
    349 "          </Loop>\n" + 
    350 "          <Loop>\n" + 
    351 "            <Loop_ID>1210855</Loop_ID>\n" + 
    352 "            <Loop_Location>RAMP_OFF</Loop_Location>\n" + 
    353 "            <Vol>0</Vol>\n" + 
    354 "            <Occ>0.0</Occ>\n" + 
    355 "          </Loop>\n" + 
    356 "        </Loops>\n" + 
    357 "      </Station>\n" + 
    358 "    </Stations>\n" + 
    359 "  </Line>\n" + 
    360 "  <Line>\n" + 
    361 "    <Line_Num>74</Line_Num>\n" + 
    362 "    <Count>0</Count>\n" + 
    363 "    <Stations>\n" + 
    364 "      <Station>\n" + 
    365 "        <LDS_ID>1204203</LDS_ID>\n" + 
    366 "        <Line_Num>74</Line_Num>\n" + 
    367 "        <Drop>2</Drop>\n" + 
    368 "        <Location>MAGDALENA</Location>\n" + 
    369 "        <Post_Mile>1.26</Post_Mile>\n" + 
    370 "        <Direction>N</Direction>\n" + 
    371 "        <Freeway>5</Freeway>\n" + 
    372 "        <ML_Tot_Vol>0</ML_Tot_Vol>\n" + 
    373 "        <Opp_Tot_Vol>0</Opp_Tot_Vol>\n" + 
    374 "        <Loops>\n" + 
    375 "          <Loop>\n" + 
    376 "            <Loop_ID>1204205</Loop_ID>\n" + 
    377 "            <Loop_Location>RAMP_ON</Loop_Location>\n" + 
    378 "            <Vol>0</Vol>\n" + 
    379 "            <Occ>0.0</Occ>\n" + 
    380 "          </Loop>\n" + 
    381 "          <Loop>\n" + 
    382 "            <Loop_ID>1204206</Loop_ID>\n" + 
    383 "            <Loop_Location>QUEUE</Loop_Location>\n" + 
    384 "            <Vol>0</Vol>\n" + 
    385 "            <Occ>0.0</Occ>\n" + 
    386 "          </Loop>\n" + 
    387 "          <Loop>\n" + 
    388 "            <Loop_ID>1204207</Loop_ID>\n" + 
    389 "            <Loop_Location>DEMAND</Loop_Location>\n" + 
    390 "            <Vol>0</Vol>\n" + 
    391 "            <Occ>0.0</Occ>\n" + 
    392 "          </Loop>\n" + 
    393 "          <Loop>\n" + 
    394 "            <Loop_ID>1204208</Loop_ID>\n" + 
    395 "            <Loop_Location>PASSAGE</Loop_Location>\n" + 
    396 "            <Vol>0</Vol>\n" + 
    397 "            <Occ>0.0</Occ>\n" + 
    398 "          </Loop>\n" + 
    399 "          <Loop>\n" + 
    400 "            <Loop_ID>1204210</Loop_ID>\n" + 
    401 "            <Loop_Location>RAMP_OFF</Loop_Location>\n" + 
    402 "            <Vol>0</Vol>\n" + 
    403 "            <Occ>0.0</Occ>\n" + 
    404 "          </Loop>\n" + 
    405 "          <Loop>\n" + 
    406 "            <Loop_ID>1204212</Loop_ID>\n" + 
    407 "            <Loop_Location>ML_1</Loop_Location>\n" + 
    408 "            <Vol>0</Vol>\n" + 
    409 "            <Occ>0.0</Occ>\n" + 
    410 "          </Loop>\n" + 
    411 "          <Loop>\n" + 
    412 "            <Loop_ID>1204213</Loop_ID>\n" + 
    413 "            <Loop_Location>ML_2</Loop_Location>\n" + 
    414 "            <Vol>0</Vol>\n" + 
    415 "            <Occ>0.0</Occ>\n" + 
    416 "          </Loop>\n" + 
    417 "          <Loop>\n" + 
    418 "            <Loop_ID>1204214</Loop_ID>\n" + 
    419 "            <Loop_Location>ML_3</Loop_Location>\n" + 
    420 "            <Vol>0</Vol>\n" + 
    421 "            <Occ>0.0</Occ>\n" + 
    422 "          </Loop>\n" + 
    423 "          <Loop>\n" + 
    424 "            <Loop_ID>1204215</Loop_ID>\n" + 
    425 "            <Loop_Location>ML_4</Loop_Location>\n" + 
    426 "            <Vol>0</Vol>\n" + 
    427 "            <Occ>0.0</Occ>\n" + 
    428 "          </Loop>\n" + 
    429 "          <Loop>\n" + 
    430 "            <Loop_ID>1204217</Loop_ID>\n" + 
    431 "            <Loop_Location>OS_1</Loop_Location>\n" + 
    432 "            <Vol>0</Vol>\n" + 
    433 "            <Occ>0.0</Occ>\n" + 
    434 "          </Loop>\n" + 
    435 "          <Loop>\n" + 
    436 "            <Loop_ID>1204218</Loop_ID>\n" + 
    437 "            <Loop_Location>OS_2</Loop_Location>\n" + 
    438 "            <Vol>0</Vol>\n" + 
    439 "            <Occ>0.0</Occ>\n" + 
    440 "          </Loop>\n" + 
    441 "          <Loop>\n" + 
    442 "            <Loop_ID>1204219</Loop_ID>\n" + 
    443 "            <Loop_Location>OS_3</Loop_Location>\n" + 
    444 "            <Vol>0</Vol>\n" + 
    445 "            <Occ>0.0</Occ>\n" + 
    446 "          </Loop>\n" + 
    447 "          <Loop>\n" + 
    448 "            <Loop_ID>1204220</Loop_ID>\n" + 
    449 "            <Loop_Location>OS_4</Loop_Location>\n" + 
    450 "            <Vol>0</Vol>\n" + 
    451 "            <Occ>0.0</Occ>\n" + 
    452 "          </Loop>\n" + 
    453 "        </Loops>\n" + 
    454 "      </Station>\n" + 
    455 "    </Stations>\n" + 
    456 "  </Line>\n" + 
    457 "</Network>\n"; 
    458216} 
  • trunk/test/atmsdriver/model/LoadHighwaysTest.java

    r212 r343  
    2929            writer.println("2"); 
    3030            writer.println("32 0 2"); 
    31             writer.println("1210831 1 5 S 0.9 8 CALAFIA"); 
    32             writer.println("1210832 ML_1"); 
    33             writer.println("1210833 ML_2"); 
    34             writer.println("1210834 ML_3"); 
    35             writer.println("1210835 ML_4"); 
    36             writer.println("1210836 PASSAGE"); 
    37             writer.println("1210837 DEMAND"); 
    38             writer.println("1210838 QUEUE"); 
    39             writer.println("1210839 RAMP_OFF"); 
    40             writer.println("1210845 2 5 S 1.49 9 EL CAMINO REAL"); 
    41             writer.println("1210846 ML_1"); 
    42             writer.println("1210847 ML_2"); 
    43             writer.println("1210848 ML_3"); 
    44             writer.println("1210849 ML_4"); 
    45             writer.println("1210850 RAMP_ON"); 
    46             writer.println("1210851 PASSAGE"); 
    47             writer.println("1210853 DEMAND"); 
    48             writer.println("1210854 QUEUE"); 
    49             writer.println("1210855 RAMP_OFF"); 
     31            writer.println("1210831 1 5 S 0.9 4 CALAFIA"); 
     32            writer.println("1210832 ML ML_1"); 
     33            writer.println("1210833 ML ML_2"); 
     34            writer.println("1210834 ML ML_3"); 
     35            writer.println("1210835 ML ML_4"); 
     36            writer.println("1210845 2 5 S 1.49 4 EL CAMINO REAL"); 
     37            writer.println("1210846 ML ML_1"); 
     38            writer.println("1210847 ML ML_2"); 
     39            writer.println("1210848 ML ML_3"); 
     40            writer.println("1210849 ML ML_4"); 
    5041            writer.println("74 0 1"); 
    51             writer.println("1204203 2 5 N 1.26 13 MAGDALENA"); 
    52             writer.println("1204205 RAMP_ON"); 
    53             writer.println("1204206 QUEUE"); 
    54             writer.println("1204207 DEMAND"); 
    55             writer.println("1204208 PASSAGE"); 
    56             writer.println("1204210 RAMP_OFF"); 
    57             writer.println("1204212 ML_1"); 
    58             writer.println("1204213 ML_2"); 
    59             writer.println("1204214 ML_3"); 
    60             writer.println("1204215 ML_4"); 
    61             writer.println("1204217 OS_1"); 
    62             writer.println("1204218 OS_2"); 
    63             writer.println("1204219 OS_3"); 
    64             writer.println("1204220 OS_4"); 
     42            writer.println("1204203 2 5 N 1.26 4 MAGDALENA"); 
     43            writer.println("1204212 ML ML_1"); 
     44            writer.println("1204213 ML ML_2"); 
     45            writer.println("1204214 ML ML_3"); 
     46            writer.println("1204215 ML ML_4"); 
    6547            writer.close(); 
    6648        } catch (Exception e) { 
     
    7759 
    7860    /** 
    79      * Test of toXML method, of class Network. 
     61     * Test of Highways constructor  
    8062     */ 
    8163    public void testLoadHighways() { 
     
    11799         
    118100        // Test for correct number of loops 
    119         assertEquals(new Integer(30), new Integer(fiveS.stations.get(0).loops.size() 
     101        assertEquals(new Integer(12), new Integer(fiveS.stations.get(0).loops.size() 
    120102            + fiveS.stations.get(1).loops.size() + fiveS.stations.get(2).loops.size())); 
    121103    } 
  • trunk/test/atmsdriver/model/StationTest.java

    r186 r343  
    7474    } 
    7575 
     76    public void testMatches() 
     77    { 
     78        Station alpha = new Station(1,2,3,"A",new ArrayList<LoopDetector>(), 4, DIRECTION.NORTH, 2.0); 
     79        assertTrue(alpha.matches(DIRECTION.NORTH, 2.0)); 
     80        assertFalse(alpha.matches(DIRECTION.NORTH,2.1)); 
     81    } 
    7682    /** 
    7783     * TODO: Test of toXML method, of class Station. 
Note: See TracChangeset for help on using the changeset viewer.