Class Car
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.rollingstock.RollingStock
-
- jmri.jmrit.operations.rollingstock.cars.Car
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,Identifiable
,PropertyChangeFirer
,PropertyChangeProvider
public class Car extends RollingStock
Represents a car on the layout
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
_caboose
protected Location
_finalDestination
protected Track
_finalDestTrack
protected boolean
_fred
protected boolean
_hazardous
protected Kernel
_kernel
protected boolean
_loadGeneratedByStaging
protected java.lang.String
_loadName
protected java.lang.String
_nextLoadName
protected boolean
_passenger
protected java.lang.String
_pickupScheduleId
protected Location
_previousFinalDestination
protected Track
_previousFinalDestTrack
protected java.lang.String
_previousScheduleId
protected java.lang.String
_routePath
protected Location
_rweDestination
protected Track
_rweDestTrack
protected java.lang.String
_rweLoadName
protected Location
_rwlDestination
protected Track
_rwlDestTrack
protected java.lang.String
_rwlLoadName
protected java.lang.String
_scheduleId
protected boolean
_utility
protected int
_wait
static java.lang.String
CABOOSE_EXTENSION
(package private) CarLoads
carLoads
static java.lang.String
EXTENSION_REGEX
static java.lang.String
FINAL_DESTINATION_CHANGED_PROPERTY
static java.lang.String
FINAL_DESTINATION_TRACK_CHANGED_PROPERTY
static java.lang.String
FRED_EXTENSION
static java.lang.String
HAZARDOUS_EXTENSION
static java.lang.String
KERNEL_NAME_CHANGED_PROPERTY
static java.lang.String
LOAD_CHANGED_PROPERTY
static java.lang.String
PASSENGER_EXTENSION
static java.lang.String
RETURN_WHEN_EMPTY_CHANGED_PROPERTY
static java.lang.String
RETURN_WHEN_LOADED_CHANGED_PROPERTY
static java.lang.String
RWE_LOAD_CHANGED_PROPERTY
static java.lang.String
RWL_LOAD_CHANGED_PROPERTY
static java.lang.String
SCHEDULE_ID_CHANGED_PROPERTY
static java.lang.String
UTILITY_EXTENSION
static java.lang.String
WAIT_CHANGED_PROPERTY
-
Fields inherited from class jmri.jmrit.operations.rollingstock.RollingStock
_blocking, _built, _color, _comment, _destination, _division, _id, _lastDate, _lastLocationId, _lastTrackId, _length, _lengthChange, _location, _locationUnknown, _moves, _number, _outOfService, _owner, _rfid, _road, _routeDestination, _routeId, _routeLocation, _selected, _tag, _tagListener, _track, _trackDestination, _train, _type, _value, _weight, _weightTons, _whenLastSeen, _whereLastSeen, COMMENT_CHANGED_PROPERTY, COUPLERS, DEFAULT_BLOCKING_ORDER, DEFAULT_WEIGHT, DESTINATION_TRACK_CHANGED_PROPERTY, ERROR_TRACK, FORCE, LENGTH_CHANGED_PROPERTY, LOCATION_UNKNOWN, MAX_BLOCKING_ORDER, NONE, number, ROUTE_DESTINATION_CHANGED_PROPERTY, ROUTE_LOCATION_CHANGED_PROPERTY, TRACK_CHANGED_PROPERTY, TRAIN_CHANGED_PROPERTY, TYPE_CHANGED_PROPERTY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
checkDestination(Location destination, Track track)
Used to determine if a car can be set out at a destination (location).Car
copy()
void
dispose()
Remove rolling stock.int
getAdjustedWeightTons()
Returns a car's weight adjusted for load.java.lang.String
getDropComment()
Location
getFinalDestination()
java.lang.String
getFinalDestinationName()
Track
getFinalDestinationTrack()
java.lang.String
getFinalDestinationTrackName()
Kernel
getKernel()
java.lang.String
getKernelName()
java.lang.String
getLoadName()
The load name assigned to this car.java.lang.String
getLoadPriority()
Gets the car's load's priority.java.lang.String
getLoadType()
Gets the car load's type, empty or load.java.lang.String
getNextLoadName()
java.lang.String
getPickupComment()
java.lang.String
getPickupScheduleId()
java.lang.String
getPickupScheduleName()
Location
getPreviousFinalDestination()
Track
getPreviousFinalDestinationTrack()
java.lang.String
getPreviousScheduleId()
Location
getReturnWhenEmptyDestination()
java.lang.String
getReturnWhenEmptyDestinationName()
Track
getReturnWhenEmptyDestTrack()
java.lang.String
getReturnWhenEmptyDestTrackName()
java.lang.String
getReturnWhenEmptyLoadName()
Location
getReturnWhenLoadedDestination()
java.lang.String
getReturnWhenLoadedDestinationName()
Track
getReturnWhenLoadedDestTrack()
java.lang.String
getReturnWhenLoadedDestTrackName()
java.lang.String
getReturnWhenLoadedLoadName()
java.lang.String
getRoutePath()
ScheduleItem
getScheduleItem(Track track)
java.lang.String
getScheduleItemId()
java.lang.String
getSplitFinalDestinationName()
java.lang.String
getSplitFinalDestinationTrackName()
java.lang.String
getSplitReturnWhenEmptyDestinationName()
java.lang.String
getSplitReturnWhenEmptyDestinationTrackName()
java.lang.String
getTypeExtensions()
int
getWait()
java.lang.String
getWeightTons()
boolean
hasFred()
Used to determine if car has FRED (Flashing Rear End Device).boolean
isCaboose()
boolean
isCarHazardous()
boolean
isCarLoadHazardous()
boolean
isHazardous()
Used to determine if the car is hazardous or the car's load is hazardous.boolean
isLead()
Used to determine if car is lead car in a kernelboolean
isLoadGeneratedFromStaging()
boolean
isLocalMove()
Used to determine if car is performing a local move.boolean
isPassenger()
protected boolean
isRwlEnabled()
Used to determine is car has been given a Return When Loaded (RWL) address or custom loadboolean
isUtility()
void
loadNext(ScheduleItem scheduleItem)
Called when setting a car's destination to this spur.void
loadNext(Track track)
Called when car is delivered to track.void
propertyChange(java.beans.PropertyChangeEvent e)
void
reset()
void
setCaboose(boolean caboose)
void
setCarHazardous(boolean hazardous)
java.lang.String
setDestination(Location destination, Track track)
Sets the car's destination on the layoutjava.lang.String
setDestination(Location destination, Track track, boolean force)
Sets the car's destination on the layoutprotected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setFinalDestination(Location destination)
Sets the final destination for a car.void
setFinalDestinationTrack(Track track)
void
setFred(boolean fred)
void
setKernel(Kernel kernel)
A kernel is a group of cars that are switched as a unit.void
setLoadGeneratedFromStaging(boolean fromStaging)
void
setLoadName(java.lang.String load)
void
setNextLoadName(java.lang.String load)
Only here for backwards compatibility before version 5.1.4.void
setPassenger(boolean passenger)
void
setPickupScheduleId(java.lang.String id)
Sets when this car will be picked up (day of the week)void
setPreviousFinalDestination(Location location)
void
setPreviousFinalDestinationTrack(Track track)
void
setPreviousScheduleId(java.lang.String id)
void
setReturnWhenEmptyDestination(Location destination)
void
setReturnWhenEmptyDestTrack(Track track)
void
setReturnWhenEmptyLoadName(java.lang.String load)
void
setReturnWhenLoadedDestination(Location destination)
void
setReturnWhenLoadedDestTrack(Track track)
void
setReturnWhenLoadedLoadName(java.lang.String load)
void
setRoutePath(java.lang.String routePath)
void
setScheduleItemId(java.lang.String id)
Used to keep track of which item in a schedule was used for this car.void
setUtility(boolean utility)
void
setWait(int count)
org.jdom2.Element
store()
Create an XML element to represent this Entry.void
updateKernel()
Updates all cars in a kernel.void
updateLoad(Track track)
Updates a car's load when placed at a spur.-
Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStock
createId, getBlocking, getBuilt, getColor, getComment, getDestination, getDestinationId, getDestinationName, getDestinationTrack, getDestinationTrackId, getDestinationTrackName, getDivision, getDivisionId, getDivisionName, getId, getIdTag, getLastDate, getLastLocationId, getLastLocationName, getLastMoveDate, getLastRouteId, getLastTrackId, getLastTrackName, getLength, getLengthInteger, getLocation, getLocationId, getLocationName, getMoves, getNumber, getOwnerName, getRfid, getRoadName, getRouteDestination, getRouteDestinationId, getRouteLocation, getRouteLocationId, getSortDate, getSplitDestinationName, getSplitDestinationTrackName, getSplitLocationName, getSplitTrackName, getStatus, getTotalLength, getTrack, getTrackId, getTrackLastSeen, getTrackLastSeenName, getTrackName, getTrackType, getTrain, getTrainName, getTypeName, getValue, getWeight, getWhenLastSeen, getWhenLastSeenDate, getWhereLastSeen, getWhereLastSeenName, isLocationUnknown, isOutOfService, isSelected, moveRollingStock, setBlocking, setBuilt, setColor, setComment, setDestination, setDestinationTrack, setDivision, setIdTag, setLastDate, setLastLocationId, setLastRouteId, setLastTrackId, setLength, setLocation, setLocation, setLocationUnknown, setMoves, setNumber, setOutOfService, setOwnerName, setRfid, setRoadName, setRouteDestination, setRouteLocation, setSelected, setTrack, setTrain, setTypeName, setValue, setWeight, setWeightTons, store, testLocation, toString
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
_passenger
protected boolean _passenger
-
_hazardous
protected boolean _hazardous
-
_caboose
protected boolean _caboose
-
_fred
protected boolean _fred
-
_utility
protected boolean _utility
-
_loadGeneratedByStaging
protected boolean _loadGeneratedByStaging
-
_loadName
protected java.lang.String _loadName
-
_wait
protected int _wait
-
_rweDestination
protected Location _rweDestination
-
_rweDestTrack
protected Track _rweDestTrack
-
_rweLoadName
protected java.lang.String _rweLoadName
-
_rwlDestination
protected Location _rwlDestination
-
_rwlDestTrack
protected Track _rwlDestTrack
-
_rwlLoadName
protected java.lang.String _rwlLoadName
-
_scheduleId
protected java.lang.String _scheduleId
-
_nextLoadName
protected java.lang.String _nextLoadName
-
_finalDestination
protected Location _finalDestination
-
_finalDestTrack
protected Track _finalDestTrack
-
_previousFinalDestination
protected Location _previousFinalDestination
-
_previousFinalDestTrack
protected Track _previousFinalDestTrack
-
_previousScheduleId
protected java.lang.String _previousScheduleId
-
_pickupScheduleId
protected java.lang.String _pickupScheduleId
-
_routePath
protected java.lang.String _routePath
-
EXTENSION_REGEX
public static final java.lang.String EXTENSION_REGEX
- See Also:
- Constant Field Values
-
CABOOSE_EXTENSION
public static final java.lang.String CABOOSE_EXTENSION
-
FRED_EXTENSION
public static final java.lang.String FRED_EXTENSION
-
PASSENGER_EXTENSION
public static final java.lang.String PASSENGER_EXTENSION
-
UTILITY_EXTENSION
public static final java.lang.String UTILITY_EXTENSION
-
HAZARDOUS_EXTENSION
public static final java.lang.String HAZARDOUS_EXTENSION
-
LOAD_CHANGED_PROPERTY
public static final java.lang.String LOAD_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
RWE_LOAD_CHANGED_PROPERTY
public static final java.lang.String RWE_LOAD_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
RWL_LOAD_CHANGED_PROPERTY
public static final java.lang.String RWL_LOAD_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
WAIT_CHANGED_PROPERTY
public static final java.lang.String WAIT_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
FINAL_DESTINATION_CHANGED_PROPERTY
public static final java.lang.String FINAL_DESTINATION_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
FINAL_DESTINATION_TRACK_CHANGED_PROPERTY
public static final java.lang.String FINAL_DESTINATION_TRACK_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
RETURN_WHEN_EMPTY_CHANGED_PROPERTY
public static final java.lang.String RETURN_WHEN_EMPTY_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
RETURN_WHEN_LOADED_CHANGED_PROPERTY
public static final java.lang.String RETURN_WHEN_LOADED_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
SCHEDULE_ID_CHANGED_PROPERTY
public static final java.lang.String SCHEDULE_ID_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
KERNEL_NAME_CHANGED_PROPERTY
public static final java.lang.String KERNEL_NAME_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
-
Method Detail
-
setCarHazardous
public void setCarHazardous(boolean hazardous)
-
isCarHazardous
public boolean isCarHazardous()
-
isCarLoadHazardous
public boolean isCarLoadHazardous()
-
isHazardous
public boolean isHazardous()
Used to determine if the car is hazardous or the car's load is hazardous.- Returns:
- true if the car or car's load is hazardous.
-
setPassenger
public void setPassenger(boolean passenger)
-
isPassenger
public boolean isPassenger()
-
setFred
public void setFred(boolean fred)
-
hasFred
public boolean hasFred()
Used to determine if car has FRED (Flashing Rear End Device).- Returns:
- true if car has FRED.
-
setLoadName
public void setLoadName(java.lang.String load)
-
getLoadName
public java.lang.String getLoadName()
The load name assigned to this car.- Returns:
- The load name assigned to this car.
-
setReturnWhenEmptyLoadName
public void setReturnWhenEmptyLoadName(java.lang.String load)
-
getReturnWhenEmptyLoadName
public java.lang.String getReturnWhenEmptyLoadName()
-
setReturnWhenLoadedLoadName
public void setReturnWhenLoadedLoadName(java.lang.String load)
-
getReturnWhenLoadedLoadName
public java.lang.String getReturnWhenLoadedLoadName()
-
getLoadPriority
public java.lang.String getLoadPriority()
Gets the car's load's priority.- Returns:
- The car's load priority.
-
getLoadType
public java.lang.String getLoadType()
Gets the car load's type, empty or load.- Returns:
- type empty or type load
-
getPickupComment
public java.lang.String getPickupComment()
-
getDropComment
public java.lang.String getDropComment()
-
setLoadGeneratedFromStaging
public void setLoadGeneratedFromStaging(boolean fromStaging)
-
isLoadGeneratedFromStaging
public boolean isLoadGeneratedFromStaging()
-
setScheduleItemId
public void setScheduleItemId(java.lang.String id)
Used to keep track of which item in a schedule was used for this car.- Parameters:
id
- The ScheduleItem id for this car.
-
getScheduleItemId
public java.lang.String getScheduleItemId()
-
getScheduleItem
public ScheduleItem getScheduleItem(Track track)
-
setNextLoadName
public void setNextLoadName(java.lang.String load)
Only here for backwards compatibility before version 5.1.4. The next load name for this car. Normally set by a schedule.- Parameters:
load
- the next load name.
-
getNextLoadName
public java.lang.String getNextLoadName()
-
getWeightTons
public java.lang.String getWeightTons()
- Overrides:
getWeightTons
in classRollingStock
-
getAdjustedWeightTons
public int getAdjustedWeightTons()
Returns a car's weight adjusted for load. An empty car's weight is 1/3 the car's loaded weight.- Overrides:
getAdjustedWeightTons
in classRollingStock
-
setWait
public void setWait(int count)
-
getWait
public int getWait()
-
setPickupScheduleId
public void setPickupScheduleId(java.lang.String id)
Sets when this car will be picked up (day of the week)- Parameters:
id
- See TrainSchedule.java
-
getPickupScheduleId
public java.lang.String getPickupScheduleId()
-
getPickupScheduleName
public java.lang.String getPickupScheduleName()
-
setFinalDestination
public void setFinalDestination(Location destination)
Sets the final destination for a car.- Parameters:
destination
- The final destination for this car.
-
getFinalDestination
public Location getFinalDestination()
-
getFinalDestinationName
public java.lang.String getFinalDestinationName()
-
getSplitFinalDestinationName
public java.lang.String getSplitFinalDestinationName()
-
setFinalDestinationTrack
public void setFinalDestinationTrack(Track track)
-
getFinalDestinationTrack
public Track getFinalDestinationTrack()
-
getFinalDestinationTrackName
public java.lang.String getFinalDestinationTrackName()
-
getSplitFinalDestinationTrackName
public java.lang.String getSplitFinalDestinationTrackName()
-
setPreviousFinalDestination
public void setPreviousFinalDestination(Location location)
-
getPreviousFinalDestination
public Location getPreviousFinalDestination()
-
setPreviousFinalDestinationTrack
public void setPreviousFinalDestinationTrack(Track track)
-
getPreviousFinalDestinationTrack
public Track getPreviousFinalDestinationTrack()
-
setPreviousScheduleId
public void setPreviousScheduleId(java.lang.String id)
-
getPreviousScheduleId
public java.lang.String getPreviousScheduleId()
-
setReturnWhenEmptyDestination
public void setReturnWhenEmptyDestination(Location destination)
-
getReturnWhenEmptyDestination
public Location getReturnWhenEmptyDestination()
-
getReturnWhenEmptyDestinationName
public java.lang.String getReturnWhenEmptyDestinationName()
-
getSplitReturnWhenEmptyDestinationName
public java.lang.String getSplitReturnWhenEmptyDestinationName()
-
setReturnWhenEmptyDestTrack
public void setReturnWhenEmptyDestTrack(Track track)
-
getReturnWhenEmptyDestTrack
public Track getReturnWhenEmptyDestTrack()
-
getReturnWhenEmptyDestTrackName
public java.lang.String getReturnWhenEmptyDestTrackName()
-
getSplitReturnWhenEmptyDestinationTrackName
public java.lang.String getSplitReturnWhenEmptyDestinationTrackName()
-
setReturnWhenLoadedDestination
public void setReturnWhenLoadedDestination(Location destination)
-
getReturnWhenLoadedDestination
public Location getReturnWhenLoadedDestination()
-
getReturnWhenLoadedDestinationName
public java.lang.String getReturnWhenLoadedDestinationName()
-
setReturnWhenLoadedDestTrack
public void setReturnWhenLoadedDestTrack(Track track)
-
getReturnWhenLoadedDestTrack
public Track getReturnWhenLoadedDestTrack()
-
getReturnWhenLoadedDestTrackName
public java.lang.String getReturnWhenLoadedDestTrackName()
-
isRwlEnabled
protected boolean isRwlEnabled()
Used to determine is car has been given a Return When Loaded (RWL) address or custom load- Returns:
- true if car has RWL
-
setRoutePath
public void setRoutePath(java.lang.String routePath)
-
getRoutePath
public java.lang.String getRoutePath()
-
setCaboose
public void setCaboose(boolean caboose)
-
isCaboose
public boolean isCaboose()
-
setUtility
public void setUtility(boolean utility)
-
isUtility
public boolean isUtility()
-
isLocalMove
public boolean isLocalMove()
Used to determine if car is performing a local move. A local move is when a car is moved to a different track at the same location. Car has to be assigned to a train.- Returns:
- true if local move
-
setKernel
public void setKernel(Kernel kernel)
A kernel is a group of cars that are switched as a unit.- Parameters:
kernel
- The assigned Kernel for this car.
-
getKernelName
public java.lang.String getKernelName()
-
isLead
public boolean isLead()
Used to determine if car is lead car in a kernel- Returns:
- true if lead car in a kernel
-
updateKernel
public void updateKernel()
Updates all cars in a kernel. After the update, the cars will all have the same final destination, load, and route path.
-
checkDestination
public java.lang.String checkDestination(Location destination, Track track)
Used to determine if a car can be set out at a destination (location). Track is optional. In addition to all of the tests that checkDestination performs, spurs with schedules are also checked.- Overrides:
checkDestination
in classRollingStock
- Parameters:
destination
- The Location.track
- The Track at destination.- Returns:
- status OKAY, TYPE, ROAD, LENGTH, ERROR_TRACK, CAPACITY, SCHEDULE, CUSTOM
-
setDestination
public java.lang.String setDestination(Location destination, Track track)
Sets the car's destination on the layout- Overrides:
setDestination
in classRollingStock
- Parameters:
track
- (yard, spur, staging, or interchange track)destination
- The Location.- Returns:
- "okay" if successful, "type" if the rolling stock's type isn't acceptable, or "length" if the rolling stock length didn't fit, or Schedule if the destination will not accept the car because the spur has a schedule and the car doesn't meet the schedule requirements. Also changes the car load status when the car reaches its destination.
-
setDestination
public java.lang.String setDestination(Location destination, Track track, boolean force)
Sets the car's destination on the layout- Overrides:
setDestination
in classRollingStock
- Parameters:
track
- (yard, spur, staging, or interchange track)force
- when true ignore track length, type, and road when setting destinationdestination
- The Location.- Returns:
- "okay" if successful, "type" if the rolling stock's type isn't acceptable, or "length" if the rolling stock length didn't fit, or Schedule if the destination will not accept the car because the spur has a schedule and the car doesn't meet the schedule requirements. Also changes the car load status when the car reaches its destination.
-
loadNext
public void loadNext(ScheduleItem scheduleItem)
Called when setting a car's destination to this spur. Loads the car with a final destination which is the ship address for the schedule item.- Parameters:
scheduleItem
- The schedule item to be applied this this car
-
loadNext
public void loadNext(Track track)
Called when car is delivered to track. Updates the car's wait, pickup day, and load if spur. If staging, can swap default loads, force load to default empty, or replace custom loads with the default empty load. Can trigger RWE or RWL.- Parameters:
track
- the destination track for this car
-
updateLoad
public void updateLoad(Track track)
Updates a car's load when placed at a spur. Load change delayed if wait count is greater than zero.- Parameters:
track
- The spur the car is sitting on
-
getTypeExtensions
public java.lang.String getTypeExtensions()
-
reset
public void reset()
- Overrides:
reset
in classRollingStock
-
dispose
public void dispose()
Description copied from class:RollingStock
Remove rolling stock. Releases all listeners.- Overrides:
dispose
in classRollingStock
-
store
public org.jdom2.Element store()
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-cars.dtd.- Returns:
- Contents in a JDOM Element
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
- Overrides:
setDirtyAndFirePropertyChange
in classRollingStock
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Overrides:
propertyChange
in classRollingStock
-
-