RailSettings is a detached block that offers the lower-level interface for the rail yard management based on Java functions and callback technique. You can use those callbacks, for example, to collect statistics on the rail car movement throughout the whole rail yard.
Please note that RailSettings will not automatically detect track crossings (i.e. places where two tracks cross each other without a switch) and it is the user’s responsibility to make sure there are no train collisions in such places, whereas collisions at switches are detected automatically and errors are signaled.
int getNCars() - Returns the number of railcars in this rail yard.
List<Agent> getCars() - Returns the railcars in this rail yard.
Agent getCar( int index ) - Returns the railcar in this rail yard with the given index, or null if there is no such car.
RailwayTrack[]
getShortestPath( RailwayTrack
sourceTrack, RailwayTrack targetTrack, boolean forwardOnTrack, double
targetOffset, RailwayTrack[] avoidTracks
) - Returns the shortest path from
sourceTrack to targetTrack,
or null if the path was not found.
Parameters: sourceTrack - source track.
targetTrack - target track.
forwardOnTrack - if true, the train will go in forward on track.
targetOffset - offset on the target
track.
avoidTracks - list of tracks
the route should not contain.
RailwayTrack[]
getShortestUnblockedPath( RailwayTrack
sourceTrack, RailwayTrack targetTrack, boolean forwardOnTrack, double
targetOffset, RailwayTrack[] avoidTracks
) - Returns the shortest path from
sourceTrack to targetTrack,
taking into account the blocked tracks. If the path was not found,
returns null.
Parameters: sourceTrack - source track.
targetTrack - target track.
forwardOnTrack - if true, the train will go in forward on track.
targetOffset - offset on the
target track.
avoidTracks - list of tracks the
route should not contain.
RailwayTrack[]
getShortestAvailablePath( Agent train, RailwayTrack
sourceTrack, RailwayTrack targetTrack, boolean forwardOnTrack, double
targetOffset, RailwayTrack[] avoidTracks
) - Returns the shortest path from
sourceTrack to targetTrack,
taking into account the blocked and reserved tracks. If the path was
not found, returns null.
Parameters: train - train that requires the shortest
available path.
sourceTrack - source track.
targetTrack - target track.
forwardOnTrack - if true, the
train will go in forward on track.
targetOffset
- offset on the target track.
avoidTracks - list of tracks the
route should not contain.
Switch[]
getRouteSwitches( Track[] route ) - Returns all switches for the specified
route.
void addCar( RC
car, RailwayTrack
track, double frontoffset, boolean orientation ) - [Obsolete since AnyLogic version 6.5.1. Use
TrainSource to create cars and trains] Adds an (already
constructed) rail car to the rail yard model, and puts it on the
specified track at a given position with a given orientation. Both
sides of the car must be on the same track. If the car intersects with
another car that is already on the track, the error is signaled.
Parameters: car - the car to add
track - the track where the car
is initially put
frontoffset - the offset of the front side of the car from the
start of the track
orientation - if true, the car
orientation (rear to front) is the same as the track orientation (start
to end)
void addTrain(
int n, RailwayTrack track, double frontoffset, boolean orientation)
- [Obsolete since AnyLogic version
6.5.1. Use TrainSource to create cars and trains] Creates a
train with a given number of cars and puts it on the specified track at
a given position with a given orientation. A customizable function newCar is used to create cars. All cars must
fully be on the same track. If the train intersects with other cars
that are already on the track, the error is signaled.
Parameters:
n - the number of cars in the train
track - the track where the train is put
frontoffset - the offset of the front
side of the first car from the start of the track
orientation - if true,
the train orientation (rear to front) is the same as the track
orientation (start to end)