Road Class Reference

A class to represent a road in the simulation. More...

#include <Road.h>

Collaboration diagram for Road:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void setLaneChangeReg (bool trackChanges, double outputTime, int roadLen, WORD registerType)
void setDriveOnRight (bool OnRight)
 Sets whether or not the vehicles should drive on the right.
void clear ()
 Clears the road so it can be used in another simulation.
int getPercentComplete ()
bool getAllowLaneChanging ()
 Gets whether or not lane changing is allowed.
void setAllowLaneChanging (bool status)
 Sets whether or not lane changing is allowed.
void setLocOuputDetectorDirPos (int loc)
 Sets the position of output detector in the positive direction.
void setLocOuputDetectorDirNeg (int loc)
 Sets the position of output detector in the negative direction.
void setNoLanesDirPos (int nlpos)
 Sets the number of lanes in the positive direction.
void setNoLanesDirNeg (int nlneg)
 Sets the number of lanes in the negative direction.
void setNoDirections (int nd)
 Sets the number of directions.
void setNoLanes (int nl)
 Sets the number of lanes.
void setRoadLength (int L)
 Sets the length of the road.
void setTrafFileNoLanesDirPos (int nl)
 Sets the number of lanes in the positive direction in the traffic file.
void setTrafFileNoLanesDirNeg (int nl)
 Sets the number of lanes in the negative direction in the traffic file.
void setIDMParams_Car (CIDMParameterSet *Params)
 Sets the Car IDM Parameter Set.
void setIDMParams_SmallTruck (CIDMParameterSet *Params)
 Sets the Small Truck IDM Parameter Set.
void setIDMParams_LargeTruck (CIDMParameterSet *Params)
 Sets the Large Truck IDM Parameter Set.
void setIDMParams_Crane (CIDMParameterSet *Params)
 Sets the Crane IDM Parameter Set.
void setIDMParams_Lowloader (CIDMParameterSet *Params)
 Sets the Lowloader IDM Parameter Set.
void SetSegmentFromFeature (CRoadFeature *pFeat)
 Sets road segments based on data specified by the user to the GUI.
void SetMetricDetFromStatDet (CStatDetector *pDet, int nLanesPos, int nLanesNeg)
 Sets the road metrics detector data from input through the GUI.
double getLength ()
 Gets the length of the road.
M2D getVehicles ()
 Gets all the vehicles on the road.
void initTruckGroup (string inFile, string outFile, WORD fileType)
 Initialises the file handler.
bool update (double step, const double curTime)
 Updates the properties of the road.
void populate (double step, const double curTime)
 Populates the road.
double init ()
 Initialises the road.
 Road ()
 Constructor.
virtual ~Road ()
 Destructor.

Private Member Functions

void passIDMParameters (RoadSegment *segment)
 Passes the IDM parameters to a given road segment.
void MapTrafLaneToSimLane (Vehicle *pVeh)
 Maps vehicles to appropriate lanes.
void setIDMDriverModel (Vehicle *pVeh)
 Sets a vehicle's drivermodel as IDM.
void SetSpeedLimitSegment (CRoadFeature *pFeat)
 Sets a speed limit based on data specified by the user to the GUI.
void SetGradientSegment (CRoadFeature *pFeat)
 Sets a gradient based on data specified by the user to the GUI.

Private Attributes

bool m_DriveOnRight
int m_PercentComplete
CIDMParameterSetm_pIDMParams_Car
CIDMParameterSetm_pIDMParams_SmallTruck
CIDMParameterSetm_pIDMParams_LargeTruck
CIDMParameterSetm_pIDMParams_Crane
CIDMParameterSetm_pIDMParams_Lowloader
int m_LocOutputDetectorDirPos
int m_LocOutputDetectorDirNeg
Direction DirectionPos
Direction DirectionNeg
int m_TrafFileNoLanesDirPos
int m_TrafFileNoLanesDirNeg
FileHandlerm_pFileHandler
std::vector< Vehicle * > m_BufferVehicles
std::vector< Lane * > m_vLanes
std::vector< Detector * > m_vDetectorsPos
std::vector< Detector * > m_vDetectorsNeg
std::vector< int > m_vLaneLengthsPos
std::vector< int > m_vLaneLengthsNeg
std::vector< RoadSegment * > m_vRoadSegmentsPos
std::vector< RoadSegment * > m_vRoadSegmentsNeg
bool m_bEndOfFile
bool m_AllowLaneChanging
int m_NoLanesDirPos
int m_NoLanesDirNeg
int m_NoDirections
int m_NoLanes
int m_RoadLength
double MIN_SPACE_FOR_NEXT_VEHICLE


Detailed Description

A class to represent a road in the simulation.

Definition at line 21 of file Road.h.


Constructor & Destructor Documentation

Road::Road (  ) 

Road::~Road (  )  [virtual]

