jmri.jmrit.operations.trains
Class Train

Show UML class diagram
java.lang.Object
  extended by jmri.jmrit.operations.trains.Train
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class Train
extends Object
implements PropertyChangeListener

Represents a train on the layout


Field Summary
protected  List<String> _afterBuildScripts
           
protected  boolean _allowCarsReturnStaging
           
protected  boolean _allowLocalMoves
           
protected  boolean _allowThroughCars
           
protected  boolean _build
           
protected  boolean _buildFailed
           
protected  String _buildFailedMessage
           
protected  boolean _buildNormal
           
protected  List<String> _buildScripts
           
protected  boolean _built
           
protected  String _builtEndYear
           
protected  String _builtStartYear
           
protected  String _cabooseRoad
           
protected  String _comment
           
protected  RouteLocation _current
           
protected  Calendar _departureTime
           
protected  Track _departureTrack
           
protected  String _description
           
protected  RouteLocation _end2Leg
           
protected  String _engineModel
           
protected  String _engineRoad
           
protected  String _id
           
protected  Engine _leadEngine
           
protected  String _leadEngineId
           
protected  String _leg2CabooseRoad
           
protected  String _leg2Engines
           
protected  String _leg2Model
           
protected  int _leg2Options
           
protected  String _leg2Road
           
protected  RouteLocation _leg2Start
           
protected  String _leg3CabooseRoad
           
protected  RouteLocation _leg3End
           
protected  String _leg3Engines
           
protected  String _leg3Model
           
protected  int _leg3Options
           
protected  String _leg3Road
           
protected  RouteLocation _leg3Start
           
(package private)  List<String> _loadList
           
protected  String _loadOption
           
protected  String _logoURL
           
protected  boolean _modified
           
protected  List<String> _moveScripts
           
protected  String _name
           
protected  String _numberEngines
           
(package private)  List<String> _ownerList
           
protected  String _ownerOption
           
protected  boolean _printed
           
protected  String _railroadName
           
protected  int _requires
           
(package private)  List<String> _roadList
           
protected  String _roadOption
           
protected  Route _route
           
protected  boolean _sendToTerminal
           
protected  boolean _showTimes
           
(package private)  List<String> _skipLocationsList
           
protected  String _status
           
protected  String _switchListStatus
           
(package private)  TrainIconAnimation _ta
           
protected  List<String> _terminationScripts
           
protected  Track _terminationTrack
           
protected  TrainIcon _trainIcon
           
protected  RouteLocation _trainIconRl
           
(package private)  List<String> _typeList
           
static int ADD_CABOOSE
           
static String ALLLOADS
           
static String ALLOWNERS
           
static String ALLROADS
           
static String AUTO
           
static String BUILD_CHANGED_PROPERTY
           
static String BUILDFAILED
           
static String BUILDING
           
static String BUILT
           
static String BUILT_CHANGED_PROPERTY
           
static String BUILT_YEAR_CHANGED_PROPERTY
           
static int CABOOSE
           
static int CHANGE_ENGINES
           
static String DEPARTURETIME_CHANGED_PROPERTY
           
static String DESCRIPTION_CHANGED_PROPERTY
           
static String DISPOSE_CHANGED_PROPERTY
           
static String EXCLUDELOADS
           
static String EXCLUDEOWNERS
           
static String EXCLUDEROADS
           
static int FRED
           
static int HELPER_ENGINES
           
static String INCLUDELOADS
           
static String INCLUDEOWNERS
           
static String INCLUDEROADS
           
static String LOADS_CHANGED_PROPERTY
           
(package private) static org.slf4j.Logger log
           
static String NAME_CHANGED_PROPERTY
           
static int NONE
           
static String OWNERS_CHANGED_PROPERTY
           
static String PARTIALBUILT
           
(package private)  PropertyChangeSupport pcs
           
static String PRINTED
           
static int REMOVE_CABOOSE
           
static String ROADS_CHANGED_PROPERTY
           
protected static String SEVEN
           
static String STATUS_CHANGED_PROPERTY
           
static String STOPS_CHANGED_PROPERTY
           
static String TERMINATED
           
static String TRAIN_LOCATION_CHANGED_PROPERTY
           
static String TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY
           
static String TRAIN_REQUIREMENTS_CHANGED_PROPERTY
           
static String TRAIN_ROUTE_CHANGED_PROPERTY
           
static String TRAININROUTE
           
static String TRAINRESET
           
static String TYPES_CHANGED_PROPERTY
           
static String UNKNOWN
           
 
Constructor Summary
Train(org.jdom.Element e)
          Construct this Entry from XML.
Train(String id, String name)
           
 
Method Summary
 boolean acceptsBuiltDate(String date)
          Determine if train will service rolling stock by built date.
 boolean acceptsLoad(String load, String type)
          Determine if train will service a specific load and car type.
 boolean acceptsLoadName(String load)
          Determine if train will service a specific load name.
 boolean acceptsOwnerName(String owner)
          Determine if train will service a specific owner name.
 boolean acceptsRoadName(String road)
          Determine if train will service a specific road name.
 boolean acceptsTypeName(String type)
          Returns true if this train will service the type of car or engine.
 void addAfterBuildScript(String pathname)
          Add a script to run after a train is built
 void addBuildScript(String pathname)
          Add a script to run before a train is built
 boolean addLoadName(String load)
          Add a load that the train will either service or exclude.
 void addMoveScript(String pathname)
          Add a script to run when train is moved
 boolean addOwnerName(String owner)
          Add a owner name that the train will either service or exclude.
 void addPropertyChangeListener(PropertyChangeListener l)
           
 boolean addRoadName(String road)
          Add a road name that the train will either service or exclude.
 void addTerminationScript(String pathname)
          Add a script to run when train is terminated
 void addTrainSkipsLocation(String locationId)
          Train will skip the RouteLocation
 void addTypeName(String type)
          Add a car or engine type name that this train will service.
 void build()
          Build this train.
 boolean buildIfSelected()
          Build this train if the build control flag is true.
 File createCSVManifestFile()
           
 void createTrainIcon()
           
 void deleteAfterBuildScript(String pathname)
           
 void deleteBuildScript(String pathname)
           
 boolean deleteLoadName(String load)
          Delete a load name that the train will either service or exclude.
 void deleteMoveScript(String pathname)
           
 boolean deleteOwnerName(String owner)
          Delete a owner name that the train will either service or exclude.
 boolean deleteRoadName(String road)
          Delete a road name that the train will either service or exclude.
 void deleteTerminationScript(String pathname)
           
 void deleteTrainSkipsLocation(String locationId)
           
 void deleteTypeName(String type)
           
 void dispose()
           
 List<String> getAfterBuildScripts()
          Gets a list of pathnames (scripts) to run after this train is built
 boolean getBuild()
          Deprecated. 
 boolean getBuildFailed()
          Returns true if the train build failed.
protected  String getBuildFailedMessage()
           
 List<String> getBuildScripts()
          Gets a list of pathnames (scripts) to run before this train is built
 boolean getBuilt()
          Deprecated. 
 String getBuiltEndYear()
           
 String getBuiltStartYear()
           
 String getCabooseRoad()
           
 String getCabooseRoadAndNumber()
          Gets the current caboose road and number if there's one assigned to the train.
protected  String[] getCarTypeNames()
           
 String getComment()
           
 RouteLocation getCurrentLocation()
          Get train's current location
 String getCurrentLocationName()
          Get train's current location name
 int getDepartTimeMinutes()
          Get train's departure time in minutes from midnight for sorting
 String getDepartureTime()
          Get's train's departure time
 String getDepartureTimeHour()
           
 String getDepartureTimeMinute()
           
 Track getDepartureTrack()
           
 String getDescription()
           
 String getEngineModel()
           
 String getEngineRoad()
          Get the road name of engines servicing this train.
 String getExpectedArrivalTime(RouteLocation routeLocation)
          Gets the expected time when this train will arrive at the location rl.
 String getExpectedDepartureTime(RouteLocation routeLocation)
           
protected  int getExpectedTravelTimeInMinutes(RouteLocation routeLocation)
           
 String getFormatedDepartureTime()
          Get's train's departure time in 12hr or 24hr format
 String getIconName()
           
 String getId()
           
 Engine getLeadEngine()
          Gets the lead engine, will create it if the program has been restarted
 String[] getLoadNames()
          Provides a list of loads that the train will either service or exclude.
 String getLoadOption()
          Gets the car load option for this train.
protected  String[] getLocoTypeNames()
           
 String getManifestLogoURL()
           
 List<String> getMoveScripts()
          Gets a list of pathnames (scripts) to run when this train moved
 String getName()
          Get's a train's name
 RouteLocation getNextLocation(RouteLocation rlc)
           
 String getNextLocationName()
          Get the train's next location name
 String getNextLocationName(int number)
          Get a location name in a train's route from the current train's location.
 int getNumberCarsInTrain()
          Gets the number of cars in the train at the current location in the train's route.
 int getNumberCarsInTrain(RouteLocation routeLocation)
          Gets the number of cars in the train when train departs the route location.
 int getNumberCarsWorked()
           
 int getNumberEmptyCarsInTrain(RouteLocation routeLocation)
          Gets the number of empty cars in the train when train departs the route location.
 String getNumberEngines()
          Get the number of engines that this train requires.
 String[] getOwnerNames()
          Provides a list of owner names that the train will either service or exclude.
 String getOwnerOption()
           
 boolean getPrinted()
          Deprecated. 
 String getRailroadName()
          Gets the optional railroad name for this train.
 int getRequirements()
          Get a train's requirements with regards to the last car in the train.
 String[] getRoadNames()
          Provides a list of road names that the train will either service or exclude.
 String getRoadOption()
          Get how this train deals with road names.
 Route getRoute()
          Gets the train's route
 String getSecondLegCabooseRoad()
           
 RouteLocation getSecondLegEndLocation()
           
 String getSecondLegEndLocationName()
           
 String getSecondLegEngineModel()
           
 String getSecondLegEngineRoad()
          Get the road name of engines servicing this train 2nd leg.
 String getSecondLegNumberEngines()
          Get the number of engines needed for the second set.
 int getSecondLegOptions()
           
 RouteLocation getSecondLegStartLocation()
           
 String getSecondLegStartLocationName()
           
 String getStatus()
          Get train's status
 String getSwitchListStatus()
           
 List<String> getTerminationScripts()
          Gets a list of pathnames (scripts) to run when this train terminates
 Track getTerminationTrack()
           
 String getThirdLegCabooseRoad()
           
 RouteLocation getThirdLegEndLocation()
           
 String getThirdLegEndLocationName()
           
 String getThirdLegEngineModel()
           
 String getThirdLegEngineRoad()
          Get the road name of engines servicing this train 3rd leg.
 String getThirdLegNumberEngines()
          Get the number of engines needed for the third set.
 int getThirdLegOptions()
           
 RouteLocation getThirdLegStartLocation()
           
 String getThirdLegStartLocationName()
           
 String getTrainDepartsName()
          Get the train's departure location's name
protected  RouteLocation getTrainDepartsRouteLocation()
           
 TrainIcon getTrainIcon()
           
 int getTrainLength()
          Gets the train's length at the current location in the train's route.
 int getTrainLength(RouteLocation routeLocation)
          Gets the train's length at the route location specified
 String getTrainRouteName()
          Get's the train's route name.
protected  String[] getTrainSkipsLocations()
           
 String getTrainTerminatesName()
          Get train's final location's name
protected  RouteLocation getTrainTerminatesRouteLocation()
           
 int getTrainWeight()
          Get the train's weight at the current location.
 int getTrainWeight(RouteLocation routeLocation)
           
