#include <SpeedLimit.h>
Public Member Functions | |
void | removeVehicle (Vehicle *pVeh) |
Removes a vehicle from a speed limit. | |
void | addVehicle (Vehicle *pVeh) |
Adds a vehicle to the speed limit. | |
double | getSpeedLimit () |
SpeedLimit (int start, int end, double limit, bool DirPos) | |
Constructor. | |
virtual | ~SpeedLimit () |
Destructor. | |
Private Attributes | |
double | m_SpeedLimit |
The speed limit for this segment. |
Definition at line 17 of file SpeedLimit.h.
SpeedLimit::SpeedLimit | ( | int | start, | |
int | end, | |||
double | limit, | |||
bool | DirPos | |||
) |
Constructor.
Definition at line 19 of file SpeedLimit.cpp.
References RoadSegment::m_Beginning, RoadSegment::m_DirPos, RoadSegment::m_End, and m_SpeedLimit.
00020 { 00021 m_Beginning = start; 00022 m_End = end; 00023 m_DirPos = DirPos; 00024 m_SpeedLimit = limit; 00025 }
SpeedLimit::~SpeedLimit | ( | ) | [virtual] |
void SpeedLimit::removeVehicle | ( | Vehicle * | pVeh | ) | [virtual] |
Removes a vehicle from a speed limit.
pVeh | The Vehicle to remove |
Reimplemented from RoadSegment.
Definition at line 75 of file SpeedLimit.cpp.
References DriverModel::ClearSpeedLimit(), and Vehicle::getDriver().
00076 { 00077 DriverModel* driver = pVeh->getDriver(); 00078 driver->ClearSpeedLimit(); 00079 }
void SpeedLimit::addVehicle | ( | Vehicle * | pVeh | ) | [virtual] |
Adds a vehicle to the speed limit.
pVeh | The vehicle to add |
Reimplemented from RoadSegment.
Definition at line 47 of file SpeedLimit.cpp.
References CIDMParameterSet::get_V0(), Vehicle::getDesiredVel(), CParameter::getDistribution(), Vehicle::getDriver(), Vehicle::getID(), RoadSegment::getIDMParams(), CDistribution::getLocation(), KM_PER_H_TO_M_PER_S, m_SpeedLimit, and DriverModel::SetSpeedLimit().
00048 { 00049 double curV0 = pVeh->getDesiredVel(); 00050 double newV0 = curV0; // set limit to current V0 if curV0 < limit 00051 00052 // do we need to generate a new lower V0? 00053 if(curV0 > m_SpeedLimit) 00054 { 00055 WORD veh_id = pVeh->getID(); 00056 CIDMParameterSet* paramSet = getIDMParams(veh_id); 00057 CParameter V0 = (*paramSet->get_V0()); 00058 // Initial method - generate new V0 00059 //newV0 = V0.GenKeepingCoV(m_SpeedLimit)*KM_PER_H_TO_M_PER_S; 00060 // revised method - keep ratio of v0/location constant 00061 double meanV0 = (V0.getDistribution()->getLocation()*KM_PER_H_TO_M_PER_S); 00062 double v0ratio = curV0/meanV0; 00063 newV0 = v0ratio * m_SpeedLimit; 00064 //TRACE("***Speed limit - m_SpeedLimit: %f\tcurV0: %f\tmeanV0: %f\tv0ratio: %f\tnewV0: %f\n",m_SpeedLimit, curV0, meanV0, v0ratio, newV0); 00065 } 00066 // this method allows for other driver models 00067 DriverModel* driver = pVeh->getDriver(); 00068 driver->SetSpeedLimit(newV0); // always call this function, even if not changing V0 00069 }
double SpeedLimit::getSpeedLimit | ( | ) |
Definition at line 33 of file SpeedLimit.cpp.
References m_SpeedLimit.
00034 { 00035 return m_SpeedLimit; 00036 }
double SpeedLimit::m_SpeedLimit [private] |
The speed limit for this segment.
Definition at line 28 of file SpeedLimit.h.
Referenced by addVehicle(), getSpeedLimit(), and SpeedLimit().