Destructor.

Definition at line 25 of file Road.cpp.

References m_pIDMParams_Car, m_pIDMParams_Crane, m_pIDMParams_LargeTruck, m_pIDMParams_Lowloader, and m_pIDMParams_SmallTruck.

00026 {
00027         m_pIDMParams_Car                = NULL;
00028         m_pIDMParams_SmallTruck = NULL;
00029         m_pIDMParams_LargeTruck = NULL;
00030         m_pIDMParams_Crane              = NULL;
00031         m_pIDMParams_Lowloader  = NULL;
00032 }


Member Function Documentation

void Road::setLaneChangeReg ( bool  trackChanges,
double  outputTime,
int  roadLen,
WORD  registerType 
)

void Road::setDriveOnRight ( bool  OnRight  ) 

Sets whether or not the vehicles should drive on the right.

Parameters:
OnRight Whether or not the vehicles should drive on the right

Definition at line 445 of file Road.cpp.

References m_DriveOnRight.

Referenced by CEvolveTrafficDoc::initSim().

00446 {
00447         m_DriveOnRight = OnRight;
00448 }

void Road::clear (  ) 

Clears the road so it can be used in another simulation.

This function clears all of the road's information so that it may be used in another simulation without re-instanciating.

Definition at line 608 of file Road.cpp.

References Direction::clear(), DirectionNeg, DirectionPos, m_BufferVehicles, m_NoDirections, m_pFileHandler, m_pIDMParams_Car, m_pIDMParams_Crane, m_pIDMParams_LargeTruck, m_pIDMParams_Lowloader, m_pIDMParams_SmallTruck, m_vDetectorsNeg, m_vDetectorsPos, m_vLanes, m_vRoadSegmentsNeg, and m_vRoadSegmentsPos.

Referenced by Sim::clear().

00609 {
00610         DirectionPos.clear();
00611         if(m_NoDirections == 2)
00612                 DirectionNeg.clear();
00613 
00614         delete m_pFileHandler;
00615 
00616         m_vLanes.clear();
00617 
00618         m_BufferVehicles.clear();
00619 
00620         m_vDetectorsPos.clear();
00621         m_vDetectorsNeg.clear();
00622 
00623         m_vRoadSegmentsPos.clear();
00624         m_vRoadSegmentsNeg.clear();
00625 
00626         // why don't we just delete these?
00627         m_pIDMParams_Car                = NULL;
00628         m_pIDMParams_SmallTruck = NULL;
00629         m_pIDMParams_LargeTruck = NULL;
00630         m_pIDMParams_Crane              = NULL;
00631         m_pIDMParams_Lowloader  = NULL;
00632 }

Here is the call graph for this function:

int Road::getPercentComplete (  ) 

Definition at line 418 of file Road.cpp.

References m_PercentComplete.

Referenced by Sim::doOneTimeStep().

00419 {
00420         return m_PercentComplete;
00421 }

bool Road::getAllowLaneChanging (  ) 

Gets whether or not lane changing is allowed.

Returns:
Whether or not lane changing is allowed

Definition at line 427 of file Road.cpp.

References m_AllowLaneChanging.

00428 {
00429         return m_AllowLaneChanging;
00430 }

void Road::setAllowLaneChanging ( bool  status  ) 

Sets whether or not lane changing is allowed.

Parameters:
status Whether or not lane changing is allowed

Definition at line 436 of file Road.cpp.

References m_AllowLaneChanging.

Referenced by CEvolveTrafficDoc::initSim().

00437 {
00438         m_AllowLaneChanging = status;
00439 }

void Road::setLocOuputDetectorDirPos ( int  loc  ) 

Sets the position of output detector in the positive direction.

Parameters:
loc The position of output detector

Definition at line 402 of file Road.cpp.

References m_LocOutputDetectorDirPos.

Referenced by CEvolveTrafficDoc::initSim().

00403 {
00404         m_LocOutputDetectorDirPos = loc;
00405 }

void Road::setLocOuputDetectorDirNeg ( int  loc  ) 

Sets the position of output detector in the negative direction.

Parameters:
loc The position of output detector

Definition at line 412 of file Road.cpp.

References m_LocOutputDetectorDirNeg, and m_RoadLength.

Referenced by CEvolveTrafficDoc::initSim().

00413 {
00414         // change from overall road coordinates to lane coordinates
00415         m_LocOutputDetectorDirNeg = m_RoadLength - loc;
00416 }

void Road::setNoLanesDirPos ( int  nlpos  ) 

Sets the number of lanes in the positive direction.

Parameters:
nlpos The number of lanes in the positive direction

Definition at line 271 of file Road.cpp.

References m_NoLanesDirPos.

Referenced by Sim::init().

00272 {
00273         m_NoLanesDirPos = nlpos;
00274 }

void Road::setNoLanesDirNeg ( int  nlneg  ) 

Sets the number of lanes in the negative direction.

Parameters:
nlneg The number of lanes in the negative direction

Definition at line 280 of file Road.cpp.

References m_NoLanesDirNeg.

Referenced by Sim::init().

00281 {
00282         m_NoLanesDirNeg = nlneg;
00283 }

void Road::setNoDirections ( int  nd  ) 

Sets the number of directions.

Parameters:
nd The number of directions

Definition at line 289 of file Road.cpp.

References m_NoDirections.

Referenced by Sim::init().

00290 {
00291         m_NoDirections = nd;
00292 }

void Road::setNoLanes ( int  nl  ) 

Sets the number of lanes.

Parameters:
nl The number of lanes

Definition at line 298 of file Road.cpp.

References m_NoLanes.

Referenced by Sim::init().

00299 {
00300         m_NoLanes = nl;
00301 }

void Road::setRoadLength ( int  L  ) 

Sets the length of the road.

Parameters:
L The length of the road

Definition at line 307 of file Road.cpp.

References m_RoadLength.

Referenced by Sim::init(), and Sim::setRoadLength().

00308 {
00309         m_RoadLength = L;
00310 }

void Road::setTrafFileNoLanesDirPos ( int  nl  ) 

Sets the number of lanes in the positive direction in the traffic file.

Parameters:
nl The number of lanes

Definition at line 384 of file Road.cpp.

References m_TrafFileNoLanesDirPos.

Referenced by CEvolveTrafficDoc::initSim().

00385 {
00386         m_TrafFileNoLanesDirPos = nl;
00387 }

void Road::setTrafFileNoLanesDirNeg ( int  nl  ) 

Sets the number of lanes in the negative direction in the traffic file.

Parameters:
nl The number of lanes

Definition at line 393 of file Road.cpp.

References m_TrafFileNoLanesDirNeg.

Referenced by CEvolveTrafficDoc::initSim().

00394 {
00395         m_TrafFileNoLanesDirNeg = nl;
00396 }

void Road::setIDMParams_Car ( CIDMParameterSet Params  ) 

Sets the Car IDM Parameter Set.

Parameters:
Params The IDM Parameter Set

Definition at line 339 of file Road.cpp.

References m_pIDMParams_Car.

Referenced by CEvolveTrafficDoc::initSim().

00340 {
00341         m_pIDMParams_Car = Params;
00342 }

void Road::setIDMParams_SmallTruck ( CIDMParameterSet Params  ) 

Sets the Small Truck IDM Parameter Set.

Parameters:
Params The IDM Parameter Set

Definition at line 348 of file Road.cpp.

References m_pIDMParams_SmallTruck.

Referenced by CEvolveTrafficDoc::initSim().

00349 {
00350         m_pIDMParams_SmallTruck = Params;
00351 }

void Road::setIDMParams_LargeTruck ( CIDMParameterSet Params  ) 

Sets the Large Truck IDM Parameter Set.

Parameters:
Params The IDM Parameter Set

Definition at line 357 of file Road.cpp.

References m_pIDMParams_LargeTruck.

Referenced by CEvolveTrafficDoc::initSim().

00358 {
00359         m_pIDMParams_LargeTruck = Params;
00360 }

void Road::setIDMParams_Crane ( CIDMParameterSet Params  ) 

Sets the Crane IDM Parameter Set.

Parameters:
Params The IDM Parameter Set

Definition at line 366 of file Road.cpp.

References m_pIDMParams_Crane.

Referenced by CEvolveTrafficDoc::initSim().

00367 {
00368         m_pIDMParams_Crane = Params;
00369 }

void Road::setIDMParams_Lowloader ( CIDMParameterSet Params  ) 

Sets the Lowloader IDM Parameter Set.

Parameters:
Params The IDM Parameter Set

Definition at line 375 of file Road.cpp.

References m_pIDMParams_Lowloader.

Referenced by CEvolveTrafficDoc::initSim().

00376 {
00377         m_pIDMParams_Lowloader = Params;
00378 }

void Road::SetSegmentFromFeature ( CRoadFeature pFeat  ) 

Sets road segments based on data specified by the user to the GUI.

Parameters:
pFeat The road feature to create
This function takes the data inputted by the user into the GUI and creates the correct road segment based on the given data

Definition at line 470 of file Road.cpp.

References FEAT_GRADIENT, FEAT_SPEEDLIMIT, CRoadFeature::getEnd(), CRoadFeature::getStart(), CRoadFeature::getType(), SetGradientSegment(), and SetSpeedLimitSegment().

Referenced by CEvolveTrafficDoc::initSim().

