| 1 | /* |
|---|
| 2 | * File: HighwaysParser.cpp |
|---|
| 3 | * Author: jtorres |
|---|
| 4 | * |
|---|
| 5 | * Created on October 28, 2017, 7:23 PM |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | #include "HighwaysParser.h" |
|---|
| 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 | * */ |
|---|
| 22 | HighwaysParser::HighwaysParser(char * hwyData) { |
|---|
| 23 | string highwaysData = hwyData; |
|---|
| 24 | istringstream stream(highwaysData); |
|---|
| 25 | parseLines(highwaysData); |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | HighwaysParser::~HighwaysParser() { |
|---|
| 29 | } |
|---|
| 30 | |
|---|
| 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 |
|---|
| 43 | { |
|---|
| 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 | { |
|---|
| 55 | string currLine; |
|---|
| 56 | getline(highwaysData, currLine); |
|---|
| 57 | int numLines; |
|---|
| 58 | sscanf(highwaysData, "%d", &numLines); |
|---|
| 59 | |
|---|
| 60 | int lineNum = 0; |
|---|
| 61 | long lds = 0; |
|---|
| 62 | long ldsIndex = 0; |
|---|
| 63 | short count = 0; |
|---|
| 64 | int schedule = 0; |
|---|
| 65 | int lineInfo = 0; |
|---|
| 66 | long systemKey = 0; |
|---|
| 67 | long globalSeq = 0; |
|---|
| 68 | 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; |
|---|
| 76 | |
|---|
| 77 | for(int lineIndex = 0; lineIndex < numLines; lineIndex++) |
|---|
| 78 | { |
|---|
| 79 | FEP_LINE * newLine = new FEP_LINE; |
|---|
| 80 | |
|---|
| 81 | getline(highwaysData, currLine); |
|---|
| 82 | int numStations = 0; |
|---|
| 83 | 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 | |
|---|
| 93 | for(int stationIndex = 0; stationIndex < numStations; stationIndex++) |
|---|
| 94 | { |
|---|
| 95 | STATION * newStation = new STATION; |
|---|
| 96 | |
|---|
| 97 | int numLoops = 0; |
|---|
| 98 | getline(highwaysData, currLine); |
|---|
| 99 | sscanf(currLine, "%ld %d %d %s %d %d", &lds, &dropNum,&routeNum, |
|---|
| 100 | direction, postmile, &numLoops); |
|---|
| 101 | |
|---|
| 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 | } |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | this->lines.push_back(newLine); |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 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 | } |
|---|