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 intB_UNIT_BLOCKING(package private) EngineModelsengineModelsstatic java.lang.StringHP_CHANGED_PROPERTYstatic intNCE_REAR_BLOCK_NUMBER(package private) booleanverboseStore-
Fields inherited from class jmri.jmrit.operations.rollingstock.RollingStock
_blocking, _built, _clone, _cloneOrder, _color, _comment, _destination, _division, _id, _lastDate, _lastLocationId, _lastTrackId, _lastTrain, _length, _lengthChange, _location, _locationUnknown, _moves, _number, _outOfService, _owner, _pickupTime, _rfid, _road, _routeDestination, _routeId, _routeLocation, _selected, _setoutTime, _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.StringcheckDestination(Location destination, Track track)Used to check destination track to see if it will accept locomotivevoiddispose()Remove rolling stock.intgetBlocking()B units that aren't part of a consist are blocked at the end.ConsistgetConsist()Get the consist for this locomotivejava.lang.StringgetConsistName()java.lang.StringgetDccAddress()Get the DCC address for this engine from the JMRI roster.java.lang.StringgetHp()intgetHpInteger()java.lang.StringgetLength()gets the body length of the rolling stockjava.lang.StringgetModel()RosterEntrygetRosterEntry()Get the RosterEntry for this engine from the JMRI roster.java.lang.StringgetTypeName()java.lang.StringgetWeightTons()booleanisBunit()booleanisLead()Used to determine if engine is lead engine in a consistprotected voidmoveRollingStock(RouteLocation current, RouteLocation next)Determine if there's a change in the lead locomotive.voidpropertyChange(java.beans.PropertyChangeEvent e)voidsetBunit(boolean bUnit)voidsetConsist(Consist consist)Place locomotive in a consistprotected voidsetDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)voidsetHp(java.lang.String hp)Set the locomotive horsepower rating for this locomotive's modelvoidsetLength(java.lang.String length)Set the locomotive length for this locomotive's modelvoidsetModel(java.lang.String model)Set the locomotive's model.voidsetTypeName(java.lang.String type)Set the locomotive type for this locomotive's modelvoidsetWeightTons(java.lang.String weight)Set the locomotive weight for this locomotive's modelorg.jdom2.Elementstore()Create an XML element to represent this Entry.-
Methods inherited from class jmri.jmrit.operations.rollingstock.RollingStock
createId, getAdjustedWeightTons, getBuilt, getCloneOrder, getColor, getComment, getDestination, getDestinationId, getDestinationName, getDestinationTrack, getDestinationTrackId, getDestinationTrackName, getDivision, getDivisionId, getDivisionName, getId, getIdTag, getLastDate, getLastLocationId, getLastLocationName, getLastMoveDate, getLastRouteId, getLastTrackId, getLastTrackName, getLastTrain, getLastTrainName, getLengthInteger, getLocation, getLocationId, getLocationName, getMoves, getNumber, getOwnerName, getPickupTime, getRfid, getRoadName, getRouteDestination, getRouteDestinationId, getRouteLocation, getRouteLocationId, getSetoutTime, getSortDate, getSplitDestinationName, getSplitDestinationTrackName, getSplitLocationName, getSplitTrackName, getStatus, getTotalLength, getTrack, getTrackId, getTrackLastSeen, getTrackLastSeenName, getTrackName, getTrackType, getTrain, getTrainName, getValue, getWeight, getWhenLastSeen, getWhenLastSeenDate, getWhereLastSeen, getWhereLastSeenName, isClone, isLocationUnknown, isOutOfService, isSelected, reset, setBlocking, setBuilt, setClone, setCloneOrder, setColor, setComment, setDestination, setDestination, setDestination, setDestinationTrack, setDivision, setIdTag, setLastDate, setLastDate, setLastLocationId, setLastRouteId, setLastTrackId, setLastTrain, setLocation, setLocation, setLocationUnknown, setMoves, setNumber, setOutOfService, setOwnerName, setPickupTime, setRfid, setRoadName, setRouteDestination, setRouteLocation, setSelected, setSetoutTime, 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:
setTypeNamein classRollingStock- Parameters:
type- Locomotive type: Steam, Diesel, Gas Turbine, etc.
-
getTypeName
public java.lang.String getTypeName()
- Overrides:
getTypeNamein 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:
setLengthin classRollingStock- Parameters:
length- locomotive length- See Also:
RollingStock.getTotalLength()
-
getLength
public java.lang.String getLength()
Description copied from class:RollingStockgets the body length of the rolling stock- Overrides:
getLengthin 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:
setWeightTonsin classRollingStock- Parameters:
weight- locomotive weight
-
getWeightTons
public java.lang.String getWeightTons()
- Overrides:
getWeightTonsin 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:
getBlockingin 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:
checkDestinationin 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:
moveRollingStockin classRollingStock
-
dispose
public void dispose()
Description copied from class:RollingStockRemove rolling stock. Releases all listeners.- Overrides:
disposein 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:
setDirtyAndFirePropertyChangein classRollingStock
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener- Overrides:
propertyChangein classRollingStock
-
-