Changeset 186 in tmcsimulator
- Timestamp:
- 10/28/2017 06:48:11 PM (9 years ago)
- Files:
-
- 1 deleted
- 11 edited
-
branches/FEPSimulator/HighwaysParser.cpp (modified) (1 diff)
-
branches/FEPSimulator/NetworkReader.h (deleted)
-
branches/FEPSimulator/nbproject/configurations.xml (modified) (3 diffs)
-
branches/FEPSimulator/nbproject/private/private.xml (modified) (1 diff)
-
trunk/src/atmsdriver/ATMSDriver.java (modified) (1 diff)
-
trunk/src/atmsdriver/model/FEPLine.java (modified) (2 diffs)
-
trunk/src/atmsdriver/model/Highways.java (modified) (1 diff)
-
trunk/src/atmsdriver/model/LoopDetector.java (modified) (2 diffs)
-
trunk/src/atmsdriver/model/Station.java (modified) (2 diffs)
-
trunk/src/tmcsim/application.properties (modified) (1 diff)
-
trunk/test/atmsdriver/model/LoadSadDotsTest.java (modified) (2 diffs)
-
trunk/test/atmsdriver/model/StationTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/FEPSimulator/HighwaysParser.cpp
r177 r186 1 #include "NetworkReader.h" 1 /* 2 * File: HighwaysParser.cpp 3 * Author: jtorres 4 * 5 * Created on October 28, 2017, 7:23 PM 6 */ 2 7 3 HighwaysParser::HighwaysParser(const char * xml) { 4 ldsIndex = 0; 5 loadLines(xml); 6 } 8 #include "HighwaysParser.h" 7 9 8 LOOP * HighwaysParser::parseLoop(TiXmlElement * loopElem) { 9 LOOP *loop = new LOOP; 10 11 TiXmlElement *subLoopElem = loopElem->FirstChildElement(); 12 loop->loopID = atoi(subLoopElem->GetText()); 13 subLoopElem = subLoopElem->NextSiblingElement(); 14 loop->loop_loc = (char *) subLoopElem->GetText(); 15 subLoopElem = subLoopElem->NextSiblingElement(); 16 subLoopElem = subLoopElem->NextSiblingElement(); // skip lane num 17 loop->vol = atoi(subLoopElem->GetText()); 18 subLoopElem = subLoopElem->NextSiblingElement(); 19 loop->occ = atof(subLoopElem->GetText()); 20 subLoopElem = subLoopElem->NextSiblingElement(); 21 loop->spd = atof(subLoopElem->GetText()); 22 23 return loop; 24 } 25 26 STATION * HighwaysParser::parseStation(TiXmlElement *stationElem, FEP_LINE *line) { 27 STATION *station = new STATION; 28 29 TiXmlElement *stationSubElem = stationElem->FirstChildElement(); 30 station->lds = atol(stationSubElem->GetText()); 31 cout << "Station: " << station->lds << endl; 32 line->lds.push_back(station->lds); 33 line->ldsIndex.push_back(ldsIndex++); 34 stationSubElem = stationSubElem->NextSiblingElement(); 35 station->line_num = atoi(stationSubElem->GetText()); 36 stationSubElem = stationSubElem->NextSiblingElement(); 37 station->drop = atoi(stationSubElem->GetText()); 38 stationSubElem = stationSubElem->NextSiblingElement(); 39 stationSubElem = stationSubElem->NextSiblingElement(); // skip location 40 stationSubElem = stationSubElem->NextSiblingElement(); // skip postmile 41 stationSubElem = stationSubElem->NextSiblingElement(); // skip direction 42 stationSubElem = stationSubElem->NextSiblingElement(); // skip freeway 43 station->MlTotVol = atoi(stationSubElem->GetText()); 44 stationSubElem = stationSubElem->NextSiblingElement(); 45 station->OppTotVol = atoi(stationSubElem->GetText()); 46 47 station->pos = 0; // NOT SURE WHY WE NEED THIS? 48 49 // Add loops to station 50 TiXmlElement *loopElem = stationSubElem->NextSiblingElement()->FirstChildElement(); 51 for (loopElem; loopElem; loopElem = loopElem->NextSiblingElement()) { 52 LOOP *loop = parseLoop(loopElem); 53 station->loops.push_back(loop); 54 } 55 cout << "Number of Loops: " << station->loops.size() << endl; 56 // Data pack ATMS message 57 station->length = station->loops.size() * 2 + CONTROL_DATA_LEN; 58 cout << station->loops.size() << endl; 59 station->dataPack = DataPacker::packData(station); 60 61 return station; 62 } 63 64 FEP_LINE * HighwaysParser::parseLine(TiXmlElement * lineElem) { 65 FEP_LINE *line = new FEP_LINE; 66 67 TiXmlElement *lineSubElem = lineElem->FirstChildElement(); 68 line->lineNum = atoi(lineSubElem->GetText()); 69 cout << "Line: " << line->lineNum << endl; 70 lineSubElem = lineSubElem->NextSiblingElement(); 71 line->count = atoi(lineSubElem->GetText()); 72 lineSubElem = lineSubElem->NextSiblingElement(); 73 line->schedule = atoi(lineSubElem->GetText()); 74 lineSubElem = lineSubElem->NextSiblingElement(); 75 line->lineInfo = atoi(lineSubElem->GetText()); 76 lineSubElem = lineSubElem->NextSiblingElement(); 77 line->systemKey = atol(lineSubElem->GetText()); 78 lineSubElem = lineSubElem->NextSiblingElement(); 79 line->globalSeq = atol(lineSubElem->GetText()); 80 lineSubElem = lineSubElem->NextSiblingElement(); 81 line->schedleSeq = atol(lineSubElem->GetText()); 82 83 TiXmlElement *stationsElem = lineSubElem->NextSiblingElement(); 84 TiXmlElement *stationElem = stationsElem->FirstChildElement(); 85 for (stationElem; stationElem; stationElem = stationElem->NextSiblingElement()) { 86 stations.push_back(parseStation(stationElem, line)); 87 } 88 return line; 89 } 90 91 void HighwaysParser::loadLines(const char * xml) { 92 // Load network xml file 93 TiXmlDocument doc; 94 doc.Parse((const char*) xml, 0, TIXML_ENCODING_UTF8); 95 96 // grab <Network> element 97 TiXmlHandle hDoc(&doc); 98 TiXmlElement *networkElem = hDoc.FirstChildElement().Element(); 99 100 // grab first <Line> element 101 TiXmlElement *lineElem = networkElem->FirstChildElement(); 102 103 // iterate through each line element to create FEP_LINE list 104 for (lineElem; lineElem; lineElem = lineElem->NextSiblingElement()) { 105 lines.push_back(parseLine(lineElem)); 106 } 107 } 108 109 vector<FEP_LINE*> HighwaysParser::getLines() { 110 111 return lines; 112 } 113 114 vector<STATION*> HighwaysParser::getStations() { 115 116 return stations; 10 HighwaysParser::HighwaysParser() { 117 11 } 118 12 119 13 HighwaysParser::~HighwaysParser() { 14 } 120 15 121 } -
branches/FEPSimulator/nbproject/configurations.xml
r185 r186 7 7 <itemPath>DataPacker.h</itemPath> 8 8 <itemPath>FEPSim.h</itemPath> 9 <itemPath> NetworkReader.h</itemPath>9 <itemPath>HighwaysParser.h</itemPath> 10 10 <itemPath>fep.h</itemPath> 11 11 <itemPath>network.h</itemPath> … … 62 62 <item path="HighwaysParser.cpp" ex="false" tool="1" flavor2="0"> 63 63 </item> 64 <item path="HighwaysParser.h" ex="false" tool="3" flavor2="0"> 65 </item> 64 66 <item path="Main.cpp" ex="false" tool="1" flavor2="0"> 65 </item>66 <item path="NetworkReader.h" ex="false" tool="3" flavor2="0">67 67 </item> 68 68 <item path="fep.h" ex="false" tool="3" flavor2="0"> … … 105 105 <item path="HighwaysParser.cpp" ex="false" tool="1" flavor2="0"> 106 106 </item> 107 <item path="HighwaysParser.h" ex="false" tool="3" flavor2="0"> 108 </item> 107 109 <item path="Main.cpp" ex="false" tool="1" flavor2="0"> 108 </item>109 <item path="NetworkReader.h" ex="false" tool="3" flavor2="0">110 110 </item> 111 111 <item path="fep.h" ex="false" tool="3" flavor2="0"> -
branches/FEPSimulator/nbproject/private/private.xml
r185 r186 8 8 <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> 9 9 <group> 10 <file>file:/Users/jtorres/tmcsimulator/branches/FEPSimulator/Main.cpp</file> 10 11 <file>file:/Users/jtorres/tmcsimulator/branches/FEPSimulator/FEPSim.cpp</file> 11 12 </group> -
trunk/src/atmsdriver/ATMSDriver.java
r184 r186 116 116 Integer.parseInt(ATMSDriverProperties.getProperty( 117 117 PROPERTIES.FEP_WRITER_PORT.name))); 118 System.out.println(highways.toCondensedFormat(false)); 118 119 // create the exchange reader 119 120 exchangeReader = new ExchangeReader(); -
trunk/src/atmsdriver/model/FEPLine.java
r184 r186 37 37 } 38 38 39 /** 40 * Returns the FEPLine meta data in string format 41 * @return FEPLine metadata 39 /** Returns a string of highways data. If MetaDataOnly is true, you get a full 40 * dump of the highways meta data, which does not include dynamic loop values, 41 * and does include the string location names. If MetaDataOnly is false, 42 * dynamic loop values are included, and unnecessary information like string 43 * location values are included. 44 * 45 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 46 * value of false, over the socket. 47 * 48 * The MetaDataOnly flag should be used to get a full dump of the highways 49 * information. This was used to get the highways_fullmap.txt output. 50 * 51 * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 52 * @return String, highways data in condensed format 42 53 */ 43 public String getLineMeta()54 public String toCondensedFormat(boolean MetaDataOnly) 44 55 { 45 56 StringBuilder build = new StringBuilder(); … … 50 61 build.append(Integer.toString(this.stations.size())); 51 62 build.append("\n"); 52 for (Station station : stations)63 for(Station station : stations) 53 64 { 54 build.append(station. getStationMeta());65 build.append(station.toCondensedFormat(MetaDataOnly)); 55 66 } 56 67 return build.toString(); -
trunk/src/atmsdriver/model/Highways.java
r184 r186 354 354 } 355 355 } 356 357 /** 358 * Returns the highways metadata in condensed form. This function took the 359 * highways model and wrote it into condensed form. It is also useful for 360 * testing. 361 * 362 * @return the highways meta data string 363 */ 364 public String getHighwaysMeta() 365 { 366 StringBuilder build = new StringBuilder(); 367 build.append(lines.size()); 368 build.append("\n"); 369 for (FEPLine line : lines) 370 { 371 build.append(line.getLineMeta()); 372 } 373 return build.toString(); 374 } 375 356 357 /** Returns a string of highways data. If MetaDataOnly is true, you get a full 358 * dump of the highways meta data, which does not include dynamic loop values, 359 * and does include the string location names. If MetaDataOnly is false, 360 * dynamic loop values are included, and unnecessary information like string 361 * location values are included. 362 * 363 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 364 * value of false, over the socket. 365 * 366 * The MetaDataOnly flag should be used to get a full dump of the highways 367 * information. This was used to get the highways_fullmap.txt output. 368 * 369 * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 370 * @return String, highways data in condensed format 371 */ 372 public String toCondensedFormat(boolean MetaDataOnly) 373 { 374 StringBuilder build = new StringBuilder(); 375 build.append(lines.size()); 376 build.append("\n"); 377 for(FEPLine line : lines) 378 { 379 build.append(line.toCondensedFormat(MetaDataOnly)); 380 } 381 return build.toString(); 382 } 383 376 384 /** 377 385 * Returns the Highways model data in XML format. -
trunk/src/atmsdriver/model/LoopDetector.java
r184 r186 68 68 } 69 69 70 /** 71 * Returns the loop metadata in condensed form. 72 * This is just a quick script function to make a proper highway 73 * metadata configuration file, so that we can read the network 74 * faster. 75 * 76 * @return loop metadata 77 */ 78 public String getLoopMeta() 70 /** Returns a string of highways data. If MetaDataOnly is true, you get a full 71 * dump of the highways meta data, which does not include dynamic loop values, 72 * and does include the string location names. If MetaDataOnly is false, 73 * dynamic loop values are included, and unnecessary information like string 74 * location values are included. 75 * 76 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 77 * value of false, over the socket. 78 * 79 * The MetaDataOnly flag should be used to get a full dump of the highways 80 * information. This was used to get the highways_fullmap.txt output. 81 * 82 * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 83 * @return String, highways data in condensed format 84 */ 85 public String toCondensedFormat(boolean MetaDataOnly) 79 86 { 80 87 StringBuilder build = new StringBuilder(); … … 83 90 build.append(Integer.toString(this.laneNum)); 84 91 build.append(" "); 85 build.append(this.loopLocation); 92 if(!MetaDataOnly) 93 { 94 build.append(" "); 95 build.append(this.occ); 96 build.append(" "); 97 build.append(this.vol); 98 build.append(" "); 99 build.append(this.spd); 100 } 101 else 102 { 103 build.append(this.loopLocation); 104 } 86 105 build.append("\n"); 87 106 return build.toString(); -
trunk/src/atmsdriver/model/Station.java
r184 r186 88 88 return oppTotVol; 89 89 } 90 91 /** 92 * Returns the station metadata in condensed form. This is just a quick 93 * script function to make a proper highway metadata configuration file, so 94 * that we can read the network faster. 95 * 96 * @return station metadata 97 */ 98 public String getStationMeta() 90 91 /** Returns a string of highways data. If MetaDataOnly is true, you get a full 92 * dump of the highways meta data, which does not include dynamic loop values, 93 * and does include the string location names. If MetaDataOnly is false, 94 * dynamic loop values are included, and unnecessary information like string 95 * location values are included. 96 * 97 * The FEPSimulator takes in the toCondensedFormat() output, with a MetaDataOnly 98 * value of false, over the socket. 99 * 100 * The MetaDataOnly flag should be used to get a full dump of the highways 101 * information. This was used to get the highways_fullmap.txt output. 102 * 103 * @param MetaDataOnly Whether you want meta data, or a full dump for FEPSim 104 * @return String, highways data in condensed format 105 */ 106 public String toCondensedFormat(boolean MetaDataOnly) 99 107 { 100 108 StringBuilder build = new StringBuilder(); … … 111 119 build.append(Integer.toString(loops.size())); 112 120 build.append(" "); 113 build.append(this.location); 121 if(MetaDataOnly) 122 { 123 build.append(this.location); 124 } 114 125 build.append("\n"); 115 126 for (LoopDetector loop : loops) 116 127 { 117 build.append(loop. getLoopMeta());128 build.append(loop.toCondensedFormat(MetaDataOnly)); 118 129 } 119 130 return build.toString(); -
trunk/src/tmcsim/application.properties
r185 r186 1 #Sat, 28 Oct 2017 19: 14:00-07001 #Sat, 28 Oct 2017 19:54:27 -0700 2 2 3 Application.revision=18 43 Application.revision=185 4 4 5 Application.buildnumber=6 35 Application.buildnumber=67 -
trunk/test/atmsdriver/model/LoadSadDotsTest.java
r185 r186 61 61 ArrayList<Station> stations = fiftyfiveN.stations; 62 62 Station sad = stations.get(0); 63 System.out.println(""+sad. getStationMeta());63 System.out.println(""+sad.toCondensedFormat(true)); 64 64 assertEquals(22, sad.loops.size()); 65 65 … … 69 69 stations = fourohfiveS.stations; 70 70 Station happy = stations.get(0); 71 System.out.println(""+happy. getStationMeta());71 System.out.println(""+happy.toCondensedFormat(true)); 72 72 assertEquals(9, happy.loops.size()); 73 73 } -
trunk/test/atmsdriver/model/StationTest.java
r103 r186 50 50 System.out.println("getStationMeta"); 51 51 String expResult = "2 3 4 N 1.0 0 A\n"; 52 String result = alpha. getStationMeta();52 String result = alpha.toCondensedFormat(true); 53 53 assertEquals(expResult, result); 54 54 }
Note: See TracChangeset
for help on using the changeset viewer.
