#include <Detector.h>
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 |
Definition at line 21 of file Detector.h.
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] |
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] |
virtual void Detector::addVehicle | ( | Vehicle * | pVeh, | |
double | curTime | |||
) | [inline, virtual] |
void Detector::CheckForOutputTime | ( | double | step | ) |
Checks if it is time for the detector to output.
step | The timestep |
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 }
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] |
virtual void Detector::doIntervalOutput | ( | ) | [inline, protected, virtual] |
Reimplemented in LaneChangeDetector, and MetricsDetector.
Definition at line 37 of file Detector.h.
Referenced by CheckForOutputTime().
virtual void Detector::ReInit | ( | ) | [inline, protected, virtual] |
std::string Detector::MapDirToString | ( | bool | DirPos | ) | [protected] |
Definition at line 65 of file Detector.cpp.
References m_DirPos.
Referenced by MetricsDetector::InitCompositionFile(), LaneChangeDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), LaneChangeDetector::InitRateFile(), LaneChangeDetector::InitSpaceTimeFile(), and LaneChangeDetector::InitVerboseFile().
00066 { 00067 if(m_DirPos) 00068 return "Pos"; 00069 else 00070 return "Neg"; 00071 }
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.
pVeh | The vehicle | |
curTime | The current time |
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 }
WORD Detector::m_DetectorType [protected] |
Definition at line 44 of file Detector.h.
Referenced by MetricsDetector::AddCurrentVehicle(), MetricsDetector::doIntervalOutput(), getDetectorType(), MetricsDetector::InitOutputFiles(), LaneChangeDetector::LaneChangeDetector(), and MetricsDetector::MetricsDetector().
int Detector::m_RoadLength [protected] |
Definition at line 45 of file Detector.h.
Referenced by MetricsDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), LaneChangeDetector::LaneChangeDetector(), and MetricsDetector::MetricsDetector().
bool Detector::m_DirPos [protected] |
Definition at line 46 of file Detector.h.
Referenced by getDirPos(), MetricsDetector::InitCompositionFile(), LaneChangeDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), LaneChangeDetector::InitRateFile(), LaneChangeDetector::InitSpaceTimeFile(), LaneChangeDetector::InitVerboseFile(), LaneChangeDetector::LaneChangeDetector(), MapDirToString(), MetricsDetector::MetricsDetector(), and OutputDetector::OutputDetector().
int Detector::m_Location [protected] |
Definition at line 47 of file Detector.h.
Referenced by FindDetectorArrivalTime(), getLocation(), MetricsDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), MetricsDetector::MetricsDetector(), and OutputDetector::OutputDetector().
int Detector::m_NoLanes [protected] |
Definition at line 48 of file Detector.h.
Referenced by MetricsDetector::doFlowDensityOutput(), MetricsDetector::doHeadwayOutput(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), MetricsDetector::initVectors(), MetricsDetector::MetricsDetector(), and MetricsDetector::ReInit().
WORD Detector::m_VehicleType [protected] |
Definition at line 49 of file Detector.h.
Referenced by MetricsDetector::AddCurrentVehicle(), LaneChangeDetector::addEvent(), MetricsDetector::addVehicle(), MetricsDetector::doIntervalOutput(), LaneChangeDetector::EndOutput(), MetricsDetector::InitCompositionFile(), LaneChangeDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), MetricsDetector::InitOutputFiles(), LaneChangeDetector::InitOutputFiles(), LaneChangeDetector::InitRateFile(), LaneChangeDetector::InitSpaceTimeFile(), LaneChangeDetector::InitVerboseFile(), LaneChangeDetector::LaneChangeDetector(), and MetricsDetector::MetricsDetector().
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] |
Definition at line 51 of file Detector.h.
Referenced by CheckForOutputTime(), Detector(), LaneChangeDetector::doCompositionOutput(), and LaneChangeDetector::doRateOutput().
double Detector::m_TimeInterval [protected] |
Definition at line 52 of file Detector.h.
Referenced by CheckForOutputTime(), MetricsDetector::doFlowDensityOutput(), LaneChangeDetector::doRateOutput(), LaneChangeDetector::LaneChangeDetector(), and MetricsDetector::MetricsDetector().
int Detector::m_IntervalNo [protected] |
Definition at line 53 of file Detector.h.
Referenced by CheckForOutputTime(), Detector(), MetricsDetector::doFlowDensityOutput(), and MetricsDetector::MetricsDetector().
std::vector<Vehicle*> Detector::m_vVehicles [protected] |
Definition at line 54 of file Detector.h.
Referenced by OutputDetector::addVehicle(), OutputDetector::clear(), and OutputDetector::WriteVehiclesToFile().
std::string Detector::m_MetricsDir [protected] |
Definition at line 55 of file Detector.h.
Referenced by Detector(), MetricsDetector::InitCompositionFile(), LaneChangeDetector::InitCompositionFile(), MetricsDetector::InitFlowDensityFile(), MetricsDetector::InitHeadwayFile(), LaneChangeDetector::InitRateFile(), LaneChangeDetector::InitSpaceTimeFile(), LaneChangeDetector::InitVerboseFile(), LaneChangeDetector::LaneChangeDetector(), and MetricsDetector::MetricsDetector().