SpeedLimit Class Reference

A derived class to represent a speed-limit section on a road. More...

#include <SpeedLimit.h>

Inheritance diagram for SpeedLimit:

Inheritance graph
[legend]
Collaboration diagram for SpeedLimit:

Collaboration graph
[legend]

List of all members.

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.


Detailed Description

A derived class to represent a speed-limit section on a road.

Definition at line 17 of file SpeedLimit.h.


Constructor & Destructor Documentation

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]

Destructor.

Definition at line 28 of file SpeedLimit.cpp.

00029 {
00030 
00031 }


Member Function Documentation

void SpeedLimit::removeVehicle ( Vehicle pVeh  )  [virtual]

Removes a vehicle from a speed limit.

Parameters:
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 }

Here is the call graph for this function:

void SpeedLimit::addVehicle ( Vehicle pVeh  )  [virtual]

Adds a vehicle to the speed limit.

Parameters:
pVeh The vehicle to add
This function adds a vehicle to a speed limit segment in the road. A new desired acceleration for the vehicle is created based on the type of vehicle. If, however, the vehicle's desired acceleration is below that of the speed limit, then the desired acceleration does not change

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 }

Here is the call graph for this function:

double SpeedLimit::getSpeedLimit (  ) 

Definition at line 33 of file SpeedLimit.cpp.

References m_SpeedLimit.

00034 {
00035         return m_SpeedLimit;
00036 }


Member Data Documentation

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().


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

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