RODFDetFlowLoader Class Reference

#include <RODFDetFlowLoader.h>


Detailed Description

A loader for detector flows.

Definition at line 47 of file RODFDetFlowLoader.h.


Public Member Functions

void read (const std::string &file) throw (IOError, ProcessError)
 Reads the given file assuming it contains detector values.
 RODFDetFlowLoader (const RODFDetectorCon &dets, RODFDetectorFlows &into, SUMOTime startTime, SUMOTime endTime, int timeOffset) throw ()
 Constructor.
 ~RODFDetFlowLoader () throw ()
 Destructor.

Private Member Functions

RODFDetFlowLoaderoperator= (const RODFDetFlowLoader &src)
 Invalidated assignment operator.
 RODFDetFlowLoader (const RODFDetFlowLoader &src)
 Invalidated copy constructor.

Private Attributes

const RODFDetectorConmyDetectorContainer
 Container holding known detectors.
SUMOTime myEndTime
bool myHaveWarnedAboutOverridingBoundaries
 Whether a warning about overriding boundaries was already written.
NamedColumnsParser myLineHandler
 The value extractor.
SUMOTime myStartTime
 The first and the last time step to read.
RODFDetectorFlowsmyStorage
 The container for read detector values.
int myTimeOffset
 The time offset to apply to read time values.

Constructor & Destructor Documentation

RODFDetFlowLoader::RODFDetFlowLoader ( const RODFDetectorCon dets,
RODFDetectorFlows into,
SUMOTime  startTime,
SUMOTime  endTime,
int  timeOffset 
) throw ()

Constructor.

Parameters:
[in] dets Definitions of known detectors
in,filled] into Container to store read values into
[in] startTime The first time step for which values shall be read
[in] endTime The last time step for which values shall be read
[in] timeOffset The offset which shall be applied to the read times

Definition at line 49 of file RODFDetFlowLoader.cpp.

00053         : myStorage(into), myTimeOffset(timeOffset),
00054         myStartTime(startTime/60), myEndTime((endTime+59)/60), myDetectorContainer(dets),
00055         myHaveWarnedAboutOverridingBoundaries(false) {}

RODFDetFlowLoader::~RODFDetFlowLoader (  )  throw ()

Destructor.

Definition at line 59 of file RODFDetFlowLoader.cpp.

00059 {}

RODFDetFlowLoader::RODFDetFlowLoader ( const RODFDetFlowLoader src  )  [private]

Invalidated copy constructor.


Member Function Documentation

RODFDetFlowLoader& RODFDetFlowLoader::operator= ( const RODFDetFlowLoader src  )  [private]

Invalidated assignment operator.

void RODFDetFlowLoader::read ( const std::string &  file  )  throw (IOError, ProcessError)

Reads the given file assuming it contains detector values.

Reads the first line, first, and parses it assuming it contains the names of the columns that follow within the next lines.

Then, the rest of the file is read and the read values for vehicle/heavy vehicle amounts and speeds are stored into "myStorage". Values that lie before "myStartTime" and behind "myEndTime" as well as values which refer to an unknown detector are omitted.

Parameters:
[in] file The name of the file to read
Exceptions:
IOError Not yet implemented!
ProcessError Thrown if a value could not be parsed properly or a needed value is missing

Definition at line 63 of file RODFDetFlowLoader.cpp.

References TplConvert< E >::_2int(), TplConvert< E >::_2SUMOReal(), RODFDetectorFlows::addFlow(), NamedColumnsParser::get(), LineReader::getFileName(), MsgHandler::getWarningInstance(), LineReader::hasMore(), MsgHandler::inform(), FlowDef::isLKW, NamedColumnsParser::know(), RODFDetectorCon::knows(), myDetectorContainer, myEndTime, myHaveWarnedAboutOverridingBoundaries, myLineHandler, myStorage, myTimeOffset, NamedColumnsParser::parseLine(), FlowDef::qLKW, FlowDef::qPKW, LineReader::readLine(), NamedColumnsParser::reinit(), FlowDef::vLKW, and FlowDef::vPKW.

Referenced by readDetectorFlows().

00063                                                                           {
00064     LineReader lr(file);
00065     // parse first line
00066     myLineHandler.reinit(lr.readLine(), ";", ";", true, true);
00067     // parse values
00068     while (lr.hasMore()) {
00069         std::string line = lr.readLine();
00070         if (line.find(';')==std::string::npos) {
00071             continue;
00072         }
00073         myLineHandler.parseLine(line);
00074         try {
00075             std::string detName = myLineHandler.get("detector");
00076             if (!myDetectorContainer.knows(detName)) {
00077                 continue;
00078             }
00079             int time = TplConvert<char>::_2int((myLineHandler.get("time").c_str()));
00080             time -= myTimeOffset;
00081             if (time<myStartTime||time>myEndTime) {
00082                 if (!myHaveWarnedAboutOverridingBoundaries) {
00083                     myHaveWarnedAboutOverridingBoundaries = true;
00084                     MsgHandler::getWarningInstance()->inform("At least one value lies beyond given time boundaries.");
00085                 }
00086                 continue;
00087             }
00088             FlowDef fd;
00089             fd.isLKW = 0;
00090             fd.qPKW = TplConvert<char>::_2SUMOReal(myLineHandler.get("qpkw").c_str());
00091             fd.vPKW = TplConvert<char>::_2SUMOReal(myLineHandler.get("vpkw").c_str());
00092             fd.qLKW = 0;
00093             if (myLineHandler.know("qLKW")) {
00094                 fd.qLKW = TplConvert<char>::_2SUMOReal(myLineHandler.get("qlkw").c_str());
00095             }
00096             fd.vLKW = 0;
00097             if (myLineHandler.know("vLKW")) {
00098                 fd.vLKW = TplConvert<char>::_2SUMOReal(myLineHandler.get("vlkw").c_str());
00099             }
00100             if (fd.qLKW<0) {
00101                 fd.qLKW = 0;
00102             }
00103             if (fd.qPKW<0) {
00104                 fd.qPKW = 0;
00105             }
00106             myStorage.addFlow(detName, time, fd);
00107             continue;
00108         } catch (UnknownElement &) {} catch (OutOfBoundsException &) {} catch (NumberFormatException &) {}
00109         throw ProcessError("The detector-flow-file '" + lr.getFileName() + "' is corrupt;\n"
00110                            + " The following values must be supplied : 'Detector', 'Time', 'qPKW', 'vPKW'\n"
00111                            + " The according column names must be given in the first line of the file.");
00112     }
00113 }


Field Documentation

Container holding known detectors.

Definition at line 97 of file RODFDetFlowLoader.h.

Referenced by read().

Definition at line 91 of file RODFDetFlowLoader.h.

Referenced by read().

Whether a warning about overriding boundaries was already written.

Definition at line 100 of file RODFDetFlowLoader.h.

Referenced by read().

The value extractor.

Definition at line 94 of file RODFDetFlowLoader.h.

Referenced by read().

The first and the last time step to read.

Definition at line 91 of file RODFDetFlowLoader.h.

The container for read detector values.

Definition at line 85 of file RODFDetFlowLoader.h.

Referenced by read().

The time offset to apply to read time values.

Definition at line 88 of file RODFDetFlowLoader.h.

Referenced by read().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:59 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6