jmri.jmrit.operations.rollingstock
Class RollingStock

java.lang.Object
  extended by jmri.jmrit.operations.rollingstock.RollingStock
All Implemented Interfaces:
PropertyChangeListener, EventListener
Direct Known Subclasses:
Car, Engine

public class RollingStock
extends Object
implements PropertyChangeListener

Represents rolling stock, both powered (engines) and not powered (cars) on the layout.

Author:
Daniel Boudreau Copyright (C) 2009, 2010

Field Summary
protected  String _built
           
protected  String _color
           
protected  String _comment
           
protected  Location _destination
           
protected  String _id
           
protected  String _length
           
protected  Location _location
           
protected  boolean _locationUnknown
           
protected  int _moves
           
protected  String _number
           
protected  boolean _outOfService
           
protected  String _owner
           
protected  String _rfid
           
protected  String _road
           
protected  RouteLocation _routeDestination
           
protected  String _routeId
           
protected  RouteLocation _routeLocation
           
protected  Track _trackDestination
           
protected  Track _trackLocation
           
protected  Train _train
           
protected  String _type
           
protected  String _value
           
protected  String _weight
           
protected  String _weightTons
           
static int COUPLER
           
protected static String DEFAULT_WEIGHT
           
static String DESTINATION_CHANGED_PROPERTY
           
static String DESTINATIONTRACK_CHANGED_PROPERTY
           
static String ERROR_TRACK
           
static String LENGTH_CHANGED_PROPERTY
           
static String LOCATION_CHANGED_PROPERTY
           
 int number
           
protected static ResourceBundle rb
           
static String TRACK_CHANGED_PROPERTY
           
static String TRAIN_CHANGED_PROPERTY
           
static String TYPE_CHANGED_PROPERTY
           
 
Constructor Summary
RollingStock()
           
RollingStock(String road, String number)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
static String createId(String road, String number)
           
 void dispose()
          Remove rolling stock.
protected  void firePropertyChange(String p, Object old, Object n)
           
 int getAdjustedWeightTons()
           
 String getBuilt()
           
 String getColor()
           
 String getComment()
           
 Location getDestination()
           
 String getDestinationId()
           
 String getDestinationName()
           
 Track getDestinationTrack()
           
 String getDestinationTrackId()
           
 String getDestinationTrackName()
           
 String getId()
           
 String getLength()
           
 Location getLocation()
           
 String getLocationId()
          Get rolling stock's location id
 String getLocationName()
          Get rolling stock's location name
 int getMoves()
           
 String getNumber()
           
 String getOwner()
           
 String getPriority()
           
 String getRfid()
           
 String getRoad()
           
 RouteLocation getRouteDestination()
           
 String getRouteDestinationId()
           
 RouteLocation getRouteLocation()
           
 String getRouteLocationId()
           
 String getSavedRouteId()
           
 String getStatus()
           
 Track getTrack()
           
 String getTrackId()
          Get rolling stock's track id
 String getTrackName()
          Get rolling stock's track name
 Train getTrain()
           
 String getTrainName()
           
 String getType()
           
 String getValue()
           
 String getWeight()
           
 String getWeightTons()
           
 boolean isLocationUnknown()
           
 boolean isOutOfService()
           
 void moveRollingStock(RouteLocation old, RouteLocation next)
           
 void propertyChange(PropertyChangeEvent e)
           
 void removePropertyChangeListener(PropertyChangeListener l)
           
protected  void reset()
           
 void rollingStock(Element e)
          Construct this Entry from XML.
 void setBuilt(String built)
           
 void setColor(String color)
           
 void setComment(String comment)
           
 void setDestination(Location destination)
          Sets rolling stock destination without reserving destination track space or drop count.
 String setDestination(Location destination, Track track)
          Sets rolling stock destination on the layout
 String setDestination(Location destination, Track track, boolean force)
          Sets rolling stock destination on the layout
 void setDestinationTrack(Track track)
          Sets rolling stock destination track without reserving destination track space or drop count.
 void setLength(String length)
          Sets the length of the rolling stock.
 void setLocation(Location location)
          Set the rolling stock's location.
 String setLocation(Location location, Track track)
          Sets rolling stock location on the layout
 String setLocation(Location location, Track track, boolean force)
          Sets rolling stock location on the layout
 void setLocationUnknown(boolean unknown)
          Set the rolling stock location as unknown.
 void setMoves(int moves)
           
 void setNumber(String number)
          Set the rolling stock identification or road number
 void setOutOfService(boolean outOfService)
          Sets the rolling stock service state.
 void setOwner(String owner)
           
 void setRfid(String id)
          Sets the RFID for this rolling stock.
 void setRoad(String road)
           
 void setRouteDestination(RouteLocation routeDestination)
          Set where in a train's route this rolling stock will be set out.
 void setRouteLocation(RouteLocation routeLocation)
          Sets the location where the rolling stock will be picked up by the train.
 void setSavedRouteId(String id)
           
 void setTrack(Track track)
          Set the rolling stock's track.
 void setTrain(Train train)
          Sets the train that will service this rolling stock.
 void setType(String type)
           
 void setValue(String value)
          Sets the value (cost, price) for this rolling stock.
 void setWeight(String weight)
           
 void setWeightTons(String weight)
           
 Element store(Element e)
          Add XML elements to represent this Entry.
 String testDestination(Location destination, Track track)
          Used to check destination track to see if it will accept rolling stock
 String testLocation(Location location, Track track)
           
 String toString()
          For combobox and identification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rb

