Changeset 109 in tmcsimulator for trunk/src


Ignore:
Timestamp:
10/12/2017 12:23:11 PM (9 years ago)
Author:
jdalbey
Message:

ATMSDriverClient.java Enhanced to call ConsoleDriver? methods to update highway colors. Removed redundant code in Station..java.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r103 r109  
    121121    } 
    122122 
    123     public void updateByDirection(DIRECTION direction, DOTCOLOR dotColor) { 
     123    /** Determine which lane fields to update based on given direction 
     124     * and update all the loop detectors with the given color. 
     125     * @param direction desired highway direction 
     126     * @param dotColor desired dot color 
     127     */ 
     128    public void updateByDirection(DIRECTION direction, DOTCOLOR dotColor)  
     129    { 
     130        String laneDir = "OPP"; 
    124131        if(direction.equals(this.direction)) 
    125132        { 
    126             updateML(dotColor); 
    127         } 
    128         else 
    129         { 
    130             updateOPP(dotColor); 
    131         } 
    132     } 
    133      
    134     private void updateML(DOTCOLOR dotcolor) 
    135     { 
    136         outputUpdateMessage(dotcolor, "ML"); 
     133            laneDir = "ML"; 
     134        } 
     135        outputUpdateMessage(dotColor, laneDir); 
    137136         
    138137        for(LoopDetector loop : loops) 
    139138        { 
    140             if(loop.loopLocation.startsWith("ML")) 
     139            if(loop.loopLocation.startsWith(laneDir)) 
    141140            { 
    142141                // UPDATE LOOP WITH VALUES 
     142                // TODO: Perhaps enhance DOTCOLOR enum to include constants for 
     143                // vol and occ along with each color.  Then the updateLoop call 
     144                // below could be update(dotColor.volume, dotColor.occ, speed) 
     145                int volume = 0; 
     146                int occ = 0; 
     147                int speed = 0; 
     148                loop.updateLoop(volume, occ, speed); 
    143149            } 
    144150        } 
    145151    } 
    146      
    147     private void updateOPP(DOTCOLOR dotcolor) 
    148     { 
    149         outputUpdateMessage(dotcolor, "OPP"); 
    150         for(LoopDetector loop : loops) 
    151         { 
    152             if(loop.loopLocation.startsWith("OP")) 
    153             { 
    154                 // UPDATE LOOP WITH VALUES 
    155             } 
    156         } 
    157     } 
    158      
     152    
    159153    private void outputUpdateMessage(DOTCOLOR dotcolor, String OPP_ML) 
    160154    { 
  • trunk/src/tmcsim/client/ATMSDriverClient.java

    r105 r109  
    11package tmcsim.client; 
    22 
     3import atmsdriver.ConsoleDriver; 
     4import atmsdriver.model.Highways; 
     5import atmsdriver.model.Station; 
    36import java.awt.event.ActionEvent; 
    47import java.awt.event.ActionListener; 
     
    9497    private Queue<String> eventQueue; 
    9598     
     99    /** Instance of ConsoleDriver that contains the highway model */ 
     100    private ConsoleDriver console; 
    96101 
    97102    /** 
     
    109114            System.exit(0); 
    110115        } 
    111  
     116        Highways highways = new Highways( 
     117        "config/vds_data/lds.txt", 
     118        "config/vds_data/loop.txt", 
     119        "config/vds_data/highwaysMeta.txt", 
     120        "localhost", 8080); 
     121        console = new ConsoleDriver(highways); 
     122         
    112123        connect(cadClientProp.getProperty(PROPERTIES.CAD_SIM_HOST.name).trim(), 
    113124                cadClientProp.getProperty(PROPERTIES.CAD_RMI_PORT.name).trim()); 
     
    146157                    { 
    147158                        System.out.println("LAUNCHING EVENT at " + nextEvent ); 
     159                        // Extract fields from event and prepare them  
     160                        Scanner lineScan = new Scanner(nextEvent); 
     161                        lineScan.next(); // skip time field 
     162                        int routeNumber = lineScan.nextInt(); 
     163                        Station.DIRECTION dir = Station.DIRECTION.toDirection(lineScan.next()); 
     164                        double postmile = lineScan.nextDouble(); 
     165                        int range = lineScan.nextInt(); 
     166                        ConsoleDriver.DOTCOLOR dotcolor = ConsoleDriver.DOTCOLOR.toDotColor(lineScan.next()); 
     167                        // apply colorization to highways 
     168                        console.applyColorToHighwayStretch(routeNumber, dir, postmile, range, dotcolor); 
     169                        // Remove this event from the queue, we're done with it. 
    148170                        eventQueue.remove(); 
    149171                    } 
    150                     //theView.updateTime("" + formatInterval(simtime)); 
    151172                } 
    152173            } 
Note: See TracChangeset for help on using the changeset viewer.