Package jmri.implementation
Class DefaultCabSignal
- java.lang.Object
-
- jmri.implementation.DefaultCabSignal
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener,java.util.EventListener,CabSignal
- Direct Known Subclasses:
CbusCabSignal,LnCabSignal
public class DefaultCabSignal extends java.lang.Object implements CabSignal, java.beans.PropertyChangeListener
Default implementation of a Cab Signal Object, describing the state of the track ahead relative to a locomotive with a given address. This is effectively a mobile signal mast.
-
-
Constructor Summary
Constructors Constructor Description DefaultCabSignal(LocoAddress address)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener l)Add a listener for consist eventsvoiddispose()A method for cleaning up the cab signalprotected voidfirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)protected voidforwardAspectToLayout()Forward the command to the layout that sets the displayed signal aspect for this addressvoidforwardCabSignalToLayout()Forward the current cab signal value to the layout.BlockgetBlock()Get the Block position of the locomotive associated with the cab signal.java.util.List<Block>getBlockList()Get Block List to the end of Path or Signal Mast Stop, whichever first.LocoAddressgetCabSignalAddress()Get the LocoAddress associated with the consistBlockgetNextBlock()Get the Next Block the locomotive is expected to enter.SignalMastgetNextMast()Get the Next Signal Mast the locomotive is expected to pass.booleanisCabSignalActive()voidpropertyChange(java.beans.PropertyChangeEvent event)voidremovePropertyChangeListener(java.beans.PropertyChangeListener l)Remove a listener for cab signal eventsprotected voidresetLayoutCabSignal()Forward the command to the layout that clears any displayed signal for this addressvoidsetBlock()Set the Block of the locomotive by searching the block list.voidsetBlock(Block position)Set the Block of the locomotivevoidsetCabSignalActive(boolean active)voidsetMasterCabSigPauseActive(boolean active)java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultCabSignal
public DefaultCabSignal(LocoAddress address)
-
-
Method Detail
-
dispose
@OverridingMethodsMustInvokeSuper public void dispose()
A method for cleaning up the cab signal
-
getCabSignalAddress
public LocoAddress getCabSignalAddress()
Get the LocoAddress associated with the consist- Specified by:
getCabSignalAddressin interfaceCabSignal- Returns:
- the cab signal address
-
setBlock
public void setBlock()
Set the Block of the locomotive by searching the block list.
-
getBlock
public Block getBlock()
Get the Block position of the locomotive associated with the cab signal.
-
getNextBlock
public Block getNextBlock()
Get the Next Block the locomotive is expected to enter. This value is calculated from the current block and direction of travel.- Specified by:
getNextBlockin interfaceCabSignal- Returns:
- The next Block position
-
getNextMast
public SignalMast getNextMast()
Get the Next Signal Mast the locomotive is expected to pass. This value is calculated from the current block and direction of travel.- Specified by:
getNextMastin interfaceCabSignal- Returns:
- The next SignalMast position
-
getBlockList
@Nonnull public java.util.List<Block> getBlockList()
Get Block List to the end of Path or Signal Mast Stop, whichever first. The first Block in the list ( if any ), will be the current Block.- Specified by:
getBlockListin interfaceCabSignal- Returns:
- list of Blocks that the loco address is expected to traverse.
-
forwardCabSignalToLayout
public void forwardCabSignalToLayout()
Forward the current cab signal value to the layout.- Specified by:
forwardCabSignalToLayoutin interfaceCabSignal
-
forwardAspectToLayout
protected void forwardAspectToLayout()
Forward the command to the layout that sets the displayed signal aspect for this address
-
isCabSignalActive
public boolean isCabSignalActive()
- Specified by:
isCabSignalActivein interfaceCabSignal
-
setCabSignalActive
public void setCabSignalActive(boolean active)
- Specified by:
setCabSignalActivein interfaceCabSignal
-
setMasterCabSigPauseActive
public void setMasterCabSigPauseActive(boolean active)
- Specified by:
setMasterCabSigPauseActivein interfaceCabSignal
-
resetLayoutCabSignal
protected void resetLayoutCabSignal()
Forward the command to the layout that clears any displayed signal for this address
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a listener for consist events- Specified by:
addPropertyChangeListenerin interfaceCabSignal- Parameters:
l- is a PropertyChangeListener object
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a listener for cab signal events- Specified by:
removePropertyChangeListenerin interfaceCabSignal- Parameters:
l- is a PropertyChangeListener object
-
firePropertyChange
protected void firePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent event)
- Specified by:
propertyChangein interfacejava.beans.PropertyChangeListener
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-