jmri.jmrit.operations.locations
Class Track

java.lang.Object
  extended by jmri.jmrit.operations.locations.Track

public class Track
extends Object

Represents a location (track) on the layout Can be a spur, yard, staging, or interchange track.

Author:
Daniel Boudreau

Field Summary
protected  String _alternativeTrackId
           
protected  String _comment
           
protected  String _dropOption
           
protected  int _dropRS
           
protected  String _id
           
protected  int _length
           
protected  String _loadOption
           
protected  int _loadOptions
           
protected  Location _location
           
protected  String _locType
           
protected  int _minimumLength
           
protected  int _mode
           
protected  int _moves
           
protected  String _name
           
protected  int _numberCars
           
protected  int _numberCarsInRoute
           
protected  int _numberEngines
           
protected  int _numberRS
           
protected  String _order
           
protected  String _pickupOption
           
protected  int _pickupRS
           
protected  Pool _pool
           
protected  int _reservationFactor
           
protected  int _reserved
           
protected  int _reservedInRoute
           
protected  String _roadOption
           
protected  int _scheduleCount
           
protected  String _scheduleId
           
protected  String _scheduleItemId
           
protected  String _scheduleName
           
protected  int _trainDir
           
protected  int _usedLength
           
static String ALLLOADS
           
static String ALLROADS
           
static String ANY
           
static String DISPOSE_CHANGED_PROPERTY
           
static String DROP_CHANGED_PROPERTY
           
static int EAST
           
static String EXCLUDELOADS
           
static String EXCLUDEROADS
           
static String FIFO
           
static String INCLUDELOADS
           
static String INCLUDEROADS
           
static String INTERCHANGE
           
static String LENGTH
           
static String LENGTH_CHANGED_PROPERTY
           
static String LIFO
           
static String LOAD
           
static String LOADS_CHANGED_PROPERTY
           
static int MATCH
           
static String MIN_LENGTH_CHANGED_PROPERTY
           
static String NAME_CHANGED_PROPERTY
           
static String NORMAL
           
static int NORTH
           
static String OKAY
           
static String PICKUP_CHANGED_PROPERTY
           
static String POOL_CHANGED_PROPERTY
           
static String ROAD
           
static String ROADS_CHANGED_PROPERTY
           
static String ROUTES
           
static String SCHEDULE_CHANGED_PROPERTY
           
static int SEQUENTIAL
           
static String SIDING
           
static int SOUTH
           
static String STAGING
           
static String TRACK_TYPE_CHANGED_PROPERTY
           
static String TRAINDIRECTION_CHANGED_PROPERTY
           
static String TRAINS
           
static String TYPE
           
static String TYPES_CHANGED_PROPERTY
           
static int WEST
           
static String YARD
           
 
Constructor Summary
Track(Element e, Location location)
           
Track(String id, String name, String type, Location location)
           
 
Method Summary
 String accepts(RollingStock rs)
           
 boolean acceptsDropRoute(Route route)
           
 boolean acceptsDropTrain(Train train)
          Determine if train can set out cars to this track.
 boolean acceptsLoadName(String load)
          Determine if track will service a specific load name.
 boolean acceptsPickupRoute(Route route)
           
 boolean acceptsPickupTrain(Train train)
          Determine if train can pick up cars from this track.
 boolean acceptsRoadName(String road)
           
 boolean acceptsTypeName(String type)
           
 void addDropId(String id)
           
 void addDropRS(RollingStock rs)
           
 boolean addLoadName(String load)
          Add a load that the track will either service or exclude.
 void addPickupId(String id)
          Add train or route id to this track.
 void addPickupRS(RollingStock rs)
          Increments the number of cars and or engines that will be picked up by a train from this track.
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void addReservedInRoute(Car car)
           
 void addRoadName(String road)
           
 void addRS(RollingStock rs)
          Adds rolling stock to a specific track.
 void addTypeName(String type)
           
 void bumpSchedule()
           
 String checkScheduleValid()
          Check to see if schedule is valid for the track at this location.
 boolean containsDropId(String id)
           
 boolean containsPickupId(String id)
           
 boolean containsRoadName(String road)
           
 void deleteDropId(String id)
           
 void deleteDropRS(RollingStock rs)
           
 boolean deleteLoadName(String load)
          Delete a load name that the track will either service or exclude.
 void deletePickupId(String id)
           
 void deletePickupRS(RollingStock rs)
           
 void deleteReservedInRoute(Car car)
           
 void deleteRoadName(String road)
           
 void deleteRS(RollingStock rs)
           
 void deleteTypeName(String type)
           
 void dispose()
           
 void enableAddLoads(boolean enable)
          When enabled, add Scheduled car loads if there's a demand.
 void enableAddLoadsAnySiding(boolean enable)
          When enabled, add Scheduled car loads if there's a demand.
 void enableLoadSwaps(boolean enable)
          Enable changing the car generic load state when car arrives at this track.
 void enableRemoveLoads(boolean enable)
          When enabled, remove Scheduled car loads.
 void enableSetLoadEmpty(boolean enable)
          Enable setting the car generic load state to empty when car arrives at this track.
protected  void firePropertyChange(String p, Object old, Object n)
           
 Track getAlternativeTrack()
           
 String getComment()
           
 ScheduleItem getCurrentScheduleItem()
          Get's the current schedule item for this track Protects against user deleting an item in a shared schedule.
 String[] getDropIds()
           
 String getDropOption()
           
 int getDropRS()
           
 String getId()
           
 int getLength()
           
 String[] getLoadNames()
          Provides a list of loads that the track will either service or exclude.
 String getLoadOption()
          Gets the car load option for this track.
 Location getLocation()
           
 String getLocType()
           
 int getMinimumLength()
           
 int getMoves()
           
 String getName()
           
 ScheduleItem getNextScheduleItem()
           
 int getNumberCars()
           
 int getNumberEngines()
           
 int getNumberOfCarsInRoute()
           
 int getNumberRS()
           
 String[] getPickupIds()
           
 String getPickupOption()
           
 int getPickupRS()
           
 Pool getPool()
           
 String getPoolName()
           
 int getReservationFactor()
           
 int getReserved()
           
 int getReservedInRoute()
          Used to determine how much track space is going to be consumed by cars in route to this track.
 String[] getRoadNames()
           
 String getRoadOption()
           
 Schedule getSchedule()
           
 int getScheduleCount()
           
 String getScheduleId()
           
 String getScheduleItemId()
          Recommend getCurrentScheduleItem() to get the current schedule item for this track.
 int getScheduleMode()
          Gets the mode of operation for the schedule assigned to this track.
 String getScheduleName()
          Returns the name of the schedule.
 String getServiceOrder()
          Get the service order for this track.
 int getTrainDirections()
           
 String[] getTypeNames()
           
 int getUsedLength()
           
 boolean isAddLoadsEnabled()
           
 boolean isAddLoadsEnabledAnySiding()
           
 boolean isLoadSwapEnabled()
           
 boolean isRemoveLoadsEnabled()
           
 boolean isSetLoadEmptyEnabled()
           
 boolean isSpaceAvailable(Car car)
          Used to determine if there's space available at this track for the car.
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void setAlternativeTrack(Track track)
           
 void setComment(String comment)
           
 void setDropOption(String option)
          Set the car drop option for this track.
 void setLength(int length)
           
 void setLoadOption(String option)
          Set how this track deals with car loads
 void setLocType(String type)
           
 void setMinimumLength(int length)
           
 void setMoves(int moves)
           
 void setName(String name)
           
 void setPickupOption(String option)
          Set the car pick up option for this track.
 void setPool(Pool pool)
           
 void setReservationFactor(int factor)
          Set the reservation factor.
 void setReserved(int reserved)
           
 void setRoadOption(String option)
          Set the road option for this track.
 void setScheduleCount(int count)
           
 void setScheduleId(String id)
           
 void setScheduleItemId(String id)
           
 void setScheduleMode(int mode)
          Sets the mode of operation for the schedule assigned to this track.
 void setServiceOrder(String order)
           
 void setTrainDirections(int direction)
          Sets the train directions that can service this track
 void setUsedLength(int length)
           
 Element store()
          Create an XML element to represent this Entry.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_id

protected String _id

_name

protected String _name

_locType

protected String _locType

_location

protected Location _location

_alternativeTrackId

protected String _alternativeTrackId

_roadOption

protected String _roadOption

_trainDir

protected int _trainDir

_numberRS

protected int _numberRS

_numberCars

protected int _numberCars

_numberEngines

protected int _numberEngines

_pickupRS

protected int _pickupRS

_dropRS

protected int _dropRS

_length

protected int _length

_reserved

protected int _reserved

_numberCarsInRoute

protected int _numberCarsInRoute

