Car Move To

The block that controls the car movement. A car can move only when it is inside a
CarMoveTo
block. When a car enters
CarMoveTo, it tries to calculate the way from its current location to the specified destination.
The destinations a car can move to include: a
road, a
parking lot, a
bus stop
or a
stop line. Specified destination should belong to the same road network as the one the car is currently in. If there is no way from the car’s current location to the specified destination, car exits the block via
outWayNotFound
port.
If a car is set to move to a road, direction of the road should be additionally specified. The car will try to use the shortest way to get to the beginning of the specified road. Once on it, the car will move along the specified road till the end
of it. Once a car reaches the end of the road, it should be immediately removed from the model by the
CarDispose
block or proceed to the other
CarMoveTo
block to be sent further. If a car is unable to leave the end of the destination road immediately, an error will be generated.
If a car is set to move to a parking lot, the car will move to the specified parking lot and try to reserve a free parking space. Cars reserve parking spaces only when they approach the parking lot. If a car is unable to reserve a parking space,
it exits the block via
outWayNotFound
port. If a car is able to successfully reserve a parking space, it parks on it and exits this block. A car can remain in parking space until it is removed from the road network or is sent to other destination by the
CarMoveTo
block.
If a car is set to move to a bus stop, the car will move to the specified bus stop. If a bus stop is already occupied by another car, the car approaching the bus stop will stop at the bus stop and wait until the bus stop is vacant. When a car
arrives at a bus stop, it parks in it and exits this block. A car can remain at the bus stop until it is removed from the road network or is sent to some other destination by the
CarMoveTo
block.
If a car is set to move to a stop line, two options of behavior at the destination stop line are possible, see the
Behavior at stop line
parameter for description..
While the car is moving under control of the
CarMoveTo
block, you still can partially control it by using the
Car
API.
Parameters
- Moves to
- Type of destination where the car is sent:
Road,
Parking lot,
Stop line
or
Bus stop.
Get value:
movesTo
Set new value at runtime:
set_movesTo(new value)
Valid values:
CarMoveTo.ROAD;
CarMoveTo.PARKING_LOT;
CarMoveTo.STOP_LINE;
CarMoveTo.BUS_STOP
- Road
[dynamic]
- [Visible and applies only if the
Moves to:
Road
option is set] Road to which the car is sent. The movement direction needs to be specified below in the
Destination
parameter.
If the
Road
is not specified, or it is not found in the current
road network
, error is generated.
If a car is not able to find the way to the specified road through the road network, this car leaves the block via its
outWayNotFound
port.
Type of value:
Road
Local variable:
car
- car that is being sent to the destination road
- Destination
- [Visible and applies only if the
Moves to:
Road
option is set] Specifies the destination (end of forward lane
or
end of backward lane) of the road to which the car will move. If the road does not have the specified destination (e.g. is one-way), the error is generated.
Get value:
destination
Set new value at runtime:
set_destination(new value)
Valid values:
CarMoveTo.END_OF_FORWARD_LANE;
CarMoveTo.END_OF_BACKWARD_LANE
- Parking lot
[dynamic]
- [Visible and applies only if the
Moves to:
Parking lot
option is set]
Parking lot
to which the car is sent. The car starts movement from its current location to the specified parking lot. When it approaches the parking lot, it tries to reserve a parking space in the lot. If the car is able to reserve a parking space, it parks at
this space and exits this
CarMoveTo
block. If the car is not able to reserve a parking space (parking lot has no free parking spaces), an error is generated in the model.
If theParking lot
is not specified, or it is not found in the current road network, error is generated.
If a car is not able to find the way to the specified parking lot through the
road network, the car leaves the block via its
outWayNotFound
port.
Type of value:
ParkingLot
Local variable:
car
- car that is being sent to the parking lot
- Stop line
[dynamic]
- [Visible and applies only if the
Moves to:
Stop line
option is set]
Stop line
to which the car is sent. The car starts movement from its current location to the specified stop line. When it approaches the stop line, it decelerates, stops, and exits this
CarMoveTo
block (its behavior can be set in the
Behavior at stop line
option below).
If theStop line
is not specified, or it is not found in the current road network, error is generated.
If a car is not able to find the way to the specified stop line through the
road network, the car leaves the block via its
outWayNotFound
port.
Type of value:
StopLine
Local variable:
car
- car that is being sent to the stop line
- Behavior at stop line
- [Visible and applies only if the
Moves to:
Stop line
option is set] Specifies the behavior at destination stop line:
Pass through stop line
- The car does not stop before the stop line and exits
CarMoveTo
block immediately after passing the specified stop line. The car should be immediately removed from model or sent to some destination by other
CarMoveTo
block, otherwise an error will be generated
Stop before stop line
– The car will stop before the specified stop line. The car will exit
CarMoveTo
block with zero speed. It is not necessary to immediately remove the car or send it to the next destination.
Get value:
stopLineBehavior
Local variable:
car
- the car that is being sent to the stop line
Set new value at runtime:
set_stopLineBehavior(new value)
Valid values:
CarMoveTo.PASS_THROUGH_STOP_LINE;
CarMoveTo.STOP_BEFORE_STOP_LINE
- Bus stop
[dynamic]
- [Visible and applies only if the
Moves to:
Bus Stop
option is set]
Bus stop
to which the car is sent. The car starts movement from its current location to the specified bus stop. When it approaches the bus stop, it tries to reserve a place in the bus stop. If the car is able to reserve place, it occupies this place and exits
the
CarMoveTo
block. If the car is not able to reserve place (bus stop has no free place), the vehicle stops on the road right next to the bus stop, expecting its turn to enter the bus stop.
If theBus stop
is not specified, or it is not found in the current road network, error is generated.
If the car is not able to find the way to the specified bus stop through the
road network, this car leaves the block via its
outWayNotFound
port.
Type of value:
BusStop
Local variable:
car
- car that is being sent to the bus stop
-
Actions
- On enter
[code]
- Code that is executed when the car enters the block.
Local variable:
car
- the car that enters the block
- On exit
[code]
- Code that is executed when car reaches its destination. If the destination was road, the code is executed at the end of the destination road. If the destination was parking lot, the code is executed when the car is parked at parking space of the
specified parking lot.
Local variable:
car
- the car that reached its destination
- On way not found
[code]
- Code that is executed when a car is unable to find its way to the specified destination from its current position.
Local variable:
car
- the car that is unable to find the way
Functions
long size()
- Returns the number of cars inside this block.
java.util.List<Agent>
getCars()
- Returns a non-modifiable collection containing the cars that are currently in this block.
Ports
- in
- The input port.
- out
- The output port.
- outWayNotFound
- The output port that a car uses to leave the block if there is no way from the car’s current location to the specified destination.