protected  String[] getTypeNames()
          Get's the type names of rolling stock this train will service
 boolean isAllowLocalMovesEnabled()
           
 boolean isAllowReturnToStagingEnabled()
          When true allow a turn to return cars to staging.
 boolean isAllowThroughCarsEnabled()
           
 boolean isBuildEnabled()
          Used to determine if train is to be built.
 boolean isBuildTrainNormalEnabled()
           
 boolean isBuilt()
          Used to determine if this train has been built.
 boolean isLocalSwitcher()
          Used to determine if train is a local switcher serving one location.
 boolean isModified()
           
 boolean isPrinted()
          Used to determine if train manifest was printed.
 boolean isSendCarsToTerminalEnabled()
           
 boolean isShowArrivalAndDepartureTimesEnabled()
           
 boolean isTrainInRoute()
          Used to determine if train has departed its
 void loadTrainIcon()
           
 void move()
          Move train to next location in route.
 boolean move(String locationName)
          Move train to a location in the train's route.
 boolean moveToNextLocation(String locationName)
          Move train to the next location in the train's route.
protected  void moveTrainIcon(RouteLocation rl)
           
 boolean openFile()
           
 void printBuildReport()
           
 boolean printBuildReport(boolean isPreview)
           
 boolean printManifest(boolean isPreview)
          Print manifest for train.
 boolean printManifestIfBuilt()
          Print manifest for train if already built.
 void propertyChange(PropertyChangeEvent e)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
 void replaceOwner(String oldName, String newName)
           
 void replaceType(String oldType, String newType)
           
 boolean reset()
          Resets the train, removes engines and cars from this train.
 boolean runFile()
           
 boolean services(Car car)
          Determines if this train will service this car.
protected  boolean services(Car car, PrintWriter buildReport)
           
 void setAllowLocalMovesEnabled(boolean enable)
           
 void setAllowReturnToStagingEnabled(boolean enable)
           
 void setAllowThroughCarsEnabled(boolean enable)
           
 void setBuild(boolean build)
          Deprecated. 
 void setBuildEnabled(boolean build)
          Control flag used to decide if this train is to be built.
protected  void setBuildFailed(boolean status)
           
protected  void setBuildFailedMessage(String message)
           
 void setBuildTrainNormalEnabled(boolean enable)
           
protected  void setBuilt(boolean built)
           
 void setBuiltEndYear(String year)
          Only rolling stock built in or before this year will be used.
 void setBuiltStartYear(String year)
          Only rolling stock built in or after this year will be used.
 void setCabooseRoad(String road)
          Set the road name of the caboose servicing this train.
 void setComment(String comment)
           
protected  void setCurrentLocation(RouteLocation location)
          Set train's current route location
 void setDepartureTime(String hour, String minute)
           
 void setDepartureTrack(Track track)
           
 void setDescription(String description)
           
protected  void setDirtyAndFirePropertyChange(String p, Object old, Object n)
           
 void setEngineModel(String model)
          Set the model name of engines servicing this train.
 void setEngineRoad(String road)
          Set the road name of engines servicing this train.
 void setLeadEngine(Engine engine)
           
protected  void setLoadNames(String[] loads)
           
 void setLoadOption(String option)
          Set how this train deals with car loads
 void setManifestLogoURL(String pathName)
          Overrides the default logo for this train.
 void setModified(boolean modified)
           
 void setName(String name)
          Sets the name of this train, normally a short name that can fit within the train icon.
 void setNumberEngines(String number)
           
protected  void setOwnerNames(String[] owners)
           
 void setOwnerOption(String option)
          Set how this train deals with car owner names
 void setRailroadName(String name)
          Overrides the default railroad name for this train.
 void setRequirements(int requires)
          Set train requirements.
protected  void setRoadNames(String[] roads)
           
 void setRoadOption(String option)
          Set how this train deals with car road names.
 void setRoute(Route route)
           
 void setSecondLegCabooseRoad(String road)
          Set the road name of the second leg caboose servicing this train.
 void setSecondLegEndLocation(RouteLocation rl)
           
 void setSecondLegEngineModel(String model)
          Set the model name of engines servicing this train's 2nd leg.
 void setSecondLegEngineRoad(String road)
          Set the road name of engines servicing this train 2nd leg.
 void setSecondLegNumberEngines(String number)
           
 void setSecondLegOptions(int options)
          Optional changes to train while in route.
 void setSecondLegStartLocation(RouteLocation rl)
           
 void setSendCarsToTerminalEnabled(boolean enable)
           
 void setShowArrivalAndDepartureTimes(boolean enable)
           
 void setStatus(String status)
          Set's the train's status
 void setSwitchListStatus(String status)
          Sets the print status for switch lists
 void setTerminationTrack(Track track)
           
 void setThirdLegCabooseRoad(String road)
          Set the road name of the third leg caboose servicing this train.
 void setThirdLegEndLocation(RouteLocation rl)
           
 void setThirdLegEngineModel(String model)
          Set the model name of engines servicing this train's 3rd leg.
 void setThirdLegEngineRoad(String road)
          Set the road name of engines servicing this train 3rd leg.
 void setThirdLegNumberEngines(String number)
           
 void setThirdLegOptions(int options)
          Optional changes to train while in route.
 void setThirdLegStartLocation(RouteLocation rl)
           
 boolean setTrainIconCoordinates()
          Sets the panel position for the train icon for the current route location.
protected  void setTrainSkipsLocations(String[] locationIds)
           
