|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vanetsim.map.Junction
public final class Junction
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.
Field Summary | |
---|---|
int |
vehicleAllowedSetTime_
When (in simulation time) the vehicleAllowedThisStep-variable was last set. |
Vehicle |
vehicleAllowedThisStep_
The vehicle which is allowed to pass the junction in this step. |
Constructor Summary | |
---|---|
Junction(Node node,
Street[] priorityStreets)
Constructor |
Method Summary | |
---|---|
void |
addJunctionRule(Node startNode,
Node targetNode,
int priority)
Adds a junction rule. |
void |
addWaitingVehicle(Vehicle vehicle,
int priority)
Adds a waiting vehicle to the junction. |
void |
allowOtherVehicle()
Allows another vehicle to pass the junction by setting vehicleOnJunction_ to false . |
boolean |
canPassJunction(Vehicle vehicle,
int priority,
Node nextNode)
Returns if a vehicle may pass. |
boolean |
canPassTrafficLight(Vehicle vehicle,
Street tmpStreet,
Node nextNode)
Returns if a vehicle may pass a Traffic Light. |
void |
delTrafficLight()
Deletes the traffic light on this junction an resets the street values |
int |
getJunctionPriority(Node startNode,
Node targetNode)
Gets the priority for going over this node. |
Node |
getNode()
|
Street[] |
getPriorityStreets()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public Vehicle vehicleAllowedThisStep_
public int vehicleAllowedSetTime_
Constructor Detail |
---|
public Junction(Node node, Street[] priorityStreets)
node
- the node associated with this junctionpriorityStreets
- the priority streets of this junctionMethod Detail |
---|
public void addJunctionRule(Node startNode, Node targetNode, int priority)
startNode
- the start nodetargetNode
- the target nodepriority
- the priority (see getJunctionPriority(Node, Node)
for details)public int getJunctionPriority(Node startNode, Node targetNode)
startNode
- the node you're coming fromtargetNode
- 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.public void addWaitingVehicle(Vehicle vehicle, int priority)
vehicle
- the vehiclepriority
- the priority of the vehicle to pass this junctionpublic void allowOtherVehicle()
false
.
public boolean canPassTrafficLight(Vehicle vehicle, Street tmpStreet, Node nextNode)
vehicle
- the vehicletmpStreet
- the streetnextNode
- the next node the vehicle will go to
true
if passing is allowed, else false
public boolean canPassJunction(Vehicle vehicle, int priority, Node nextNode)
vehicle
- the vehiclepriority
- the priority of the vehicle to pass this junctionnextNode
- the next node the vehicle will go to
true
if passing is allowed, else false
public void delTrafficLight()
public Node getNode()
public Street[] getPriorityStreets()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |