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 void
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a listener for consist eventsvoid
dispose()
A method for cleaning up the cab signalprotected void
firePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
protected void
forwardAspectToLayout()
Forward the command to the layout that sets the displayed signal aspect for this addressvoid
forwardCabSignalToLayout()
Forward the current cab signal value to the layout.Block
getBlock()
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.LocoAddress
getCabSignalAddress()
Get the LocoAddress associated with the consistBlock
getNextBlock()
Get the Next Block the locomotive is expected to enter.SignalMast
getNextMast()
Get the Next Signal Mast the locomotive is expected to pass.boolean
isCabSignalActive()
void
propertyChange(java.beans.PropertyChangeEvent event)
void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a listener for cab signal eventsprotected void
resetLayoutCabSignal()
Forward the command to the layout that clears any displayed signal for this addressvoid
setBlock()
Set the Block of the locomotive by searching the block list.void
setBlock(Block position)
Set the Block of the locomotivevoid
setCabSignalActive(boolean active)
void
setMasterCabSigPauseActive(boolean active)
java.lang.String
toString()
-
-
-
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:
getCabSignalAddress
in 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:
getNextBlock
in 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:
getNextMast
in 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:
getBlockList
in 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:
forwardCabSignalToLayout
in 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:
isCabSignalActive
in interfaceCabSignal
-
setCabSignalActive
public void setCabSignalActive(boolean active)
- Specified by:
setCabSignalActive
in interfaceCabSignal
-
setMasterCabSigPauseActive
public void setMasterCabSigPauseActive(boolean active)
- Specified by:
setMasterCabSigPauseActive
in 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:
addPropertyChangeListener
in interfaceCabSignal
- Parameters:
l
- is a PropertyChangeListener object
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a listener for cab signal events- Specified by:
removePropertyChangeListener
in 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:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-