protected  void setTypeNames(String[] types)
          Set the type of cars or engines this train will service, see types in Cars and Engines.
 boolean skipsLocation(String locationId)
          Determines if this train skips a location (doesn't service the location).
 org.jdom.Element store()
          Create an XML element to represent this Entry.
 void terminate()
          Terminate train.
 String toString()
          Get's a train's name
 
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

_description

protected String _description

_current

protected RouteLocation _current

_status

protected String _status

_buildFailedMessage

protected String _buildFailedMessage

_built

protected boolean _built

_modified

protected boolean _modified

_build

protected boolean _build

_buildFailed

protected boolean _buildFailed

_printed

protected boolean _printed

_sendToTerminal

protected boolean _sendToTerminal

_allowLocalMoves

protected boolean _allowLocalMoves

_allowThroughCars

protected boolean _allowThroughCars

_buildNormal

protected boolean _buildNormal

_allowCarsReturnStaging

protected boolean _allowCarsReturnStaging

_route

protected Route _route

_departureTrack

protected Track _departureTrack

_terminationTrack

protected Track _terminationTrack

_roadOption

protected String _roadOption

_requires

protected int _requires

_numberEngines

protected String _numberEngines

_engineRoad

protected String _engineRoad

_engineModel

protected String _engineModel

_cabooseRoad

protected String _cabooseRoad

_departureTime

protected Calendar _departureTime

_leadEngineId

protected String _leadEngineId

_builtStartYear

protected String _builtStartYear

_builtEndYear

protected String _builtEndYear

_loadOption

protected String _loadOption

_ownerOption

protected String _ownerOption

_buildScripts

protected List<String> _buildScripts

_afterBuildScripts

protected List<String> _afterBuildScripts

_moveScripts

protected List<String> _moveScripts

_terminationScripts

protected List<String> _terminationScripts

_railroadName

protected String _railroadName

_logoURL

protected String _logoURL

_showTimes

protected boolean _showTimes

_leadEngine

protected Engine _leadEngine

_switchListStatus

protected String _switchListStatus

_comment

protected String _comment

_leg2Options

protected int _leg2Options

_leg2Start

protected RouteLocation _leg2Start

_end2Leg

protected RouteLocation _end2Leg

_leg2Engines

protected String _leg2Engines

_leg2Road

protected String _leg2Road

_leg2Model

protected String _leg2Model

_leg2CabooseRoad

protected String _leg2CabooseRoad

_leg3Options

protected int _leg3Options

_leg3Start

protected RouteLocation _leg3Start

_leg3End

protected RouteLocation _leg3End

_leg3Engines

protected String _leg3Engines

_leg3Road

protected String _leg3Road

_leg3Model

protected String _leg3Model

_leg3CabooseRoad

protected String _leg3CabooseRoad

CHANGE_ENGINES

public static final int CHANGE_ENGINES
See Also:
Constant Field Values

HELPER_ENGINES

public static final int HELPER_ENGINES
See Also:
Constant Field Values

ADD_CABOOSE

public static final int ADD_CABOOSE
See Also:
Constant Field Values

REMOVE_CABOOSE

public static final int REMOVE_CABOOSE
See Also:
Constant Field Values

DISPOSE_CHANGED_PROPERTY

public static final String DISPOSE_CHANGED_PROPERTY
See Also:
Constant Field Values

STOPS_CHANGED_PROPERTY

public static final String STOPS_CHANGED_PROPERTY
See Also:
Constant Field Values

TYPES_CHANGED_PROPERTY

public static final String TYPES_CHANGED_PROPERTY
See Also:
Constant Field Values

BUILT_CHANGED_PROPERTY

public static final String BUILT_CHANGED_PROPERTY
See Also:
Constant Field Values

BUILT_YEAR_CHANGED_PROPERTY

public static final String BUILT_YEAR_CHANGED_PROPERTY
See Also:
Constant Field Values

BUILD_CHANGED_PROPERTY

public static final String BUILD_CHANGED_PROPERTY
See Also:
Constant Field Values

ROADS_CHANGED_PROPERTY

public static final String ROADS_CHANGED_PROPERTY
See Also:
Constant Field Values

LOADS_CHANGED_PROPERTY

public static final String LOADS_CHANGED_PROPERTY
See Also:
Constant Field Values

OWNERS_CHANGED_PROPERTY

public static final String OWNERS_CHANGED_PROPERTY
See Also:
Constant Field Values

NAME_CHANGED_PROPERTY

public static final String NAME_CHANGED_PROPERTY
See Also:
Constant Field Values

DESCRIPTION_CHANGED_PROPERTY

public static final String DESCRIPTION_CHANGED_PROPERTY
See Also:
Constant Field Values

STATUS_CHANGED_PROPERTY

public static final String STATUS_CHANGED_PROPERTY
See Also:
Constant Field Values

DEPARTURETIME_CHANGED_PROPERTY

public static final String DEPARTURETIME_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAIN_LOCATION_CHANGED_PROPERTY

public static final String TRAIN_LOCATION_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAIN_ROUTE_CHANGED_PROPERTY

public static final String TRAIN_ROUTE_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAIN_REQUIREMENTS_CHANGED_PROPERTY

public static final String TRAIN_REQUIREMENTS_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY

public static final String TRAIN_MOVE_COMPLETE_CHANGED_PROPERTY
See Also:
Constant Field Values

BUILDFAILED

public static final String BUILDFAILED

BUILDING

public static final String BUILDING

BUILT

public static final String BUILT

PARTIALBUILT

public static final String PARTIALBUILT

TERMINATED

public static final String TERMINATED

TRAINRESET

public static final String TRAINRESET

TRAININROUTE

public static final String TRAININROUTE

NONE

public static final int NONE
See Also:
Constant Field Values

CABOOSE

public static final int CABOOSE
See Also:
Constant Field Values

FRED

public static final int FRED
See Also:
Constant Field Values

ALLROADS

public static final String ALLROADS

INCLUDEROADS

public static final String INCLUDEROADS

EXCLUDEROADS

public static final String EXCLUDEROADS

ALLOWNERS

public static final String ALLOWNERS

INCLUDEOWNERS

public static final String INCLUDEOWNERS

EXCLUDEOWNERS

public static final String EXCLUDEOWNERS

ALLLOADS

public static final String ALLLOADS

INCLUDELOADS

public static final String INCLUDELOADS

EXCLUDELOADS

public static final String EXCLUDELOADS

UNKNOWN

public static final String UNKNOWN
See Also:
Constant Field Values

PRINTED

public static final String PRINTED

AUTO

public static final String AUTO

_skipLocationsList

List<String> _skipLocationsList

_typeList

List<String> _typeList

_roadList

List<String> _roadList

_loadList

List<String> _loadList

_ownerList

List<String> _ownerList

SEVEN

protected static final String SEVEN
See Also:
Constant Field Values

_trainIconRl

protected RouteLocation _trainIconRl

_ta

TrainIconAnimation _ta

_trainIcon

protected TrainIcon _trainIcon

pcs

PropertyChangeSupport pcs

log

static org.slf4j.Logger log
Constructor Detail

Train

public Train(String id,
             String name)

Train

public Train(org.jdom.Element e)
Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-trains.dtd

Parameters:
e - Consist XML element
Method Detail

getId

public String getId()

setName

public void setName(String name)
Sets the name of this train, normally a short name that can fit within the train icon.

Parameters:
name - the train's name.

toString

public String toString()
Get's a train's name

Overrides:
toString in class Object
Returns:
train's name

getName

public String getName()
Get's a train's name

Returns:
train's name

getDepartureTime

public String getDepartureTime()
Get's train's departure time

Returns:
train's departure time in the String format hh:mm

getFormatedDepartureTime

public String getFormatedDepartureTime()
Get's train's departure time in 12hr or 24hr format

Returns:
train's departure time in the String format hh:mm or hh:mm(AM/PM)

getDepartTimeMinutes

public int getDepartTimeMinutes()
Get train's departure time in minutes from midnight for sorting

Returns:
int hh*60+mm

setDepartureTime

public void setDepartureTime(String hour,
                             String minute)

getDepartureTimeHour

public String getDepartureTimeHour()

getDepartureTimeMinute

public String getDepartureTimeMinute()

getExpectedArrivalTime

public String getExpectedArrivalTime(RouteLocation routeLocation)
Gets the expected time when this train will arrive at the location rl. Expected arrival time is based on the number of car pick up and set outs for this train. TODO Doesn't provide expected arrival time if train is in route, instead provides relative time. If train has passed the location return -1.

Returns:
expected arrival time

getExpectedDepartureTime

public String getExpectedDepartureTime(RouteLocation routeLocation)

getExpectedTravelTimeInMinutes

protected int getExpectedTravelTimeInMinutes(RouteLocation routeLocation)

setRequirements

public void setRequirements(int requires)
Set train requirements. If NONE, then train doesn't require a caboose or car with FRED.

Parameters:
requires - NONE CABOOSE FRED

getRequirements

public int getRequirements()
Get a train's requirements with regards to the last car in the train.

Returns:
NONE CABOOSE FRED

setRoute

public void setRoute(Route route)

getRoute

public Route getRoute()
Gets the train's route

Returns:
train's route

getTrainRouteName

public String getTrainRouteName()
Get's the train's route name.

Returns:
Train's route name.

getTrainDepartsName

public String getTrainDepartsName()
Get the train's departure location's name

Returns:
train's departure location's name

getTrainDepartsRouteLocation

protected RouteLocation getTrainDepartsRouteLocation()

getTrainTerminatesName

public String getTrainTerminatesName()
Get train's final location's name

Returns:
train's final location's name

getTrainTerminatesRouteLocation

protected RouteLocation getTrainTerminatesRouteLocation()

setCurrentLocation

protected void setCurrentLocation(RouteLocation location)
Set train's current route location


getCurrentLocationName

public String getCurrentLocationName()
Get train's current location name

Returns:
Train's current route location name

getCurrentLocation

public RouteLocation getCurrentLocation()
Get train's current location

Returns:
Train's current route location

getNextLocationName

public String getNextLocationName()
Get the train's next location name

Returns:
Train's next route location name

getNextLocationName

public String getNextLocationName(int number)
Get a location name in a train's route from the current train's location. A number of "1" means get the next location name in a train's route.

Parameters:
number - The stop number, must be greater than 0
Returns:
Name of the location that is the number of stops away from the train's current location.

getNextLocation

public RouteLocation getNextLocation(RouteLocation rlc)

setDepartureTrack

public void setDepartureTrack(Track track)

getDepartureTrack

public Track getDepartureTrack()

setTerminationTrack

public void setTerminationTrack(Track track)

getTerminationTrack

public Track getTerminationTrack()

setStatus

public void setStatus(String status)
Set's the train's status

Parameters:
status - BUILDING PARTIALBUILT BUILT TERMINATED TRAINRESET TRAININROUTE

getStatus

public String getStatus()
Get train's status

Returns:
Train's status BUILDING PARTIALBUILT BUILT TERMINATED TRAINRESET TRAININROUTE

isTrainInRoute

public boolean isTrainInRoute()
Used to determine if train has departed its

Returns:
true if train is in route

isLocalSwitcher

public boolean isLocalSwitcher()
Used to determine if train is a local switcher serving one location. Note the the train can have more than location in its route, but all location names must be same.

Returns:
true if local switcher

getTrainSkipsLocations

protected String[] getTrainSkipsLocations()

setTrainSkipsLocations

protected void setTrainSkipsLocations(String[] locationIds)

addTrainSkipsLocation

public void addTrainSkipsLocation(String locationId)
Train will skip the RouteLocation

Parameters:
locationId - RouteLocation Id

deleteTrainSkipsLocation

public void deleteTrainSkipsLocation(String locationId)

skipsLocation

public boolean skipsLocation(String locationId)
Determines if this train skips a location (doesn't service the location).

Parameters:
locationId - The route location id.
Returns:
true if the train will not service the location.

getTypeNames

protected String[] getTypeNames()
Get's the type names of rolling stock this train will service

Returns:
The type names for cars and or engines

getCarTypeNames

protected String[] getCarTypeNames()

getLocoTypeNames

protected String[] getLocoTypeNames()

setTypeNames

protected void setTypeNames(String[] types)
Set the type of cars or engines this train will service, see types in Cars and Engines.

Parameters:
types - The type names for cars and or engines

addTypeName

public void addTypeName(String type)
Add a car or engine type name that this train will service.

Parameters:
type - The new type name to service.

deleteTypeName

public void deleteTypeName(String type)

acceptsTypeName

public boolean acceptsTypeName(String type)
Returns true if this train will service the type of car or engine.

Parameters:
type - The car or engine type name.
Returns:
true if this train will service the particular type.

replaceType

public void replaceType(String oldType,
                        String newType)

getRoadOption

public String getRoadOption()
Get how this train deals with road names.

Returns:
ALLROADS INCLUDEROADS EXCLUDEROADS

setRoadOption

public void setRoadOption(String option)
Set how this train deals with car road names.

Parameters:
option - ALLROADS INCLUDEROADS EXCLUDEROADS

setRoadNames

protected void setRoadNames(String[] roads)

getRoadNames

public String[] getRoadNames()
Provides a list of road names that the train will either service or exclude. See setRoadOption

Returns:
Array of road names as Strings

addRoadName

public boolean addRoadName(String road)
Add a road name that the train will either service or exclude. See setRoadOption

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

deleteRoadName

public boolean deleteRoadName(String road)
Delete a road name that the train will either service or exclude. See setRoadOption

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

acceptsRoadName

public boolean acceptsRoadName(String road)
Determine if train will service a specific road name.

Parameters:
road - the road name to check.
Returns:
true if train will service this road name.

getLoadOption

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

Returns:
ALLLOADS INCLUDELOADS EXCLUDELOADS

setLoadOption

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

Parameters:
option - ALLLOADS INCLUDELOADS EXCLUDELOADS

setLoadNames

protected void setLoadNames(String[] loads)

getLoadNames

public String[] getLoadNames()
Provides a list of loads that the train 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 train 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 train 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 train will service a specific load name.

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

acceptsLoad

public boolean acceptsLoad(String load,
                           String type)
Determine if train will service a specific load and car type.

Parameters:
load - the load name to check.
type - the type of car used to carry the load.
Returns:
true if train will service this load.

getOwnerOption

public String getOwnerOption()

setOwnerOption

public void setOwnerOption(String option)
Set how this train deals with car owner names

Parameters:
option - ALLOWNERS INCLUDEOWNERS EXCLUDEOWNERS

setOwnerNames

protected void setOwnerNames(String[] owners)

getOwnerNames

public String[] getOwnerNames()
Provides a list of owner names that the train will either service or exclude. See setOwnerOption

Returns:
Array of owner names as Strings

addOwnerName

public boolean addOwnerName(String owner)
Add a owner name that the train will either service or exclude. See setOwnerOption

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

deleteOwnerName

public boolean deleteOwnerName(String owner)
Delete a owner name that the train will either service or exclude. See setOwnerOption

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

acceptsOwnerName

public boolean acceptsOwnerName(String owner)
Determine if train will service a specific owner name.

Parameters:
owner - the owner name to check.
Returns:
true if train will service this owner name.

replaceOwner

public void replaceOwner(String oldName,
                         String newName)

setBuiltStartYear

public void setBuiltStartYear(String year)
Only rolling stock built in or after this year will be used.

Parameters:
year -

getBuiltStartYear

public String getBuiltStartYear()

setBuiltEndYear

public void setBuiltEndYear(String year)
Only rolling stock built in or before this year will be used.

Parameters:
year -

getBuiltEndYear

public String getBuiltEndYear()

acceptsBuiltDate

public boolean acceptsBuiltDate(String date)
Determine if train will service rolling stock by built date.

Parameters:
date -
Returns:
true is built date is in the acceptable range.

services

public boolean services(Car car)
Determines if this train will service this car. Note this code doesn't check the location or tracks that needs to be done separately. See Router.java.

Parameters:
car - The car to be tested.
Returns:
true if this train can service the car.

services

protected boolean services(Car car,
                           PrintWriter buildReport)

getNumberCarsWorked

public int getNumberCarsWorked()
Returns:
The number of cars worked by this train

getNumberCarsInTrain

public int getNumberCarsInTrain()
Gets the number of cars in the train at the current location in the train's route.

Returns:
The number of cars currently in the train

getNumberCarsInTrain

public int getNumberCarsInTrain(RouteLocation routeLocation)
Gets the number of cars in the train when train departs the route location.

Returns:
The number of cars in the train departing the route location.

getNumberEmptyCarsInTrain

public int getNumberEmptyCarsInTrain(RouteLocation routeLocation)
Gets the number of empty cars in the train when train departs the route location.

Returns:
The number of empty cars in the train departing the route location.

getTrainLength

public int getTrainLength()
Gets the train's length at the current location in the train's route.

Returns:
The train length at this location

getTrainLength

public int getTrainLength(RouteLocation routeLocation)
Gets the train's length at the route location specified

Parameters:
routeLocation - The route location
Returns:
The train length at the route location

getTrainWeight

public int getTrainWeight()
Get the train's weight at the current location.

Returns:
Train's weight in tons.

getTrainWeight

public int getTrainWeight(RouteLocation routeLocation)

getCabooseRoadAndNumber

public String getCabooseRoadAndNumber()
Gets the current caboose road and number if there's one assigned to the train.

Returns:
Road and number of caboose.

setDescription

public void setDescription(String description)

getDescription

public String getDescription()

setNumberEngines

public void setNumberEngines(String number)

getNumberEngines

public String getNumberEngines()
Get the number of engines that this train requires.

Returns:
The number of engines that this train requires.

getSecondLegNumberEngines

public String getSecondLegNumberEngines()
Get the number of engines needed for the second set.

Returns:
The number of engines needed in route

setSecondLegNumberEngines

public void setSecondLegNumberEngines(String number)

getThirdLegNumberEngines

public String getThirdLegNumberEngines()
Get the number of engines needed for the third set.

Returns:
The number of engines needed in route

setThirdLegNumberEngines

public void setThirdLegNumberEngines(String number)

setEngineRoad

public void setEngineRoad(String road)
Set the road name of engines servicing this train.

Parameters:
road - The road name of engines servicing this train.

getEngineRoad

public String getEngineRoad()
Get the road name of engines servicing this train.

Returns:
The road name of engines servicing this train.

setSecondLegEngineRoad

public void setSecondLegEngineRoad(String road)
Set the road name of engines servicing this train 2nd leg.

Parameters:
road - The road name of engines servicing this train.

getSecondLegEngineRoad

public String getSecondLegEngineRoad()
Get the road name of engines servicing this train 2nd leg.

Returns:
The road name of engines servicing this train.

setThirdLegEngineRoad

public void setThirdLegEngineRoad(String road)
Set the road name of engines servicing this train 3rd leg.

Parameters:
road - The road name of engines servicing this train.

getThirdLegEngineRoad

public String getThirdLegEngineRoad()
Get the road name of engines servicing this train 3rd leg.

Returns:
The road name of engines servicing this train.

setEngineModel

public void setEngineModel(String model)
Set the model name of engines servicing this train.

Parameters:
model - The model name of engines servicing this train.

getEngineModel

public String getEngineModel()

setSecondLegEngineModel

public void setSecondLegEngineModel(String model)
Set the model name of engines servicing this train's 2nd leg.

Parameters:
model - The model name of engines servicing this train.

getSecondLegEngineModel

public String getSecondLegEngineModel()

setThirdLegEngineModel

public void setThirdLegEngineModel(String model)
Set the model name of engines servicing this train's 3rd leg.

Parameters:
model - The model name of engines servicing this train.

getThirdLegEngineModel

public String getThirdLegEngineModel()

setCabooseRoad

public void setCabooseRoad(String road)
Set the road name of the caboose servicing this train.

Parameters:
road - The road name of the caboose servicing this train.

getCabooseRoad

public String getCabooseRoad()

setSecondLegCabooseRoad

public void setSecondLegCabooseRoad(String road)
Set the road name of the second leg caboose servicing this train.

Parameters:
road - The road name of the caboose servicing this train's 2nd leg.

getSecondLegCabooseRoad

public String getSecondLegCabooseRoad()

setThirdLegCabooseRoad

public void setThirdLegCabooseRoad(String road)
Set the road name of the third leg caboose servicing this train.

Parameters:
road - The road name of the caboose servicing this train's 3rd leg.

getThirdLegCabooseRoad

public String getThirdLegCabooseRoad()

setSecondLegStartLocation

public void setSecondLegStartLocation(RouteLocation rl)

getSecondLegStartLocation

public RouteLocation getSecondLegStartLocation()

getSecondLegStartLocationName

public String getSecondLegStartLocationName()

setThirdLegStartLocation

public void setThirdLegStartLocation(RouteLocation rl)

getThirdLegStartLocation

public RouteLocation getThirdLegStartLocation()

getThirdLegStartLocationName

public String getThirdLegStartLocationName()

setSecondLegEndLocation

public void setSecondLegEndLocation(RouteLocation rl)

getSecondLegEndLocationName

public String getSecondLegEndLocationName()

getSecondLegEndLocation

public RouteLocation getSecondLegEndLocation()

setThirdLegEndLocation

public void setThirdLegEndLocation(RouteLocation rl)

getThirdLegEndLocation

public RouteLocation getThirdLegEndLocation()

getThirdLegEndLocationName

public String getThirdLegEndLocationName()

setSecondLegOptions

public void setSecondLegOptions(int options)
Optional changes to train while in route.

Parameters:
options - NONE, CHANGE_ENGINES, ADD_CABOOSE, HELPER_ENGINES, REMOVE_CABOOSE

getSecondLegOptions

public int getSecondLegOptions()

setThirdLegOptions

public void setThirdLegOptions(int options)
Optional changes to train while in route.

Parameters:
options - NONE, CHANGE_ENGINES, ADD_CABOOSE, HELPER_ENGINES, REMOVE_CABOOSE

getThirdLegOptions

public int getThirdLegOptions()

setComment

public void setComment(String comment)

getComment

public String getComment()

addBuildScript

public void addBuildScript(String pathname)
Add a script to run before a train is built

Parameters:
pathname - The script's pathname

deleteBuildScript

public void deleteBuildScript(String pathname)

getBuildScripts

public List<String> getBuildScripts()
Gets a list of pathnames (scripts) to run before this train is built

Returns:
A list of pathnames to run before this train is built

addAfterBuildScript

public void addAfterBuildScript(String pathname)
Add a script to run after a train is built

Parameters:
pathname - The script's pathname

deleteAfterBuildScript

public void deleteAfterBuildScript(String pathname)

getAfterBuildScripts

public List<String> getAfterBuildScripts()
Gets a list of pathnames (scripts) to run after this train is built

Returns:
A list of pathnames to run after this train is built

addMoveScript

public void addMoveScript(String pathname)
Add a script to run when train is moved

Parameters:
pathname - The script's pathname

deleteMoveScript

public void deleteMoveScript(String pathname)

getMoveScripts

public List<String> getMoveScripts()
Gets a list of pathnames (scripts) to run when this train moved

Returns:
A list of pathnames to run when this train moved

addTerminationScript

public void addTerminationScript(String pathname)
Add a script to run when train is terminated

Parameters:
pathname - The script's pathname

deleteTerminationScript

public void deleteTerminationScript(String pathname)

getTerminationScripts

public List<String> getTerminationScripts()
Gets a list of pathnames (scripts) to run when this train terminates

Returns:
A list of pathnames to run when this train terminates

getRailroadName

public String getRailroadName()
Gets the optional railroad name for this train.

Returns:
Train's railroad name.

setRailroadName

public void setRailroadName(String name)
Overrides the default railroad name for this train.

Parameters:
name - The railroad name for this train.

getManifestLogoURL

public String getManifestLogoURL()

setManifestLogoURL

public void setManifestLogoURL(String pathName)
Overrides the default logo for this train.

Parameters:
pathName - file location for the logo.

isShowArrivalAndDepartureTimesEnabled

public boolean isShowArrivalAndDepartureTimesEnabled()

setShowArrivalAndDepartureTimes

public void setShowArrivalAndDepartureTimes(boolean enable)

isSendCarsToTerminalEnabled

public boolean isSendCarsToTerminalEnabled()

setSendCarsToTerminalEnabled

public void setSendCarsToTerminalEnabled(boolean enable)

isAllowLocalMovesEnabled

public boolean isAllowLocalMovesEnabled()

setAllowLocalMovesEnabled

public void setAllowLocalMovesEnabled(boolean enable)

isAllowThroughCarsEnabled

public boolean isAllowThroughCarsEnabled()

setAllowThroughCarsEnabled

public void setAllowThroughCarsEnabled(boolean enable)

isBuildTrainNormalEnabled

public boolean isBuildTrainNormalEnabled()

setBuildTrainNormalEnabled

public void setBuildTrainNormalEnabled(boolean enable)

isAllowReturnToStagingEnabled

public boolean isAllowReturnToStagingEnabled()
When true allow a turn to return cars to staging. A turn is a train that departs and terminates at the same location.

Returns:
true if cars can return to staging

setAllowReturnToStagingEnabled

public void setAllowReturnToStagingEnabled(boolean enable)

setBuilt

protected void setBuilt(boolean built)

isBuilt

public boolean isBuilt()
Used to determine if this train has been built.

Returns:
true if the train was successfully built.

setModified

public void setModified(boolean modified)

isModified

public boolean isModified()

getBuilt

@Deprecated
public boolean getBuilt()
Deprecated. 

Deprecated, kept for user scripts. Use isBuilt()

Returns:
true if the train was successfully built.

setBuildEnabled

public void setBuildEnabled(boolean build)
Control flag used to decide if this train is to be built.

Parameters:
build - When true, build this train.

isBuildEnabled

public boolean isBuildEnabled()
Used to determine if train is to be built.

Returns:
true if train is to be built.

setBuild

@Deprecated
public void setBuild(boolean build)
Deprecated. 

Deprecated, use setBuildEnabled(build).

Parameters:
build - When true, build this train.

getBuild

@Deprecated
public boolean getBuild()
Deprecated. 

Deprecated, use isBuildEnabled()

Returns:
true if train is to be built.

buildIfSelected

public boolean buildIfSelected()
Build this train if the build control flag is true.

Returns:
True only if train is successfully built.

build

public void build()
Build this train. Creates a train manifest.


printBuildReport

public void printBuildReport()

printBuildReport

public boolean printBuildReport(boolean isPreview)

setBuildFailed

protected void setBuildFailed(boolean status)

getBuildFailed

public boolean getBuildFailed()
Returns true if the train build failed. Note that returning false doesn't mean the build was successful.

Returns:
true if train build failed.

setBuildFailedMessage

protected void setBuildFailedMessage(String message)

getBuildFailedMessage

protected String getBuildFailedMessage()

printManifestIfBuilt

public boolean printManifestIfBuilt()
Print manifest for train if already built.

Returns:
true if print successful.

printManifest

public boolean printManifest(boolean isPreview)
Print manifest for train.

Returns:
true if print successful.

openFile

public boolean openFile()

runFile

public boolean runFile()

createCSVManifestFile

public File createCSVManifestFile()

isPrinted

public boolean isPrinted()
Used to determine if train manifest was printed.

Returns:
true if the train manifest was printed.

getPrinted

@Deprecated
public boolean getPrinted()
Deprecated. 

Deprecated, kept for user scripts. Use isPrinted()

Returns:
true if the train manifest was printed.

setTrainIconCoordinates

public boolean setTrainIconCoordinates()
Sets the panel position for the train icon for the current route location.

Returns:
true if train coordinates can be set

terminate

public void terminate()
Terminate train.


move

public void move()
Move train to next location in route. Will move engines, cars, and train icon. Will also terminate a train after it arrives at its final destination.


move

public boolean move(String locationName)
Move train to a location in the train's route. Code checks to see if the location requested is part of the train's route and if the train hasn't already visited the location. This command can only move the train forward in its route. Note that you can not terminate the train using this command. See move() or terminate().

Parameters:
locationName - The name of the location to move this train.
Returns:
true if train was able to move to the named location.

moveToNextLocation

public boolean moveToNextLocation(String locationName)
Move train to the next location in the train's route. The location name provided must be equal to the next location name in the train's route.

Parameters:
locationName - The next location name in the train's route.
Returns:
true if successful.

loadTrainIcon

public void loadTrainIcon()

moveTrainIcon

protected void moveTrainIcon(RouteLocation rl)

getIconName

public String getIconName()

getLeadEngine

public Engine getLeadEngine()
Gets the lead engine, will create it if the program has been restarted

Returns:
lead engine for this train

setLeadEngine

public void setLeadEngine(Engine engine)

getTrainIcon

public TrainIcon getTrainIcon()

createTrainIcon

public void createTrainIcon()

setSwitchListStatus

public void setSwitchListStatus(String status)
Sets the print status for switch lists

Parameters:
status - UNKNOWN PRINTED

getSwitchListStatus

public String getSwitchListStatus()

reset

public boolean reset()
Resets the train, removes engines and cars from this train.

Returns:
true if reset successful

dispose

public void dispose()

store

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

Returns:
Contents in a JDOM Element

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

setDirtyAndFirePropertyChange

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


Copyright © 1997-2013 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