Package jmri.jmrit.operations.trains
Class TrainBuilderBase
- java.lang.Object
-
- jmri.jmrit.operations.trains.TrainCommon
-
- jmri.jmrit.operations.trains.TrainBuilderBase
-
- Direct Known Subclasses:
TrainBuilderEngines
public class TrainBuilderBase extends TrainCommon
Methods to support the TrainBuilder class.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.PrintWriter
_buildReport
(package private) int
_carIndex
(package private) java.util.List<Car>
_carList
(package private) int
_completedMoves
(package private) Location
_departLocation
(package private) Track
_departStageTrack
(package private) java.util.List<Engine>
_engineList
(package private) Engine
_lastEngine
(package private) java.util.List<Location>
_modifiedLocations
(package private) java.util.List<Car>
_notRoutable
(package private) int
_numberCars
(package private) java.util.Hashtable<java.lang.String,java.lang.Integer>
_numOfBlocks
(package private) int
_reqNumOfMoves
(package private) java.util.List<RouteLocation>
_routeList
(package private) Engine
_secondLeadEngine
(package private) java.util.Date
_startTime
(package private) Location
_terminateLocation
(package private) Track
_terminateStageTrack
(package private) Engine
_thirdLeadEngine
(package private) Train
_train
(package private) int
_warnings
(package private) CarLoads
carLoads
protected static int
DISPLAY_CAR_LIMIT_100
protected static int
DISPLAY_CAR_LIMIT_20
protected static int
DISPLAY_CAR_LIMIT_50
protected static java.lang.String
FIVE
protected static java.lang.String
ONE
(package private) Router
router
(package private) boolean
routeToTrackFound
protected static java.lang.String
SEVEN
protected static java.lang.String
THREE
(package private) TrainManager
trainManager
(package private) TrainScheduleManager
trainScheduleManager
protected static boolean
USE_BUNIT
-
Fields inherited from class jmri.jmrit.operations.trains.TrainCommon
_dropCars, _pickupCars, _printLocalMoveHeader, _printPickupHeader, _printSetoutHeader, BLANK_LINE, BUILD_REPORT_CHAR, carManager, doneCars, ENGINE, engineManager, HORIZONTAL_LINE_CHAR, HYPHEN, index, IS_MANIFEST, IS_TWO_COLUMN_TRACK, LOCAL, locationManager, NEW_LINE, PAPER_MARGINS, PICKUP, SPACE, TAB, TEXT_COLOR_DONE, TEXT_COLOR_END, TEXT_COLOR_START, utilityCarTypes, VERTICAL_LINE_CHAR
-
-
Constructor Summary
Constructors Constructor Description TrainBuilderBase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCarToTrain(Car car, RouteLocation rl, RouteLocation rld, Track track)
Add car to train, and adjust train length and weightprotected void
addEnginesBasedHPT(int hpAvailable, int extraHpNeeded, RouteLocation rlNeedHp, RouteLocation rl, RouteLocation rld)
Adds engines to the train if needed based on HPT.protected void
adjustCarsInStaging()
Adjust car list to only have cars from one staging trackprotected boolean
checkBasicMoves(Car car, Track track)
protected boolean
checkDepartureStagingTrack(Track departStageTrack)
Check departure staging track to see if engines and cars are available to a new train.protected boolean
checkDropTrainDirection(RollingStock rs, RouteLocation rld, Track track)
protected boolean
checkDropTrainDirection(RouteLocation rld)
protected RouteLocation
checkForEarlierDrop(Car car, Track trackTemp, RouteLocation rld, int start, int routeEnd)
Used to determine if car could be set out at earlier location in the train's route.protected boolean
checkForLaterPickUp(Car car, RouteLocation rl, RouteLocation rld)
Returns true if car can be picked up later in a train's routeprotected boolean
checkPickUpTrainDirection(RollingStock rs, RouteLocation rl)
Determine if rolling stock can be picked up based on train direction at the route location.protected boolean
checkPickUpTrainDirection(RouteLocation rl)
Used to report a problem picking up the rolling stock due to train direction.protected void
checkStuckCarsInStaging()
Checks to see if all cars on a staging track have been given a destination.protected boolean
checkTerminateStagingTrack(Track terminateStageTrack)
Checks to see if staging track can accept train.protected boolean
checkThroughCarsAllowed(Car car, java.lang.String destinationName)
Returns true is cars are allowed to travel from origin to terminalprotected boolean
checkTrainCanDrop(RollingStock rs, Track track)
Determinate if rolling stock can be dropped by this train to the track specified.protected boolean
checkTrainLength(Car car, RouteLocation rl, RouteLocation rld)
Checks to see if train length would be exceeded if this car was added to the train.protected int
countRollingStockAt(RouteLocation rl, java.util.List<RollingStock> list)
protected void
createBuildReportFile()
protected void
finishAddRsToTrain(RollingStock rs, RouteLocation rl, RouteLocation rld, int length, int weightTons)
protected boolean
generateLoadCarDepartingAndTerminatingIntoStaging(Car car, Track stageTrack)
Creates a car load for a car departing staging and eventually terminating into staging.protected void
getCarList()
Creates the carList.protected boolean
getConsist(java.lang.String reqNumEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld)
protected boolean
getEngines(java.lang.String requestedEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld)
protected boolean
getEngines(java.lang.String requestedEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld, boolean useBunit)
Get the engines for this train at a route location.protected java.lang.String
getLargestBlock()
protected RouteLocation
getLocationWithMaximumMoves(java.util.List<RouteLocation> blockRouteList, java.lang.String blockId)
Returns the routeLocation with the most available moves.protected void
getNewEngine(int hpNeeded, Engine leadEngine, java.lang.String model, java.lang.String road)
Removes engine from train and attempts to replace it with engine or consist that meets the HP requirements of the train.protected int
getNumberEngines(java.lang.String requestEngines)
Used to determine the number of engines requested by the user.protected ScheduleItem
getScheduleItem(Car car, Track track)
Used when generating a car load from staging.protected java.util.List<Track>
getTracksAtDestination(Car car, RouteLocation rld)
Returns a list containing two tracks.protected boolean
isCarStuckStaging()
Used to determine if a car on a staging track doesn't have a destination or trainprotected void
makeAdjustmentsIfDepartingStaging()
Temporally remove cars from staging track if train returning to the same staging track to free up track space.protected Track
promptFromStagingDialog()
Ask which staging track the train is to depart on.protected Track
promptToStagingDialog()
Ask which staging track the train is to terminate on.protected boolean
redirectCarsFromAlternateTrack()
Checks to see if cars that are already in the train can be redirected from the alternate track to the spur that really wants the car.protected void
removeCaboosesAndCarsWithFred()
Removes the remaining cabooses and cars with FRED from consideration.protected void
removeCarsFromStaging()
build has failed due to cars in staging not having destinations this routine removes those cars from the staging track by user request.protected void
removeEngineFromTrain(Engine engine)
protected void
removeRollingStockFromTrain(RollingStock rs)
Remove rolling stock from trainprotected void
restoreCarsIfDepartingStaging()
Restores cars departing staging track assignment.protected void
saveCarFinalDestinations()
Save the car's final destination and schedule, id in case of train resetprotected void
setDepartureTrack(Track departStageTrack)
Will also set the termination track if returning to stagingprotected boolean
setEngineDestination(Engine engine, RouteLocation rl, RouteLocation rld)
Sets the destination track for an engine and assigns it to the train.protected void
setUpRoute()
protected void
showAndInitializeTrainRoute()
Show and initialize the train's route.protected void
showBuildReportInfo()
Creates the build report header information lines.protected void
showCarsByLocation()
List available cars by location.protected void
showCarServiceOrder(Car car)
protected void
showCarsNotMoved(RouteLocation rl)
report any cars left at route locationprotected void
showCarsNotRoutable()
Lists cars that couldn't be routed.protected void
showEnginesByLocation()
protected void
showIfLocalSwitcher()
reports if local switcherprotected void
showLoadGenerationOptionsStaging()
protected void
showSpecificTrainBuildOptions()
protected void
showTrainBuildOptions()
show train build options when in detailed modeprotected void
showTrainCabooseRoads()
protected void
showTrainCarRoads()
protected void
showTrainCarTypes()
protected void
showTrainLoadNames()
protected void
showTrainRequirements()
Show how many engines are required for this train, and if a certain road name for the engine is requested.protected void
showTrainServices()
Adds to the build report what the train will service.protected void
sortCarsOnFifoLifoTracks()
protected Track
tryStaging(Car car, RouteLocation rldSave)
-
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
-
ONE
protected static final java.lang.String ONE
- See Also:
- Constant Field Values
-
THREE
protected static final java.lang.String THREE
- See Also:
- Constant Field Values
-
FIVE
protected static final java.lang.String FIVE
- See Also:
- Constant Field Values
-
SEVEN
protected static final java.lang.String SEVEN
- See Also:
- Constant Field Values
-
DISPLAY_CAR_LIMIT_20
protected static final int DISPLAY_CAR_LIMIT_20
- See Also:
- Constant Field Values
-
DISPLAY_CAR_LIMIT_50
protected static final int DISPLAY_CAR_LIMIT_50
- See Also:
- Constant Field Values
-
DISPLAY_CAR_LIMIT_100
protected static final int DISPLAY_CAR_LIMIT_100
- See Also:
- Constant Field Values
-
USE_BUNIT
protected static final boolean USE_BUNIT
- See Also:
- Constant Field Values
-
_startTime
java.util.Date _startTime
-
_numberCars
int _numberCars
-
_engineList
java.util.List<Engine> _engineList
-
_lastEngine
Engine _lastEngine
-
_secondLeadEngine
Engine _secondLeadEngine
-
_thirdLeadEngine
Engine _thirdLeadEngine
-
_carIndex
int _carIndex
-
_routeList
java.util.List<RouteLocation> _routeList
-
_numOfBlocks
java.util.Hashtable<java.lang.String,java.lang.Integer> _numOfBlocks
-
_completedMoves
int _completedMoves
-
_reqNumOfMoves
int _reqNumOfMoves
-
_departLocation
Location _departLocation
-
_departStageTrack
Track _departStageTrack
-
_terminateLocation
Location _terminateLocation
-
_terminateStageTrack
Track _terminateStageTrack
-
_buildReport
java.io.PrintWriter _buildReport
-
_notRoutable
java.util.List<Car> _notRoutable
-
_modifiedLocations
java.util.List<Location> _modifiedLocations
-
_warnings
int _warnings
-
trainManager
TrainManager trainManager
-
trainScheduleManager
TrainScheduleManager trainScheduleManager
-
routeToTrackFound
boolean routeToTrackFound
-
-
Constructor Detail
-
TrainBuilderBase
public TrainBuilderBase()
-
-
Method Detail
-
createBuildReportFile
protected void createBuildReportFile() throws BuildFailedException
- Throws:
BuildFailedException
-
showBuildReportInfo
protected void showBuildReportInfo()
Creates the build report header information lines. Build report date, JMRI version, train schedule, build report display levels, setup comment.
-
setUpRoute
protected void setUpRoute() throws BuildFailedException
- Throws:
BuildFailedException
-
showTrainBuildOptions
protected void showTrainBuildOptions()
show train build options when in detailed mode
-
showSpecificTrainBuildOptions
protected void showSpecificTrainBuildOptions()
-
showTrainServices
protected void showTrainServices()
Adds to the build report what the train will service. Road and owner names, built dates, and engine types.
-
showAndInitializeTrainRoute
protected void showAndInitializeTrainRoute() throws BuildFailedException
Show and initialize the train's route. Determines the number of car moves requested for this train. Also adjust the number of car moves if the random car moves option was selected.- Throws:
BuildFailedException
- if random variable isn't an integer
-
showIfLocalSwitcher
protected void showIfLocalSwitcher()
reports if local switcher
-
showTrainRequirements
protected void showTrainRequirements()
Show how many engines are required for this train, and if a certain road name for the engine is requested. Show if there are any engine changes in the route, or if helper engines are needed. There can be up to 2 engine changes or helper requests. Show if caboose or FRED is needed for train, and if there's a road name requested. There can be up to 2 caboose changes in the route.
-
setDepartureTrack
protected void setDepartureTrack(Track departStageTrack)
Will also set the termination track if returning to staging- Parameters:
departStageTrack
- departure track from staging
-
showTrainCarRoads
protected void showTrainCarRoads()
-
showTrainCabooseRoads
protected void showTrainCabooseRoads()
-
showTrainCarTypes
protected void showTrainCarTypes()
-
showTrainLoadNames
protected void showTrainLoadNames()
-
promptFromStagingDialog
protected Track promptFromStagingDialog()
Ask which staging track the train is to depart on.- Returns:
- The departure track the user selected.
-
promptToStagingDialog
protected Track promptToStagingDialog()
Ask which staging track the train is to terminate on.- Returns:
- The termination track selected by the user.
-
removeCaboosesAndCarsWithFred
protected void removeCaboosesAndCarsWithFred() throws BuildFailedException
Removes the remaining cabooses and cars with FRED from consideration.- Throws:
BuildFailedException
- code check if car being removed is in staging
-
saveCarFinalDestinations
protected void saveCarFinalDestinations()
Save the car's final destination and schedule, id in case of train reset
-
getCarList
protected void getCarList() throws BuildFailedException
Creates the carList. Only cars that can be serviced by this train are in the list.- Throws:
BuildFailedException
- if car is marked as missing and is in staging
-
adjustCarsInStaging
protected void adjustCarsInStaging() throws BuildFailedException
Adjust car list to only have cars from one staging track- Throws:
BuildFailedException
- if all cars departing staging can't be used
-
showCarsByLocation
protected void showCarsByLocation() throws BuildFailedException
List available cars by location. Removes non-lead kernel cars from the car list.- Throws:
BuildFailedException
- if kernel doesn't have lead or cars aren't on the same track.
-
sortCarsOnFifoLifoTracks
protected void sortCarsOnFifoLifoTracks()
-
getLargestBlock
protected java.lang.String getLargestBlock()
-
getLocationWithMaximumMoves
protected RouteLocation getLocationWithMaximumMoves(java.util.List<RouteLocation> blockRouteList, java.lang.String blockId)
Returns the routeLocation with the most available moves. Used for blocking a train out of staging.- Parameters:
blockRouteList
- The route for this train, modified by deleting RouteLocations servicedblockId
- Where these cars were originally picked up from.- Returns:
- The location in the route with the most available moves.
-
makeAdjustmentsIfDepartingStaging
protected void makeAdjustmentsIfDepartingStaging()
Temporally remove cars from staging track if train returning to the same staging track to free up track space.
-
restoreCarsIfDepartingStaging
protected void restoreCarsIfDepartingStaging()
Restores cars departing staging track assignment.
-
showLoadGenerationOptionsStaging
protected void showLoadGenerationOptionsStaging()
-
checkStuckCarsInStaging
protected void checkStuckCarsInStaging() throws BuildFailedException
Checks to see if all cars on a staging track have been given a destination. Throws exception if there's a car without a destination.- Throws:
BuildFailedException
- if car on staging track not assigned to train
-
isCarStuckStaging
protected boolean isCarStuckStaging()
Used to determine if a car on a staging track doesn't have a destination or train- Returns:
- true if at least one car doesn't have a destination or train. false if all cars have a destination.
-
addCarToTrain
protected void addCarToTrain(Car car, RouteLocation rl, RouteLocation rld, Track track)
Add car to train, and adjust train length and weight- Parameters:
car
- the car being added to the trainrl
- the departure route location for this carrld
- the destination route location for this cartrack
- the destination track for this car
-
finishAddRsToTrain
protected void finishAddRsToTrain(RollingStock rs, RouteLocation rl, RouteLocation rld, int length, int weightTons)
-
checkPickUpTrainDirection
protected boolean checkPickUpTrainDirection(RollingStock rs, RouteLocation rl) throws BuildFailedException
Determine if rolling stock can be picked up based on train direction at the route location.- Parameters:
rs
- The rolling stockrl
- The rolling stock's route location- Returns:
- true if there isn't a problem
- Throws:
BuildFailedException
- if coding issue
-
checkPickUpTrainDirection
protected boolean checkPickUpTrainDirection(RouteLocation rl)
Used to report a problem picking up the rolling stock due to train direction.- Parameters:
rl
- The route location- Returns:
- true if there isn't a problem
-
checkTrainLength
protected boolean checkTrainLength(Car car, RouteLocation rl, RouteLocation rld)
Checks to see if train length would be exceeded if this car was added to the train.- Parameters:
car
- the car in questionrl
- the departure route location for this carrld
- the destination route location for this car- Returns:
- true if car can be added to train
-
checkDropTrainDirection
protected boolean checkDropTrainDirection(RollingStock rs, RouteLocation rld, Track track)
-
checkDropTrainDirection
protected boolean checkDropTrainDirection(RouteLocation rld)
-
checkTrainCanDrop
protected boolean checkTrainCanDrop(RollingStock rs, Track track)
Determinate if rolling stock can be dropped by this train to the track specified.- Parameters:
rs
- the rolling stock to be set out.track
- the destination track.- Returns:
- true if able to drop.
-
checkDepartureStagingTrack
protected boolean checkDepartureStagingTrack(Track departStageTrack)
Check departure staging track to see if engines and cars are available to a new train. Also confirms that the engine and car type, load, road, etc. are accepted by the train.- Parameters:
departStageTrack
- The staging track- Returns:
- true is there are engines and cars available.
-
checkTerminateStagingTrack
protected boolean checkTerminateStagingTrack(Track terminateStageTrack)
Checks to see if staging track can accept train.- Parameters:
terminateStageTrack
- the staging track- Returns:
- true if staging track is empty, not reserved, and accepts car and engine types, roads, and loads.
-
checkBasicMoves
protected boolean checkBasicMoves(Car car, Track track)
-
getScheduleItem
protected ScheduleItem getScheduleItem(Car car, Track track) throws BuildFailedException
Used when generating a car load from staging.- Parameters:
car
- the car.track
- the car's destination track that has the schedule.- Returns:
- ScheduleItem si if match found, null otherwise.
- Throws:
BuildFailedException
- if schedule doesn't have any line items
-
showCarServiceOrder
protected void showCarServiceOrder(Car car)
-
getTracksAtDestination
protected java.util.List<Track> getTracksAtDestination(Car car, RouteLocation rld)
Returns a list containing two tracks. The 1st track found for the car, the 2nd track is the car's final destination if an alternate track was used for the car. 2nd track can be null.- Parameters:
car
- The car needing a destination trackrld
- the RouteLocation destination- Returns:
- List containing up to two tracks. No tracks if none found.
-
checkForEarlierDrop
protected RouteLocation checkForEarlierDrop(Car car, Track trackTemp, RouteLocation rld, int start, int routeEnd)
Used to determine if car could be set out at earlier location in the train's route.- Parameters:
car
- The cartrackTemp
- The destination track for this carrld
- Where in the route the destination track was foundstart
- Where to begin the checkrouteEnd
- Where to stop the check- Returns:
- The best RouteLocation to drop off the car
-
tryStaging
protected Track tryStaging(Car car, RouteLocation rldSave) throws BuildFailedException
- Throws:
BuildFailedException
-
checkForLaterPickUp
protected boolean checkForLaterPickUp(Car car, RouteLocation rl, RouteLocation rld) throws BuildFailedException
Returns true if car can be picked up later in a train's route- Parameters:
car
- the carrl
- car's route locationrld
- car's route location destination- Returns:
- true if car can be picked up later in a train's route
- Throws:
BuildFailedException
- if coding issue
-
checkThroughCarsAllowed
protected boolean checkThroughCarsAllowed(Car car, java.lang.String destinationName)
Returns true is cars are allowed to travel from origin to terminal- Parameters:
car
- The cardestinationName
- Destination name for this car- Returns:
- true if through cars are allowed. false if not.
-
generateLoadCarDepartingAndTerminatingIntoStaging
protected boolean generateLoadCarDepartingAndTerminatingIntoStaging(Car car, Track stageTrack) throws BuildFailedException
Creates a car load for a car departing staging and eventually terminating into staging.- Parameters:
car
- the car!stageTrack
- the staging track the car will terminate to- Returns:
- true if a load was generated this this car.
- Throws:
BuildFailedException
- if coding check fails
-
redirectCarsFromAlternateTrack
protected boolean redirectCarsFromAlternateTrack() throws BuildFailedException
Checks to see if cars that are already in the train can be redirected from the alternate track to the spur that really wants the car. Fixes the issue of having cars placed at the alternate when the spur's cars get pulled by this train, but cars were sent to the alternate because the spur was full at the time it was tested.- Returns:
- true if one or more cars were redirected
- Throws:
BuildFailedException
- if coding issue
-
showCarsNotMoved
protected void showCarsNotMoved(RouteLocation rl)
report any cars left at route location- Parameters:
rl
- route location
-
removeRollingStockFromTrain
protected void removeRollingStockFromTrain(RollingStock rs)
Remove rolling stock from train- Parameters:
rs
- the rolling stock to be removed
-
showCarsNotRoutable
protected void showCarsNotRoutable()
Lists cars that couldn't be routed.
-
removeCarsFromStaging
protected void removeCarsFromStaging()
build has failed due to cars in staging not having destinations this routine removes those cars from the staging track by user request.
-
addEnginesBasedHPT
protected void addEnginesBasedHPT(int hpAvailable, int extraHpNeeded, RouteLocation rlNeedHp, RouteLocation rl, RouteLocation rld) throws BuildFailedException
Adds engines to the train if needed based on HPT. Note that the engine additional weight isn't considered in this method so HP requirements can be lower compared to the original calculation which did include the weight of the engines.- Parameters:
hpAvailable
- the engine hp already assigned to the train for this legextraHpNeeded
- the additional hp neededrlNeedHp
- where in the route the additional hp is neededrl
- the start of the legrld
- the end of the leg- Throws:
BuildFailedException
- if unable to add engines to train
-
getNumberEngines
protected int getNumberEngines(java.lang.String requestEngines)
Used to determine the number of engines requested by the user.- Parameters:
requestEngines
- Can be a number, AUTO or AUTO HPT.- Returns:
- the number of engines requested by user.
-
setEngineDestination
protected boolean setEngineDestination(Engine engine, RouteLocation rl, RouteLocation rld)
Sets the destination track for an engine and assigns it to the train.- Parameters:
engine
- The engine to be added to trainrl
- Departure route locationrld
- Destination route location- Returns:
- true if destination track found and set
-
getConsist
protected boolean getConsist(java.lang.String reqNumEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld) throws BuildFailedException
- Throws:
BuildFailedException
-
showEnginesByLocation
protected void showEnginesByLocation()
-
countRollingStockAt
protected int countRollingStockAt(RouteLocation rl, java.util.List<RollingStock> list)
-
getEngines
protected boolean getEngines(java.lang.String requestedEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld) throws BuildFailedException
- Throws:
BuildFailedException
-
getEngines
protected boolean getEngines(java.lang.String requestedEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld, boolean useBunit) throws BuildFailedException
Get the engines for this train at a route location. If departing from staging engines must come from that track. Finds the required number of engines in a consist, or if the option to build from single locos, builds a consist for the user. When true, engines successfully added to train for the leg requested.- Parameters:
requestedEngines
- Requested number of Engines, can be number, AUTO or AUTO HPTmodel
- Optional model name for the enginesroad
- Optional road name for the enginesrl
- Departure route location for the enginesrld
- Destination route location for the enginesuseBunit
- true if B unit engine is allowed- Returns:
- true if correct number of engines found.
- Throws:
BuildFailedException
- if coding issue
-
getNewEngine
protected void getNewEngine(int hpNeeded, Engine leadEngine, java.lang.String model, java.lang.String road) throws BuildFailedException
Removes engine from train and attempts to replace it with engine or consist that meets the HP requirements of the train.- Parameters:
hpNeeded
- How much hp is neededleadEngine
- The lead engine for this legmodel
- The engine's modelroad
- The engine's road- Throws:
BuildFailedException
- if new engine not found
-
removeEngineFromTrain
protected void removeEngineFromTrain(Engine engine)
-
-