Changeset 103 in tmcsimulator for trunk/src/atmsdriver/model/Station.java


Ignore:
Timestamp:
10/12/2017 12:28:28 AM (9 years ago)
Author:
jtorres
Message:

trunk/src/atmsdriver/ConsoleDriver.java: Created console driver for ATMSDriver, completed and very nice. Still need to apply correct vol/occ values to actually change the colors. Still need to write a JUnit test for it. trunk/src/atmsdriver/ATMSDriver.java: Refactored to run the console driver. ATMSDriver runs in thread, console driver runs, and they share the highways instance. Renamed NetworkLoader?.java to FEPLineLoader.java. trunk/src/atmsdriver/model/Highways.java: refactored loadHighways() method to conform to new undirected highway abstraction. trunk/src/atmsdriver/model/Station.java: added updateByDirection(DIRECTION dir) method and supporting utility methods. trunk/test/atmsdriver/model/LoadHighwaysTest.java: Conformed LoadHighways? test to new undirected highway abstraction. trunk/test/atmsdriver/model/StationTest.java: Conformed StationTest?.java to new changes - very minor stuff. Went through all model classes and changed any final privates with a getter method to final public, for good OOP practice and simplicity. Went through ALL FILES and commented everything very well. minor application custom configuration changes. Removed all .class or .o.d files from svn repository

File:
1 edited

Legend:

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

    r94 r103  
    11package atmsdriver.model; 
    22 
     3import atmsdriver.ConsoleDriver; 
     4import atmsdriver.ConsoleDriver.DOTCOLOR; 
    35import java.util.List; 
    46import org.w3c.dom.Document; 
     
    2123 
    2224    /* Static Station meta data */ 
    23     final private int lineNum; 
    24     final private int ldsID; // double check 
    25     final private int drop; 
    26     final private String location; 
    27     final private List<LoopDetector> loops; 
    28     final private int highwayNum; 
    29     final private double postmile; 
    30     final private DIRECTION direction; 
     25    final public int lineNum; 
     26    final public int ldsID; // double check 
     27    final public int drop; 
     28    final public String location; 
     29    final public List<LoopDetector> loops; 
     30    final public int routeNumber; 
     31    final public double postmile; 
     32    final public DIRECTION direction; 
    3133 
    3234    /* Dynamic Station data */ 
     
    4648        this.postmile = postmile; 
    4749        this.direction = direction; 
    48         this.highwayNum = hwy; 
     50        this.routeNumber = hwy; 
    4951 
    5052        this.MLTotVol = 0; 
    5153        this.OppTotVol = 0; 
    52     } 
    53  
    54     public int getHighwayNumber() 
    55     { 
    56         return this.highwayNum; 
    57     } 
    58  
    59     public DIRECTION getDirection() 
    60     { 
    61         return this.direction; 
    6254    } 
    6355 
     
    7668        build.append(Integer.toString(this.drop)); 
    7769        build.append(" "); 
    78         build.append(Integer.toString(this.highwayNum)); 
     70        build.append(Integer.toString(this.routeNumber)); 
    7971        build.append(" "); 
    8072        build.append(this.direction.getLetter()); 
     
    9183        } 
    9284        return build.toString(); 
    93     } 
    94  
    95     public double getPostmile() 
    96     { 
    97         return postmile; 
    9885    } 
    9986 
     
    117104 
    118105        // get difference of values 
    119         double otherStationPostmile = ((Station) otherStation).getPostmile(); 
     106        double otherStationPostmile = ((Station) otherStation).postmile; 
    120107        double val = this.postmile - otherStationPostmile; 
    121108 
     
    134121    } 
    135122 
     123    public void updateByDirection(DIRECTION direction, DOTCOLOR dotColor) { 
     124        if(direction.equals(this.direction)) 
     125        { 
     126            updateML(dotColor); 
     127        } 
     128        else 
     129        { 
     130            updateOPP(dotColor); 
     131        } 
     132    } 
     133     
     134    private void updateML(DOTCOLOR dotcolor) 
     135    { 
     136        outputUpdateMessage(dotcolor, "ML"); 
     137         
     138        for(LoopDetector loop : loops) 
     139        { 
     140            if(loop.loopLocation.startsWith("ML")) 
     141            { 
     142                // UPDATE LOOP WITH VALUES 
     143            } 
     144        } 
     145    } 
     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     
     159    private void outputUpdateMessage(DOTCOLOR dotcolor, String OPP_ML) 
     160    { 
     161        System.out.printf("Updating route %-3.3s %-5.5s %-3.3s lanes\t %-12.12s " 
     162                + "at postmile %-6.6s to %-7.7s\n",  
     163                Integer.toString(this.routeNumber), this.direction.name(),  
     164                OPP_ML, this.location, Double.toString(this.postmile),  
     165                dotcolor.name()); 
     166    } 
     167     
    136168    private static enum XML_TAGS 
    137169    { 
     
    189221 
    190222        Element freewayElement = theDoc.createElement(XML_TAGS.FREEWAY.tag); 
    191         freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.highwayNum))); 
     223        freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.routeNumber))); 
    192224        stationElement.appendChild(freewayElement); 
    193225 
Note: See TracChangeset for help on using the changeset viewer.