AnyLogic
Expand
Font size
All Superinterfaces:
java.io.Serializable

public interface TrackDataSource
extends java.io.Serializable

Method Summary

All Methods Instance Methods Abstract Methods 
void cancelReservation()
Cancel any existing reservations, if any.
Agent getCar​(int index)
Returns a car on the track at a given position counted from the beginning of the track.
java.util.List<Agent> getCars()
Returns the list of rail cars that are (maybe, partially) located of this track
Agent getFirstCar()
Returns the car closest to the beginning of the track, or null if the track is empty
double getFreeSpace​(boolean fromstart)
Tests the availability of space on the track.
Agent getLastCar()
Returns the car closest to the end of the track, or null if the track is empty
int getNCars()
Returns the number of cars on the track (including partially)
java.util.List<Agent> getReservations()
Return all the trains that this track has been reserved for
java.util.List<Agent> getTrains()
Returns the list of the trains on the track
boolean isAvailableFor​(Agent train)
Tests if the certain train is prohibited from moving through the track
boolean isEmpty()
Tests if the track is empty, i.e.
void onToggleBlock()
Callback at block status toggle
void reserveFor​(Agent... trains)
Allow or disallow the specified trains to go through the track.
Modifier and Type Method Description

Method Detail

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

java.util.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

java.util.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

java.util.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
How can we improve this article?