Changeset 424 in tmcsimulator
- Timestamp:
- 06/23/2019 01:08:58 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/tmcsim/application.properties (modified) (1 diff)
-
src/tmcsim/highwaymodel/Station.java (modified) (5 diffs)
-
test/tmcsim/highwaymodel/StationTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/application.properties
r422 r424 1 #Sun, 23 Jun 2019 1 1:49:46-07001 #Sun, 23 Jun 2019 14:38:34 -0700 2 2 3 Application.revision=4 193 Application.revision=423 4 4 5 5 Application.buildnumber=140 -
trunk/src/tmcsim/highwaymodel/Station.java
r422 r424 21 21 public final class Station implements Comparable 22 22 { 23 24 23 /* Static Station meta data */ 25 24 final public int lineID; … … 33 32 34 33 /* Dynamic Station data */ 35 private int MLTotVol; 36 private int OppTotVol; 34 private int totalVolume; 37 35 38 36 /* Constructor */ … … 50 48 this.routeNumber = hwy; 51 49 52 this.MLTotVol = getMLTotVol(); 53 this.OppTotVol = getOPPTotVol(); 54 } 55 56 /** 57 * Calculates the total ML Volume. 58 * 59 * @return total ML volume. 60 */ 61 private int getMLTotVol() 50 this.totalVolume = calcTotalVolume(); 51 } 52 53 /** 54 * Calculates the total lane Volume. 55 * Reserved for future use. 56 * @return total lane volume. 57 */ 58 private int calcTotalVolume() 62 59 { 63 60 int mlTotVol = 0; 64 61 for (LoopDetector loop : loops) 65 62 { 66 if (loop.loopLocation.startsWith("ML"))67 {68 63 mlTotVol += loop.vol; 69 }70 64 } 71 65 return mlTotVol; 72 }73 74 /**75 * Calculates the total OPP Volume76 *77 * @return total OPP volume.78 */79 private int getOPPTotVol()80 {81 int oppTotVol = 0;82 for (LoopDetector loop : loops)83 {84 if (loop.loopLocation.startsWith("OS"))85 {86 oppTotVol += loop.vol;87 }88 }89 return oppTotVol;90 }91 92 /**93 * Returns a string of highways data. If MetaDataOnly is true, you get a94 * full dump of the highways meta data, which does not include dynamic loop95 * values, and does include the string location names. If MetaDataOnly is96 * false, dynamic loop values are included, and unnecessary information like97 * string location values are included.98 *99 * The FEPSimulator takes in the toCondensedFormat() output, with a100 * MetaDataOnly value of false, over the socket.101 *102 * The MetaDataOnly flag should be used to get a full dump of the highways103 * information. This was used to get the highways_fullmap.txt output.104 *105 * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim106 * @return String, highways data in condensed format107 */108 public String toCondensedFormat(boolean MetaDataOnly)109 {110 StringBuilder build = new StringBuilder();111 build.append(Integer.toString(this.vdsID));112 build.append(" ");113 build.append(Integer.toString(this.drop));114 build.append(" ");115 build.append(Integer.toString(this.routeNumber));116 build.append(" ");117 build.append(this.direction.getLetter());118 build.append(" ");119 build.append(Double.toString(this.postmile));120 build.append(" ");121 build.append(Integer.toString(loops.size()));122 build.append(" ");123 if (MetaDataOnly)124 {125 build.append(this.location);126 }127 build.append("\n");128 for (LoopDetector loop : loops)129 {130 build.append(loop.toCondensedFormat(MetaDataOnly));131 }132 return build.toString();133 66 } 134 67 … … 201 134 } 202 135 203 this.MLTotVol = getMLTotVol(); 204 this.OppTotVol = getOPPTotVol(); 136 this.totalVolume = calcTotalVolume(); 205 137 } 206 138 } … … 252 184 OPP_ML, this.location, Double.toString(this.postmile), 253 185 dotcolor.name()); 254 }255 256 /**257 * XML tags used for toXML() method.258 */259 private static enum XML_TAGS260 {261 262 STATION("Station"),263 LDS_ID("LDS_ID"),264 LINE_NUM("Line_Num"),265 DROP("Drop"),266 LOOPS("Loops"),267 LOCATION("Location"),268 POST_MILE("Post_Mile"),269 DIRECTION("Direction"),270 FREEWAY("Freeway"),271 ML_TOT_VOL("ML_Tot_Vol"),272 OPP_TOT_VOL("Opp_Tot_Vol");273 274 String tag;275 276 private XML_TAGS(String n)277 {278 tag = n;279 }280 }281 282 /**283 * Returns the Station data in XMLFormat.284 *285 * @param currElem The current XML <Station> element286 */287 public void toXML(Element currElem)288 {289 Document theDoc = currElem.getOwnerDocument();290 291 Element stationElement = theDoc.createElement(XML_TAGS.STATION.tag);292 currElem.appendChild(stationElement);293 294 Element ldsIDElement = theDoc.createElement(XML_TAGS.LDS_ID.tag);295 ldsIDElement.appendChild(theDoc.createTextNode(String.valueOf(this.vdsID)));296 stationElement.appendChild(ldsIDElement);297 298 Element lineNumElement = theDoc.createElement(XML_TAGS.LINE_NUM.tag);299 lineNumElement.appendChild(theDoc.createTextNode(String.valueOf(this.lineID)));300 stationElement.appendChild(lineNumElement);301 302 Element dropElement = theDoc.createElement(XML_TAGS.DROP.tag);303 dropElement.appendChild(theDoc.createTextNode(String.valueOf(this.drop)));304 stationElement.appendChild(dropElement);305 306 Element locationElement = theDoc.createElement(XML_TAGS.LOCATION.tag);307 locationElement.appendChild(theDoc.createTextNode(this.location));308 stationElement.appendChild(locationElement);309 310 Element postMileElement = theDoc.createElement(XML_TAGS.POST_MILE.tag);311 postMileElement.appendChild(theDoc.createTextNode(String.valueOf(this.postmile)));312 stationElement.appendChild(postMileElement);313 314 Element directionElement = theDoc.createElement(XML_TAGS.DIRECTION.tag);315 directionElement.appendChild(theDoc.createTextNode("" + this.direction.getLetter()));316 stationElement.appendChild(directionElement);317 318 Element freewayElement = theDoc.createElement(XML_TAGS.FREEWAY.tag);319 freewayElement.appendChild(theDoc.createTextNode(String.valueOf(this.routeNumber)));320 stationElement.appendChild(freewayElement);321 322 Element mlElement = theDoc.createElement(XML_TAGS.ML_TOT_VOL.tag);323 mlElement.appendChild(theDoc.createTextNode(String.valueOf(this.MLTotVol)));324 stationElement.appendChild(mlElement);325 326 Element oppElement = theDoc.createElement(XML_TAGS.OPP_TOT_VOL.tag);327 oppElement.appendChild(theDoc.createTextNode(String.valueOf(this.OppTotVol)));328 stationElement.appendChild(oppElement);329 330 Element loopsElement = theDoc.createElement(XML_TAGS.LOOPS.tag);331 stationElement.appendChild(loopsElement);332 333 for (LoopDetector loop : loops)334 {335 loop.toXML(loopsElement);336 }337 186 } 338 187 -
trunk/test/tmcsim/highwaymodel/StationTest.java
r422 r424 47 47 48 48 /** 49 * Test of getStationMeta method, of class Station.50 */51 public void testGetStationMeta() {52 System.out.println("getStationMeta");53 String expResult = "2 3 4 N 1.0 0 A\n";54 String result = alpha.toCondensedFormat(true);55 assertEquals(expResult, result);56 }57 58 /**59 49 * Test of getPostmile method, of class Station. 60 50 */
Note: See TracChangeset
for help on using the changeset viewer.
