Class CarManager
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrit.operations.rollingstock.RollingStockManager<Car>
jmri.jmrit.operations.rollingstock.cars.CarManager
- All Implemented Interfaces:
PropertyChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,InstanceManagerAutoDefault,InstanceManagerAutoInitialize
public class CarManager
extends RollingStockManager<Car>
implements InstanceManagerAutoDefault, InstanceManagerAutoInitialize
Manages the cars.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int(package private) intFields inherited from class jmri.jmrit.operations.rollingstock.RollingStockManager
_hashTable, BY_BLOCKING, BY_BUILT, BY_COLOR, BY_COMMENT, BY_DESTINATION, BY_LAST, BY_LOCATION, BY_MOVES, BY_NUMBER, BY_OWNER, BY_RFID, BY_ROAD, BY_TRAIN, BY_TYPE, BY_VALUE, LISTLENGTH_CHANGED_PROPERTY, NONEFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcalculateCarWeight(String carLength) Determines a car's weight in ounces based on car's scale lengthvoidderegister(Car car) Unload RollingStock.getAvailableTrainList(Train train) Return a list available cars (no assigned train or car already assigned to this train) on a route, cars are ordered least recently moved to most recently moved.Sort by car kernel namesSort by car loadsSort by rolling stock locationSort by car return when empty location and trackgetByTrainDestinationList(Train train) Provides a very sorted list of cars assigned to the train.Sort by car wait countGet a list of car road names where the car was flagged as a caboose.intReturns the highest clone creation order given to a clone.protected Comparator<Car>getComparator(int attribute) Get a list of car road names where the car was flagged with FREDintvoidPerform any initialization that occurs after this object has been constructed and made available by the InstanceManager.booleanUsed to determine if there are clone cars.booleanUsed to determine if any car has been assigned a divisionvoidload(org.jdom2.Element root) Finds an existing Car or creates a new Car if needed requires car's road and numbervoidvoidreplaceLoad(String type, String oldLoadName, String newLoadName) Replace car loadsprotected voidsetDirtyAndFirePropertyChange(String p, Object old, Object n) sortByLoadPriority(List<Car> list) voidstore(org.jdom2.Element root) Create an XML element to represent this Entry.Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStockManager
convertBuildDate, deleteAll, dispose, getByBuiltList, getByColorList, getByCommentList, getByDestinationList, getById, getByIdList, getByLastDateList, getByLastDateList, getByList, getByMovesList, getByNumberList, getByOwnerList, getByRfid, getByRfidList, getByRoadAndNumber, getByRoadNameList, getByTrainList, getByTrainList, getByTypeAndRoad, getByTypeList, getByTypeList, getByValueList, getList, getList, getList, getList, getNumEntries, register, resetMoves, resetMoves, sortByTrackPriorityMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
cloneCreationOrder
-
_commentLength
int _commentLength
-
-
Constructor Details
-
CarManager
public CarManager()
-
-
Method Details
-
newRS
Finds an existing Car or creates a new Car if needed requires car's road and number- Specified by:
newRSin classRollingStockManager<Car>- Parameters:
road- car roadnumber- car number- Returns:
- new car or existing Car
-
deregister
Description copied from class:RollingStockManagerUnload RollingStock.- Overrides:
deregisterin classRollingStockManager<Car>- Parameters:
car- The RollingStock to delete.
-
getByLocationList
Sort by rolling stock location- Overrides:
getByLocationListin classRollingStockManager<Car>- Returns:
- list of cars ordered by the Car's location
-
getByKernelList
Sort by car kernel names- Returns:
- list of cars ordered by car kernel
-
getByLoadList
Sort by car loads- Returns:
- list of cars ordered by car loads
-
getByRweList
Sort by car return when empty location and track- Returns:
- list of cars ordered by car return when empty
-
getByRwlList
-
getByRouteList
-
getByDivisionList
-
getByFinalDestinationList
-
getByWaitList
Sort by car wait count- Returns:
- list of cars ordered by wait count
-
getByPickupList
-
getComparator
- Overrides:
getComparatorin classRollingStockManager<Car>
-
getAvailableTrainList
Return a list available cars (no assigned train or car already assigned to this train) on a route, cars are ordered least recently moved to most recently moved. Note that it is possible for a car to have a location, but no track assignment.- Parameters:
train- The Train to use.- Returns:
- List of cars with no assigned train on a route
-
sortByLoadPriority
-
getByTrainDestinationList
Provides a very sorted list of cars assigned to the train. Note that this isn't the final sort as the cars must be sorted by each location the train visits.The sort priority is as follows:
- Caboose or car with FRED to the end of the list, unless passenger.
- Passenger cars have blocking numbers which places them relative to each other. Passenger cars with positive blocking numbers to the end of the list, but before cabooses or car with FRED. Passenger cars with negative blocking numbers are placed at the front of the train.
- Car's destination (alphabetical by location and track name or by track blocking order)
- Car is hazardous (hazardous placed after a non-hazardous car)
- Car's current location (alphabetical by location and track name)
- Car's final destination (alphabetical by location and track name)
Cars in a kernel are placed together by their kernel blocking numbers, except if they are type passenger. The kernel's position in the list is based on the lead car in the kernel.
If the train is to be blocked by track blocking order, all of the tracks at that location need a blocking number greater than 0.
- Parameters:
train- The selected Train.- Returns:
- Ordered list of cars assigned to the train
-
getCabooseRoadNames
Get a list of car road names where the car was flagged as a caboose.- Returns:
- List of caboose road names.
-
getFredRoadNames
Get a list of car road names where the car was flagged with FRED- Returns:
- List of road names of cars with FREDs
-
replaceLoad
Replace car loads- Parameters:
type- type of caroldLoadName- old load namenewLoadName- new load name
-
getCarsLocationUnknown
-
calculateCarWeight
Determines a car's weight in ounces based on car's scale length- Parameters:
carLength- Car's scale length- Returns:
- car's weight in ounces
- Throws:
NumberFormatException- if length isn't a number
-
isThereDivisions
Used to determine if any car has been assigned a division- Returns:
- true if any car has been assigned a division, otherwise false
-
isThereClones
Used to determine if there are clone cars.- Returns:
- true if there are clone cars, otherwise false.
-
getCloneCreationOrder
Returns the highest clone creation order given to a clone.- Returns:
- 1 if the first clone created, otherwise the highest found plus one. Automatically increments.
-
getMaxCommentLength
-
load
-
store
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-cars.dtd.- Parameters:
root- The common Element for operations-cars.dtd.
-
setDirtyAndFirePropertyChange
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classRollingStockManager<Car>
-
initialize
Description copied from interface:InstanceManagerAutoInitializePerform any initialization that occurs after this object has been constructed and made available by the InstanceManager.- Specified by:
initializein interfaceInstanceManagerAutoInitialize
-