Changeset 186 in tmcsimulator for branches


Ignore:
Timestamp:
10/28/2017 06:48:11 PM (9 years ago)
Author:
jtorres
Message:

Highways.java, FEPLine.java, LoopDetector?.java, Station.java: reconfigured the getHighwaysMeta() function to a toCondensedFormat(boolean MetaDataOnly?) method. By specifying MetaDataOnly? as true, you get the same output as the previous getHighwaysMeta() function. By specifying MetaDataOnly? as false, you get the new condensed format needed to send to the FEPSim over the socket. This allows us to use the same function to get a meta data dump, as well as get the highways data format needed for FEPSim socket. HighwaysParser?.cpp: removed the old tinyxml code, set up skeleton for new parser. NetworkReader?.h: deleted, and added HighwaysParser?.h. LoadSadDotsTest?.java and StationTest?.java: configured to use new toCondensedFormat method instead of getHighwaysMeta.

Location:
branches/FEPSimulator
Files:
1 deleted
3 edited

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 */ 
    27 
    3 HighwaysParser::HighwaysParser(const char * xml) { 
    4     ldsIndex = 0; 
    5     loadLines(xml); 
    6 } 
     8#include "HighwaysParser.h" 
    79 
    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; 
     10HighwaysParser::HighwaysParser() { 
    11711} 
    11812 
    11913HighwaysParser::~HighwaysParser() { 
     14} 
    12015 
    121 } 
  • branches/FEPSimulator/nbproject/configurations.xml

    r185 r186  
    77      <itemPath>DataPacker.h</itemPath> 
    88      <itemPath>FEPSim.h</itemPath> 
    9       <itemPath>NetworkReader.h</itemPath> 
     9      <itemPath>HighwaysParser.h</itemPath> 
    1010      <itemPath>fep.h</itemPath> 
    1111      <itemPath>network.h</itemPath> 
     
    6262      <item path="HighwaysParser.cpp" ex="false" tool="1" flavor2="0"> 
    6363      </item> 
     64      <item path="HighwaysParser.h" ex="false" tool="3" flavor2="0"> 
     65      </item> 
    6466      <item path="Main.cpp" ex="false" tool="1" flavor2="0"> 
    65       </item> 
    66       <item path="NetworkReader.h" ex="false" tool="3" flavor2="0"> 
    6767      </item> 
    6868      <item path="fep.h" ex="false" tool="3" flavor2="0"> 
     
    105105      <item path="HighwaysParser.cpp" ex="false" tool="1" flavor2="0"> 
    106106      </item> 
     107      <item path="HighwaysParser.h" ex="false" tool="3" flavor2="0"> 
     108      </item> 
    107109      <item path="Main.cpp" ex="false" tool="1" flavor2="0"> 
    108       </item> 
    109       <item path="NetworkReader.h" ex="false" tool="3" flavor2="0"> 
    110110      </item> 
    111111      <item path="fep.h" ex="false" tool="3" flavor2="0"> 
  • branches/FEPSimulator/nbproject/private/private.xml

    r185 r186  
    88    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> 
    99        <group> 
     10            <file>file:/Users/jtorres/tmcsimulator/branches/FEPSimulator/Main.cpp</file> 
    1011            <file>file:/Users/jtorres/tmcsimulator/branches/FEPSimulator/FEPSim.cpp</file> 
    1112        </group> 
Note: See TracChangeset for help on using the changeset viewer.