VANET Simulator
 All Classes Functions Variables
Public Member Functions | Public Attributes | List of all members
vanetsim.map.Junction Class Reference

Public Member Functions

 Junction (Node node, Street[] priorityStreets)
 
void addJunctionRule (Node startNode, Node targetNode, int priority)
 
int getJunctionPriority (Node startNode, Node targetNode)
 
synchronized void addWaitingVehicle (Vehicle vehicle, int priority)
 
void allowOtherVehicle ()
 
synchronized boolean canPassTrafficLight (Vehicle vehicle, Street tmpStreet, Node nextNode)
 
synchronized boolean canPassJunction (Vehicle vehicle, int priority, Node nextNode)
 
void delTrafficLight ()
 
Node getNode ()
 
Street[] getPriorityStreets ()
 

Public Attributes

Vehicle vehicleAllowedThisStep_ = null
 
int vehicleAllowedSetTime_ = 0
 

Detailed Description

A junction which always belongs to one specific node. If vehicles move from one priority street to another, they don't have to wait. Otherwise one vehicle can pass this junction every JUNCTION_PASS_INTERVAL. Vehicles coming from priority streets are preferred to pass this junction.

To store the rules, one-dimensional arrays are used as they are very efficient here. Originally, a double-dimensional IdentityHashMap was used but they need more RAM and are in most cases slower as there are only relatively few junction rules and linear searching through the arrays is faster than the IdentityHashMap-overhead with autoboxing, function calls and so on.

Constructor & Destructor Documentation

vanetsim.map.Junction.Junction ( Node  node,
Street[]  priorityStreets 
)
inline

Traffic Light Constructor

Parameters
nodethe node associated with this junction
priorityStreetsthe priority streets of this junction

Member Function Documentation

void vanetsim.map.Junction.addJunctionRule ( Node  startNode,
Node  targetNode,
int  priority 
)
inline

Adds a junction rule.

Parameters
startNodethe start node
targetNodethe target node
prioritythe priority (see getJunctionPriority(Node, Node) for details)
synchronized void vanetsim.map.Junction.addWaitingVehicle ( Vehicle  vehicle,
int  priority 
)
inline

Adds a waiting vehicle to the junction.
Note: This function sets the vehicle which is allowed to pass in the current simulation step. Thus, it is absolutely necessary, that this function is the first one in each step which is called on this object!

Parameters
vehiclethe vehicle
prioritythe priority of the vehicle to pass this junction
void vanetsim.map.Junction.allowOtherVehicle ( )
inline

Allows another vehicle to pass the junction by setting vehicleOnJunction_ to false.

synchronized boolean vanetsim.map.Junction.canPassJunction ( Vehicle  vehicle,
int  priority,
Node  nextNode 
)
inline

Returns if a vehicle may pass. Passing is only allowed every 2,5s and if there's no vehicle coming from the priority streets.

Parameters
vehiclethe vehicle
prioritythe priority of the vehicle to pass this junction
nextNodethe next node the vehicle will go to
Returns
true if passing is allowed, else false
synchronized boolean vanetsim.map.Junction.canPassTrafficLight ( Vehicle  vehicle,
Street  tmpStreet,
Node  nextNode 
)
inline

Returns if a vehicle may pass a Traffic Light.

Parameters
vehiclethe vehicle
tmpStreetthe street
nextNodethe next node the vehicle will go to
Returns
true if passing is allowed, else false
void vanetsim.map.Junction.delTrafficLight ( )
inline

Deletes the traffic light on this junction an resets the street values. *

int vanetsim.map.Junction.getJunctionPriority ( Node  startNode,
Node  targetNode 
)
inline

Gets the priority for going over this node.

Parameters
startNodethe node you're coming from
targetNodethe node you're going to
Returns
1 if it's possible to go over without any notice, 2 if it's a right turnoff from a priority street, 3 if it's a left turnoff from a priority street or 4 if it's just a normal street (forced to stop at junction) with no need to look for vehicles at target street. 5 is the same as 4 but with a need to look for vehicles on target street.

Member Data Documentation

int vanetsim.map.Junction.vehicleAllowedSetTime_ = 0

When (in simulation time) the vehicleAllowedThisStep-variable was last set.

Vehicle vanetsim.map.Junction.vehicleAllowedThisStep_ = null

The vehicle which is allowed to pass the junction in this step. Used against synchronization problems.


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