AnyLogic
Expand
Font size
All Superinterfaces:
Serializable

public interface TrackDataSource
extends Serializable

Method Summary

Modifier and TypeMethodDescription
voidcancelReservation()
Cancel any existing reservations, if any.
AgentgetCar(int index)
Returns a car on the track at a given position counted from the beginning of the track.
List<Agent>getCars()
Returns the list of rail cars that are (maybe, partially) located of this track
AgentgetFirstCar()
Returns the car closest to the beginning of the track, or null if the track is empty
doublegetFreeSpace(boolean fromstart)
Tests the availability of space on the track.
AgentgetLastCar()
Returns the car closest to the end of the track, or null if the track is empty
intgetNCars()
Returns the number of cars on the track (including partially)
List<Agent>getReservations()
Return all the trains that this track has been reserved for
List<Agent>getTrains()
Returns the list of the trains on the track
booleanisAvailableFor(Agent train)
Tests if the certain train is prohibited from moving through the track
booleanisEmpty()
Tests if the track is empty, i.e.
voidonToggleBlock()
Callback at block status toggle
voidreserveFor(Agent... trains)
Allow or disallow the specified trains to go through the track.

Method Details

isEmpty

boolean isEmpty()
Tests if the track is empty, i.e. there are no cars that are (even partially) on the track.
Returns:
true if the track is empty, false otherwise

getNCars

int getNCars()
Returns the number of cars on the track (including partially)
Returns:
the number of cars on the track

getFirstCar

Agent getFirstCar()
Returns the car closest to the beginning of the track, or null if the track is empty
Returns:
the first car on the track or null

getLastCar

Agent getLastCar()
Returns the car closest to the end of the track, or null if the track is empty
Returns:
the last car on the track or null

getCar

Agent getCar(int index)
Returns a car on the track at a given position counted from the beginning of the track. All cars count: moving, standing, coupled, and cars that are only partially on this track.
Parameters:
index - the index of the car
Returns:
the car at a given position, or null

getCars

List<Agent> getCars()
Returns the list of rail cars that are (maybe, partially) located of this track
Returns:
the list of cars on this track

getFreeSpace

double getFreeSpace(boolean fromstart)
Tests the availability of space on the track. If there are no cars on the track, returns infinity. If there are cars, returns the distance from the track start or end point (depending on the parameter fromstart) to the nearest car. If there is a car partially entered or exited the track at a given side, returns a negative value.
Parameters:
fromstart - if true, space is checked from the start point of the track, otherwise from end point
Returns:
the free space from a given side of the track in meters, or infinity

getTrains

List<Agent> getTrains()
Returns the list of the trains on the track

onToggleBlock

void onToggleBlock()
Callback at block status toggle

isAvailableFor

boolean isAvailableFor(Agent train)
Tests if the certain train is prohibited from moving through the track
Parameters:
train -
Returns:
true if the train cannot move through the track, false otherwise

reserveFor

void reserveFor(Agent... trains)
Allow or disallow the specified trains to go through the track. Every call invalidates previous calls of this method and rewrites
Parameters:
trains - trains that are allowed or disallowed on the track
allow - if true - only the specified trains can go through the track, if false - all but the specified trains are allowed

getReservations

List<Agent> getReservations()
Return all the trains that this track has been reserved for
Returns:
all the trains that this track has been reserved for

cancelReservation

void cancelReservation()
Cancel any existing reservations, if any. NB: global block is unaffected