Class Engine
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.rollingstock.RollingStock
-
- jmri.jmrit.operations.rollingstock.engines.Engine
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,Identifiable
,PropertyChangeFirer
,PropertyChangeProvider
public class Engine extends RollingStock
Represents a locomotive on the layout
-
-
Field Summary
Fields Modifier and Type Field Description static int
B_UNIT_BLOCKING
(package private) EngineModels
engineModels
static java.lang.String
HP_CHANGED_PROPERTY
static int
NCE_REAR_BLOCK_NUMBER
(package private) boolean
verboseStore
-
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 check destination track to see if it will accept locomotivevoid
dispose()
Remove rolling stock.int
getBlocking()
B units that aren't part of a consist are blocked at the end.Consist
getConsist()
Get the consist for this locomotivejava.lang.String
getConsistName()
java.lang.String
getDccAddress()
Get the DCC address for this engine from the JMRI roster.java.lang.String
getHp()
int
getHpInteger()
java.lang.String
getLength()
gets the body length of the rolling stockjava.lang.String
getModel()
RosterEntry
getRosterEntry()
Get the RosterEntry for this engine from the JMRI roster.java.lang.String
getTypeName()
java.lang.String
getWeightTons()
boolean
isBunit()
boolean
isLead()
Used to determine if engine is lead engine in a consistprotected void
moveRollingStock(RouteLocation current, RouteLocation next)
Determine if there's a change in the lead locomotive.void
propertyChange(java.beans.PropertyChangeEvent e)
void
setBunit(boolean bUnit)
void
setConsist(Consist consist)
Place locomotive in a consistprotected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setHp(java.lang.String hp)
Set the locomotive horsepower rating for this locomotive's modelvoid
setLength(java.lang.String length)
Set the locomotive length for this locomotive's modelvoid
setModel(java.lang.String model)
Set the locomotive's model.void
setTypeName(java.lang.String type)
Set the locomotive type for this locomotive's modelvoid
setWeightTons(java.lang.String weight)
Set the locomotive weight for this locomotive's modelorg.jdom2.Element
store()
Create an XML element to represent this Entry.-
Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStock
createId, getAdjustedWeightTons, getBuilt, getColor, getComment, getDestination, getDestinationId, getDestinationName, getDestinationTrack, getDestinationTrackId, getDestinationTrackName, getDivision, getDivisionId, getDivisionName, getId, getIdTag, getLastDate, getLastLocationId, getLastLocationName, getLastMoveDate, getLastRouteId, getLastTrackId, getLastTrackName, 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, getValue, getWeight, getWhenLastSeen, getWhenLastSeenDate, getWhereLastSeen, getWhereLastSeenName, isLocationUnknown, isOutOfService, isSelected, reset, setBlocking, setBuilt, setColor, setComment, setDestination, setDestination, setDestination, setDestinationTrack, setDivision, setIdTag, setLastDate, setLastLocationId, setLastRouteId, setLastTrackId, setLocation, setLocation, setLocationUnknown, setMoves, setNumber, setOutOfService, setOwnerName, setRfid, setRoadName, setRouteDestination, setRouteLocation, setSelected, setTrack, setTrain, setValue, setWeight, 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
-
NCE_REAR_BLOCK_NUMBER
public static final int NCE_REAR_BLOCK_NUMBER
- See Also:
- Constant Field Values
-
B_UNIT_BLOCKING
public static final int B_UNIT_BLOCKING
- See Also:
- Constant Field Values
-
HP_CHANGED_PROPERTY
public static final java.lang.String HP_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
engineModels
EngineModels engineModels
-
verboseStore
boolean verboseStore
-
-
Method Detail
-
setModel
public void setModel(java.lang.String model)
Set the locomotive's model. Note a model has only one length, type, and horsepower rating.- Parameters:
model
- The string model name.
-
getModel
public java.lang.String getModel()
-
setTypeName
public void setTypeName(java.lang.String type)
Set the locomotive type for this locomotive's model- Overrides:
setTypeName
in classRollingStock
- Parameters:
type
- Locomotive type: Steam, Diesel, Gas Turbine, etc.
-
getTypeName
public java.lang.String getTypeName()
- Overrides:
getTypeName
in classRollingStock
-
setHp
public void setHp(java.lang.String hp)
Set the locomotive horsepower rating for this locomotive's model- Parameters:
hp
- locomotive horsepower
-
getHp
public java.lang.String getHp()
-
getHpInteger
public int getHpInteger()
-
setLength
public void setLength(java.lang.String length)
Set the locomotive length for this locomotive's model- Overrides:
setLength
in classRollingStock
- Parameters:
length
- locomotive length- See Also:
RollingStock.getTotalLength()
-
getLength
public java.lang.String getLength()
Description copied from class:RollingStock
gets the body length of the rolling stock- Overrides:
getLength
in classRollingStock
- Returns:
- length in feet or meters
- See Also:
RollingStock.getTotalLength()
-
setWeightTons
public void setWeightTons(java.lang.String weight)
Set the locomotive weight for this locomotive's model- Overrides:
setWeightTons
in classRollingStock
- Parameters:
weight
- locomotive weight
-
getWeightTons
public java.lang.String getWeightTons()
- Overrides:
getWeightTons
in classRollingStock
-
setBunit
public void setBunit(boolean bUnit)
-
isBunit
public boolean isBunit()
-
setConsist
public void setConsist(Consist consist)
Place locomotive in a consist- Parameters:
consist
- The Consist to use.
-
getConsist
public Consist getConsist()
Get the consist for this locomotive- Returns:
- null if locomotive isn't in a consist
-
getConsistName
public java.lang.String getConsistName()
-
getBlocking
public int getBlocking()
B units that aren't part of a consist are blocked at the end.- Overrides:
getBlocking
in classRollingStock
-
isLead
public boolean isLead()
Used to determine if engine is lead engine in a consist- Returns:
- true if lead engine in a consist
-
getDccAddress
public java.lang.String getDccAddress()
Get the DCC address for this engine from the JMRI roster. Does 4 attempts, 1st by road and number, 2nd by number, 3rd by dccAddress using the engine's road number, 4th by id.- Returns:
- dccAddress
-
getRosterEntry
public RosterEntry getRosterEntry()
Get the RosterEntry for this engine from the JMRI roster. Does 4 attempts, 1st by road and number, 2nd by number, 3rd by dccAddress using the engine's road number, 4th by id.- Returns:
- RosterEntry, can be null
-
checkDestination
public java.lang.String checkDestination(Location destination, Track track)
Used to check destination track to see if it will accept locomotive- Overrides:
checkDestination
in classRollingStock
- Parameters:
destination
- The Location.track
- The Track at destination.- Returns:
- status, see RollingStock.java
-
moveRollingStock
protected void moveRollingStock(RouteLocation current, RouteLocation next)
Determine if there's a change in the lead locomotive. There are two possible locations in a train's route. TODO this code places the last loco added to the train as the lead. It would be better if the first one became the lead loco.- Overrides:
moveRollingStock
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-engines.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
-
-