_usedLength

protected int _usedLength

_moves

protected int _moves

_comment

protected String _comment

_loadOption

protected String _loadOption

_scheduleName

protected String _scheduleName

_scheduleId

protected String _scheduleId

_scheduleItemId

protected String _scheduleItemId

_scheduleCount

protected int _scheduleCount

_reservedInRoute

protected int _reservedInRoute

_reservationFactor

protected int _reservationFactor

_mode

protected int _mode

_dropOption

protected String _dropOption

_pickupOption

protected String _pickupOption

ANY

public static final String ANY
See Also:
Constant Field Values

TRAINS

public static final String TRAINS
See Also:
Constant Field Values

ROUTES

public static final String ROUTES
See Also:
Constant Field Values

_loadOptions

protected int _loadOptions

_order

protected String _order

NORMAL

public static final String NORMAL

FIFO

public static final String FIFO

LIFO

public static final String LIFO

STAGING

public static final String STAGING
See Also:
Constant Field Values

INTERCHANGE

public static final String INTERCHANGE
See Also:
Constant Field Values

YARD

public static final String YARD
See Also:
Constant Field Values

SIDING

public static final String SIDING
See Also:
Constant Field Values

EAST

public static final int EAST
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

ALLROADS

public static final String ALLROADS

INCLUDEROADS

public static final String INCLUDEROADS

EXCLUDEROADS

public static final String EXCLUDEROADS

ALLLOADS

public static final String ALLLOADS

INCLUDELOADS

public static final String INCLUDELOADS

EXCLUDELOADS

public static final String EXCLUDELOADS

SEQUENTIAL

public static final int SEQUENTIAL
See Also:
Constant Field Values

MATCH

public static final int MATCH
See Also:
Constant Field Values

_pool

protected Pool _pool

_minimumLength

protected int _minimumLength

OKAY

public static final String OKAY

LENGTH

public static final String LENGTH

TYPE

public static final String TYPE

ROAD

public static final String ROAD

LOAD

public static final String LOAD

TYPES_CHANGED_PROPERTY

public static final String TYPES_CHANGED_PROPERTY
See Also:
Constant Field Values

ROADS_CHANGED_PROPERTY

public static final String ROADS_CHANGED_PROPERTY
See Also:
Constant Field Values

NAME_CHANGED_PROPERTY

public static final String NAME_CHANGED_PROPERTY
See Also:
Constant Field Values

LENGTH_CHANGED_PROPERTY

public static final String LENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

MIN_LENGTH_CHANGED_PROPERTY

public static final String MIN_LENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

SCHEDULE_CHANGED_PROPERTY

public static final String SCHEDULE_CHANGED_PROPERTY
See Also:
Constant Field Values

DISPOSE_CHANGED_PROPERTY

public static final String DISPOSE_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAINDIRECTION_CHANGED_PROPERTY

public static final String TRAINDIRECTION_CHANGED_PROPERTY
See Also:
Constant Field Values

DROP_CHANGED_PROPERTY

public static final String DROP_CHANGED_PROPERTY
See Also:
Constant Field Values

PICKUP_CHANGED_PROPERTY

public static final String PICKUP_CHANGED_PROPERTY
See Also:
Constant Field Values

TRACK_TYPE_CHANGED_PROPERTY

public static final String TRACK_TYPE_CHANGED_PROPERTY
See Also:
Constant Field Values

LOADS_CHANGED_PROPERTY

public static final String LOADS_CHANGED_PROPERTY
See Also:
Constant Field Values

POOL_CHANGED_PROPERTY

public static final String POOL_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

Track

public Track(String id,
             String name,
             String type,
             Location location)

Track

public Track(Element e,
             Location location)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getId

public String getId()

getLocation

public Location getLocation()

setName

public void setName(String name)

getName

public String getName()

getLocType

public String getLocType()

setLocType

public void setLocType(String type)

setLength

public void setLength(int length)

getLength

public int getLength()

setMinimumLength

public void setMinimumLength(int length)

getMinimumLength

public int getMinimumLength()

setReserved

public void setReserved(int reserved)

getReserved

public int getReserved()

addReservedInRoute

public void addReservedInRoute(Car car)

deleteReservedInRoute

public void deleteReservedInRoute(Car car)

getReservedInRoute

public int getReservedInRoute()
Used to determine how much track space is going to be consumed by cars in route to this track. See isSpaceAvailable().

