Changeset 199 in tmcsimulator


Ignore:
Timestamp:
10/30/2017 04:05:39 PM (9 years ago)
Author:
jtorres
Message:

updated HighwaysParser?.cpp, not done

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/FEPSimulator/HighwaysParser.cpp

    r195 r199  
    77 
    88#include "HighwaysParser.h" 
    9  
     9     /* 43                   // "number of lines" 
     10     * 32 0 13              // "line id" "count num" "number of stations" 
     11     * 1210831 1 5 S 0.9 8  // "station id" "drop num" "route num"... 
     12     *                      //      ..."direction" "postmile" "number of loops" 
     13     * 1210832  0.0 0       // "loop id" "occ" "vol" 
     14     * 1210833  0.0 0       // .. 
     15     * 1210834  0.0 0       // .. 
     16     * 1210835  0.0 0       // .. 
     17     * 1210836  0.0 0       // .. 
     18     * 1210837  0.0 0       // .. 
     19     * 1210838  0.0 0       // .. 
     20     * 1210839  0.0 0       // .. 
     21      * */ 
    1022HighwaysParser::HighwaysParser(char * hwyData) { 
    1123    string highwaysData = hwyData; 
     
    2436     
    2537} 
    26 // FEP line: Represents a serial communication line from field stations to the  
    27 // An FEP Line has several Loop Detector Stations (Stations) connected) 
    28 typedef struct fep_line FEP_LINE; 
    29 struct  fep_line 
     38 
     39// Loop Detector: A single sensor that detects the volume, occupancy, and speed 
     40// in a single highway lane 
     41typedef struct loop LOOP; 
     42struct loop 
    3043{ 
    31         int             lineNum; 
    32         vector<long>    lds; 
    33         vector<long>    ldsIndex;       // location in ldsMap 
    34  
    35         short   count;  // actual count from caltrans 
    36         int     schedule; 
    37         int     lineInfo; 
    38         long    systemKey; 
    39         long    globalSeq; 
    40         long    schedleSeq; 
     44    // meta data 
     45    long loopID; 
     46    char *loop_loc; 
     47     
     48    // dynamic data 
     49    int vol; 
     50    float occ; 
     51    double spd; 
    4152}; 
    4253void HighwaysParser::parseLines(istringstream highwaysData) 
     
    5667    long globalSeq = 0; 
    5768    long schedleSeq = 0; 
     69    short dropNum = 0; 
     70    int routeNum = 0; 
     71    char * direction = ""; 
     72    float postmile = 0; 
     73    long loopID = 0; 
     74    float occ = 0; 
     75    int vol = 0; 
    5876     
    5977    for(int lineIndex = 0; lineIndex < numLines; lineIndex++) 
    6078    { 
     79        FEP_LINE * newLine = new FEP_LINE; 
     80         
    6181        getline(highwaysData, currLine); 
    6282        int numStations = 0; 
    6383        sscanf(currLine, "%d %d %d", &lineNum, &count, &numStations); 
     84 
     85        newLine->lineNum = lineNum; 
     86        newLine->count = count; 
     87        newLine->schedule = schedule; 
     88        newLine->lineInfo = lineInfo; 
     89        newLine->systemKey = systemKey; 
     90        newLine->globalSeq = globalSeq; 
     91        newLine->schedleSeq = schedleSeq; 
     92         
    6493        for(int stationIndex = 0; stationIndex < numStations; stationIndex++) 
    6594        { 
     95            STATION * newStation = new STATION; 
     96             
     97            int numLoops = 0; 
    6698            getline(highwaysData, currLine); 
    67             sscanf(currLine, "%d %d %d %d %d %d", &lds, ) 
     99            sscanf(currLine, "%ld %d %d %s %d %d", &lds, &dropNum,&routeNum,  
     100                    direction, postmile, &numLoops); 
    68101             
     102            newLine->lds.push_back(lds); 
     103            newLine->ldsIndex.push_back(ldsIndex++); 
     104             
     105            for(int loopIndex = 0; loopIndex < numLoops; loopIndex++) 
     106            { 
     107                getline(highwaysData, currLine); 
     108                sscanf(currLine, "%ld %f %d", &loopID, &occ, &vol); 
     109            } 
    69110        } 
     111         
     112        this->lines.push_back(newLine); 
    70113    } 
    71     getline(highwaysData, currLine); 
    72114} 
    73115 
Note: See TracChangeset for help on using the changeset viewer.