00471 {
00472         ASSERT(pFeat->getStart() < pFeat->getEnd());    // should be since done in CRoadFeaturesDlg validation
00473 
00474         switch( pFeat->getType() )
00475         {
00476                 case FEAT_SPEEDLIMIT:
00477                         SetSpeedLimitSegment(pFeat);
00478                         break;
00479                 case FEAT_GRADIENT:     
00480                         SetGradientSegment(pFeat);
00481                         break;
00482                 default:
00483                         break;
00484         }
00485         
00486 }

Here is the call graph for this function:

void Road::SetMetricDetFromStatDet ( CStatDetector pDet,
int  nLanesPos,
int  nLanesNeg 
)

Sets the road metrics detector data from input through the GUI.

Parameters:
pDet The detector to create
nLanesPos The number of lanes in the positive direction
nLanesNeg The number of lanes in the negative direction
This function takes the data inputted by the user into the GUI and creates a detector based on the given data. The detector is then passed to the correct direction.

Definition at line 555 of file Road.cpp.

References CStatDetector::getDetectorType(), CStatDetector::getDirPos(), CStatDetector::getLocation(), CStatDetector::getStdStrMetricsDir(), CStatDetector::getTimeInterval(), CStatDetector::getVehicleType(), m_RoadLength, m_vDetectorsNeg, m_vDetectorsPos, and METRICS_TYPE_LANE_CHANGE.

Referenced by CEvolveTrafficDoc::initSim().

00556 {
00557         bool bDirPos = pDet->getDirPos();
00558 
00559         if(pDet->getDetectorType() == METRICS_TYPE_LANE_CHANGE)
00560         {
00561                 LaneChangeDetector* pLCD;
00562                 pLCD = new LaneChangeDetector(  pDet->getStdStrMetricsDir(),
00563                                                                                 pDet->getTimeInterval(),
00564                                                                                 pDet->getLocation(),
00565                                                                                 m_RoadLength,
00566                                                                                 bDirPos,
00567                                                                                 pDet->getVehicleType());
00568                 if( bDirPos )
00569                         m_vDetectorsPos.push_back(pLCD);
00570                 else
00571                         m_vDetectorsNeg.push_back(pLCD);
00572         }
00573         else
00574         {
00575                 MetricsDetector* pMD;
00576                 if( bDirPos )
00577                 {
00578                         pMD = new MetricsDetector(      pDet->getStdStrMetricsDir(),
00579                                                                                 pDet->getDetectorType(), 
00580                                                                                 bDirPos,
00581                                                                                 nLanesPos,
00582                                                                                 pDet->getVehicleType(), 
00583                                                                                 pDet->getTimeInterval(), 
00584                                                                                 pDet->getLocation(), 
00585                                                                                 m_RoadLength);
00586                         m_vDetectorsPos.push_back(pMD);
00587                 }
00588                 else
00589                 {
00590                         pMD = new MetricsDetector(      pDet->getStdStrMetricsDir(),
00591                                                                                 pDet->getDetectorType(), 
00592                                                                                 bDirPos,
00593                                                                                 nLanesNeg,
00594                                                                                 pDet->getVehicleType(), 
00595                                                                                 pDet->getTimeInterval(), 
00596                                                                                 m_RoadLength - pDet->getLocation(),     // change from global road to local dirn coords
00597                                                                                 m_RoadLength);                                          // need this to revert filenames to global positions
00598                         m_vDetectorsNeg.push_back(pMD);
00599                 }
00600         }
00601 }

Here is the call graph for this function:

double Road::getLength (  ) 

Gets the length of the road.

Returns:
The length of the road

Definition at line 262 of file Road.cpp.

References m_RoadLength.

Referenced by Sim::getRoadLength().

00263 {
00264         return m_RoadLength;
00265 }

M2D Road::getVehicles (  ) 

Gets all the vehicles on the road.

Returns:
All the vehicles on the road

Definition at line 238 of file Road.cpp.

References DirectionNeg, DirectionPos, Direction::getGlobalPos(), m_NoDirections, m_NoLanesDirNeg, and m_NoLanesDirPos.

Referenced by Sim::doOneTimeStep().

00239 {       
00240         M2D pos;
00241 
00242         M2D temp = DirectionPos.getGlobalPos(); // get DirPos positions
00243         for(int i = 0; i < m_NoLanesDirPos; i++)                // and add lane by lane
00244                 pos.push_back(temp[i]);
00245 
00246         if(m_NoDirections == 2)         // Uni-directional roads are in Dir1
00247         {
00248                 temp.clear();
00249                 
00250                 temp = DirectionNeg.getGlobalPos();     // get DirNeg positions
00251                 for(i = 0; i < m_NoLanesDirNeg; i++)            // and add lane by lane
00252                         pos.push_back(temp[i]);
00253         }
00254 
00255         return pos;
00256 }

Here is the call graph for this function:

void Road::initTruckGroup ( string  inFile,
string  outFile,
WORD  fileType 
)

Initialises the file handler.