protected static final ResourceBundle rb

DEFAULT_WEIGHT

protected static final String DEFAULT_WEIGHT
See Also:
Constant Field Values

_id

protected String _id

_number

protected String _number

_road

protected String _road

_type

protected String _type

_length

protected String _length

_color

protected String _color

_weight

protected String _weight

_weightTons

protected String _weightTons

_built

protected String _built

_owner

protected String _owner

_comment

protected String _comment

_routeId

protected String _routeId

_rfid

protected String _rfid

_value

protected String _value

_locationUnknown

protected boolean _locationUnknown

_outOfService

protected boolean _outOfService

_location

protected Location _location

_trackLocation

protected Track _trackLocation

_destination

protected Location _destination

_trackDestination

protected Track _trackDestination

_train

protected Train _train

_routeLocation

protected RouteLocation _routeLocation

_routeDestination

protected RouteLocation _routeDestination

_moves

protected int _moves

number

public int number

ERROR_TRACK

public static final String ERROR_TRACK
See Also:
Constant Field Values

LOCATION_CHANGED_PROPERTY

public static final String LOCATION_CHANGED_PROPERTY
See Also:
Constant Field Values

TRACK_CHANGED_PROPERTY

public static final String TRACK_CHANGED_PROPERTY
See Also:
Constant Field Values

DESTINATION_CHANGED_PROPERTY

public static final String DESTINATION_CHANGED_PROPERTY
See Also:
Constant Field Values

DESTINATIONTRACK_CHANGED_PROPERTY

public static final String DESTINATIONTRACK_CHANGED_PROPERTY
See Also:
Constant Field Values

TRAIN_CHANGED_PROPERTY

public static final String TRAIN_CHANGED_PROPERTY
See Also:
Constant Field Values

LENGTH_CHANGED_PROPERTY

public static final String LENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

TYPE_CHANGED_PROPERTY

public static final String TYPE_CHANGED_PROPERTY
See Also:
Constant Field Values

COUPLER

public static final int COUPLER
See Also:
Constant Field Values
Constructor Detail

RollingStock

public RollingStock()

RollingStock

public RollingStock(String road,
                    String number)
Method Detail

createId

public static String createId(String road,
                              String number)

getId

public String getId()

setNumber

public void setNumber(String number)
Set the rolling stock identification or road number

Parameters:
number -

getNumber

public String getNumber()

setRoad

public void setRoad(String road)

getRoad

public String getRoad()

toString

public String toString()
For combobox and identification

Overrides:
toString in class Object

setType

public void setType(String type)

getType

public String getType()

setLength

public void setLength(String length)
Sets the length of the rolling stock.

Parameters:
length -

getLength

public String getLength()

setColor

public void setColor(String color)

getColor

public String getColor()

setWeight

public void setWeight(String weight)
Parameters:
weight - rolling stock weight in ounces.

getWeight

public String getWeight()

setWeightTons

public void setWeightTons(String weight)
Parameters:
weight - full scale rolling stock weight in tons.

getWeightTons

public String getWeightTons()

getAdjustedWeightTons

public int getAdjustedWeightTons()

setBuilt

public void setBuilt(String built)

getBuilt

public String getBuilt()

getStatus

public String getStatus()

getLocation

public Location getLocation()

setLocation

public void setLocation(Location location)
Set the rolling stock's location. Doesn't do any checking and does not fire a property change. Used exclusively by the Router code. Use setLocation(Location, Track) instead.

Parameters:
location - where to set the rolling stock.

getLocationName

public String getLocationName()
Get rolling stock's location name

Returns:
empty string if rolling stock isn't on layout

getLocationId

public String getLocationId()
Get rolling stock's location id

Returns:
empty string if rolling stock isn't on the layout

getTrack

public Track getTrack()

setTrack

public void setTrack(Track track)
Set the rolling stock's track. Doesn't do any checking and does not fire a property change. Used exclusively by the Router code. Use setLocation(Location, Track) instead.

