Changeset 422 in tmcsimulator


Ignore:
Timestamp:
06/23/2019 10:27:35 AM (7 years ago)
Author:
jdalbey
Message:

Remove ATMS functionality. Reworked and simplified the Highway model to use only VDS data from PeMS. Updated all unit tests.

Location:
trunk
Files:
2 added
3 deleted
19 edited
13 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/atmsdriver/ConsoleTrafficDriver.java

    r255 r422  
    11package atmsdriver; 
    22 
    3 import atmsdriver.model.Highways; 
    4 import atmsdriver.model.Station.DIRECTION; 
    5 import atmsdriver.model.Highway; 
    6 import atmsdriver.model.Station; 
    7 import atmsdriver.model.LoopDetector.DOTCOLOR; 
     3import tmcsim.highwaymodel.Highways; 
     4import tmcsim.highwaymodel.Station.DIRECTION; 
     5import tmcsim.highwaymodel.Highway; 
     6import tmcsim.highwaymodel.Station; 
     7import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
    88import java.io.FileInputStream; 
    99import java.util.ArrayList; 
     
    4949                // Create the Highway Model 
    5050                Highways highways = new Highways( 
    51                     "config/vds_data/highways_fullmap.txt", 
    52                     ConsoleDriverProperties.getProperty( 
    53                         "FEPWriterHost"), 
    54                     Integer.parseInt(ConsoleDriverProperties.getProperty( 
    55                         "FEPWriterPort"))); 
     51                    "config/vds_data/highways_fullmap.txt"); 
    5652 
    5753                // Construct the console driver using the highways model 
     
    139135            { 
    140136                // Send highway model to FEP for transmit to ATMS 
    141                 try { 
    142                     highways.writeToFEP(); 
    143                 } catch (SimulationException ex) { 
    144                     System.out.println("Skipping writeToFEP..."); 
    145                 } 
     137                highways.toJson(); 
    146138                System.out.println("Add another entry or Quit? (A/Q)"); 
    147139                choice = sc.next().toUpperCase().trim().charAt(0); 
  • trunk/src/atmsdriver/GoogleMapAnimator.java

    r340 r422  
    11package atmsdriver; 
    22 
    3 import atmsdriver.model.Highways; 
    4 import atmsdriver.model.TrafficEvent; 
     3import tmcsim.highwaymodel.Highways; 
     4import tmcsim.highwaymodel.TrafficEvent; 
    55import java.io.FileInputStream; 
    66import java.io.FileNotFoundException; 
     
    6767        incidents = new HashMap<String, List<TrafficEvent>>(); 
    6868        highways = new Highways( 
    69                 "config/vds_data/highways_fullmap.txt", 
    70                 // following aren't used by this application 
    71                 "localhost", 8080); 
     69                "config/vds_data/highways_fullmap.txt"); 
    7270        final String CONFIG_FILE_NAME = "traffic_model_config.properties"; 
    7371        String propertiesFile = "config" + System.getProperty("file.separator")  
  • trunk/src/atmsdriver/TrafficEventsAnimator.java

    r246 r422  
    11package atmsdriver; 
    22 
    3 import atmsdriver.model.Highways; 
    4 import atmsdriver.model.TrafficEvent; 
     3import tmcsim.highwaymodel.Highways; 
     4import tmcsim.highwaymodel.TrafficEvent; 
    55import java.io.FileInputStream; 
    66import java.io.FileNotFoundException; 
     
    6666        incidents = new HashMap<String, List<TrafficEvent>>(); 
    6767        highways = new Highways( 
    68                 "config/vds_data/highways_fullmap.txt", 
    69                 // following aren't used by this application 
    70                 "localhost", 8080); 
     68                "config/vds_data/highways_fullmap.txt"); 
    7169        final String CONFIG_FILE_NAME = "traffic_model_config.properties"; 
    7270        String propertiesFile = "config" + System.getProperty("file.separator")  
  • trunk/src/atmsdriver/trafficeventseditor/TimeFrames.java

    r240 r422  
    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  */ 
     1 
    62package atmsdriver.trafficeventseditor; 
    73 
    8 import atmsdriver.model.Highway; 
    9 import atmsdriver.model.Highways; 
    10 import atmsdriver.model.LoopDetector; 
    11 import atmsdriver.model.LoopDetector.DOTCOLOR; 
    12 import atmsdriver.model.Station; 
     4import tmcsim.highwaymodel.Highway; 
     5import tmcsim.highwaymodel.Highways; 
     6import tmcsim.highwaymodel.LoopDetector; 
     7import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
     8import tmcsim.highwaymodel.Station; 
    139import java.util.ArrayList; 
    1410import java.util.List; 
     
    3531    { 
    3632        frames = new ArrayList<>(); 
    37         highways = new Highways("./config/vds_data/highways_fullmap.txt",  
    38                 "192.168.251.46", 8080); 
     33        highways = new Highways("./config/vds_data/postmile_coordinates.txt"); 
    3934    } 
    4035     
     
    194189    void writeToFEP() 
    195190    { 
    196         try 
    197         { 
    198             highways.writeToFEP(); 
    199         }  
    200         catch (SimulationException ex) 
    201         { 
    202             System.out.println("writeToFEP() failed"); 
    203         } 
     191            highways.toJson(); 
    204192    } 
    205193 
  • trunk/src/atmsdriver/trafficeventseditor/TrafficEventsEditor.java

    r343 r422  
    11package atmsdriver.trafficeventseditor; 
    22 
    3 import atmsdriver.model.Highway; 
    4 import atmsdriver.model.LoopDetector; 
    5 import atmsdriver.model.LoopDetector.DOTCOLOR; 
    6 import atmsdriver.model.Station; 
     3import tmcsim.highwaymodel.Highway; 
     4import tmcsim.highwaymodel.LoopDetector; 
     5import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
     6import tmcsim.highwaymodel.Station; 
    77import timeselector.*; 
    88import java.io.File; 
  • trunk/src/atmsdriver/trafficeventseditor/TrafficLaneEvent.java

    r238 r422  
    11package atmsdriver.trafficeventseditor; 
    22 
    3 import atmsdriver.model.LoopDetector; 
    4 import atmsdriver.model.LoopDetector.DOTCOLOR; 
    5 import atmsdriver.model.Station; 
     3import tmcsim.highwaymodel.LoopDetector; 
     4import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
     5import tmcsim.highwaymodel.Station; 
    66 
    77/** 
  • trunk/src/tmcsim/application.properties

    r419 r422  
    1 #Thu, 20 Jun 2019 14:43:41 -0700 
     1#Sun, 23 Jun 2019 11:49:46 -0700 
    22 
    3 Application.revision=417 
     3Application.revision=419 
    44 
    55Application.buildnumber=140 
  • trunk/src/tmcsim/cadsimulator/managers/TrafficModelManager.java

    r407 r422  
    22 
    33import atmsdriver.GoogleMapAnimator; 
    4 import atmsdriver.model.Highways; 
    5 import atmsdriver.model.LoopDetector; 
    6 import atmsdriver.model.TrafficEvent; 
     4import tmcsim.highwaymodel.Highways; 
     5import tmcsim.highwaymodel.LoopDetector; 
     6import tmcsim.highwaymodel.TrafficEvent; 
    77import java.awt.event.ActionEvent; 
    88import java.awt.event.ActionListener; 
     
    129129            incidents = new HashMap<String, List<TrafficEvent>>(); 
    130130            highways = new Highways( 
    131                     props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name), 
    132                     props.getProperty(PROPERTIES.FEPSIM_IP_ADDR.name), 
    133                     8080);  
     131                    props.getProperty(PROPERTIES.HIGHWAYS_MAP_FILE.name));  
    134132            this.theCoordinator = theCoordinator; 
    135133        } 
     
    211209        timer.start(); 
    212210 
    213         if (props.getProperty(PROPERTIES.OUTPUT_DEST.name).equals("FEP")) 
    214         { 
    215             // Start the FEP thread (to update ATMS every 30 sec). (See class def below) 
    216             Thread wtfep = new WriteToFEPThread(); 
    217             wtfep.start(); 
    218         } 
    219         else 
    220         { 
    221             Thread wtConsole = new WriteToConsoleThread(); 
    222             wtConsole.start(); 
    223         } 
    224211        // Always write to json for google map display 
    225212        Thread wtJson = new WriteToJsonThread(); 
     
    411398    } 
    412399 
    413     class WriteToConsoleThread extends Thread 
    414     { 
    415  
    416         public void run() 
    417         { 
    418             System.out.println("WriteToConsole Thread starting."); 
    419             // Run indefinitely 
    420             while (true) 
    421             { 
    422                  // Write the highway network status to the Console 
    423                  System.out.println(highways.toString()); 
    424                 // Pause the thread 
    425                 try 
    426                 { 
    427                     Thread.sleep(10000); 
    428                 } 
    429                 catch (InterruptedException ie) 
    430                 { 
    431                     ie.printStackTrace(); 
    432                 } 
    433             } 
    434  
    435         } 
    436     } 
    437400    /** Writes the highway model to a GeoJson file for reading 
    438401     *  by Google Maps. 
     
    475438    } 
    476439     
    477     class WriteToFEPThread extends Thread 
    478     { 
    479  
    480         public void run() 
    481         { 
    482             System.out.println("WriteToFEP Thread starting."); 
    483             // Run indefinitely 
    484             boolean running = true; 
    485             while (running) 
    486             { 
    487                 try 
    488                 { 
    489                     // Write the highway network status to the FEP Simulator 
    490                     highways.writeToFEP(); 
    491                 } 
    492                 catch (SimulationException ex) 
    493                 { 
    494                     // Ask user if they want to proceed without FEP Sim connection 
    495 //                    int reply = JOptionPane.showConfirmDialog(null, "Failed to connect to FEP Sim, proceed anyway?", "Network Failure", JOptionPane.YES_NO_OPTION); 
    496 //                    if (reply == JOptionPane.NO_OPTION) 
    497 //                    { 
    498 //                        System.exit(0); 
    499 //                    } 
    500                     System.out.println("Skipping writeToFEP..."); 
    501                     running = false; 
    502                 } 
    503  
    504                 // Wait for FEP Sim to process the data we just sent 
    505                 try 
    506                 { 
    507                     Thread.sleep(FEPSIM_INTERVAL); 
    508                 } 
    509                 catch (InterruptedException ie) 
    510                 { 
    511                     ie.printStackTrace(); 
    512                 } 
    513             } 
    514  
    515         } 
    516     } 
     440     
    517441} 
  • trunk/src/tmcsim/cadsimulator/viewer/TrafficModelViewPanel.java

    r277 r422  
    11package tmcsim.cadsimulator.viewer; 
    22 
    3 import atmsdriver.model.TrafficEvent; 
     3import tmcsim.highwaymodel.TrafficEvent; 
    44import java.util.LinkedList; 
    55import java.util.List; 
  • trunk/src/tmcsim/highwaymodel/Highway.java

    r353 r422  
    1 package atmsdriver.model; 
     1package tmcsim.highwaymodel; 
    22 
    3 import atmsdriver.model.Station.DIRECTION; 
     3import tmcsim.highwaymodel.Station.DIRECTION; 
    44import java.util.ArrayList; 
    55import java.util.HashSet; 
  • trunk/src/tmcsim/highwaymodel/Highways.java

    r398 r422  
    1 package atmsdriver.model; 
     1package tmcsim.highwaymodel; 
    22 
    33import atmsdriver.trafficeventseditor.TrafficLaneEvent; 
    4 import atmsdriver.model.LoopDetector.DOTCOLOR; 
    5 import atmsdriver.model.Station.DIRECTION; 
     4import tmcsim.highwaymodel.Station.DIRECTION; 
    65import java.io.File; 
    76import java.io.FileInputStream; 
    87import java.io.FileNotFoundException; 
    9 import java.io.IOException; 
    10 import java.io.PrintWriter; 
    11 import java.io.StringWriter; 
    12 import java.io.Writer; 
    13 import java.net.Socket; 
    148import java.util.ArrayList; 
    159import java.util.Collections; 
     
    2115import java.util.logging.Level; 
    2216import java.util.logging.Logger; 
    23 import javax.xml.parsers.DocumentBuilder; 
    24 import javax.xml.parsers.DocumentBuilderFactory; 
    25 import javax.xml.transform.OutputKeys; 
    26 import javax.xml.transform.Transformer; 
    27 import javax.xml.transform.TransformerFactory; 
    28 import javax.xml.transform.dom.DOMSource; 
    29 import javax.xml.transform.stream.StreamResult; 
    30 import org.w3c.dom.Document; 
    31 import org.w3c.dom.Element; 
    32 import tmcsim.common.SimulationException; 
    3317 
    3418/** 
    35  * The Highways class aggregates all Highway instances within a geographic 
    36  * region, and all of the FEPLines within an electronic detector network, in the 
    37  * same geographic region. An instance of Highways.java comprises the underlying 
    38  * model for the ATMSDriver application. 
     19 * Highways represents California state highways supervised by CalTrans.  
     20 * The highways have sensors to detect traffic flow.  In the simulation 
     21 * the traffic flow is artificially created and Highways maintains the 
     22 * current levels of traffic flow throughout the network. 
    3923 * 
    40  * Highways uses method writeToFEP() to communicate with the FEP Simulator. It 
    41  * creates a socket client which sends the FEP Simulator a highways status 
    42  * message over the socket. This message is sent in the format required by the 
    43  * FEP Simulator. 
     24 * Highways builds an internal representation of the highway network 
     25 * from VDS data (obtained from PeMS) The current state of the network 
     26 * is output to a json file for use by CPTMS.  
    4427 * 
    45  * 
    46  * @author John A. Torres 
     28 * @author John A. Torres, jdalbey 
    4729 */ 
    4830final public class Highways 
    4931{ 
    50  
    51     final private String FEPHostName; 
    52     final private int FEPPortNum; 
    53      
    54     final private List<FEPLine> lines; 
    5532    final public List<Highway> highways; 
    5633 
    57     public Highways(String highwaysMapFileName, String FEPHostName, int FEPPortNum) 
    58     { 
    59         // load FEP Lines 
    60         lines = loadLines(highwaysMapFileName); 
    61         // build highways data structure 
    62         this.highways = buildHighways(); 
    63  
    64         // write to FEP host and port number 
    65         this.FEPHostName = FEPHostName; 
    66         this.FEPPortNum = FEPPortNum; 
    67     } 
    68  
    69     private ArrayList<Highway> buildHighways() 
    70     { 
     34    public Highways(String highwaysMapFileName) 
     35    { 
     36       // build highways data structure 
     37        this.highways = buildHighwayNetwork(highwaysMapFileName); 
     38    } 
     39     
     40    private ArrayList<Highway> buildHighwayNetwork(String highwaysMapFileName) 
     41    { 
     42        // NOTE: Could this method be streamlined? Is it necessary to have the 
     43        // second data structure? 
    7144        System.out.println("Building highways..."); 
    7245        // The list of highways to return 
     
    7649        Map<Integer, ArrayList<Station>> highwayMap = new HashMap<>(); 
    7750         
    78         // iterate through FEPLines and get data to add to the above map 
    79         for (FEPLine line : lines) 
    80         { 
    81             // grab all stations from the current FEPLine 
    82             ArrayList<Station> lineStations = (ArrayList<Station>) line.stations; 
    83             // iterate through each station in the list of stations 
    84             for (Station station : lineStations) 
    85             { 
     51        // Open the postmile file and scan each line 
     52        File file = new File(highwaysMapFileName); 
     53        try  
     54        { 
     55            Scanner scanner = new Scanner(file); 
     56            while (scanner.hasNext()) 
     57            { 
     58                Station station = loadStation(scanner);  
    8659                Integer hwyNum = station.routeNumber; 
    8760                // if the map does not contain an entry for the highway, create 
     
    10174                } 
    10275            } 
    103         } 
    104          
     76        }catch (FileNotFoundException e) { 
     77            e.printStackTrace(); 
     78        } 
    10579        // get the set of highway numbers 
    10680        Set<Integer> hwyKeys = highwayMap.keySet(); 
     
    229203    } 
    230204     
     205     
    231206    /** 
    232      * Loads all FEPLines from the specified highways map file. 
    233      *  
    234      * @param highwaysMapFileName 
    235      * @return List of FEPLines 
    236      */ 
    237     private ArrayList<FEPLine> loadLines(String highwaysMapFileName) 
    238     { 
    239         ArrayList<FEPLine> lines = new ArrayList<>(); 
    240         try 
    241         { 
    242             Scanner sc = new Scanner(new File(highwaysMapFileName)); 
    243             // first line of file contains number of FEP Lines 
    244             String firstLine = sc.nextLine(); 
    245             Scanner linesc = new Scanner(firstLine); 
    246             int numLines = linesc.nextInt(); 
    247             linesc.close(); 
    248             // FOR each FEP Line 
    249             for (int i = 0; i < numLines; i++) 
    250             { 
    251                 lines.add(loadLine(sc)); 
    252             } 
    253             sc.close(); 
    254  
    255         } catch (FileNotFoundException ex) 
    256         { 
    257             Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex); 
    258         } 
    259         return lines; 
    260     } 
    261      
    262     /** 
    263      * Load all the stations for a single FEP Line from the highways map file. 
    264      *  
    265      * @param sc scanner at the current FEPLine line 
    266      * @return FEPLine 
    267      */ 
    268     private FEPLine loadLine(Scanner sc) 
     207     * Loads a single Station from the postmile coordinates file 
     208     * @param sc scanner at the current station line 
     209     * @return Station 
     210     */ 
     211    private Station loadStation(Scanner sc) 
    269212    { 
    270213        String line = sc.nextLine(); 
    271214        Scanner scline = new Scanner(line); 
    272         // Get the attributes of this FEP Line 
    273         int lineNum = scline.nextInt(); 
    274         int count = scline.nextInt(); 
    275         int numStations = scline.nextInt(); 
     215        scline.useDelimiter(","); 
    276216         
    277         // initialze stations array 
    278         ArrayList<Station> stations = new ArrayList<>(); 
    279         // Read all the stations for thie FEP Line 
    280         for (int i = 0; i < numStations; i++) 
    281         { 
    282             stations.add(loadStation(sc, lineNum)); 
    283         } 
    284  
    285         return new FEPLine(lineNum, stations, count); 
    286     } 
    287      
    288     /** 
    289      * Loads a single Station from the highways map file 
    290      * @param sc scanner at the current station line 
    291      * @param lineNum the FEPLine number for the station 
    292      * @return Station 
    293      */ 
    294     private Station loadStation(Scanner sc, int lineNum) 
    295     { 
    296         String line = sc.nextLine(); 
    297         Scanner scline = new Scanner(line); 
    298          
    299         int ldsID = scline.nextInt(); 
    300         int drop = scline.nextInt(); 
    301         int fwy = scline.nextInt(); 
    302         DIRECTION dir = DIRECTION.toDirection(scline.next()); 
    303         double postmile = scline.nextDouble(); 
    304         int numLoops = scline.nextInt(); 
    305         String location = getStationLoc(line); 
     217        String route  = scline.next(); // FWY DIR POSTMILE 
     218        scline.next();  // skip lat 
     219        scline.next();  // skip long 
     220        String description = scline.next(); // the description of the location 
     221 
     222        Scanner rteScan = new Scanner(route); 
     223        int fwy = rteScan.nextInt(); 
     224        DIRECTION dir = DIRECTION.toDirection(rteScan.next()); 
     225        double postmile = rteScan.nextDouble(); 
     226 
    306227        ArrayList<LoopDetector> loops = new ArrayList<>(); 
    307         for (int i = 0; i < numLoops; i++) 
    308         { 
    309             loops.add(loadLoop(sc)); 
    310         } 
    311  
    312         return new Station(lineNum, ldsID, drop, location, loops, fwy, dir, postmile); 
    313     } 
    314      
    315     /** 
    316      * Loads a single loop from the highways map file 
    317      * 
    318      * @param sc scanner at the current loop line 
    319      * @return LoopDetector 
    320      */ 
    321     private LoopDetector loadLoop(Scanner sc) 
    322     { 
    323         String line = sc.nextLine(); 
    324         Scanner scline = new Scanner(line); 
    325  
    326         int loopID = scline.nextInt(); 
    327         String loopLocID = scline.next(); 
    328         String loopLoc = scline.next(); 
    329         scline.close(); 
    330         return new LoopDetector(loopID, loopLocID, loopLoc); 
    331     } 
    332  
    333     /** 
    334      * Scans the LoopDetector line and grabs the String location from the line. 
    335      *  
    336      * @param line the line containing the location 
    337      * @return A String loop location. 
    338      */ 
    339     private String getLoopLoc(String line) 
    340     { 
    341         Scanner sc = new Scanner(line); 
    342         sc.nextInt(); 
    343  
    344      // GRABS FROM CURRENT TO END OF LINE 
    345         sc.useDelimiter("\\z"); 
    346         String loc = sc.next().trim(); 
    347         sc.close(); 
    348         return loc; 
    349     } 
    350  
    351     /** 
    352      * Scans the Station line and grabs the String location from the line. 
    353      *  
    354      * @param line the line containing the location 
    355      * @return A String station location. 
    356      */ 
    357     private String getStationLoc(String line) 
    358     { 
    359         Scanner scline = new Scanner(line); 
    360         scline.nextInt(); 
    361         scline.nextInt(); 
    362         scline.nextInt(); 
    363         scline.next(); 
    364         scline.nextDouble(); 
    365         scline.nextInt(); 
    366  
    367         // GRABS FROM CURRENT TO END OF LINE 
    368         scline.useDelimiter("\\z"); 
    369         String loc = scline.next().trim(); 
    370         scline.close(); 
    371         return loc; 
    372     } 
    373      
    374     /**  
    375      * Creates a socket client that writes the Highways data to the FEP Simulator. 
    376      *  
    377      * @throws SimulationException  
    378      */ 
    379     public void writeToFEP() throws SimulationException 
    380     { 
    381         try 
    382         { 
    383             // Create the socket to the FEP Simulator 
    384             Socket sock = new Socket(FEPHostName, FEPPortNum); 
    385             PrintWriter out = new PrintWriter(sock.getOutputStream(), true); 
    386              
    387             // Print the number of bytes the highways data message contains 
    388             System.out.println("Highways sending " + this.toCondensedFormat(false).toCharArray().length + 1 + "bytes to FEPSIM."); 
    389             String outMsg = this.toCondensedFormat(false); 
    390             // Write the highways data over the socket 
    391             out.println(outMsg); 
    392              
    393             // close the socket 
    394             sock.close(); 
    395         } catch (java.net.ConnectException ex) 
    396         { 
    397             //Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex); 
    398             System.out.println("writeToFEP() can't connect, no data sent to FEP."); 
    399             throw new SimulationException(SimulationException.BINDING); 
    400         } catch (IOException ex) 
    401         { 
    402             //Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex); 
    403             System.out.println("Highway Model failed writing to FEPSim."); 
    404             throw new SimulationException(SimulationException.BINDING); 
    405         } 
    406     } 
    407      
    408     /** Returns a string of highways data. If MetaDataOnly is true, you get a full 
    409      *  dump of the highways meta data, which does not include dynamic loop values, 
    410      *  and does include the string location names. If MetaDataOnly is false, 
    411      *  dynamic loop values are included, and unnecessary information like string 
    412      *  location values are not included. 
    413      *  
    414      *  The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 
    415      *  value of false, over the socket. 
    416      *  
    417      *  The MetaDataOnly flag should be used to get a full dump of the highways 
    418      *  information. This was used to get the highways_fullmap.txt output. 
    419      *  
    420      * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 
    421      * @return String, highways data in condensed format 
    422      *  
    423      * Example toCondensedFormat(MetaDataOnly = false) output: 
    424      *  
    425      * 43                       // "number of lines" 
    426      * 32 0 13                  // "line id" "count num" "number of stations" 
    427      * 1210831 1 5 S 0.9 8      // "station id" "drop num" "route num"... 
    428      *                          //      ..."direction" "postmile" "number of loops" 
    429      * 1210832  0.0 0  ML_1     // "loop id" "occ" "vol" 
    430      * 1210833  0.0 0  ML_2     // .. 
    431      * 1210834  0.0 0  ML_3     // .. 
    432      * 1210835  0.0 0  ML_4     // .. 
    433      * 1210836  0.0 0  PASSAGE  // .. 
    434      * 1210837  0.0 0  DEMAND   // .. 
    435      * 1210838  0.0 0  QUEUE    // .. 
    436      * 1210839  0.0 0  RAMP_OFF // .. 
    437      * ... 
    438      *  
    439      * Example toCondensedFormat(MetaDataOnly = true) output: 
    440      *  
    441      * 43                           // "number of lines" 
    442      * 32 0 13                      // "line id" "count num" "number of stations" 
    443      * 1210831 1 5 S 0.9 8 CALAFIA  // "station id" "drop num" "route num"... 
    444      *                              //      ..."direction" "postmile"... 
    445      *                              //      ..."number of loops" "string location" 
    446      * 1210832 ML_1                 // "loop id" "loop location" 
    447      * 1210833 ML_2                 // "            " 
    448      * 1210834 ML_3                 // "            " 
    449      * 1210835 ML_4                 // "            " 
    450      * 1210836 PASSAGE              // "            " 
    451      * 1210837 DEMAND               // "            " 
    452      * 1210838 QUEUE                // "            " 
    453      * 1210839 RAMP_OFF             // "            " 
    454      * ... 
    455      */ 
    456     public String toCondensedFormat(boolean MetaDataOnly) 
    457     { 
    458         // first line: number of FEPLines 
    459         StringBuilder build = new StringBuilder(); 
    460         build.append(lines.size()); 
    461         build.append("\n"); 
    462         // append each fep line to the string 
    463         for(FEPLine line : lines) 
    464         { 
    465             build.append(line.toCondensedFormat(MetaDataOnly)); 
    466         } 
    467         // return the full condensed format string 
    468         return build.toString(); 
    469     } 
    470      
    471     /** 
    472      * Returns the Highways model data in XML format. 
    473      * Probably obsolete, since we aren't using exchange.xml any longer. 
    474      * @return highways data in XML format 
    475      */ 
    476     public String toXML() 
    477     { 
    478         String xml = null; 
    479         try 
    480         { 
    481             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 
    482             DocumentBuilder builder = factory.newDocumentBuilder(); 
    483             Document theDoc = builder.newDocument(); 
    484  
    485             Element networkElement = theDoc.createElement(XML_TAGS.NETWORK.tag); 
    486             theDoc.appendChild(networkElement); 
    487  
    488             for (FEPLine line : lines) 
    489             { 
    490                 line.toXML(networkElement); 
    491             } 
    492  
    493             Transformer tf = TransformerFactory.newInstance().newTransformer(); 
    494  
    495             tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); 
    496             tf.setOutputProperty(OutputKeys.INDENT, "yes"); 
    497             tf.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); 
    498  
    499             Writer out = new StringWriter(); 
    500             tf.transform(new DOMSource(theDoc), new StreamResult(out)); 
    501             xml = out.toString(); 
    502             out.close(); 
    503         } catch (Exception ex) 
    504         { 
    505             Logger.getLogger(Highways.class.getName()).log(Level.SEVERE, null, ex); 
    506         } 
    507         return xml; 
    508  
    509     } 
    510  
     228        // For now we'll use just a dummy loop detector 
     229        LoopDetector detector = new LoopDetector(1,"ML","ML_1"); 
     230        loops.add(detector); 
     231 
     232        return new Station(11, 123, 99, description, loops, fwy, dir, postmile); 
     233    } 
     234      
    511235    /** 
    512236     * Returns a highway by given highway number. 
     
    531255    } 
    532256 
    533     /** Return a string representation of the Highways */ 
     257    /** Return a string representation of the Highways - for debugging */ 
    534258    public String toString() 
    535259    { 
     
    543267                StringBuilder lineout = new StringBuilder(); 
    544268                // Examine every station on this highway and direction 
    545                 for (Station stat: hwy.stations) 
    546                 { 
    547                     if (stat.direction.equals(dir)) 
     269                for (Station station: hwy.stations) 
     270                { 
     271                    if (station.direction.equals(dir)) 
    548272                    { 
    549273                    //lineout.append("" + dir.getLetter() + stat.postmile); 
    550                     lineout.append(stat.getColor()); 
     274                    lineout.append(station.getColor().symbol()); 
    551275                    //lineout.append("  "); 
    552276                    } 
     
    616340                    String outString = currentPM.toJson(); 
    617341                    // replace the color code with the color name 
    618                     String colorName=stat.getColorName(); 
     342                    String colorName=stat.getColor().htmlColor(); 
    619343                    outString = outString.replace("desiredcolor",colorName); 
    620344                    lineout.append(outString); 
     
    664388    } 
    665389     
    666     public void reset() 
    667     { 
    668         for(FEPLine line : lines) 
    669         { 
    670             for(Station stn : line.stations) 
     390    /** Reset all the traffic levels to free flowing (green) */ 
     391    public void reset()             
     392    { 
     393        for(Highway hwy: highways) 
     394        { 
     395            for(Station stn : hwy.stations) 
    671396            { 
    672397                for(LoopDetector ld : stn.loops) 
    673398                { 
    674                     ld.occ = 0; 
    675                     ld.vol = 0; 
     399                    ld.setAttributes(LoopDetector.DOTCOLOR.GREEN); 
    676400                } 
    677401            } 
  • trunk/src/tmcsim/highwaymodel/LoopDetector.java

    r343 r422  
    1 package atmsdriver.model; 
     1package tmcsim.highwaymodel; 
    22 
    33import java.util.ArrayList; 
     
    1212 *  occ, and spd. 
    1313 * 
     14 * Lane Type    A string indicating the type of lane. Possible values (and their meaning) are: 
     15 * 
     16 *    CD (Coll/Dist) 
     17 *    CH (Conventional Highway) 
     18 *    FF (Fwy-Fwy connector) 
     19 *    FR (Off Ramp) 
     20 *    HV (HOV) 
     21 *    ML (Mainline) 
     22 *    OR (On Ramp) 
    1423 * @author John A. Torres 
    1524 * @version 09/10/2017 
     
    2837    /** 
    2938     * Constructs a LoopDetector from loopID, loopLocation, and laneNum 
     39     * with initially free flowing traffic. 
    3040     *  
    3141     * @param loopID 
     
    4454    } 
    4555     
     56    /**  
     57     * Setter for loop detector dynamic attributes.  Reserved for future use 
     58     * with "live" highway data. 
     59     * @param vol volume 
     60     * @param occ occupancy 
     61     * @param spd speed not used 
     62     */ 
     63    public void setAttributes(int vol, float occ) 
     64    { 
     65        this.vol = vol; 
     66        this.occ = occ; 
     67    } 
     68    /** Set the attributes of this detector given a color. 
     69     * @param DOTCOLOR of the attributes to assign.  
     70     */ 
     71    public void setAttributes(DOTCOLOR color) 
     72    { 
     73        this.vol = color.volume(); 
     74        this.occ = color.occupancy(); 
     75    } 
    4676    /** 
    4777     * XML tags used for toXML() method. 
     
    100130        return build.toString(); 
    101131    } 
    102      
    103     /**  
    104      * Updates loop detector dynamic attributes. 
    105      * @param vol volume 
    106      * @param occ occupancy 
    107      * @param spd speed 
    108      */ 
    109     public void updateLoop(int vol, float occ) 
    110     { 
    111         this.vol = vol; 
    112         this.occ = occ; 
    113     } 
    114132 
    115133    /** 
     
    144162    /** 
    145163     * Enum for highway status dot colors. Each color has associated volume 
    146      * and occupancy constants. 
     164     * and occupancy constants, single character symbol, and hml color name. 
    147165     * 
    148166     * @author John A. Torres, jdalbey 
     
    151169    public static enum DOTCOLOR { 
    152170 
    153         RED(1, 0.06f),    // "Stopped" is less than 25mph 
    154         YELLOW(3,0.059f), // speed = 26 
    155         GREEN(0,0); 
     171        RED(1, 0.06f,'@',"red"),    // "Stopped" is less than 25mph 
     172        YELLOW(3,0.059f,'+',"yellow"), // speed = 26 
     173        GREEN(0,0,'-',"lime");       // freeflowing 
    156174         
    157175        // All the first letters of the values, in order. 
     
    160178        private int vol;  /* volume */ 
    161179        private float occ;  /* occupancy */       
    162          
    163         private DOTCOLOR(int v, float o) 
     180        private char symbol; /* symbolic representation of this color */ 
     181        private String htmlColor; /* html color name */ 
     182         
     183         
     184        private DOTCOLOR(int v, float o, char symbol, String htmlColor) 
    164185        { 
    165186            vol = v; 
    166187            occ = o; 
     188            this.symbol = symbol; 
     189            this.htmlColor = htmlColor; 
    167190        } 
    168191        /** 
     
    183206            return occ; 
    184207        } 
     208        public char symbol() 
     209        { 
     210            return symbol; 
     211        } 
     212        public String htmlColor() 
     213        { 
     214            return htmlColor; 
     215        } 
    185216        /** 
    186          * Returns a dot color given its first character. 
     217         * Returns a DOTCOLOR given its first character. 
    187218         * 
    188          * @param letter the first character of a dot color 
    189          * @return dot color corresponding to letter 
     219         * @param letter the first character of a DOTCOLOR 
     220         * @return DOTCOLOR corresponding to letter 
    190221         * @pre letter must be one of allLetters 
    191222         */ 
  • trunk/src/tmcsim/highwaymodel/PostmileCoords.java

    r274 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
    44import java.util.ArrayList; 
  • trunk/src/tmcsim/highwaymodel/Station.java

    r343 r422  
    1 package atmsdriver.model; 
    2  
    3 import atmsdriver.model.LoopDetector.DOTCOLOR; 
     1package tmcsim.highwaymodel; 
     2 
     3import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 
    44import java.util.ArrayList; 
    55import java.util.List; 
     
    99/** 
    1010 * 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 
     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 
     
    194194            outputUpdateMessage(dotColor, direction.toString()); 
    195195 
     196            // Set the values for all lanes at this station 
    196197            for (LoopDetector loop : loops) 
    197198            { 
    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     //            } 
     199                // Set loop detector attributes given the desired color 
     200                loop.setAttributes(dotColor); 
    205201            } 
    206202 
     
    210206    } 
    211207    /** 
    212      * Return the color for the lanes in a given direction. 
    213      * @return character representing color of this station's traffic flow 
    214      * '@' = red, '+' = yellow, '-' = green 
    215      */ 
    216     public char getColor() 
     208     * Compute the color for the lanes in a given direction. 
     209     * @return DOTCOLOR of this station's traffic flow 
     210     */ 
     211    public DOTCOLOR getColor() 
    217212    { 
    218213        /* For now just use the color of the first lane.  
    219          * TODO: Average the color in ALL the lanes for the given direction */ 
     214         * TODO: Average the color in ALL the lanes */ 
    220215 
    221216        String laneDir = ""; 
    222217         
    223             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    224             // creates a highway map based on VDS instead of Controller (LDS). 
    225 //        if (direction.equals(this.direction)) 
    226 //        { 
    227 //            laneDir = "ML"; 
    228 //        } 
    229 //        else if (direction.equals(this.direction.getOpposite())) 
    230 //        { 
    231 //            laneDir = "OS"; 
    232 //        } 
    233         // Search lanes to find specified direction 
    234         for (LoopDetector loop : loops) 
    235         { 
    236             // THIS DECISION ISN'T NEEDED after JD's BuildHighwayFile pgm 
    237             // creates a highway map based on VDS instead of Controller (LDS). 
    238 //            if (loop.loopLocation.substring(0,2).equals(laneDir)) 
    239 //            { 
    240                 // Return color according to loop volume of first matching lane 
    241                 if (loop.vol == 1) 
    242                 { 
    243                     return '@'; 
    244                 } 
    245                 if (loop.vol == 3) 
    246                 { 
    247                     return '+'; 
    248                 } 
    249                 if (loop.vol == 0) 
    250                 { 
    251                     return '-'; 
    252                 } 
    253 //            } 
    254         } 
    255         // Default case for when the route is not on this direction 
    256         return ' '; 
    257     } 
    258     /** 
    259      * Return the color name for the traffic volume of this station. 
    260      */ 
    261     public String getColorName() 
    262     { 
    263         String colorName = ""; 
    264         switch (this.getColor()) 
    265         { 
    266             case '@': colorName = "red";break; 
    267             case '+': colorName = "yellow"; break; 
    268             case '-': colorName = "lime";break; 
    269             case ' ': colorName = "lime";break; 
    270         } 
    271         return colorName; 
    272     } 
     218        // FOR FUTURE USE we will need to examine all detectors for this station 
     219        // and perform an average 
     220        // for (LoopDetector loop : loops) 
     221        { 
     222            // for now, Return color according to loop volume of first lane 
     223            if (loops.get(0).vol == 1) 
     224            { 
     225                return DOTCOLOR.RED; 
     226            } 
     227            if (loops.get(0).vol == 3) 
     228            { 
     229                return DOTCOLOR.YELLOW; 
     230            } 
     231            if (loops.get(0).vol == 0) 
     232            { 
     233                return DOTCOLOR.GREEN; 
     234            } 
     235        } 
     236         
     237        // Default case for invalid data 
     238        return DOTCOLOR.GREEN; 
     239    } 
     240 
    273241    /** 
    274242     * Output for updateByDirection. Logs the update to the console. 
  • trunk/src/tmcsim/highwaymodel/StationComparator.java

    r353 r422  
    1 package atmsdriver.model; 
     1package tmcsim.highwaymodel; 
    22 
    33import java.util.Comparator; 
  • trunk/src/tmcsim/highwaymodel/TrafficEvent.java

    r204 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
    44import java.text.ParseException; 
  • trunk/src/tmcsim/utilities/BuildHighwayFile.java

    r345 r422  
    1515 
    1616/** 
     17 * OBSOLETE since deprecating ATMS functionality. No longer used. 
    1718 * This utility program is used to create the highway map file used as part 
    1819 * of the configuration files needed by the simulator. 
  • trunk/test/atmsdriver/TrafficModelEventDriver.java

    r343 r422  
    11package atmsdriver; 
    22 
    3 import atmsdriver.model.Highways; 
    4 import atmsdriver.model.TrafficEvent; 
     3import tmcsim.highwaymodel.Highways; 
     4import tmcsim.highwaymodel.TrafficEvent; 
    55import java.io.FileInputStream; 
    66import java.io.FileNotFoundException; 
     
    6363        incidents = new HashMap<String, List<TrafficEvent>>(); 
    6464        highways = new Highways( 
    65                 "config/vds_data/highways_fullmap.txt", 
    66                 // following aren't used by this application 
    67                 "localhost", 8080); 
     65                "config/vds_data/highways_fullmap.txt"); 
    6866        final String CONFIG_FILE_NAME = "traffic_model_config.properties"; 
    6967        String propertiesFile = "config" + System.getProperty("file.separator")  
  • trunk/test/tmcsim/cadsimulator/CADSimulatorConsoleTest.java

    r345 r422  
    6060        removeMe.delete(); 
    6161        removeMe = new File("pconfig.txt"); 
     62        removeMe.delete(); 
     63        removeMe = new File("tconfig.txt"); 
    6264        removeMe.delete(); 
    6365        removeMe = new File("empty.txt"); 
     
    272274            + "ATMSProperties         = empty.txt\n" 
    273275            + "TrafficMgrProperties   = tconfig.txt\n" 
    274             + "MediaProperties        = empty.txt\n"; 
    275     static final String trafficMgrData = "Highways_Map_File = config/vds_data/highways_fullmap.txt\n" 
     276            + "MediaProperties        = empty.txt\n" 
     277            + "ElapsedTimeFile        = webapps/dynamicdata/sim_elapsedtime.json"; 
     278    static final String trafficMgrData = "Highways_Map_File = config/vds_data/postmile_coordinates.txt\n" 
    276279            +"Events_File = config/vds_data/atmsBatchEvents.txt\n" 
    277280            +"FEPSim_IP_addr = localhost\n" 
    278281            +"Output_Destination = Console\n" 
    279             +"Json_Path = /tmp/highway_status.json\n"; 
     282            +"Highway_Status_File = /tmp/highway_status.json\n"; 
    280283    static final String paramicsData = "ParamicsCommHost = 127.0.0.1\n" 
    281284            + "ParamicsCommPort       = 4450\n" 
  • trunk/test/tmcsim/cadsimulator/CADSimulatorGUITest.java

    r228 r422  
    6868//        } 
    6969 
    70         System.setProperty("CONFIG_DIR", "config/testConfig"); 
     70        System.setProperty("CONFIG_DIR", "config/"); 
    7171        if (System.getProperty("CONFIG_DIR") != null) 
    7272        { 
  • trunk/test/tmcsim/cadsimulator/SystemConsoleTest.java

    r123 r422  
    5252        try 
    5353        { 
    54             engine = new CADServer("config/testConfig/cad_simulator_console_config.properties"); 
     54            engine = new CADServer("config/cad_simulator_console_config.properties"); 
    5555        } catch (Exception e) 
    5656        { 
     
    5959 
    6060        ParamicsCommunicator pc = null; 
    61         pc = new ParamicsCommunicator("config/testConfig/paramics_communicator_config.properties"); 
     61        pc = new ParamicsCommunicator("config/paramics_communicator_config.properties"); 
    6262        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI(); 
    6363        pc.setGUI(theGUI); 
     
    145145        { 
    146146        } 
    147         assertEquals("Network 1 Loaded", txtParamStatus.getText()); 
    148         System.out.println("Network Loaded Passed"); 
     147        //assertEquals("Network 1 Loaded", txtParamStatus.getText()); 
     148        //System.out.println("Network Loaded Passed"); 
    149149 
    150150        // Load a script file 
  • trunk/test/tmcsim/cadsimulator/SystemTest.java

    r210 r422  
    5353                try 
    5454                { 
    55                     engine = new CADServer("config/testConfig/cad_simulator_config.properties"); 
     55                    engine = new CADServer("config/cad_simulator_config.properties"); 
    5656                } catch (Exception e) 
    5757                { 
     
    7272 
    7373        ParamicsCommunicator pc = null; 
    74         pc = new ParamicsCommunicator("config/testConfig/paramics_communicator_config.properties"); 
     74        pc = new ParamicsCommunicator("config/paramics_communicator_config.properties"); 
    7575        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI(); 
    7676        pc.setGUI(theGUI); 
     
    158158        { 
    159159        } 
    160         assertEquals("Network 1 Loaded", txtParamStatus.getText()); 
    161         assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim()); 
     160        //assertEquals("Network 1 Loaded", txtParamStatus.getText()); 
     161        //assertEquals("network id should be 1", "1", mainPanel.getTextBox("networkLoadedTF").getText().trim()); 
    162162 
    163163 
  • trunk/test/tmcsim/cadsimulator/VisibleSystemDemoDriver.java

    r52 r422  
    4848 
    4949        ParamicsCommunicator pc = null; 
    50         pc = new ParamicsCommunicator("config/testConfig/paramics_communicator_config.properties"); 
     50        pc = new ParamicsCommunicator("config/paramics_communicator_config.properties"); 
    5151        ParamicsCommunicatorGUI theGUI = new ParamicsCommunicatorGUI(); 
    5252        pc.setGUI(theGUI); 
  • trunk/test/tmcsim/cadsimulator/managers/TrafficModelManagerTest.java

    r220 r422  
    22package tmcsim.cadsimulator.managers; 
    33 
    4 import atmsdriver.model.TrafficEvent; 
     4import tmcsim.highwaymodel.TrafficEvent; 
    55import java.text.ParseException; 
    66import java.util.LinkedList; 
  • trunk/test/tmcsim/highwaymodel/HighwayTest.java

    r343 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
    4 import atmsdriver.model.Station.DIRECTION; 
     4import tmcsim.highwaymodel.LoopDetector; 
     5import tmcsim.highwaymodel.Station; 
     6import tmcsim.highwaymodel.Highway; 
     7import tmcsim.highwaymodel.Station.DIRECTION; 
    58import java.util.ArrayList; 
    69import java.util.Set; 
  • trunk/test/tmcsim/highwaymodel/HighwaysTest.java

    r354 r422  
    1 package atmsdriver.model; 
    2  
    3 import archive.ATMSDriver; 
    4 import atmsdriver.model.LoopDetector.DOTCOLOR; 
    5 import atmsdriver.model.Station.DIRECTION; 
    6 import java.io.File; 
     1package tmcsim.highwaymodel; 
     2 
     3import tmcsim.highwaymodel.LoopDetector; 
     4import tmcsim.highwaymodel.Station; 
     5import tmcsim.highwaymodel.Highways; 
     6import tmcsim.highwaymodel.Station.DIRECTION; 
    77import java.io.FileWriter; 
    88import java.io.PrintWriter; 
     
    3131        PrintWriter writer = null; 
    3232        try { 
    33             writer = new PrintWriter(new FileWriter("test/atmsdriver/model/ldssample.txt")); 
    34             writer.println("2"); 
    35             writer.println("32 0 2"); 
    36             writer.println("1210831 1 5 S 0.9 4 CALAFIA"); 
    37             writer.println("1210832 ML ML_1"); 
    38             writer.println("1210833 ML ML_2"); 
    39             writer.println("1210834 ML ML_3"); 
    40             writer.println("1210835 ML ML_4"); 
    41             writer.println("1210845 2 5 S 1.49 4 EL CAMINO REAL"); 
    42             writer.println("1210846 ML ML_1"); 
    43             writer.println("1210847 ML ML_2"); 
    44             writer.println("1210848 ML ML_3"); 
    45             writer.println("1210849 ML ML_4"); 
    46             writer.println("74 0 1"); 
    47             writer.println("1204203 2 5 N 1.26 4 MAGDALENA"); 
    48             writer.println("1204212 ML ML_1"); 
    49             writer.println("1204213 ML ML_2"); 
    50             writer.println("1204214 ML ML_3"); 
    51             writer.println("1204215 ML ML_4"); 
     33            writer = new PrintWriter(new FileWriter("test/atmsdriver/postmiles1.txt")); 
     34            writer.println("5 S 0.9,33.408425,-117.599923,CALAFIA,0,0"); 
     35            writer.println("5 N 1.24,33.413051,-117.601964,MAGDALENA,0,0"); 
     36            writer.println("5 S 1.49,33.416348,-117.603827,EL CAMINO REAL,0,0"); 
    5237            writer.close(); 
    53              
    54             writer = new PrintWriter(new FileWriter("test/atmsdriver/model/ldssample2.txt")); 
    55             writer.println("1"); 
    56             writer.println("44 0 6"); 
    57             writer.println("1204390 6 5 S 7.99 5 AEROPUERTO"); 
    58             writer.println("1204391 ML ML_1"); 
    59             writer.println("1204392 ML ML_2"); 
    60             writer.println("1204393 ML ML_3"); 
    61             writer.println("1204394 ML ML_4"); 
    62             writer.println("1210062 ML ML_5"); 
    63             writer.println("1204384 5 5 N 7.46 4 CAPISTRANO"); 
    64             writer.println("1204385 ML ML_1"); 
    65             writer.println("1204386 ML ML_2"); 
    66             writer.println("1204387 ML ML_3"); 
    67             writer.println("1204388 ML ML_4"); 
    68             writer.println("1204316 1 5 N 5.73 4 ESTRELLA1"); 
    69             writer.println("1204317 ML ML_1"); 
    70             writer.println("1204318 ML ML_2"); 
    71             writer.println("1204319 ML ML_3"); 
    72             writer.println("1204320 ML ML_4"); 
    73             writer.println("1204340 3 5 N 6.47 4 SACRAMENTO"); 
    74             writer.println("1204341 ML ML_1"); 
    75             writer.println("1204342 ML ML_2"); 
    76             writer.println("1204343 ML ML_3"); 
    77             writer.println("1204344 ML ML_4"); 
    78             writer.println("1204345 3 5 S 6.47 5 SACRAMENTO"); 
    79             writer.println("1204346 OS OS_1"); 
    80             writer.println("1204347 OS OS_2"); 
    81             writer.println("1204348 OS OS_3"); 
    82             writer.println("1204349 OS OS_4"); 
    83             writer.println("1204350 OS OS_5"); 
    84             writer.println("1211075 5 5 S 7.46 5 CAPISTRANO"); 
    85             writer.println("1211069 OS OS_1"); 
    86             writer.println("1211070 OS OS_2"); 
    87             writer.println("1211071 OS OS_3"); 
    88             writer.println("1211072 OS OS_4"); 
    89             writer.println("1211073 OS OS_5"); 
     38 
     39            writer = new PrintWriter(new FileWriter("test/atmsdriver/postmiles2.txt")); 
     40            writer.println("5 N 5.89,33.459637,-117.657305,ESTRELLA2,0,0"); 
     41            writer.println("5 S 6.47,33.464281,-117.665631,SACRAMENTO,-0.56275,-0.826627"); 
     42            writer.println("5 N 6.47,33.464404,-117.665509,SACRAMENTO,0.523797,0.851843"); 
     43            writer.println("5 S 7.46,33.475102,-117.674584,CAPISTRANO,-0.815879,0.578222"); 
     44            writer.println("5 N 7.46,33.475073,-117.674271,CAPISTRANO,0.816519,-0.577318"); 
     45            writer.println("5 S 7.99,33.481738,-117.669881,AEROPUERTO,-0.815879,0.578222"); 
     46            writer.println("5 N 7.99,33.481685,-117.669596,AEROPUERTO,0.816519,-0.577318"); 
    9047            writer.close(); 
    9148 
    92             writer = new PrintWriter(new FileWriter("test/atmsdriver/model/ldssample3.txt")); 
    93             writer.println("1"); 
    94             writer.println("44 0 6"); 
    95             writer.println("1204390 6 73 N 23.9 5 BISON 2"); 
    96             writer.println("1204391 ML ML_1"); 
    97             writer.println("1204392 ML ML_2"); 
    98             writer.println("1204393 ML ML_3"); 
    99             writer.println("1204394 ML ML_4"); 
    100             writer.println("1210062 ML ML_5"); 
    101             writer.println("1204384 2 55 S 6.88 4 MACARTHU1"); 
    102             writer.println("1204385 ML ML_1"); 
    103             writer.println("1204386 ML ML_2"); 
    104             writer.println("1204387 ML ML_3"); 
    105             writer.println("1204388 ML ML_4"); 
    106             writer.println("1204316 1 5 N 5.73 4 ESTRELLA1"); 
    107             writer.println("1204317 ML ML_1"); 
    108             writer.println("1204318 ML ML_2"); 
    109             writer.println("1204319 ML ML_3"); 
    110             writer.println("1204320 ML ML_4"); 
    111             writer.println("1204340 3 5 N 6.47 4 SACRAMENTO"); 
    112             writer.println("1204341 ML ML_1"); 
    113             writer.println("1204342 ML ML_2"); 
    114             writer.println("1204343 ML ML_3"); 
    115             writer.println("1204344 ML ML_4"); 
    116             writer.println("1204345 4 405 N 6.21 5 HARVARD"); 
    117             writer.println("1204346 OS OS_1"); 
    118             writer.println("1204347 OS OS_2"); 
    119             writer.println("1204348 OS OS_3"); 
    120             writer.println("1204349 OS OS_4"); 
    121             writer.println("1204350 OS OS_5"); 
    122             writer.println("1211075 5 405 S 6.8 5 JAMBOREE1"); 
    123             writer.println("1211069 OS OS_1"); 
    124             writer.println("1211070 OS OS_2"); 
    125             writer.println("1211071 OS OS_3"); 
    126             writer.println("1211072 OS OS_4"); 
    127             writer.println("1211073 OS OS_5"); 
     49            writer = new PrintWriter(new FileWriter("test/atmsdriver/postmiles3.txt")); 
     50            writer.println("73 N 23.9,33.643656,-117.859875,BISON 2,0.976131,0.217185"); 
     51            writer.println("55 S 6.88,33.697495,-117.862677,MACARTHU1,-0.710326,0.703873"); 
     52            writer.println("5 N 5.73,33.458342,-117.655008,ESTRELLA1,0,0"); 
     53            writer.println("5 N 6.47,33.464404,-117.665509,SACRAMENTO,0.523797,0.851843"); 
     54            writer.println("405 N 6.21,33.672851,-117.832271,HARVARD,0.320278,0.947323"); 
     55            writer.println("405 S 6.8,33.675863,-117.84179,JAMBOREE1,-0.402558,-0.915394"); 
    12856            writer.close(); 
    12957        } catch (Exception e) { 
     
    13563    protected void tearDown() throws Exception { 
    13664        super.tearDown(); 
    137         Path path = FileSystems.getDefault().getPath("test/atmsdriver/model", "ldssample.txt"); 
     65        Path path = FileSystems.getDefault().getPath("test/atmsdriver", "postmiles1.txt"); 
    13866        Files.delete(path); 
    139         path = FileSystems.getDefault().getPath("test/atmsdriver/model", "ldssample2.txt"); 
     67        path = FileSystems.getDefault().getPath("test/atmsdriver", "postmiles2.txt"); 
    14068        Files.delete(path); 
    141         path = FileSystems.getDefault().getPath("test/atmsdriver/model", "ldssample3.txt"); 
     69        path = FileSystems.getDefault().getPath("test/atmsdriver", "postmiles3.txt"); 
    14270        Files.delete(path); 
    14371    } 
    14472 
    145     public void testFindStation() 
    146     { 
     73    public void testFindStation() { 
    14774        System.out.println("test FindStation()"); 
    14875        Highways highways = new Highways( 
    149                 "test/atmsdriver/model/ldssample.txt", 
    150                 "localhost", 8080); 
     76                "test/atmsdriver/postmiles1.txt"); 
    15177        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 0.9)); 
    15278        assertTrue(null != highways.findStation(5, DIRECTION.SOUTH, 1.49)); 
    153         assertTrue(null != highways.findStation(5, DIRECTION.NORTH, 1.26)); 
    154         assertTrue(null == highways.findStation(5, DIRECTION.SOUTH, 1.1)); 
    155     } 
     79        assertTrue(null != highways.findStation(5, DIRECTION.NORTH, 1.24)); 
     80    } 
     81 
    15682    /** 
    15783     * Test of toString method 
     
    16086        System.out.println("toString"); 
    16187        Highways highways = new Highways( 
    162                 "config/vds_data/highways_fullmap.txt", 
    163                 "localhost", 8080); 
     88                "test/atmsdriver/postmiles2.txt"); 
    16489        highways.getHighwayByRouteNumber(5).stations.get(0).loops.get(0).vol = 1; 
    16590        String result = highways.toString(); 
    16691        String[] resultLines = result.split("\n"); 
    167         String actual = resultLines[3].substring(0,9); 
    168         assertEquals("  5 S @.-",actual); 
    169         highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 18.8, 0.8,  
    170                 LoopDetector.DOTCOLOR.RED); 
    171         result = highways.toString(); 
    172         System.out.println("bravo:\n"+result); 
    173         assertEquals("241 N -@.@@.-",result.substring(0,13)); 
    174         highways.applyColorToHighwayStretch(241, Station.DIRECTION.SOUTH, 18.8, 2.0,  
     92        String actual = resultLines[0]; 
     93        assertEquals("  5 N @.-.-.-", actual); 
     94        highways.applyColorToHighwayStretch(5, Station.DIRECTION.NORTH, 7.99, 2.0, 
    17595                LoopDetector.DOTCOLOR.YELLOW); 
    17696        result = highways.toString(); 
    177         System.out.println("charly:\n"+result); 
    178         resultLines = result.split("\n"); 
    179         actual = resultLines[1].substring(0,16); 
    180         assertEquals("241 S ..-..+.++.",actual); 
    181     } 
    182  
     97        System.out.println("bravo:\n" + result); 
     98        assertEquals("5 N @.+.+.+\n  5 S .-.-.-.", result.trim()); 
     99        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 6.47, 1.51, 
     100                LoopDetector.DOTCOLOR.YELLOW); 
     101        result = highways.toString(); 
     102        System.out.println("charly:\n" + result); 
     103        actual = result.trim(); 
     104        assertEquals("5 N @.+.+.+\n  5 S .+.+.-.", actual); 
     105    } 
    183106 
    184107    public void testToJson() throws ParseException { 
    185108        System.out.println("toJson"); 
    186109        Highways highways = new Highways( 
    187                 "test/atmsdriver/model/ldssample.txt", 
    188                 "localhost", 8080); 
     110                "test/atmsdriver/postmiles1.txt"); 
    189111        String result = highways.toJson(); 
    190112        System.out.println(result); 
     
    193115        JSONObject obj = (JSONObject) parser.parse(result); 
    194116        System.out.println(obj); 
    195         JSONArray array = (JSONArray)obj.get("features"); 
    196         JSONObject item1 = (JSONObject)array.get(0); 
     117        JSONArray array = (JSONArray) obj.get("features"); 
     118        JSONObject item1 = (JSONObject) array.get(0); 
    197119        String id1 = (String) item1.get("id"); 
    198         JSONObject item2 = (JSONObject)array.get(1); 
     120        JSONObject item2 = (JSONObject) array.get(1); 
    199121        String id2 = (String) item2.get("id"); 
    200         JSONObject item3 = (JSONObject)array.get(2); 
     122        JSONObject item3 = (JSONObject) array.get(2); 
    201123        String id3 = (String) item3.get("id"); 
    202         assertEquals("5 N 1.26", id1); 
     124        assertEquals("5 N 1.24", id1); 
    203125        assertEquals("5 S 0.9", id2); 
    204126        assertEquals("5 S 1.49", id3); 
    205127    } 
     128 
    206129    public void testStationSort() throws ParseException { 
    207130        System.out.println("stationSort"); 
    208131        Highways highways = new Highways( 
    209                 "test/atmsdriver/model/ldssample2.txt", 
    210                 "localhost", 8080); 
     132                "test/atmsdriver/postmiles3.txt"); 
    211133        String result = highways.toJson(); 
    212134        JSONParser parser = new JSONParser(); 
    213135        JSONObject obj = (JSONObject) parser.parse(result); 
    214         JSONArray array = (JSONArray)obj.get("features"); 
    215         JSONObject item1 = (JSONObject)array.get(0); 
     136        JSONArray array = (JSONArray) obj.get("features"); 
     137        JSONObject item1 = (JSONObject) array.get(0); 
    216138        String id1 = (String) item1.get("id"); 
    217         JSONObject item2 = (JSONObject)array.get(1); 
     139        JSONObject item2 = (JSONObject) array.get(1); 
    218140        String id2 = (String) item2.get("id"); 
    219         JSONObject item3 = (JSONObject)array.get(2); 
     141        JSONObject item3 = (JSONObject) array.get(2); 
    220142        String id3 = (String) item3.get("id"); 
    221143        assertEquals("5 N 5.73", id1); 
    222144        assertEquals("5 N 6.47", id2); 
    223         assertEquals("5 N 7.46", id3); 
    224         JSONObject item4 = (JSONObject)array.get(3); 
     145        assertEquals("55 S 6.88", id3); 
     146        JSONObject item4 = (JSONObject) array.get(3); 
    225147        String id4 = (String) item4.get("id"); 
    226         JSONObject item5 = (JSONObject)array.get(4); 
     148        JSONObject item5 = (JSONObject) array.get(4); 
    227149        String id5 = (String) item5.get("id"); 
    228         assertEquals("5 S 6.47", id4); 
    229         assertEquals("5 S 7.46", id5); 
    230     } 
     150        assertEquals("73 N 23.9", id4); 
     151        assertEquals("405 N 6.21", id5); 
     152    } 
     153 
    231154    public void testRouteSort() throws ParseException { 
    232155        System.out.println("routeSort"); 
    233156        Highways highways = new Highways( 
    234                 "test/atmsdriver/model/ldssample3.txt", 
    235                 "localhost", 8080); 
     157                "test/atmsdriver/postmiles3.txt"); 
    236158        String result = highways.toJson(); 
    237159        JSONParser parser = new JSONParser(); 
    238160        JSONObject obj = (JSONObject) parser.parse(result); 
    239         JSONArray array = (JSONArray)obj.get("features"); 
    240         JSONObject item1 = (JSONObject)array.get(0); 
     161        JSONArray array = (JSONArray) obj.get("features"); 
     162        JSONObject item1 = (JSONObject) array.get(0); 
    241163        String id1 = (String) item1.get("id"); 
    242         JSONObject item2 = (JSONObject)array.get(1); 
     164        JSONObject item2 = (JSONObject) array.get(1); 
    243165        String id2 = (String) item2.get("id"); 
    244         JSONObject item3 = (JSONObject)array.get(2); 
     166        JSONObject item3 = (JSONObject) array.get(2); 
    245167        String id3 = (String) item3.get("id"); 
    246         JSONObject item4 = (JSONObject)array.get(3); 
     168        JSONObject item4 = (JSONObject) array.get(3); 
    247169        String id4 = (String) item4.get("id"); 
    248         JSONObject item5 = (JSONObject)array.get(4); 
     170        JSONObject item5 = (JSONObject) array.get(4); 
    249171        String id5 = (String) item5.get("id"); 
    250172        assertEquals("5 N 5.73", id1); 
     
    254176        assertEquals("405 N 6.21", id5); 
    255177    } 
    256     
    257     public void testApplyColor() 
    258     { 
     178 
     179    public void testApplyColor() { 
    259180        System.out.println("apply color"); 
    260181        Highways highways = new Highways( 
    261             "test/atmsdriver/model/ldssample.txt", 
    262             "localhost", 8080); 
    263         highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0,  
     182                "test/atmsdriver/postmiles1.txt"); 
     183        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 0.9, 2.0, 
    264184                LoopDetector.DOTCOLOR.RED); 
    265185        Station target = highways.findStation(5, DIRECTION.SOUTH, 0.9); 
    266         assertEquals('@',target.getColor()); 
     186        assertEquals('@', target.getColor().symbol()); 
    267187        String result = highways.toString(); 
    268         System.out.println("applyto:\n"+result); 
     188        System.out.println("applyto:\n" + result); 
    269189        assertEquals("5 N .-.\n  5 S @.@", result.trim()); 
    270          
    271         highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 2.0,  
     190 
     191        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 2.0, 
    272192                LoopDetector.DOTCOLOR.YELLOW); 
    273193        result = highways.toString(); 
    274194        assertEquals("5 N .-.\n  5 S @.+", result.trim()); 
    275          
    276         highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 0.59,  
     195 
     196        highways.applyColorToHighwayStretch(5, Station.DIRECTION.SOUTH, 1.49, 0.59, 
    277197                LoopDetector.DOTCOLOR.GREEN); 
    278198        result = highways.toString(); 
    279199        assertEquals("5 N .-.\n  5 S @.-", result.trim()); 
    280200 
    281         highways.applyColorToHighwayStretch(5, Station.DIRECTION.NORTH, 1.83, 2.0,  
     201        highways.applyColorToHighwayStretch(5, Station.DIRECTION.NORTH, 1.83, 2.0, 
    282202                LoopDetector.DOTCOLOR.RED); 
    283203        result = highways.toString(); 
    284204        assertEquals("5 N .@.\n  5 S @.-", result.trim()); 
    285          
     205 
    286206        //highways.applyColorToHighwayStretch(241, Station.DIRECTION.NORTH, 20.13, 4.0, LoopDetector.DOTCOLOR.RED); 
    287207        //result = highways.toString(); 
    288208        //assertTrue(result.length()>0); //"241 N @@ @@@@@-",result.substring(0,15)); 
    289  
    290     }             
    291      
    292     public void testToCondensedFormat() 
    293     { 
    294         System.out.println("ToCondensedFormat"); 
    295         Highways highways = new Highways( 
    296                 "test/atmsdriver/model/ldssample.txt", 
    297                 "localhost", 8080); 
    298  
    299         String actualCondensedFormatMeta = highways.toCondensedFormat(true); 
    300         String actualCondensedFormatFEP = highways.toCondensedFormat(false); 
    301         System.out.println(actualCondensedFormatMeta); 
    302          
    303         assertEquals(expectedCondensedFormatFEP, actualCondensedFormatFEP); 
    304         assertEquals(expectedCondensedFormatMeta, actualCondensedFormatMeta); 
    305     } 
    306     String expectedCondensedFormatMeta =  
    307             "2\n" + 
    308             "32 0 2\n" + 
    309             "1210831 1 5 S 0.9 4 CALAFIA\n" + 
    310             "1210832 ML ML_1\n" + 
    311             "1210833 ML ML_2\n" + 
    312             "1210834 ML ML_3\n" + 
    313             "1210835 ML ML_4\n" + 
    314             "1210845 2 5 S 1.49 4 EL CAMINO REAL\n" + 
    315             "1210846 ML ML_1\n" + 
    316             "1210847 ML ML_2\n" + 
    317             "1210848 ML ML_3\n" + 
    318             "1210849 ML ML_4\n" + 
    319             "74 0 1\n" + 
    320             "1204203 2 5 N 1.26 4 MAGDALENA\n" + 
    321             "1204212 ML ML_1\n" + 
    322             "1204213 ML ML_2\n" + 
    323             "1204214 ML ML_3\n" + 
    324             "1204215 ML ML_4\n"; 
    325     String expectedCondensedFormatFEP =  
    326             "2\n" + 
    327             "32 0 2\n" + 
    328             "1210831 1 5 S 0.9 4 \n" + 
    329             "1210832  0.0 0 ML_1\n" + 
    330             "1210833  0.0 0 ML_2\n" + 
    331             "1210834  0.0 0 ML_3\n" + 
    332             "1210835  0.0 0 ML_4\n" + 
    333             "1210845 2 5 S 1.49 4 \n" + 
    334             "1210846  0.0 0 ML_1\n" + 
    335             "1210847  0.0 0 ML_2\n" + 
    336             "1210848  0.0 0 ML_3\n" + 
    337             "1210849  0.0 0 ML_4\n" + 
    338             "74 0 1\n" + 
    339             "1204203 2 5 N 1.26 4 \n" + 
    340             "1204212  0.0 0 ML_1\n" + 
    341             "1204213  0.0 0 ML_2\n" + 
    342             "1204214  0.0 0 ML_3\n" + 
    343             "1204215  0.0 0 ML_4\n"; 
    344      
     209                 
     210        highways.reset(); 
     211        result = highways.toString(); 
     212        assertEquals("5 N .-.\n  5 S -.-", result.trim()); 
     213    } 
     214 
     215 
    345216} 
  • trunk/test/tmcsim/highwaymodel/LoadHighwaysTest.java

    r343 r422  
    1 package atmsdriver.model; 
     1package tmcsim.highwaymodel; 
    22 
     3import tmcsim.highwaymodel.Station; 
     4import tmcsim.highwaymodel.Highways; 
     5import tmcsim.highwaymodel.Highway; 
    36import java.io.FileWriter; 
    47import java.io.PrintWriter; 
     
    2528        PrintWriter writer = null; 
    2629        try { 
    27             writer = new PrintWriter(new FileWriter("test/atmsdriver/model/lds_loadhighways_sample.txt")); 
    28              
    29             writer.println("2"); 
    30             writer.println("32 0 2"); 
    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"); 
    41             writer.println("74 0 1"); 
    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"); 
     30            writer = new PrintWriter(new FileWriter("test/atmsdriver/postmiles1.txt")); 
     31            writer.println("5 S 0.9,33.408425,-117.599923,CALAFIA,0,0"); 
     32            writer.println("5 N 1.24,33.413051,-117.601964,MAGDALENA,0,0"); 
     33            writer.println("5 S 1.49,33.416348,-117.603827,EL CAMINO REAL,0,0"); 
    4734            writer.close(); 
     35            writer = new PrintWriter(new FileWriter("test/atmsdriver/postmiles3.txt")); 
     36            writer.println("73 N 23.9,33.643656,-117.859875,BISON 2,0.976131,0.217185"); 
     37            writer.println("55 S 6.88,33.697495,-117.862677,MACARTHU1,-0.710326,0.703873"); 
     38            writer.println("5 N 5.73,33.458342,-117.655008,ESTRELLA1,0,0"); 
     39            writer.println("5 N 6.47,33.464404,-117.665509,SACRAMENTO,0.523797,0.851843"); 
     40            writer.println("405 N 6.21,33.672851,-117.832271,HARVARD,0.320278,0.947323"); 
     41            writer.println("405 S 6.8,33.675863,-117.84179,JAMBOREE1,-0.402558,-0.915394"); 
     42            writer.close();             
    4843        } catch (Exception e) { 
    4944            e.printStackTrace(); 
     
    5449    protected void tearDown() throws Exception { 
    5550        super.tearDown(); 
    56         Path path = FileSystems.getDefault().getPath("test/atmsdriver/model", "lds_loadhighways_sample.txt"); 
     51        Path path = FileSystems.getDefault().getPath("test/atmsdriver", "postmiles1.txt"); 
     52        Files.delete(path); 
     53        path = FileSystems.getDefault().getPath("test/atmsdriver", "postmiles3.txt"); 
    5754        Files.delete(path); 
    5855    } 
     
    6259     */ 
    6360    public void testLoadHighways() { 
    64         System.out.println("toXML"); 
     61        System.out.println("testLoadHighways"); 
    6562        Highways highways = new Highways( 
    66                 "test/atmsdriver/model/lds_loadhighways_sample.txt", 
    67                 "localhost", 8080); 
     63                "test/atmsdriver/postmiles1.txt"); 
    6864 
    6965        // Test for correct number of highways 
     
    7874        assertEquals(new Integer(3), new Integer(fiveS.stations.size())); 
    7975         
    80         // Test 5 stations are sorted by postmile 
     76        // Test hwy5 stations are sorted by postmile 
    8177        List<Station> stations = (ArrayList) fiveS.stations; 
    8278        ArrayList<Double> stationsPostmiles = new ArrayList<>(); 
     
    8985        ArrayList<Double> expectedStationsPostmiles = new ArrayList<>(); 
    9086        expectedStationsPostmiles.add(new Double(0.9)); 
    91         expectedStationsPostmiles.add(new Double(1.26)); 
     87        expectedStationsPostmiles.add(new Double(1.24)); 
    9288        expectedStationsPostmiles.add(new Double(1.49)); 
    9389 
     
    9793                    stationsPostmiles.get(i)); 
    9894        } 
     95    } 
     96    public void testLoadHighways2() { 
     97        System.out.println("testLoadHighways2"); 
     98        Highways highways = new Highways( 
     99                "test/atmsdriver/postmiles3.txt"); 
     100 
     101        // Test for correct number of highways 
     102        List<Highway> result = (ArrayList) highways.highways; 
     103        assertEquals(4, result.size()); 
    99104         
    100         // Test for correct number of loops 
    101         assertEquals(new Integer(12), new Integer(fiveS.stations.get(0).loops.size() 
    102             + fiveS.stations.get(1).loops.size() + fiveS.stations.get(2).loops.size())); 
     105        Highway five = result.get(0); 
     106        assertEquals(new Integer(5), five.routeNumber); 
     107        assertEquals(new Integer(405), result.get(1).routeNumber); 
     108        assertEquals(new Integer(55), result.get(2).routeNumber); 
     109        assertEquals(new Integer(73), result.get(3).routeNumber); 
    103110    } 
    104111} 
  • trunk/test/tmcsim/highwaymodel/PostmileCoordsTest.java

    r269 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
     4import tmcsim.highwaymodel.PostmileCoords; 
    45import java.io.FileInputStream; 
    56import java.io.FileNotFoundException; 
  • trunk/test/tmcsim/highwaymodel/StationTest.java

    r343 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
    4 import atmsdriver.model.Station.DIRECTION; 
     4import tmcsim.highwaymodel.LoopDetector; 
     5import tmcsim.highwaymodel.Station; 
     6import tmcsim.highwaymodel.Station.DIRECTION; 
    57import java.util.ArrayList; 
    68import junit.framework.TestCase; 
     
    8183    } 
    8284    /** 
    83      * TODO: Test of toXML method, of class Station. 
     85     * Test get Color and LoopDetector accessors 
    8486     */ 
    85      
     87    public void testGetColor() 
     88    { 
     89        LoopDetector lane = new LoopDetector(999,"locid","loc"); 
     90        ArrayList<LoopDetector> lanes = new ArrayList<LoopDetector>(); 
     91        lanes.add(lane); 
     92        Station alpha = new Station(1,2,3,"A",lanes, 4, DIRECTION.NORTH, 2.0); 
     93        assertEquals('-',alpha.getColor().symbol()); 
     94        assertEquals("lime",alpha.getColor().htmlColor()); 
     95        lane.setAttributes(LoopDetector.DOTCOLOR.YELLOW); 
     96        assertEquals('+',alpha.getColor().symbol()); 
     97        assertEquals("yellow",alpha.getColor().htmlColor()); 
     98        lane.setAttributes(LoopDetector.DOTCOLOR.RED); 
     99        assertEquals('@',alpha.getColor().symbol()); 
     100        assertEquals("red",alpha.getColor().htmlColor()); 
     101    } 
    86102} 
  • trunk/test/tmcsim/highwaymodel/TrafficEventTest.java

    r183 r422  
    11 
    2 package atmsdriver.model; 
     2package tmcsim.highwaymodel; 
    33 
     4import tmcsim.highwaymodel.TrafficEvent; 
    45import java.text.ParseException; 
    56import java.util.PriorityQueue; 
  • trunk/test/tmcsim/paramicslog/ParamicsLogFileHandlerTest.java

    r123 r422  
    4343        try 
    4444        { 
    45             new CADServer("config/testConfig/cad_simulator_console_config.properties"); 
     45            new CADServer("config/cad_simulator_console_config.properties"); 
    4646        } catch (Exception e) 
    4747        { 
  • trunk/test/tmcsim/paramicslog/ParamicsLogRMITestSkeleton.java

    r123 r422  
    4444        try 
    4545        { 
    46             CADServer engine = new CADServer("config/testConfig/cad_simulator_console_config.properties"); 
     46            CADServer engine = new CADServer("config/cad_simulator_console_config.properties"); 
    4747        } catch (Exception e) 
    4848        { 
Note: See TracChangeset for help on using the changeset viewer.