Changeset 422 in tmcsimulator for trunk/src/tmcsim/highwaymodel/Station.java
- Timestamp:
- 06/23/2019 10:27:35 AM (7 years ago)
- Location:
- trunk/src/tmcsim/highwaymodel
- Files:
-
- 1 added
- 1 copied
-
. (added)
-
Station.java (copied) (copied from trunk/src/atmsdriver/model/Station.java) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/highwaymodel/Station.java
r343 r422 1 package atmsdriver.model;2 3 import atmsdriver.model.LoopDetector.DOTCOLOR;1 package tmcsim.highwaymodel; 2 3 import tmcsim.highwaymodel.LoopDetector.DOTCOLOR; 4 4 import java.util.ArrayList; 5 5 import java.util.List; … … 9 9 /** 10 10 * A Station (VDS or Vehicle Detector Station) represents a group of lane detectors 11 * across all lanes in onedirection at a particular point on a highway. A station is identified11 * across all lanes in ONE direction at a particular point on a highway. A station is identified 12 12 * by its highway number and postmile. A station has an associated direction 13 13 * used to establish which direction is Main and which is Opposite. The MLTotVol … … 194 194 outputUpdateMessage(dotColor, direction.toString()); 195 195 196 // Set the values for all lanes at this station 196 197 for (LoopDetector loop : loops) 197 198 { 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); 205 201 } 206 202 … … 210 206 } 211 207 /** 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() 217 212 { 218 213 /* 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 */ 220 215 221 216 String laneDir = ""; 222 217 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 273 241 /** 274 242 * Output for updateByDirection. Logs the update to the console.
Note: See TracChangeset
for help on using the changeset viewer.