Parameters:
inFile The input file to read from
outFile The output file to write to
fileType The type of file
This function determines whether the type of file being used is CASTOR or SAFT format, and creates an appropriate filehandler based on the input provided.

Definition at line 322 of file Road.cpp.

References CASTOR, m_pFileHandler, and SAFT.

Referenced by Sim::init().

00323 {
00324         if(fileType == CASTOR)
00325         {
00326                 m_pFileHandler = new CASTORFile(inFile, outFile);
00327 
00328         }
00329         else if(fileType == SAFT)
00330         {
00331                 m_pFileHandler = new SAFTFile(inFile, outFile);
00332         }
00333 }

bool Road::update ( double  step,
const double  curTime 
)

Updates the properties of the road.

Parameters:
step The timestep
curTime The current time
Returns:
Whether or not the simulation is still running
This function is called for each timestep of the simulation and updates its directions, once the directions are not empty

Definition at line 43 of file Road.cpp.

References DirectionNeg, DirectionPos, m_bEndOfFile, m_NoDirections, m_vDetectorsNeg, m_vDetectorsPos, and Direction::update().

Referenced by Sim::doOneTimeStep().

00044 {
00045         bool SimulationOver = false;
00046         bool RoadEmpty = false;
00047         bool DirPosEmpty = false;
00048         bool DirNegEmpty = false;
00049 
00050         // since there's always one direction
00051         DirPosEmpty = DirectionPos.update(step, curTime);
00052 
00053         if(m_NoDirections == 2)
00054                 DirNegEmpty = DirectionNeg.update(step, curTime);
00055 
00056         if(DirPosEmpty && DirNegEmpty)
00057                 RoadEmpty = true;
00058 
00059         if(RoadEmpty && m_bEndOfFile)   // if no more vehicles and road is empty
00060                 SimulationOver = true;          // we are finished!
00061 
00062         if(SimulationOver)      // tidy up detector output
00063         {
00064                 for(int i = 0; i < m_vDetectorsPos.size(); i++)
00065                         m_vDetectorsPos[i]->EndOutput();
00066                 for(i = 0; i < m_vDetectorsNeg.size(); i++)
00067                         m_vDetectorsNeg[i]->EndOutput();
00068         }
00069 
00070         return SimulationOver;                  
00071 }

Here is the call graph for this function:

void Road::populate ( double  step,
const double  curTime 
)

Populates the road.

Parameters:
step The timestep
curTime The simulation's current time
This function handles the population of the road which is called in each timestep. The main loop handles the processing of the vehicles in the buffer. If the head of the buffer is currently entering the road, then the other vehicles are also checked. However, since the vehicles are sorted in order of time, if the head of the buffer is not currently entering the road, then no other vehicle is either. When a vehicle enters the road from the buffer, the next vehicle is read from the file being used, and added to the buffer.

Definition at line 141 of file Road.cpp.

References FileHandler::getPercentComplete(), m_bEndOfFile, m_BufferVehicles, m_DriveOnRight, m_PercentComplete, m_pFileHandler, m_RoadLength, m_vLanes, MapTrafLaneToSimLane(), MIN_SPACE_FOR_NEXT_VEHICLE, FileHandler::readLine(), and setIDMDriverModel().

Referenced by Sim::doOneTimeStep().

00142 {
00143         bool frontOn = true;
00144         while(m_BufferVehicles.size() > 0 && frontOn)
00145         {
00146                 frontOn = false;
00147                 int lane = m_BufferVehicles.front()->getLane() - 1;             // the cumulative lane no of the next truck on the road
00148 
00149                 if(m_vLanes.at(lane)->getLastPos() >= MIN_SPACE_FOR_NEXT_VEHICLE)               // If there is space for another vehicle
00150                 {
00151                         if(m_BufferVehicles.front()->getTime() <= curTime)      // If it is time for the next vehicle
00152                         {
00153                                 int noVeh = m_vLanes.at(lane)->getNoVeh();              // crashes here sim has fewer lanes than the truck file.
00154 
00155                                 // set the driver, roadlength, insert into lane and remove from buffer
00156                                 setIDMDriverModel(m_BufferVehicles.front());
00157                                 m_BufferVehicles.front()->init(m_RoadLength, m_DriveOnRight);
00158                                 m_vLanes.at(lane)->insert(noVeh, m_BufferVehicles.front());
00159                                 m_BufferVehicles.erase(m_BufferVehicles.begin());
00160 
00161                                 Vehicle* tempVeh = m_pFileHandler->readLine();
00162                                 m_PercentComplete = m_pFileHandler->getPercentComplete();
00163                                 if(tempVeh != NULL)
00164                                 {
00165                                         MapTrafLaneToSimLane(tempVeh);
00166                                         m_BufferVehicles.push_back(tempVeh);
00167                                 }
00168                                 else
00169                                         m_bEndOfFile = true;
00170                                 frontOn = true;
00171                         }
00172                 }
00173 
00174         }
00175 }

Here is the call graph for this function:

double Road::init (  ) 

Initialises the road.

Returns:
The time to the first vehicle
This function initialises the road object. Firstly, the special segments of the road are sorted depending on their road position. Next, we load a buffer of vehicles which the road processes, and maps these vehicles to their respective lanes. Directions are initialised, and the road then takes account of cumulative lane identifiers by loading each direction's lanes into a vector of cumulative lanes. Detectors, if specified by the user, are also set in each direction to facilitate the retrieval of updated vehicle information when a vehicle passes a specified point.

Definition at line 85 of file Road.cpp.

References RoadSegment::CompareSegments(), Direction::createLanes(), DirectionNeg, DirectionPos, Direction::getLane(), Direction::getNoLanes(), Direction::init(), INPUT_FILE_BUFFER_SIZE, FileHandler::loadTruckGroup(), m_AllowLaneChanging, m_BufferVehicles, m_DriveOnRight, m_LocOutputDetectorDirNeg, m_LocOutputDetectorDirPos, m_NoDirections, m_NoLanesDirNeg, m_NoLanesDirPos, m_pFileHandler, m_RoadLength, m_vDetectorsNeg, m_vDetectorsPos, m_vLanes, m_vRoadSegmentsNeg, m_vRoadSegmentsPos, and MapTrafLaneToSimLane().

Referenced by Sim::init().

00086 {       
00087         sort(m_vRoadSegmentsPos.begin(), m_vRoadSegmentsPos.end(), RoadSegment::CompareSegments);       
00088         sort(m_vRoadSegmentsNeg.begin(), m_vRoadSegmentsNeg.end(), RoadSegment::CompareSegments);       
00089 
00090         // Initially set up vehicles and their sim lanes
00091         m_BufferVehicles = m_pFileHandler->loadTruckGroup(INPUT_FILE_BUFFER_SIZE);
00092         for(int i = 0; i < m_BufferVehicles.size(); i++)
00093                 MapTrafLaneToSimLane(m_BufferVehicles.at(i));
00094 
00096         // lane vector
00097         std::vector<int> vLaneLengthsPos(m_NoLanesDirPos,m_RoadLength); // this is for future extension
00098 
00099         // true means positive x-direction
00100         OutputDetector* pDetDirPos = new OutputDetector(m_LocOutputDetectorDirPos, true, m_pFileHandler);
00101         DirectionPos.init(true, pDetDirPos, m_AllowLaneChanging, m_RoadLength, m_DriveOnRight);         
00102         DirectionPos.createLanes(0, vLaneLengthsPos, m_vDetectorsPos, m_vRoadSegmentsPos);
00103         
00104         // Using cumulative lane identifiers
00105         for(i = 0; i < DirectionPos.getNoLanes(); i++)
00106                 m_vLanes.push_back(&DirectionPos.getLane(i));
00107 
00109         if(m_NoDirections == 2)
00110         {
00111                 // lane vector
00112                 std::vector<int> vLaneLengthsNeg(m_NoLanesDirNeg,m_RoadLength);
00113                 
00114                 // false means the negative x-direction
00115                 OutputDetector* pDetDirNeg = new OutputDetector(m_LocOutputDetectorDirNeg, false, m_pFileHandler);
00116                 DirectionNeg.init(false, pDetDirNeg, m_AllowLaneChanging, m_RoadLength, m_DriveOnRight);
00117                 DirectionNeg.createLanes(m_NoLanesDirPos, vLaneLengthsNeg, m_vDetectorsNeg, m_vRoadSegmentsNeg);
00118 
00119                 for(i = 0; i < DirectionNeg.getNoLanes(); i++)
00120                         m_vLanes.push_back(&DirectionNeg.getLane(i));
00121         }
00122 
00123         // Return the time of the first truck of the traffic file
00124         return m_BufferVehicles.front()->getTime();
00125 }

Here is the call graph for this function:

void Road::passIDMParameters ( RoadSegment segment  )  [private]

void Road::MapTrafLaneToSimLane ( Vehicle pVeh  )  [private]

Maps vehicles to appropriate lanes.

Parameters:
pVeh The vehicle to map
This function updates the lane provided by the vehicle's original traffic file assignment to an appropriate lane in the simulation. This is to facilitate the simulation of more lanes than the input file allows for

Definition at line 185 of file Road.cpp.

References Vehicle::getDirection(), Vehicle::getLane(), m_NoLanes, m_TrafFileNoLanesDirNeg, m_TrafFileNoLanesDirPos, Vehicle::setLane(), and Vehicle::setTotalNoLanesInRoad().

Referenced by init(), and populate().

00186 {
00187         // first tell the vehicle how many lanes the road has for later use
00188         pVeh->setTotalNoLanesInRoad(m_NoLanes);
00189 
00190         // then map its current local to global lane number
00191         if(!pVeh->getDirection())       // only if it's in the negative direction
00192         {
00193                 int TrafFileNoLanes = m_TrafFileNoLanesDirPos + m_TrafFileNoLanesDirNeg;
00194                 int lanesFromNegVerge = TrafFileNoLanes - pVeh->getLane();
00195                 int newLane = m_NoLanes - lanesFromNegVerge;    // vehicle lane numbers are 1-based
00196                 pVeh->setLane(newLane);
00197         }
00198 }

Here is the call graph for this function:

void Road::setIDMDriverModel ( Vehicle pVeh  )  [private]

Sets a vehicle's drivermodel as IDM.

Parameters:
pVeh The vehicle to set
This function sets the drivermodel of a particular vehicle based on the type of that vehicle

Definition at line 207 of file Road.cpp.

References CIDMParameterSet::Generate(), Vehicle::getID(), m_pIDMParams_Car, m_pIDMParams_Crane, m_pIDMParams_LargeTruck, m_pIDMParams_Lowloader, m_pIDMParams_SmallTruck, Vehicle::setDriver(), VEH_ID_CAR, VEH_ID_CRANE, VEH_ID_LARGETRUCK, VEH_ID_LOWLOADER, and VEH_ID_SMALLTRUCK.

Referenced by populate().

00208 {
00209         WORD VEH_ID = pVeh->getID();
00210         
00211         switch(VEH_ID)
00212         {
00213                 case VEH_ID_CAR:
00214                         pVeh->setDriver( m_pIDMParams_Car->Generate() );
00215                         break;
00216                 case VEH_ID_SMALLTRUCK:
00217                         pVeh->setDriver( m_pIDMParams_SmallTruck->Generate() );
00218                         break;
00219                 case VEH_ID_LARGETRUCK:
00220                         pVeh->setDriver( m_pIDMParams_LargeTruck->Generate() );
00221                         break;
00222                 case VEH_ID_CRANE:
00223                         pVeh->setDriver( m_pIDMParams_Crane->Generate() );
00224                         break;
00225                 case VEH_ID_LOWLOADER:
00226                         pVeh->setDriver( m_pIDMParams_Lowloader->Generate() );
00227                         break;
00228                 default:
00229                         pVeh->setDriver( m_pIDMParams_Car->Generate() );
00230         };
00231 }

Here is the call graph for this function:

void Road::SetSpeedLimitSegment ( CRoadFeature pFeat  )  [private]

Sets a speed limit based on data specified by the user to the GUI.

Parameters:
pFeat The speed limit to create
This function takes the data inputted by the user into the GUI and creates a speed limit based on the given data

Definition at line 495 of file Road.cpp.

References CRoadFeature::getDirPos(), CRoadFeature::getEnd(), CRoadFeature::getStart(), CRoadFeature::getValue(), m_RoadLength, m_vRoadSegmentsNeg, m_vRoadSegmentsPos, and passIDMParameters().

Referenced by SetSegmentFromFeature().

00496 {
00497         bool bDirPos = pFeat->getDirPos();
00498         SpeedLimit* pSL;
00499         if( bDirPos )
00500         {
00501                 pSL = new SpeedLimit(pFeat->getStart(), pFeat->getEnd(), pFeat->getValue(), bDirPos);
00502                 m_vRoadSegmentsPos.push_back(pSL);
00503         }
00504         else
00505         {
00506                 int start = pFeat->getStart();
00507                 int end = pFeat->getEnd();
00508 
00509                 pSL = new SpeedLimit(m_RoadLength - end, m_RoadLength - start, pFeat->getValue(), bDirPos);
00510                 
00511                 m_vRoadSegmentsNeg.push_back(pSL);
00512         }
00513         passIDMParameters(pSL);
00514 }

Here is the call graph for this function:

void Road::SetGradientSegment ( CRoadFeature pFeat  )  [private]

Sets a gradient based on data specified by the user to the GUI.

Parameters:
pFeat The gradient to create
This function takes the data inputted by the user into the GUI and creates a gradient based on the given data

Definition at line 523 of file Road.cpp.

References CRoadFeature::getDirPos(), CRoadFeature::getEnd(), CRoadFeature::getStart(), CRoadFeature::getValue(), m_RoadLength, m_vRoadSegmentsNeg, m_vRoadSegmentsPos, and passIDMParameters().

Referenced by SetSegmentFromFeature().

