Package jmri.jmrit.operations.router
Class Router
- java.lang.Object
-
- jmri.jmrit.operations.trains.TrainCommon
-
- jmri.jmrit.operations.router.Router
-
- All Implemented Interfaces:
InstanceManagerAutoDefault
public class Router extends TrainCommon implements InstanceManagerAutoDefault
Router for car movement. This code attempts to find a way (a route) to move a car to its final destination through the use of two or more trains. First the code tries to move car using a single train. If that fails, attempts are made using two trains via a classification/interchange (C/I) tracks, then yard tracks if enabled. Next attempts are made using three or more trains using any combination of C/I and yard tracks. If that fails and routing via staging is enabled, the code tries two trains using staging tracks, then multiple trains using a combination of C/I, yards, and staging tracks. Currently the router is limited to seven trains.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.PrintWriter
_buildReport
protected java.util.List<Track>
_lastLocationTracks
protected java.util.List<Train>
_lastLocationTrains
protected java.util.Hashtable<java.lang.String,Train>
_listTrains
protected java.util.List<Track>
_next2ndLocationTracks
protected java.util.List<Track>
_next3rdLocationTracks
protected java.util.List<Track>
_next4thLocationTracks
protected java.util.List<Track>
_nextLocationTracks
protected java.util.List<Train>
_nextLocationTrains
(package private) java.util.Date
_startTime
protected static java.lang.String
STATUS_NOT_ABLE
protected static java.lang.String
STATUS_NOT_THIS_TRAIN
static java.lang.String
STATUS_NOT_THIS_TRAIN_PREFIX
protected static java.lang.String
STATUS_ROUTER_DISABLED
(package private) TrainManager
tmanager
-
Fields inherited from class jmri.jmrit.operations.trains.TrainCommon
_dropCars, _pickupCars, BLANK_LINE, BUILD_REPORT_CHAR, ENGINE, HORIZONTAL_LINE_CHAR, HYPHEN, IS_MANIFEST, IS_TWO_COLUMN_TRACK, LOCAL, NEW_LINE, PAPER_MARGINS, PICKUP, SPACE, TAB, TEXT_COLOR_DONE, TEXT_COLOR_END, TEXT_COLOR_START, VERTICAL_LINE_CHAR
-
-
Constructor Summary
Constructors Constructor Description Router()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getStatus()
Returns the status of the router when using the setDestination() for a car.boolean
isCarRouteable(Car car, Train train, Location destination, Track track, java.io.PrintWriter buildReport)
boolean
isCarRouteable(Car car, Train train, Track track, java.io.PrintWriter buildReport)
Determines if car can be routed to the destination trackboolean
setDestination(Car car, Train train, java.io.PrintWriter buildReport)
Attempts to set the car's destination if a final destination exists.-
Methods inherited from class jmri.jmrit.operations.trains.TrainCommon
addCarsLocationUnknown, addLine, addLine, blockCarsByTrack, blockCarsByTrackNameTwoColumn, blockCarsTwoColumn, blockLocosTwoColumn, clearUtilityCarTypes, convertStringToDate, countPickupUtilityCars, countSetoutUtilityCars, countUtilityCars, createTabIfNeeded, dropCar, dropCar, dropEngine, dropEngines, formatColorString, formatStringToCommaSeparated, getDate, getDate, getDropCarHeader, getDropEngineHeader, getISO8601Date, getLineLength, getLocalMoveHeader, getManifestHeaderLineLength, getPageSize, getPickupCarHeader, getPickupEngineHeader, getTextColor, getTextColorName, getTextColorString, isNextCar, isNextCar, isThereWorkAtLocation, isThereWorkAtLocation, localMoveCar, newLine, newLine, padAndTruncate, padAndTruncateIfNeeded, padString, pickupCar, pickUpCar, pickUpCarTruncated, pickupEngine, pickupEngines, pickupUtilityCars, pickupUtilityCars, printCarHeader, printDropCarHeader, printDropEngineHeader, printEngineHeader, printHorizontalLine, printHorizontalLine, printLocalCarMoveHeader, printPickupCarHeader, printPickupEngineHeader, printTrackComments, printTrackNameHeader, setoutUtilityCars, setoutUtilityCars, setoutUtilityCars, splitString, tabString, truncatedDropCar
-
-
-
-
Field Detail
-
tmanager
TrainManager tmanager
-
_nextLocationTracks
protected final java.util.List<Track> _nextLocationTracks
-
_lastLocationTracks
protected final java.util.List<Track> _lastLocationTracks
-
_next2ndLocationTracks
protected final java.util.List<Track> _next2ndLocationTracks
-
_next3rdLocationTracks
protected final java.util.List<Track> _next3rdLocationTracks
-
_next4thLocationTracks
protected final java.util.List<Track> _next4thLocationTracks
-
_nextLocationTrains
protected final java.util.List<Train> _nextLocationTrains
-
_lastLocationTrains
protected final java.util.List<Train> _lastLocationTrains
-
_listTrains
protected java.util.Hashtable<java.lang.String,Train> _listTrains
-
STATUS_NOT_THIS_TRAIN
protected static final java.lang.String STATUS_NOT_THIS_TRAIN
-
STATUS_NOT_THIS_TRAIN_PREFIX
public static final java.lang.String STATUS_NOT_THIS_TRAIN_PREFIX
-
STATUS_NOT_ABLE
protected static final java.lang.String STATUS_NOT_ABLE
-
STATUS_ROUTER_DISABLED
protected static final java.lang.String STATUS_ROUTER_DISABLED
-
_buildReport
java.io.PrintWriter _buildReport
-
_startTime
java.util.Date _startTime
-
-
Constructor Detail
-
Router
public Router()
-
-
Method Detail
-
getStatus
public java.lang.String getStatus()
Returns the status of the router when using the setDestination() for a car.- Returns:
- Track.OKAY, STATUS_NOT_THIS_TRAIN, STATUS_NOT_ABLE, STATUS_ROUTER_DISABLED, or the destination track status is there's an issue.
-
isCarRouteable
public boolean isCarRouteable(Car car, Train train, Track track, java.io.PrintWriter buildReport)
Determines if car can be routed to the destination track- Parameters:
car
- the car being testedtrain
- the first train servicing the car, can be nulltrack
- the destination track, can not be nullbuildReport
- the report, can be null- Returns:
- true if the car can be routed to the track
-
isCarRouteable
public boolean isCarRouteable(Car car, Train train, Location destination, Track track, java.io.PrintWriter buildReport)
-
setDestination
public boolean setDestination(Car car, Train train, java.io.PrintWriter buildReport)
Attempts to set the car's destination if a final destination exists. Only sets the car's destination if the train is part of the car's route.- Parameters:
car
- the car to routetrain
- the first train to carry this car, can be nullbuildReport
- PrintWriter for build report, and can be null- Returns:
- true if car can be routed.
-
-