#include <Lane.h>
Public Member Functions | |
void | setOutputDetector (Detector *out) |
Sets the output detector for the direction. | |
Lane () | |
Default constructor. | |
Lane (int length, std::vector< Detector * > detectors, bool DirPos, bool AllowLaneChange) | |
Main constructor. | |
virtual | ~Lane () |
Default destructor. | |
bool | update (double step) |
Updates the positions of all Vehicles in the Lane. | |
int | getIndex () |
Gets the index of the lane. | |
double | getLastPos () |
Gets the position of the last vehicle in the lane. | |
int | getNoVeh () |
Gets the number of vehicles in the lane. | |
double | getLength () |
Gets the length of the Lane. | |
void | insert (int i, Vehicle *pVeh) |
Inserts a Vehicle into the Lane. | |
bool | ChangeLanes (Vehicle *pVeh) |
Changes a Vehicle's Lane if advantageous and possible. | |
void | setRightLane (Lane *right) |
Sets a pointer to the Lane to the right of the current Lane. | |
void | setLeftLane (Lane *left) |
Sets a pointer to the Lane to the left of the current Lane. | |
std::vector< Vehicle * > | getPos () |
Gets all the Vehicles currently in the Lane. | |
Private Member Functions | |
Vehicle * | FinadAdjacentVehicle (Lane *AdjacentLane, double location, bool front, int *iAdjacentLane=NULL) |
Finds a vehicle in the adjacent lane. | |
void | ImplementLaneChange (Vehicle *pVeh, int LaneChangeID, int iVehLeftLane, int iVehRightLane) |
Changes a vehicle to another lane. | |
void | AddVehicleToDetector (double prevPosition, double curPosition, Vehicle *pVeh) |
Adds a vehicle to the detectors list of vehicles for that step. | |
Private Attributes | |
std::vector< Vehicle * > | m_pVehicles |
std::vector< Detector * > | m_vDetectors |
int | m_Dir |
int | m_iLane |
double | m_Flow |
double | m_RoadLength |
int | m_NoVeh |
double | m_PrevVehiclePosition |
bool | m_AllowLaneChanging |
bool | m_DirPos |
Lane * | m_LeftLane |
Lane * | m_RightLane |
Detector * | m_OutputDetector |
Static Private Attributes | |
static int | m_index = 0 |
Lane::Lane | ( | ) |
Default constructor.
Lane::Lane | ( | int | RoadLength, | |
std::vector< Detector * > | detectors, | |||
bool | DirPos, | |||
bool | AllowLaneChange | |||
) |
Lane::~Lane | ( | ) | [virtual] |
Default destructor.
void Lane::setOutputDetector | ( | Detector * | out | ) |
Sets the output detector for the direction.
out | The output detector |
bool Lane::update | ( | double | step | ) |
Updates the positions of all Vehicles in the Lane.
This function is called for each iteration of the simulation, and handles the updating of the positions of Vehicles, and the removal of Vehicles which are no longer on the Road. If there are any Vehicles on the Road, the Vehicle at the head of the Lane is updated with respect to the clear Road ahead of it. Following this, all Vehicles following the Vehicle at the head of the Road are updated with respect to the preceding Vehicle. These Vehicles are also checked to see if it is time to determine if changing to another Lane would be advantageous. After all Vehicles have been updated, it is checked to see whether the Vehicle at the head of the Lane has yet passed the end of the Road. If it has, it is removed from the Lane and the simulation. Vehicles are also checked to see if they have passed a detector during the update
step | The timestep |
int Lane::getIndex | ( | ) |
Gets the index of the lane.
double Lane::getLastPos | ( | ) |
Gets the position of the last vehicle in the lane.
int Lane::getNoVeh | ( | ) |
Gets the number of vehicles in the lane.
void Lane::insert | ( | int | i, | |
Vehicle * | pVeh | |||
) |
bool Lane::ChangeLanes | ( | Vehicle * | pVeh | ) |
Changes a Vehicle's Lane if advantageous and possible.
pVeh | The vehicle changing lanes |
void Lane::setRightLane | ( | Lane * | right | ) |
void Lane::setLeftLane | ( | Lane * | left | ) |
std::vector< Vehicle * > Lane::getPos | ( | ) |
Vehicle * Lane::FinadAdjacentVehicle | ( | Lane * | AdjacentLane, | |
double | location, | |||
bool | front, | |||
int * | iAdjacentLane = NULL | |||
) | [private] |
Finds a vehicle in the adjacent lane.
AdjacentLane | The lane at which we are looking | |
location | The location of the vehicle wishing to change | |
front | Whether or not we are looking for the vehicle in front of the current vehicle's position | |
iAdjacentLane | The index to switch into in the adjacent lane |
void Lane::ImplementLaneChange | ( | Vehicle * | pVeh, | |
int | LaneChangeID, | |||
int | iVehLeftLane, | |||
int | iVehRightLane | |||
) | [private] |
Changes a vehicle to another lane.
pVeh | The vehicle changing lane | |
LaneChangeID | The lane to change to | |
iVehLeftLane | The index of the vehicle if moving to the left lane | |
iVehRightLane | The index of the vehicle if moving to the right lane |
void Lane::AddVehicleToDetector | ( | double | prevPosition, | |
double | curPosition, | |||
Vehicle * | pVeh | |||
) | [private] |
Adds a vehicle to the detectors list of vehicles for that step.
prevPosition | The vehicle's previous position | |
curPosition | The vehicle's current position | |
pVeh | The vehicle passing the detector |
std::vector<Vehicle*> Lane::m_pVehicles [private] |
std::vector<Detector*> Lane::m_vDetectors [private] |
int Lane::m_Dir [private] |
int Lane::m_index = 0 [static, private] |
int Lane::m_iLane [private] |
double Lane::m_Flow [private] |
double Lane::m_RoadLength [private] |
int Lane::m_NoVeh [private] |
double Lane::m_PrevVehiclePosition [private] |
bool Lane::m_AllowLaneChanging [private] |
bool Lane::m_DirPos [private] |
Lane* Lane::m_LeftLane [private] |
Lane* Lane::m_RightLane [private] |
Detector* Lane::m_OutputDetector [private] |