jmri.jmrit.operations.rollingstock.cars
Class Car

java.lang.Object
  extended by jmri.jmrit.operations.rollingstock.RollingStock
      extended by jmri.jmrit.operations.rollingstock.cars.Car
All Implemented Interfaces:
PropertyChangeListener, EventListener

public class Car
extends RollingStock

Represents a car on the layout

Author:
Daniel Boudreau Copyright (C) 2008, 2009, 2010

Field Summary
protected  boolean _caboose
           
protected  boolean _fred
           
protected  boolean _hazardous
           
protected  Kernel _kernel
           
protected  String _load
           
protected  boolean _loadGeneratedByStaging
           
protected  Location _nextDestination
           
protected  Track _nextDestTrack
           
protected  String _nextLoad
           
protected  int _nextWait
           
protected  int _order
           
protected  boolean _passenger
           
protected  Location _previousNextDestination
           
protected  Track _previousNextDestTrack
           
protected  Location _rweDestination
           
protected  Track _rweDestTrack
           
protected  String _scheduleId
           
protected  int _wait
           
static String CAPACITY
           
static String CUSTOM
           
static String LOAD_CHANGED_PROPERTY
           
static String NEXT_DESTINATION_CHANGED_PROPERTY
           
static String NEXT_DESTINATION_TRACK_CHANGED_PROPERTY
           
static String NEXTWAIT_CHANGED_PROPERTY
           
static String RETURN_WHEN_EMPTY_CHANGED_PROPERTY
           
static String SCHEDULE
           
static String WAIT_CHANGED_PROPERTY
           
 
Fields inherited from class jmri.jmrit.operations.rollingstock.RollingStock
_built, _color, _comment, _destination, _id, _length, _location, _locationUnknown, _moves, _number, _outOfService, _owner, _rfid, _road, _routeDestination, _routeId, _routeLocation, _trackDestination, _trackLocation, _train, _type, _value, _weight, _weightTons, COUPLER, DEFAULT_WEIGHT, DESTINATION_CHANGED_PROPERTY, DESTINATIONTRACK_CHANGED_PROPERTY, ERROR_TRACK, LENGTH_CHANGED_PROPERTY, LOCATION_CHANGED_PROPERTY, number, rb, TRACK_CHANGED_PROPERTY, TRAIN_CHANGED_PROPERTY, TYPE_CHANGED_PROPERTY
 
Constructor Summary
Car()
           
Car(Element e)
          Construct this Entry from XML.
Car(String road, String number)
           
 
Method Summary
 void dispose()
          Remove rolling stock.
 int getAdjustedWeightTons()
          Returns a car's weight adjusted for load.
 String getDropComment()
           
 Kernel getKernel()
           
 String getKernelName()
           
 String getLoad()
           
 Location getNextDestination()
           
 String getNextDestinationName()
           
 Track getNextDestTrack()
           
 String getNextDestTrackName()
           
 String getNextLoad()
           
 int getNextWait()
           
 int getOrder()
           
 String getPickupComment()
           
 Location getPreviousNextDestination()
           
 Track getPreviousNextDestTrack()
           
 String getPriority()
          Gets the car load's priority.
 Location getReturnWhenEmptyDestination()
           
 String getReturnWhenEmptyDestinationName()
           
 String getReturnWhenEmptyDestName()
           
 Track getReturnWhenEmptyDestTrack()
           
 String getReturnWhenEmptyDestTrackName()
           
 String getScheduleId()
           
 int getWait()
           
 String getWeightTons()
           
 boolean hasFred()
           
 boolean isCaboose()
           
 boolean isHazardous()
           
 boolean isLoadGeneratedFromStaging()
           
 boolean isPassenger()
           
 void propertyChange(PropertyChangeEvent e)
           