Parameters:
track - to place the rolling stock on.

getTrackName

public String getTrackName()
Get rolling stock's track name

Returns:
empty string if rolling stock isn't on a track

getTrackId

public String getTrackId()
Get rolling stock's track id

Returns:
empty string if rolling stock isn't on a track

setLocation

public String setLocation(Location location,
                          Track track)
Sets rolling stock location on the layout

Parameters:
location -
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.

setLocation

public String setLocation(Location location,
                          Track track,
                          boolean force)
Sets rolling stock location on the layout

Parameters:
location -
track - (yard, spur, staging, or interchange track)
force - when true place rolling stock ignore track length, type, & road
Returns:
"okay" if successful, "type" if the rolling stock's type isn't acceptable, "road" if rolling stock road isn't acceptable, or "length" if the rolling stock length didn't fit.

testLocation

public String testLocation(Location location,
                           Track track)

setDestination

public String setDestination(Location destination,
                             Track track)
Sets rolling stock destination on the layout

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.

setDestination

public String setDestination(Location destination,
                             Track track,
                             boolean force)
Sets rolling stock destination on the layout

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.

testDestination

public String testDestination(Location destination,
                              Track track)
Used to check destination track to see if it will accept rolling stock

Parameters:
destination -
track -
Returns:
status OKAY, TYPE, ROAD, LENGTH, ERROR_TRACK

getDestination

public Location getDestination()

setDestination

public void setDestination(Location destination)
Sets rolling stock destination without reserving destination track space or drop count. Does not fire a property change. Used by car router to test destinations. Use setDestination(Location, Track) instead.

Parameters:
destination - for the rolling stock

getDestinationName

public String getDestinationName()

getDestinationId

public String getDestinationId()

setDestinationTrack

public void setDestinationTrack(Track track)
Sets rolling stock destination track without reserving destination track space or drop count. Used by car router to test destinations. Does not fire a property change. Use setDestination(Location, Track) instead.

Parameters:
track -

getDestinationTrack

public Track getDestinationTrack()

getDestinationTrackName

public String getDestinationTrackName()

getDestinationTrackId

public String getDestinationTrackId()

setMoves

public void setMoves(int moves)

getMoves

public int getMoves()

setTrain

public void setTrain(Train train)
Sets the train that will service this rolling stock.

Parameters:
train -

getTrain

public Train getTrain()

getTrainName

public String getTrainName()

setRouteLocation

public void setRouteLocation(RouteLocation routeLocation)
Sets the location where the rolling stock will be picked up by the train.

Parameters:
routeLocation - the pick up location for this rolling stock.

getRouteLocation

public RouteLocation getRouteLocation()

getRouteLocationId

public String getRouteLocationId()

getSavedRouteId

public String getSavedRouteId()

setSavedRouteId

public void setSavedRouteId(String id)

getValue

public String getValue()

setValue

public void setValue(String value)
Sets the value (cost, price) for this rolling stock. Currently has nothing to do with operations. But nice to have.

Parameters:
value - a string representing what this item is worth.

getRfid

public String getRfid()

setRfid

public void setRfid(String id)
Sets the RFID for this rolling stock.

Parameters:
id - 12 character RFID string.

setRouteDestination

public void setRouteDestination(RouteLocation routeDestination)
Set where in a train's route this rolling stock will be set out.

Parameters:
routeDestination - the location where the rolling stock is to leave the train.

getRouteDestination

public RouteLocation getRouteDestination()

getRouteDestinationId

public String getRouteDestinationId()

setOwner

public void setOwner(String owner)

getOwner

public String getOwner()

setLocationUnknown

public void setLocationUnknown(boolean unknown)
Set the rolling stock location as unknown.

Parameters:
unknown - when true, the rolling stock location is unknown.

isLocationUnknown

public boolean isLocationUnknown()
Returns:
true when car's location is unknown

setOutOfService

public void setOutOfService(boolean outOfService)
Sets the rolling stock service state. When true, rolling stock is out of service. Normal state is false, the rolling stock is in service and available.

Parameters:
outOfService - when true, out of service

isOutOfService

public boolean isOutOfService()
Returns:
true when rolling stock is out of service

getPriority

public String getPriority()

setComment

public void setComment(String comment)

getComment

public String getComment()

moveRollingStock

public void moveRollingStock(RouteLocation old,
                             RouteLocation next)

reset

protected void reset()

dispose

public void dispose()
Remove rolling stock. Releases all listeners.


rollingStock

public void rollingStock(Element e)
Construct this Entry from XML.

Parameters:
e - RollingStock XML element

store

public Element store(Element e)
Add XML elements to represent this Entry.

Returns:
Contents in a JDOM Element

propertyChange

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

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


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