Returns:
The length of all cars in route to this track including couplers.

getNumberOfCarsInRoute

public int getNumberOfCarsInRoute()

setReservationFactor

public void setReservationFactor(int factor)
Set the reservation factor. Default 100 (100%). Used by the program when generating car loads from staging. A factor of 100% allows the program to fill a track with car loads. Numbers over 100% can overload a track.

Parameters:
factor - A number from 0 to 10000.

getReservationFactor

public int getReservationFactor()

setScheduleMode

public void setScheduleMode(int mode)
Sets the mode of operation for the schedule assigned to this track.

Parameters:
mode - Track.SEQUENTIAL or Track.MATCH

getScheduleMode

public int getScheduleMode()
Gets the mode of operation for the schedule assigned to this track.

Returns:
Mode of operation: Track.SEQUENTIAL or Track.MATCH

setAlternativeTrack

public void setAlternativeTrack(Track track)

getAlternativeTrack

public Track getAlternativeTrack()

isSpaceAvailable

public boolean isSpaceAvailable(Car car)
Used to determine if there's space available at this track for the car. Considers cars currently placed on the track and cars in route to this track. Ignores car pick ups. Used to prevent overloading the track.

Parameters:
car - The car to be set out.
Returns:
true if space available.

setUsedLength

public void setUsedLength(int length)

getUsedLength

public int getUsedLength()

getNumberRS

public int getNumberRS()
Returns:
The number of rolling stock (cars and engines) on this track

getNumberCars

public int getNumberCars()
Returns:
The number of cars on this track

getNumberEngines

public int getNumberEngines()
Returns:
The number of engines on this track

addRS

public void addRS(RollingStock rs)
Adds rolling stock to a specific track.

Parameters:
rs -

deleteRS

public void deleteRS(RollingStock rs)

addPickupRS

public void addPickupRS(RollingStock rs)
Increments the number of cars and or engines that will be picked up by a train from this track.


deletePickupRS

public void deletePickupRS(RollingStock rs)

getPickupRS

public int getPickupRS()
Returns:
the number of rolling stock (cars and or locos) that are scheduled for pick up from this track.

getDropRS

public int getDropRS()

addDropRS

public void addDropRS(RollingStock rs)

deleteDropRS

public void deleteDropRS(RollingStock rs)

setComment

public void setComment(String comment)

getComment

public String getComment()

getTypeNames

public String[] getTypeNames()

addTypeName

public void addTypeName(String type)

deleteTypeName

public void deleteTypeName(String type)

acceptsTypeName

public boolean acceptsTypeName(String type)

getRoadOption

public String getRoadOption()

setRoadOption

public void setRoadOption(String option)
Set the road option for this track.

Parameters:
option - ALLROADS, INCLUDEROADS, or EXCLUDEROADS

setTrainDirections

public void setTrainDirections(int direction)
Sets the train directions that can service this track

Parameters:
direction - EAST, WEST, NORTH, SOUTH

getTrainDirections

public int getTrainDirections()

getRoadNames

public String[] getRoadNames()

addRoadName

public void addRoadName(String road)

deleteRoadName

public void deleteRoadName(String road)

acceptsRoadName

public boolean acceptsRoadName(String road)

containsRoadName

public boolean containsRoadName(String road)

getLoadOption

public String getLoadOption()
Gets the car load option for this track.

Returns:
ALLLOADS INCLUDELOADS EXCLUDELOADS

setLoadOption

public void setLoadOption(String option)
Set how this track deals with car loads

Parameters:
option - ALLLOADS INCLUDELOADS EXCLUDELOADS

getLoadNames

public String[] getLoadNames()
Provides a list of loads that the track will either service or exclude. See setLoadOption

Returns:
Array of load names as Strings

addLoadName

public boolean addLoadName(String load)
Add a load that the track will either service or exclude. See setLoadOption

Returns:
true if load name was added, false if load name wasn't in the list.

deleteLoadName

public boolean deleteLoadName(String load)
Delete a load name that the track will either service or exclude. See setLoadOption

Returns:
true if load name was removed, false if load name wasn't in the list.

acceptsLoadName

public boolean acceptsLoadName(String load)
Determine if track will service a specific load name.

Parameters:
load - the load name to check.
Returns:
true if track will service this load.

getDropOption

public String getDropOption()

setDropOption

public void setDropOption(String option)
Set the car drop option for this track.

Parameters:
option - ANY, TRAINS, or ROUTES