protected  void reset()
           
 void setCaboose(boolean caboose)
           
 String setDestination(Location destination, Track track)
          Sets the car's destination on the layout
 String setDestination(Location destination, Track track, boolean force)
          Sets the car's destination on the layout
 void setFred(boolean fred)
           
 void setHazardous(boolean hazardous)
           
 void setKernel(Kernel kernel)
          A kernel is a group of cars that are switched as a unit.
 void setLoad(String load)
           
 void setLoadGeneratedFromStaging(boolean fromStaging)
           
 void setNextDestination(Location destination)
          Sets the final destination for a car.
 void setNextDestTrack(Track track)
           
 void setNextLoad(String load)
           
 void setNextWait(int count)
           
 void setOrder(int number)
          This car's service order when placed at a track that considers car order.
 void setPassenger(boolean passenger)
           
 void setPreviousNextDestination(Location location)
           
 void setPreviousNextDestTrack(Track track)
           
 void setReturnWhenEmptyDestination(Location destination)
           
 void setReturnWhenEmptyDestTrack(Track track)
           
 void setScheduleId(String id)
           
 void setWait(int count)
           
 Element store()
          Create an XML element to represent this Entry.
 String testDestination(Location destination, Track track)
          Used to determine if a car can be set out at a destination (location).
 String testSchedule(Track track)
           
 void updateKernel()
           
 
Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStock
addPropertyChangeListener, createId, firePropertyChange, getBuilt, getColor, getComment, getDestination, getDestinationId, getDestinationName, getDestinationTrack, getDestinationTrackId, getDestinationTrackName, getId, getLength, getLocation, getLocationId, getLocationName, getMoves, getNumber, getOwner, getRfid, getRoad, getRouteDestination, getRouteDestinationId, getRouteLocation, getRouteLocationId, getSavedRouteId, getStatus, getTrack, getTrackId, getTrackName, getTrain, getTrainName, getType, getValue, getWeight, isLocationUnknown, isOutOfService, moveRollingStock, removePropertyChangeListener, rollingStock, setBuilt, setColor, setComment, setDestination, setDestinationTrack, setLength, setLocation, setLocation, setLocation, setLocationUnknown, setMoves, setNumber, setOutOfService, setOwner, setRfid, setRoad, setRouteDestination, setRouteLocation, setSavedRouteId, setTrack, setTrain, setType, setValue, setWeight, setWeightTons, store, testLocation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_passenger

protected boolean _passenger

_hazardous

protected boolean _hazardous

_caboose

protected boolean _caboose

_fred

protected boolean _fred

_loadGeneratedByStaging

protected boolean _loadGeneratedByStaging

_kernel

protected Kernel _kernel

_load

protected String _load

_wait

protected int _wait

_order

protected int _order

_rweDestination

protected Location _rweDestination

_rweDestTrack

protected Track _rweDestTrack

_scheduleId

protected String _scheduleId

_nextLoad

protected String _nextLoad

_nextWait

protected int _nextWait

_nextDestination

protected Location _nextDestination

_nextDestTrack

protected Track _nextDestTrack

_previousNextDestination

protected Location _previousNextDestination

_previousNextDestTrack

protected Track _previousNextDestTrack

LOAD_CHANGED_PROPERTY

public static final String LOAD_CHANGED_PROPERTY
See Also:
Constant Field Values

WAIT_CHANGED_PROPERTY

public static final String WAIT_CHANGED_PROPERTY
See Also:
Constant Field Values

NEXTWAIT_CHANGED_PROPERTY

public static final String NEXTWAIT_CHANGED_PROPERTY
See Also:
Constant Field Values

NEXT_DESTINATION_CHANGED_PROPERTY

public static final String NEXT_DESTINATION_CHANGED_PROPERTY
See Also:
Constant Field Values

NEXT_DESTINATION_TRACK_CHANGED_PROPERTY

public static final String NEXT_DESTINATION_TRACK_CHANGED_PROPERTY
See Also:
Constant Field Values

RETURN_WHEN_EMPTY_CHANGED_PROPERTY

public static final String RETURN_WHEN_EMPTY_CHANGED_PROPERTY
See Also:
Constant Field Values

SCHEDULE

public static final String SCHEDULE

CUSTOM

public static final String CUSTOM

CAPACITY

public static final String CAPACITY
Constructor Detail

Car

public Car()

Car

public Car(String road,
           String number)

Car

public Car(Element e)
Construct this Entry from XML. This member has to remain synchronized with the detailed DTD in operations-cars.dtd

Parameters:
e - Car XML element
Method Detail

setHazardous

public void setHazardous(boolean hazardous)

isHazardous

public boolean isHazardous()

