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 |
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.
Traffic Light Constructor
node | the node associated with this junction |
priorityStreets | the priority streets of this junction |
Adds a junction rule.
startNode | the start node |
targetNode | the target node |
priority | the priority (see getJunctionPriority(Node, Node) for details) |
|
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!
vehicle | the vehicle |
priority | the priority of the vehicle to pass this junction |
|
inline |
Allows another vehicle to pass the junction by setting vehicleOnJunction_ to false
.
|
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.
vehicle | the vehicle |
priority | the priority of the vehicle to pass this junction |
nextNode | the next node the vehicle will go to |
true
if passing is allowed, else false
|
inline |
Returns if a vehicle may pass a Traffic Light.
vehicle | the vehicle |
tmpStreet | the street |
nextNode | the next node the vehicle will go to |
true
if passing is allowed, else false
|
inline |
Deletes the traffic light on this junction an resets the street values. *
Gets the priority for going over this node.
startNode | the node you're coming from |
targetNode | the node you're going to |
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. 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.