00524 {
00525         bool bDirPos = pFeat->getDirPos();
00526         Gradient* pGr;
00527 
00528         if( bDirPos )
00529         {
00530                 pGr = new Gradient(pFeat->getStart(), pFeat->getEnd(), pFeat->getValue(), bDirPos);
00531                 m_vRoadSegmentsPos.push_back(pGr);
00532         }
00533         else
00534         {
00535                 int start = pFeat->getStart();
00536                 int end = pFeat->getEnd();
00537 
00538                 pGr = new Gradient(m_RoadLength - end, m_RoadLength - start, pFeat->getValue(), bDirPos);
00539                 
00540                 m_vRoadSegmentsNeg.push_back(pGr);
00541         }
00542         passIDMParameters(pGr);
00543 }

Here is the call graph for this function:


Member Data Documentation

bool Road::m_DriveOnRight [private]

Definition at line 64 of file Road.h.

Referenced by init(), populate(), and setDriveOnRight().

int Road::m_PercentComplete [private]

Definition at line 65 of file Road.h.

Referenced by getPercentComplete(), and populate().

Definition at line 72 of file Road.h.

Referenced by clear(), passIDMParameters(), Road(), setIDMDriverModel(), setIDMParams_Car(), and ~Road().

Definition at line 73 of file Road.h.

Referenced by clear(), passIDMParameters(), Road(), setIDMDriverModel(), setIDMParams_SmallTruck(), and ~Road().

Definition at line 74 of file Road.h.

Referenced by clear(), passIDMParameters(), Road(), setIDMDriverModel(), setIDMParams_LargeTruck(), and ~Road().

Definition at line 75 of file Road.h.

Referenced by clear(), passIDMParameters(), Road(), setIDMDriverModel(), setIDMParams_Crane(), and ~Road().

Definition at line 76 of file Road.h.

Referenced by clear(), passIDMParameters(), Road(), setIDMDriverModel(), setIDMParams_Lowloader(), and ~Road().

Definition at line 78 of file Road.h.

Referenced by init(), and setLocOuputDetectorDirPos().

Definition at line 79 of file Road.h.

Referenced by init(), and setLocOuputDetectorDirNeg().

Definition at line 81 of file Road.h.

Referenced by clear(), getVehicles(), init(), and update().

Definition at line 82 of file Road.h.

Referenced by clear(), getVehicles(), init(), and update().

Definition at line 84 of file Road.h.

Referenced by MapTrafLaneToSimLane(), and setTrafFileNoLanesDirPos().

Definition at line 85 of file Road.h.

Referenced by MapTrafLaneToSimLane(), and setTrafFileNoLanesDirNeg().

Definition at line 87 of file Road.h.

Referenced by clear(), init(), initTruckGroup(), populate(), and Road().

std::vector<Vehicle*> Road::m_BufferVehicles [private]

Definition at line 88 of file Road.h.

Referenced by clear(), init(), and populate().

std::vector<Lane*> Road::m_vLanes [private]

Definition at line 89 of file Road.h.

Referenced by clear(), init(), and populate().

std::vector<Detector*> Road::m_vDetectorsPos [private]

Definition at line 90 of file Road.h.

Referenced by clear(), init(), SetMetricDetFromStatDet(), and update().

std::vector<Detector*> Road::m_vDetectorsNeg [private]

Definition at line 91 of file Road.h.

Referenced by clear(), init(), SetMetricDetFromStatDet(), and update().

std::vector<int> Road::m_vLaneLengthsPos [private]

Definition at line 93 of file Road.h.

std::vector<int> Road::m_vLaneLengthsNeg [private]

Definition at line 94 of file Road.h.

std::vector<RoadSegment*> Road::m_vRoadSegmentsPos [private]

Definition at line 96 of file Road.h.

Referenced by clear(), init(), SetGradientSegment(), and SetSpeedLimitSegment().

std::vector<RoadSegment*> Road::m_vRoadSegmentsNeg [private]

Definition at line 97 of file Road.h.

Referenced by clear(), init(), SetGradientSegment(), and SetSpeedLimitSegment().

bool Road::m_bEndOfFile [private]

Definition at line 99 of file Road.h.

Referenced by populate(), Road(), and update().

bool Road::m_AllowLaneChanging [private]

Definition at line 100 of file Road.h.

Referenced by getAllowLaneChanging(), init(), and setAllowLaneChanging().

int Road::m_NoLanesDirPos [private]

Definition at line 101 of file Road.h.

Referenced by getVehicles(), init(), and setNoLanesDirPos().

int Road::m_NoLanesDirNeg [private]

Definition at line 102 of file Road.h.

Referenced by getVehicles(), init(), and setNoLanesDirNeg().

int Road::m_NoDirections [private]

Definition at line 103 of file Road.h.

Referenced by clear(), getVehicles(), init(), setNoDirections(), and update().

int Road::m_NoLanes [private]

Definition at line 104 of file Road.h.

Referenced by MapTrafLaneToSimLane(), and setNoLanes().

int Road::m_RoadLength [private]

Definition at line 107 of file Road.h.

Referenced by populate(), and Road().


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