setPassenger

public void setPassenger(boolean passenger)

isPassenger

public boolean isPassenger()

setFred

public void setFred(boolean fred)

hasFred

public boolean hasFred()

setLoad

public void setLoad(String load)

getLoad

public String getLoad()

getPriority

public String getPriority()
Gets the car load's priority.

Overrides:
getPriority in class RollingStock

getPickupComment

public String getPickupComment()

getDropComment

public String getDropComment()

setLoadGeneratedFromStaging

public void setLoadGeneratedFromStaging(boolean fromStaging)

isLoadGeneratedFromStaging

public boolean isLoadGeneratedFromStaging()

setScheduleId

public void setScheduleId(String id)

getScheduleId

public String getScheduleId()

setNextLoad

public void setNextLoad(String load)

getNextLoad

public String getNextLoad()

getWeightTons

public String getWeightTons()
Overrides:
getWeightTons in class RollingStock

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 class RollingStock

setWait

public void setWait(int count)

getWait

public int getWait()

setOrder

public void setOrder(int number)
This car's service order when placed at a track that considers car order. There are two track orders, FIFO and LIFO. Car's with the lowest numbers are serviced first when placed at a track in FIFO mode. Car's with the highest numbers are serviced first when place at a track in LIFO mode.

Parameters:
number - The assigned service order for this car.

getOrder

public int getOrder()

setNextWait

public void setNextWait(int count)

getNextWait

public int getNextWait()

setNextDestination

public void setNextDestination(Location destination)
Sets the final destination for a car.

Parameters:
destination - The final destination for this car.

getNextDestination

public Location getNextDestination()

getNextDestinationName

public String getNextDestinationName()

setNextDestTrack

public void setNextDestTrack(Track track)

getNextDestTrack

public Track getNextDestTrack()

getNextDestTrackName

public String getNextDestTrackName()

setPreviousNextDestination

public void setPreviousNextDestination(Location location)

getPreviousNextDestination

public Location getPreviousNextDestination()

setPreviousNextDestTrack

public void setPreviousNextDestTrack(Track track)

getPreviousNextDestTrack

public Track getPreviousNextDestTrack()

setReturnWhenEmptyDestination

public void setReturnWhenEmptyDestination(Location destination)

getReturnWhenEmptyDestination

public Location getReturnWhenEmptyDestination()

getReturnWhenEmptyDestinationName

public String getReturnWhenEmptyDestinationName()

setReturnWhenEmptyDestTrack

public void setReturnWhenEmptyDestTrack(Track track)

getReturnWhenEmptyDestTrack

public Track getReturnWhenEmptyDestTrack()

getReturnWhenEmptyDestTrackName

public String getReturnWhenEmptyDestTrackName()

getReturnWhenEmptyDestName

public String getReturnWhenEmptyDestName()

setCaboose

public void setCaboose(boolean caboose)

isCaboose

public boolean isCaboose()

setKernel

public void setKernel(Kernel kernel)
A kernel is a group of cars that are switched as a unit.

Parameters:
kernel -

getKernel

public Kernel getKernel()

getKernelName

public String getKernelName()

testDestination

public String testDestination(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 testLocation performs, spurs with schedules are also checked.

Overrides:
testDestination in class RollingStock
Returns:
status OKAY, TYPE, ROAD, LENGTH, ERROR_TRACK

testSchedule

public String testSchedule(Track track)

setDestination

public String setDestination(Location destination,
                             Track track)
Sets the car's destination on the layout

Overrides:
setDestination in class RollingStock
Parameters:
destination -
track - (yard, spur, staging, or interchange track)
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 String setDestination(Location destination,
                             Track track,
                             boolean force)
Sets the car's destination on the layout

Overrides:
setDestination in class RollingStock
Parameters:
destination -
track - (yard, spur, staging, or interchange track)
force - when true ignore track length, type, & road when setting destination
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.

updateKernel

public void updateKernel()

reset

protected void reset()
Overrides:
reset in class RollingStock

dispose

public void dispose()
Description copied from class: RollingStock
Remove rolling stock. Releases all listeners.

Overrides:
dispose in class RollingStock

store

public 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

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener
Overrides:
propertyChange in class RollingStock


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads