Changeset 202 in tmcsimulator


Ignore:
Timestamp:
10/30/2017 06:35:42 PM (9 years ago)
Author:
jtorres
Message:

Further progress on condensed format reader, not all green dots showing

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/FEPSimulator/DataPacker.cpp

    r159 r202  
    127127    // dataPack2 (2 bytes per loop) 
    128128    dataPack[2 - 1] = station->loops.size() * 2 + Fixed_Byte_To_Checksum; 
    129  
    130129    // dataPacket 3 (lowbyte: # of mainline loops, highbyte: # of opposite loops) 
    131130    int low = 0, high = 0; 
  • branches/FEPSimulator/FEPSim.cpp

    r177 r202  
    2323void FEPSim::sendReplys(char * buffer) { 
    2424    HighwaysParser highwaysParser = HighwaysParser(buffer); 
    25     vector<FEP_LINE*> lines = highwaysParser.getLines(); 
    26     vector<STATION*> ldsMap = highwaysParser.getStations(); 
     25    vector<FEP_LINE*> lines = highwaysParser.lines; 
     26    vector<STATION*> ldsMap = highwaysParser.stations; 
    2727 
    2828    // Send one reply for every FEPLine 
     
    9494            // Transfer the station data to ATMS and listen for response 
    9595            handleCallResponse(fep_reply_xfer_32(&fepReply, clnt)); 
     96            unsigned int sleepseconds = /* 100 * */1000; 
     97            usleep(sleepseconds); 
    9698        } 
    9799    } 
  • branches/FEPSimulator/HighwaysParser.cpp

    r199 r202  
    2121      * */ 
    2222HighwaysParser::HighwaysParser(char * hwyData) { 
    23     string highwaysData = hwyData; 
    24     istringstream stream(highwaysData); 
    25     parseLines(highwaysData); 
     23    parseLines(hwyData); 
    2624} 
    2725 
     
    2927} 
    3028 
    31 vector<FEP_LINE *> HighwaysParser::getLines() { 
    32      
    33 } 
    34  
    35 vector<STATION *> HighwaysParser::getStations() { 
    36      
    37 } 
    38  
    39 // Loop Detector: A single sensor that detects the volume, occupancy, and speed 
    40 // in a single highway lane 
    41 typedef struct loop LOOP; 
    42 struct loop 
     29void HighwaysParser::parseLines(char * hwyData) 
    4330{ 
    44     // meta data 
    45     long loopID; 
    46     char *loop_loc; 
    47      
    48     // dynamic data 
    49     int vol; 
    50     float occ; 
    51     double spd; 
    52 }; 
    53 void HighwaysParser::parseLines(istringstream highwaysData) 
    54 { 
     31    string highwaysData = hwyData; 
     32    istringstream highwaysStream(highwaysData); 
    5533    string currLine; 
    56     getline(highwaysData, currLine); 
     34    getline(highwaysStream, currLine); 
    5735    int numLines; 
    58     sscanf(highwaysData, "%d", &numLines); 
    59      
     36    sscanf(currLine.c_str(), "%d", &numLines); 
     37    cout << currLine << endl; 
    6038    int lineNum = 0; 
    6139    long lds = 0; 
     
    6947    short dropNum = 0; 
    7048    int routeNum = 0; 
    71     char * direction = ""; 
    7249    float postmile = 0; 
    7350    long loopID = 0; 
    7451    float occ = 0; 
    7552    int vol = 0; 
    76      
     53    char loopLoc[25]; 
    7754    for(int lineIndex = 0; lineIndex < numLines; lineIndex++) 
    7855    { 
    7956        FEP_LINE * newLine = new FEP_LINE; 
    8057         
    81         getline(highwaysData, currLine); 
     58        getline(highwaysStream, currLine); 
    8259        int numStations = 0; 
    83         sscanf(currLine, "%d %d %d", &lineNum, &count, &numStations); 
    84  
     60        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; 
    8564        newLine->lineNum = lineNum; 
    8665        newLine->count = count; 
     
    9473        { 
    9574            STATION * newStation = new STATION; 
    96              
     75     
    9776            int numLoops = 0; 
    98             getline(highwaysData, currLine); 
    99             sscanf(currLine, "%ld %d %d %s %d %d", &lds, &dropNum,&routeNum,  
    100                     direction, postmile, &numLoops); 
    101              
     77            getline(highwaysStream, currLine); 
     78            cout << currLine << endl; 
     79            char direction; 
     80            sscanf(currLine.c_str(), "%ld %hd %d %c %f %d", &lds, &dropNum, &routeNum, &direction, 
     81                    &postmile, &numLoops); 
     82            cout << "NumberLoops: " << numLoops << endl; 
     83            cout << "DropNum: " << dropNum << endl; 
     84            cout << "LDS: " << lds << endl; 
     85            cout << "LDSIndex: " << ldsIndex << endl; 
     86            cout << "postmile: " << postmile << endl; 
    10287            newLine->lds.push_back(lds); 
    10388            newLine->ldsIndex.push_back(ldsIndex++); 
     89            newStation->lds = lds; 
     90            newStation->line_num = lineNum; 
     91            newStation->drop = dropNum; 
     92            newStation->pos = 0; 
     93            newStation->MlTotVol = 0; 
     94            newStation->OppTotVol = 0; 
    10495             
    10596            for(int loopIndex = 0; loopIndex < numLoops; loopIndex++) 
    10697            { 
    107                 getline(highwaysData, currLine); 
    108                 sscanf(currLine, "%ld %f %d", &loopID, &occ, &vol); 
     98                LOOP * newLoop = new LOOP; 
     99                 
     100                getline(highwaysStream, currLine); 
     101                cout << currLine << endl; 
     102                sscanf(currLine.c_str(), "%ld %f %d %s", &loopID, &occ, &vol, loopLoc); 
     103                cout << "LOOP ID: " << loopID << endl; 
     104                cout << "OCC: " << occ << endl; 
     105                cout << "VOL: " << vol << endl; 
     106                cout << "LOOPLOC: " << loopLoc << endl; 
     107                newLoop->loopID = loopID; 
     108                newLoop->occ = occ; 
     109                newLoop->vol = vol; 
     110                newLoop->loop_loc = loopLoc; 
     111                 
     112                newStation->loops.push_back(newLoop); 
    109113            } 
     114            newStation->length = newStation->loops.size() * 2 + CONTROL_DATA_LEN; 
     115            newStation->dataPack = DataPacker::packData(newStation); 
     116             
     117            cout << "NUMBER OF LOOPS: " << newStation->loops.size() << endl; 
     118             
     119            this->stations.push_back(newStation); 
    110120        } 
    111121         
     
    113123    } 
    114124} 
    115  
    116 FEP_LINE * HighwaysParser::parseLine(istringstream highwaysData) 
    117 { 
    118  
    119 } 
    120  
    121 STATION * HighwaysParser::parseStation(istringstream highwaysData) 
    122 { 
    123      
    124 } 
    125  
    126 LOOP * HighwaysParser::parseLoop(istringstream highwaysData) 
    127 { 
    128      
    129 } 
  • branches/FEPSimulator/HighwaysParser.h

    r198 r202  
    1313#include <iostream> 
    1414#include <sstream> 
     15#include <stdio.h> 
     16#include "DataPacker.h" 
    1517 
    1618class HighwaysParser { 
     
    1820    HighwaysParser(char * highwaysData); 
    1921     
    20     vector<FEP_LINE*> getLines(); 
    21     vector<STATION*> getStations(); 
    22      
     22    vector<FEP_LINE*> lines; 
     23    vector<STATION*> stations; 
    2324    virtual ~HighwaysParser(); 
    2425private: 
    25     vector<FEP_LINE*> lines; 
    26     vector<STATION*> stations; 
    27      
    28     FEP_LINE * parseLine(istringstream highwaysData); 
    29     STATION * parseStation(istringstream highwaysData); 
    30     LOOP * parseLoop(istringstream highwaysData); 
    31     void parseLines(istringstream highwaysData); 
     26    void parseLines(char * highwaysData); 
    3227}; 
    3328 
  • trunk/src/atmsdriver/model/LoopDetector.java

    r190 r202  
    8888            build.append(" "); 
    8989            build.append(this.vol); 
     90            build.append(" "); 
    9091        } 
    91         else 
    92         { 
    93             build.append(this.loopLocation); 
    94         } 
     92        build.append(this.loopLocation); 
    9593        build.append("\n"); 
    9694        return build.toString(); 
  • trunk/src/tmcsim/application.properties

    r195 r202  
    1 #Mon, 30 Oct 2017 00:56:17 -0700 
     1#Mon, 30 Oct 2017 19:17:39 -0700 
    22 
    3 Application.revision=190 
     3Application.revision=195 
    44 
    5 Application.buildnumber=67 
     5Application.buildnumber=68 
Note: See TracChangeset for help on using the changeset viewer.