Class TrainBuilderBase
- java.lang.Object
-
- jmri.jmrit.operations.trains.trainbuilder.TrainCommon
-
- jmri.jmrit.operations.trains.trainbuilder.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) CarLoadscarLoadsprotected static intDISPLAY_CAR_LIMIT_100protected static intDISPLAY_CAR_LIMIT_20protected static intDISPLAY_CAR_LIMIT_50protected static java.lang.StringFIVEprotected static java.lang.StringONE(package private) Routerrouter(package private) booleanrouteToTrackFoundprotected static java.lang.StringSEVENprotected static java.lang.StringTHREEprotected static java.lang.StringTIMING(package private) TrainManagertrainManager(package private) TrainScheduleManagertrainScheduleManagerprotected static booleanUSE_BUNIT-
Fields inherited from class jmri.jmrit.operations.trains.trainbuilder.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 voidaddEnginesBasedHPT(int hpAvailable, int extraHpNeeded, RouteLocation rlNeedHp, RouteLocation rl, RouteLocation rld)Adds engines to the train if needed based on HPT.protected voidadjustCarsInStaging()Adjust car list to only have cars from one staging trackprotected booleancheckBasicMoves(Car car, Track track)protected booleancheckDepartureStagingTrack(Track departStageTrack)Check departure staging track to see if engines and cars are available to a new train.protected booleancheckDropTrainDirection(RollingStock rs, RouteLocation rld, Track track)protected booleancheckDropTrainDirection(RouteLocation rld)protected booleancheckForAlternate(Car car, Track testTrack)Checks to see if track has an alternate and can be usedprotected RouteLocationcheckForEarlierDrop(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 booleancheckForLaterPickUp(Car car, RouteLocation rl, RouteLocation rld)Returns true if car can be picked up later in a train's routeprotected booleancheckPickupInterchangeOrSpur(Car car)Determines if car can be pulled from an interchange or spur.protected booleancheckPickUpTrainDirection(RollingStock rs, RouteLocation rl)Determine if rolling stock can be picked up based on train direction at the route location.protected booleancheckPickUpTrainDirection(RouteLocation rl)Used to report a problem picking up the rolling stock due to train direction.protected java.lang.StringcheckReserved(Train train, RouteLocation rld, Car car, Track destTrack, boolean printMsg)protected voidcheckStuckCarsInStaging()Checks to see if all cars on a staging track have been given a destination.protected booleancheckTerminateStagingTrack(Track terminateStageTrack)Checks to see if staging track can accept train.protected booleancheckThroughCarsAllowed(Car car, java.lang.String destinationName)Returns true is cars are allowed to travel from origin to terminalprotected booleancheckTrainCanDrop(RollingStock rs, Track track)Determinate if rolling stock can be dropped by this train to the track specified.protected booleancheckTrainLength(Car car, RouteLocation rl, RouteLocation rld)Checks to see if train length would be exceeded if this car was added to the train.protected intcountRollingStockAt(RouteLocation rl, java.util.List<RollingStock> list)protected voidcreateBuildReportFile()protected voidfinishAddRsToTrain(RollingStock rs, RouteLocation rl, RouteLocation rld, int length, int weightTons)protected booleangenerateLoadCarDepartingAndTerminatingIntoStaging(Car car, Track stageTrack)Creates a car load for a car departing staging and eventually terminating into staging.protected voidgetCarList()Creates the carList.protected booleangetConsist(java.lang.String reqNumEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld)protected booleangetEngines(java.lang.String requestedEngines, java.lang.String model, java.lang.String road, RouteLocation rl, RouteLocation rld)protected booleangetEngines(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.StringgetLargestBlock()protected RouteLocationgetLocationWithMaximumMoves(java.util.List<RouteLocation> blockRouteList, java.lang.String blockId)Returns the routeLocation with the most available moves.protected voidgetNewEngine(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 intgetNumberEngines(java.lang.String requestEngines)Used to determine the number of engines requested by the user.protected ScheduleItemgetScheduleItem(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 booleanisCarStuckStaging()Used to determine if a car on a staging track doesn't have a destination or trainprotected voidmakeAdjustmentsIfDepartingStaging()Temporally remove cars from staging track if train returning to the same staging track to free up track space.protected TrackpromptFromStagingDialog()Ask which staging track the train is to depart on.protected TrackpromptToStagingDialog()Ask which staging track the train is to terminate on.protected voidremoveCaboosesAndCarsWithFred()Removes the remaining cabooses and cars with FRED from consideration.protected voidremoveCarsFromStaging()build has failed due to cars in staging not having destinations this routine removes those cars from the staging track by user request.protected voidremoveEngineFromTrain(Engine engine)protected voidremoveRollingStockFromTrain(RollingStock rs)Remove rolling stock from trainprotected voidrestoreCarsIfDepartingStaging()Restores cars departing staging track assignment.protected voidsaveCarFinalDestinations()Save the car's final destination and schedule id in case of train resetprotected voidsetDepartureTrack(Track departStageTrack)Will also set the termination track if returning to stagingprotected booleansetEngineDestination(Engine engine, RouteLocation rl, RouteLocation rld)Sets the destination track for an engine and assigns it to the train.protected voidsetUpRoute()protected voidshowAndInitializeTrainRoute()Show and initialize the train's route.protected voidshowBuildReportInfo()Creates the build report header information lines.protected voidshowCarsByLocation()List available cars by location.protected voidshowCarServiceOrder(Car car)protected voidshowCarsNotMoved(RouteLocation rl)report any cars left at route locationprotected voidshowCarsNotRoutable()Lists cars that couldn't be routed.protected voidshowEnginesByLocation()protected voidshowIfLocalSwitcher()reports if local switcherprotected voidshowLoadGenerationOptionsStaging()protected voidshowSpecificTrainBuildOptions()protected voidshowTrainBuildOptions()show train build options when in detailed modeprotected voidshowTrainCabooseRoads()protected voidshowTrainCarRoads()protected voidshowTrainCarTypes()protected voidshowTrainLoadNames()protected voidshowTrainRequirements()Show how many engines are required for this train, and if a certain road name for the engine is requested.protected voidshowTrainServices()Adds to the build report what the train will service.protected voidsortCarsOnFifoLifoTracks()protected TracktryStaging(Car car, RouteLocation rldSave)-
Methods inherited from class jmri.jmrit.operations.trains.trainbuilder.TrainCommon
addCarsLocationUnknown, addLine, addLine, blockCarsByTrack, blockCarsByTrackNameTwoColumn, blockCarsTwoColumn, blockLocosTwoColumn, clearUtilityCarTypes, convertStringTime, convertStringToDate, countPickupUtilityCars, countSetoutUtilityCars, countUtilityCars, createTabIfNeeded, dropCar, dropCar, dropEngine, dropEngines, formatColorString, formatStringToCommaSeparated, getDate, getDate, getDropCarHeader, getDropEngineHeader, getISO8601Date, getLineLength, getLocalMoveHeader, getManifestHeaderLineLength, getPageSize, getPickupCarHeader, getPickupEngineHeader, getSwitchListTrainStatus, getTextColor, getTextColorName, getTextColorString, getTrainMessage, isNextCar, isNextCar, isThereWorkAtLocation, isThereWorkAtLocation, localMoveCar, newLine, newLine, padAndTruncate, padAndTruncateIfNeeded, padString, pickupCar, pickUpCar, pickUpCarTruncated, pickupEngine, pickupEngines, pickupUtilityCars, pickupUtilityCars, printCarHeader, printDropCarHeader, printDropEngineHeader, printEngineHeader, printHorizontalLine, printHorizontalLine, printHorizontalLine1, printHorizontalLine2, printHorizontalLine3, printLocalCarMoveHeader, printPickupCarHeader, printPickupEngineHeader, printTrackComments, printTrackNameHeader, setCarPickupAndSetoutTimes, setoutUtilityCars, setoutUtilityCars, setoutUtilityCars, splitString, splitStringLeftParenthesis, 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
-
TIMING
protected static final java.lang.String TIMING
- 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.
-
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
-
checkPickupInterchangeOrSpur
protected boolean checkPickupInterchangeOrSpur(Car car)
Determines if car can be pulled from an interchange or spur. Needed for quick service tracks.- Parameters:
car- the car being pulled- Returns:
- true if car can be pulled, otherwise false.
-
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.
-
checkForAlternate
protected boolean checkForAlternate(Car car, Track testTrack)
Checks to see if track has an alternate and can be used- Parameters:
car- the car being droppedtestTrack- the destination track- Returns:
- true if track has an alternate and can be used
-
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
-
checkReserved
protected java.lang.String checkReserved(Train train, RouteLocation rld, Car car, Track destTrack, boolean printMsg)
-
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
-
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)
-
-