getPickupOption

public String getPickupOption()

setPickupOption

public void setPickupOption(String option)
Set the car pick up option for this track.

Parameters:
option - ANY, TRAINS, or ROUTES

getDropIds

public String[] getDropIds()

addDropId

public void addDropId(String id)

deleteDropId

public void deleteDropId(String id)

acceptsDropTrain

public boolean acceptsDropTrain(Train train)
Determine if train can set out cars to this track. Based on the train's id or train's route id. See setDropOption(option).

Parameters:
train -
Returns:
true if the train can set out cars to this track.

acceptsDropRoute

public boolean acceptsDropRoute(Route route)

containsDropId

public boolean containsDropId(String id)

getPickupIds

public String[] getPickupIds()

addPickupId

public void addPickupId(String id)
Add train or route id to this track.

Parameters:
id -

deletePickupId

public void deletePickupId(String id)

acceptsPickupTrain

public boolean acceptsPickupTrain(Train train)
Determine if train can pick up cars from this track. Based on the train's id or train's route id. See setPickupOption(option).

Parameters:
train -
Returns:
true if the train can pick up cars from this track.

acceptsPickupRoute

public boolean acceptsPickupRoute(Route route)

containsPickupId

public boolean containsPickupId(String id)

accepts

public String accepts(RollingStock rs)

getMoves

public int getMoves()

setMoves

public void setMoves(int moves)

getServiceOrder

public String getServiceOrder()
Get the service order for this track. Only yards and interchange have this feature.

Returns:
Service order: Track.NORMAL, Track.FIFO, Track.LIFO

setServiceOrder

public void setServiceOrder(String order)

getScheduleName

public String getScheduleName()
Returns the name of the schedule. Note that this returns the schedule name based on the schedule's id. A schedule's name can be modified by the user.

Returns:
Schedule name

getSchedule

public Schedule getSchedule()

getScheduleId

public String getScheduleId()

setScheduleId

public void setScheduleId(String id)

getScheduleItemId

public String getScheduleItemId()
Recommend getCurrentScheduleItem() to get the current schedule item for this track. Protects against user deleting a schedule item from the schedule.

Returns:
schedule item id

setScheduleItemId

public void setScheduleItemId(String id)

getCurrentScheduleItem

public ScheduleItem getCurrentScheduleItem()
Get's the current schedule item for this track Protects against user deleting an item in a shared schedule. Recommend using this versus getScheduleItemId() as the id can be obsolete.


bumpSchedule

public void bumpSchedule()

getNextScheduleItem

public ScheduleItem getNextScheduleItem()

getScheduleCount

public int getScheduleCount()

setScheduleCount

public void setScheduleCount(int count)

checkScheduleValid

public String checkScheduleValid()
Check to see if schedule is valid for the track at this location.

Returns:
"" if schedule okay, otherwise an error message.

enableLoadSwaps

public void enableLoadSwaps(boolean enable)
Enable changing the car generic load state when car arrives at this track.

Parameters:
enable - when true, swap generic car load state

isLoadSwapEnabled

public boolean isLoadSwapEnabled()

enableSetLoadEmpty

public void enableSetLoadEmpty(boolean enable)
Enable setting the car generic load state to empty when car arrives at this track.

Parameters:
enable - when true, set generic car load to empty

isSetLoadEmptyEnabled

public boolean isSetLoadEmptyEnabled()

enableRemoveLoads

public void enableRemoveLoads(boolean enable)
When enabled, remove Scheduled car loads.

Parameters:
enable - when true, remove Scheduled loads from cars

isRemoveLoadsEnabled

public boolean isRemoveLoadsEnabled()

enableAddLoads

public void enableAddLoads(boolean enable)
When enabled, add Scheduled car loads if there's a demand.

Parameters:
enable - when true, add Scheduled loads from cars

isAddLoadsEnabled

public boolean isAddLoadsEnabled()

enableAddLoadsAnySiding

public void enableAddLoadsAnySiding(boolean enable)
When enabled, add Scheduled car loads if there's a demand.

Parameters:
enable - when true, add Scheduled loads from cars

isAddLoadsEnabledAnySiding

public boolean isAddLoadsEnabledAnySiding()

setPool

public void setPool(Pool pool)

getPool

public Pool getPool()

getPoolName

public String getPoolName()

dispose

public void dispose()

store

public Element store()
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-location.dtd.

Returns:
Contents in a JDOM Element

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads