/* * File: HighwaysParser.cpp * Author: jtorres * * Created on October 28, 2017, 7:23 PM */ #include "HighwaysParser.h" /* 43 // "number of lines" * 32 0 13 // "line id" "count num" "number of stations" * 1210831 1 5 S 0.9 8 // "station id" "drop num" "route num"... * // ..."direction" "postmile" "number of loops" * 1210832 0.0 0 // "loop id" "occ" "vol" * 1210833 0.0 0 // .. * 1210834 0.0 0 // .. * 1210835 0.0 0 // .. * 1210836 0.0 0 // .. * 1210837 0.0 0 // .. * 1210838 0.0 0 // .. * 1210839 0.0 0 // .. * */ HighwaysParser::HighwaysParser(char * hwyData) { string highwaysData = hwyData; istringstream stream(highwaysData); parseLines(highwaysData); } HighwaysParser::~HighwaysParser() { } vector HighwaysParser::getLines() { } vector HighwaysParser::getStations() { } // Loop Detector: A single sensor that detects the volume, occupancy, and speed // in a single highway lane typedef struct loop LOOP; struct loop { // meta data long loopID; char *loop_loc; // dynamic data int vol; float occ; double spd; }; void HighwaysParser::parseLines(istringstream highwaysData) { string currLine; getline(highwaysData, currLine); int numLines; sscanf(highwaysData, "%d", &numLines); int lineNum = 0; long lds = 0; long ldsIndex = 0; short count = 0; int schedule = 0; int lineInfo = 0; long systemKey = 0; long globalSeq = 0; long schedleSeq = 0; short dropNum = 0; int routeNum = 0; char * direction = ""; float postmile = 0; long loopID = 0; float occ = 0; int vol = 0; for(int lineIndex = 0; lineIndex < numLines; lineIndex++) { FEP_LINE * newLine = new FEP_LINE; getline(highwaysData, currLine); int numStations = 0; sscanf(currLine, "%d %d %d", &lineNum, &count, &numStations); newLine->lineNum = lineNum; newLine->count = count; newLine->schedule = schedule; newLine->lineInfo = lineInfo; newLine->systemKey = systemKey; newLine->globalSeq = globalSeq; newLine->schedleSeq = schedleSeq; for(int stationIndex = 0; stationIndex < numStations; stationIndex++) { STATION * newStation = new STATION; int numLoops = 0; getline(highwaysData, currLine); sscanf(currLine, "%ld %d %d %s %d %d", &lds, &dropNum,&routeNum, direction, postmile, &numLoops); newLine->lds.push_back(lds); newLine->ldsIndex.push_back(ldsIndex++); for(int loopIndex = 0; loopIndex < numLoops; loopIndex++) { getline(highwaysData, currLine); sscanf(currLine, "%ld %f %d", &loopID, &occ, &vol); } } this->lines.push_back(newLine); } } FEP_LINE * HighwaysParser::parseLine(istringstream highwaysData) { } STATION * HighwaysParser::parseStation(istringstream highwaysData) { } LOOP * HighwaysParser::parseLoop(istringstream highwaysData) { }