- Timestamp:
- 10/28/2017 06:48:11 PM (9 years ago)
- Location:
- branches/FEPSimulator
- Files:
-
- 1 deleted
- 3 edited
-
HighwaysParser.cpp (modified) (1 diff)
-
NetworkReader.h (deleted)
-
nbproject/configurations.xml (modified) (3 diffs)
-
nbproject/private/private.xml (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>
Note: See TracChangeset
for help on using the changeset viewer.
