Detector Class Reference

A base class from which other, specific detectors are derived. More...

#include <Detector.h>

Inheritance diagram for Detector:

Inheritance graph
[legend]

List of all members.

Public Member Functions

bool getDirPos ()
 Detector ()
virtual ~Detector ()
virtual void EndOutput ()
virtual void addVehicle (Vehicle *pVeh, double curTime)
void CheckForOutputTime (double step)
 Checks if it is time for the detector to output.
int getLocation ()
WORD getDetectorType ()

Protected Member Functions

virtual void InitOutputFiles ()
virtual void doIntervalOutput ()
virtual void ReInit ()
std::string MapDirToString (bool DirPos)
std::string MapDetVehTypeToString (WORD VehType)
double FindDetectorArrivalTime (Vehicle *pVeh, const double curTime)
 Finds the arrival time of a vehicle.

Protected Attributes

WORD m_DetectorType
int m_RoadLength
bool m_DirPos
int m_Location
int m_NoLanes
WORD m_VehicleType
double m_CurrentTime
double m_TotalTime
double m_TimeInterval
int m_IntervalNo
std::vector< Vehicle * > m_vVehicles
std::string m_MetricsDir


Detailed Description

A base class from which other, specific detectors are derived.

Definition at line 21 of file Detector.h.


Constructor & Destructor Documentation

Detector::Detector (  ) 

Definition at line 19 of file Detector.cpp.

References m_CurrentTime, m_IntervalNo, m_MetricsDir, and m_TotalTime.

00020 {
00021         m_TotalTime = 0.0;
00022         m_CurrentTime = 0.0;
00023         m_IntervalNo = 0;
00024         m_MetricsDir = "C:\\EvolveTraffic\\Metrics\\";
00025 }

Detector::~Detector (  )  [virtual]

Definition at line 27 of file Detector.cpp.

00028 {
00029 
00030 }


Member Function Documentation

bool Detector::getDirPos (  ) 

Definition at line 95 of file Detector.cpp.

References m_DirPos.

Referenced by Lane::Lane().

00096 {
00097         return m_DirPos;
00098 }

virtual void Detector::EndOutput (  )  [inline, virtual]

Reimplemented in LaneChangeDetector, and MetricsDetector.

Definition at line 28 of file Detector.h.

00028 {};

virtual void Detector::addVehicle ( Vehicle pVeh,
double  curTime 
) [inline, virtual]

Reimplemented in MetricsDetector, and OutputDetector.

Definition at line 29 of file Detector.h.

00029 {};

void Detector::CheckForOutputTime ( double  step  ) 

Checks if it is time for the detector to output.

Parameters:
step The timestep
Given the timestep and the time at which the detector should output, this function is called each iteration. When the output time has been reached, the detector outputs

Definition at line 39 of file Detector.cpp.

References doIntervalOutput(), m_CurrentTime, m_IntervalNo, m_TimeInterval, and m_TotalTime.

00040 {
00041         m_TotalTime += step;
00042         m_CurrentTime += step;
00043         if(m_CurrentTime >= m_TimeInterval)
00044         {
00045                 m_CurrentTime -= m_TimeInterval;        // We reset the timer
00046                 m_IntervalNo++;                                         // increase the index
00047                 doIntervalOutput();                                     // we call the virtual write function
00048         }
00049 }

Here is the call graph for this function:

int Detector::getLocation (  ) 

Definition at line 90 of file Detector.cpp.

References m_Location.

Referenced by Lane::CheckDetectors().

00091 {
00092         return m_Location;
00093 }

WORD Detector::getDetectorType (  ) 

Definition at line 100 of file Detector.cpp.

References m_DetectorType.

Referenced by Lane::Lane().

00101 {
00102         return m_DetectorType;
00103 }

virtual void Detector::InitOutputFiles (  )  [inline, protected, virtual]

Reimplemented in LaneChangeDetector, and MetricsDetector.

Definition at line 36 of file Detector.h.

00036 {};

virtual void Detector::doIntervalOutput (  )  [inline, protected, virtual]

Reimplemented in LaneChangeDetector, and MetricsDetector.

Definition at line 37 of file Detector.h.

Referenced by CheckForOutputTime().

00037 {};

virtual void Detector::ReInit (  )  [inline, protected, virtual]

Reimplemented in LaneChangeDetector, and MetricsDetector.

Definition at line 38 of file Detector.h.

00038 {};

std::string Detector::MapDirToString ( bool  DirPos  )  [protected]

std::string Detector::MapDetVehTypeToString ( WORD  VehType  )  [protected]

Definition at line 51 of file Detector.cpp.

References METRICS_VEH_ALL, METRICS_VEH_CAR, METRICS_VEH_CRANE, METRICS_VEH_LARGETRUCK, METRICS_VEH_LOWLOADER, and METRICS_VEH_SMALLTRUCK.

Referenced by MetricsDetector::InitCompositionFile(), LaneChangeDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), LaneChangeDetector::InitRateFile(), LaneChangeDetector::InitSpaceTimeFile(), and LaneChangeDetector::InitVerboseFile().

00052 {
00053         switch(DetVehType)
00054         {
00055                 case METRICS_VEH_ALL:                   return "All";
00056                 case METRICS_VEH_CAR:                   return "Car";
00057                 case METRICS_VEH_SMALLTRUCK:    return "ST";
00058                 case METRICS_VEH_LARGETRUCK:    return "LT";
00059                 case METRICS_VEH_CRANE:                 return "Crane";
00060                 case METRICS_VEH_LOWLOADER:             return "LL";
00061                 default: return "All"; 
00062         }
00063 }

double Detector::FindDetectorArrivalTime ( Vehicle pVeh,
const double  curTime 
) [protected]

Finds the arrival time of a vehicle.

Parameters:
pVeh The vehicle
curTime The current time
Returns:
The time of arrival
This function finds the time that a vehicle arrived at a detector by interpolating between simulation steps

Definition at line 82 of file Detector.cpp.

References Vehicle::getPos(), Vehicle::getVelocity(), and m_Location.

Referenced by MetricsDetector::AddCurrentVehicle(), and OutputDetector::addVehicle().

00083 {
00084         double distBeyondDetector = pVeh->getPos() - m_Location;
00085         double ArrivalTime = curTime - distBeyondDetector/pVeh->getVelocity();
00086 
00087         return ArrivalTime;
00088 }

Here is the call graph for this function:


Member Data Documentation

WORD Detector::m_DetectorType [protected]

int Detector::m_RoadLength [protected]

bool Detector::m_DirPos [protected]

int Detector::m_Location [protected]

int Detector::m_NoLanes [protected]

WORD Detector::m_VehicleType [protected]

double Detector::m_CurrentTime [protected]

Definition at line 50 of file Detector.h.

Referenced by CheckForOutputTime(), Detector(), and MetricsDetector::MetricsDetector().

double Detector::m_TotalTime [protected]

double Detector::m_TimeInterval [protected]

int Detector::m_IntervalNo [protected]

std::vector<Vehicle*> Detector::m_vVehicles [protected]

std::string Detector::m_MetricsDir [protected]


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

Generated on Wed Aug 20 00:48:47 2008 for EvolveTraffic by  doxygen 1.5.6