Changeset 209 in tmcsimulator for branches/FEPSimulator/HighwaysParser.cpp


Ignore:
Timestamp:
11/02/2017 12:07:25 AM (9 years ago)
Author:
jtorres
Message:

branches/FEPSimulator/tests: added unit test HighwaysParserTest?.cpp, which yielded a bug in HighwayParser?.cpp (not returning correct loop_loc... garbage data...), this likely explains why not all green dots were showing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FEPSimulator/HighwaysParser.cpp

    r205 r209  
    3535    int numLines; 
    3636    sscanf(currLine.c_str(), "%d", &numLines); 
    37     cout << currLine << endl; 
    3837    int lineNum = 0; 
    3938    long lds = 0; 
     
    5150    float occ = 0; 
    5251    int vol = 0; 
    53     char loopLoc[25]; 
     52 
    5453    for(int lineIndex = 0; lineIndex < numLines; lineIndex++) 
    5554    { 
     
    5958        int numStations = 0; 
    6059        sscanf(currLine.c_str(), "%d %hd %d", &lineNum, &count, &numStations); 
    61         cout << "Line num: " << lineNum << endl; 
    62         cout << "Count: " << count << endl; 
    63         cout << "numStations: " << numStations << endl; 
    6460        newLine->lineNum = lineNum; 
    6561        newLine->count = count; 
     
    9389                 
    9490                getline(highwaysStream, currLine); 
    95                 cout << currLine << endl; 
    96                 sscanf(currLine.c_str(), "%ld %f %d %s", &loopID, &occ, &vol, loopLoc); 
     91                newLoop->loop_loc = (char *) malloc(25 * sizeof(char)); 
     92                sscanf(currLine.c_str(), "%ld %f %d %s", &loopID, &occ, &vol, newLoop->loop_loc); 
    9793                newLoop->loopID = loopID; 
    9894                newLoop->occ = occ; 
    9995                newLoop->vol = vol; 
    10096                newLoop->spd = 0; 
    101                 newLoop->loop_loc = loopLoc; 
    102                 cout << "Adding " << newLoop->loopID << " to " << newStation->lds << endl; 
    10397                newStation->loops.push_back(newLoop); 
    10498            } 
     
    109103                printf("%02X", (unsigned char) newStation->dataPack[byte]); 
    110104            } 
     105            printf("\n"); 
    111106             
    112             cout << "Adding " << newStation->lds << " to ldsMap " << " at index " << ldsIndex << endl; 
    113107            this->stations.push_back(newStation); 
    114108        } 
    115         cout << "Adding " << newLine->lineNum << " to lines" << endl; 
    116109        this->lines.push_back(newLine); 
    117110    } 
Note: See TracChangeset for help on using the changeset viewer.