Package jmri.implementation
Class DefaultSignalMastLogic
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.DefaultSignalMastLogic
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener,java.lang.Comparable<NamedBean>,java.util.EventListener,PropertyChangeProvider,NamedBean,SignalMastLogic
public class DefaultSignalMastLogic extends AbstractNamedBean implements SignalMastLogic, java.beans.VetoableChangeListener
Default implementation ofSignalMastLogic.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) SignalMastdestination(package private) java.util.Hashtable<SignalMast,jmri.implementation.DefaultSignalMastLogic.DestinationMast>destList(package private) booleandisposing(package private) LayoutEditoreditor(package private) LayoutBlockfacingBlock(package private) booleaninWait(package private) LayoutBlockremoteProtectingBlock(package private) SignalMastsource(package private) java.lang.StringstopAspect-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN
-
Fields inherited from interface jmri.SignalMastLogic
PROPERTY_AUTO_BLOCKS, PROPERTY_AUTO_MASTS, PROPERTY_AUTO_TURNOUTS, PROPERTY_BLOCKS, PROPERTY_LENGTH, PROPERTY_MASTS, PROPERTY_SENSORS, PROPERTY_TURNOUTS, PROPERTY_UPDATED_DESTINATION, PROPERTY_UPDATED_SOURCE, STOREALL, STOREMASTSONLY, STORENONE
-
-
Constructor Summary
Constructors Constructor Description DefaultSignalMastLogic(SignalMast source)Initialise a Signal Mast Logic for a given source Signal Mast.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSensor(java.lang.String sensorName, int state, SignalMast destination)Add an individual control Sensor and its set to state to the Signal Mast Logic.voidallowAutoMaticSignalMastGeneration(boolean allow, SignalMast destination)Sets whether we should allow the system to automatically generate a list of signal masts that could cause a conflicting route.booleanallowAutoMaticSignalMastGeneration(SignalMast destination)Query if we are allowing the system to automatically generate a list of conflicting Signal Mast that have a direct effect on our logic.voidallowTurnoutLock(boolean lock, SignalMast destination)Sets whether we should lock all turnouts between the source and destination signal masts when the logic goes active, to prevent them from being changed.booleanareBlocksIncluded(java.util.List<Block> blks)Returns true if any of the blocks in the supplied list are included in any of the logics that set this signal.(package private) booleancheckStates()Check if routes to the destination Signal Mast are clear.voiddisableLayoutEditorUse()voiddispose()Note: This does not stop any delayed operations that might be queued.SignalMastgetActiveDestination()Get the active destination Signal Mast for this Signal Mast Logic.SectiongetAssociatedSection(SignalMast destination)Return the Section configured between the source and destination mast.java.util.List<Block>getAutoBlocks(SignalMast destination)Return all the blocks that have been detected as being in use for this logic.java.util.List<Block>getAutoBlocksBetweenMasts(SignalMast destination)Return a list of blocks just that have been detected as being directly between the source and destination mast.intgetAutoBlockState(Block block, SignalMast destination)Return the Set State of a control block as it is configured between the source and destination mast.java.util.List<SignalMast>getAutoMasts(SignalMast destination)Return a list of control masts that have been automatically detected as being directly between the source and destination mast.java.lang.StringgetAutoSignalMastState(SignalMast mast, SignalMast destination)Return the Set State (Aspect) of a control mast as it is configured between the source and destination mast.java.util.List<Turnout>getAutoTurnouts(SignalMast destination)Return only the turnouts that have been detected as being directly between the source and destination mast.intgetAutoTurnoutState(Turnout turnout, SignalMast destination)Return the Set State of a control turnout as it is configured between the source and destination mast.java.lang.StringgetBeanType()For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.java.util.List<Block>getBlocks(SignalMast destination)Return the Layout Blocks that have been defined by the user to control the SML to the destination mast.intgetBlockState(Block block, SignalMast destination)Return the Set To State of a control block as it is configured between the source and destination mast.java.lang.StringgetComment(SignalMast dest)Get the comment set on this SML.java.util.List<SignalMast>getDestinationList()Return a list of all Signal Masts that have been configured as Destination Masts on this SML.LayoutBlockgetFacingBlock()Get the block defined as facing our source signal mast.floatgetMaximumSpeed(SignalMast destination)Get the Maximum Speed set for the destination Signal Mast in this SML.java.util.List<NamedBeanHandle<Sensor>>getNamedSensors(SignalMast destination)Return the Sensors that have been defined by the user to control the SML to the destination mast as NamedBeanHandles.java.util.List<NamedBeanHandle<Turnout>>getNamedTurnouts(SignalMast destination)Return the Turnouts that have been defined by the user to control the SML to the destination mast as NamedBeanHandles.LayoutBlockgetProtectingBlock(SignalMast dest)Get the block that the source signal is protecting on the path to the destination signal mast.java.util.List<Sensor>getSensors(SignalMast destination)Return the Sensors that have been defined by the user to control the SML to the destination mast.intgetSensorState(Sensor sensor, SignalMast destination)Return the Set To State of a control Sensor as it is configured between the source and destination mast.java.util.List<SignalMast>getSignalMasts(SignalMast destination)Return the Signal Masts that have been defined by the user to control the SML to the destination mast.java.lang.StringgetSignalMastState(SignalMast mast, SignalMast destination)Return the Set To State (Aspect) of a control Signal Mast as it is configured between the source and destination mast.SignalMastgetSourceMast()Get the Source Mast.intgetState()No valid integer state, always return a constant.intgetStoreState(SignalMast destination)Return where the signal mast logic should be stored, if so how much.java.util.List<Turnout>getTurnouts(SignalMast destination)Return the Turnouts that have been defined by the user to control the SML to the destination mast.intgetTurnoutState(Turnout turnout, SignalMast destination)Return the Set State of a control Turnout as it is configured between the source and destination mast.java.util.List<NamedBeanUsageReport>getUsageReport(NamedBean bean)Get a list of references for the specified bean.voidinitialise()General method to initialise all SMLs on the source SIgnal Mast using destListvoidinitialise(SignalMast destination)Initialise the signal mast after all the parameters have been set.booleanisActive(SignalMast dest)Query if the Signal Mast Logic from the current source signal mast to the destination signal mast is active.booleanisBlockIncluded(Block block, SignalMast destination)Check whether the Block is part of at least one of the logics.booleanisDestinationValid(SignalMast dest)Check if signal mast is a destination signal mast in one of the logicsbooleanisEnabled(SignalMast dest)Query if the Signal Mast Logic from the current source signal mast to the specified destination signal mast is enabled.booleanisSensorIncluded(Sensor sensor, SignalMast destination)Check if a sensor is part of at least one of the logics that set a SignalMast.booleanisSignalMastIncluded(SignalMast signal, SignalMast destination)Check if a signal mast is part of at least one of the logics that set another signal mast.booleanisTurnoutIncluded(Turnout turnout, SignalMast destination)Check if a turnout is part of at least one of the logics that set a signal mast.booleanisTurnoutLockAllowed(SignalMast destination)Query if we are allowing the system to lock turnouts when the logic goes active.voidremoveConflictingLogic(SignalMast sm, LevelXing lx)Remove control elements for a SML pair containing a destination signal mast that itself is incompatible with an SML around a level crossing.booleanremoveDestination(SignalMast dest)Remove the destination signal mast as a pair in this SML.voidremoveDirectionSensors()remove direction sensors from SML need to autoActiveTrains.voidremoveSensor(java.lang.String sensorName, SignalMast destination)Remove an individual control Sensor from the Signal Mast Logic.voidremoveSensor(Sensor sen, SignalMast destination)voidremoveTurnout(Turnout turn, SignalMast destination)voidreplaceDestinationMast(SignalMast oldMast, SignalMast newMast)Replace the existing destination Signal Mast with another signal mast.voidreplaceSourceMast(SignalMast oldMast, SignalMast newMast)Replace the existing source Signal Mast with another signal mast.voidsetAssociatedSection(Section sec, SignalMast destination)Define a Section between the source and destination mast.voidsetAutoBlocks(java.util.LinkedHashMap<Block,java.lang.Integer> blocks, SignalMast destination)Set which blocks must be in a given state for the signal mast not to be set to a Stop aspect.voidsetAutoMasts(java.util.Hashtable<SignalMast,java.lang.String> masts, SignalMast destination)Set which control signal masts must be in a given state before our source mast can be set.voidsetAutoTurnouts(java.util.Hashtable<Turnout,java.lang.Integer> turnouts, SignalMast destination)Set which turnouts must be set to a given state for the signal mast not to be set to a Stop aspect.voidsetBlocks(java.util.Hashtable<Block,java.lang.Integer> blocks, SignalMast destination)Set which blocks must be in a given state for the signal mast not to be set to a Stop aspect.voidsetComment(java.lang.String comment, SignalMast dest)Set the comment for this SML.voidsetConflictingLogic(SignalMast sm, LevelXing lx)Add control elements for a SML pair containing a destination signal mast that itself is skipped as it is incompatible with an SML around a level crossing.voidsetDestinationMast(SignalMast dest)Set the destination signal mast for this SML.voidsetDisabled(SignalMast dest)Set the logic to the destination signal mast to Disabled.voidsetEnabled(SignalMast dest)Set the logic to the destination signal mast to Enabled.voidsetFacingBlock(LayoutBlock facing)Set the block facing our source signal mast.(package private) voidsetMastAppearance()Evaluate the destination signal mast Aspect and set ours accordingly.voidsetMasts(java.util.Hashtable<SignalMast,java.lang.String> masts, SignalMast destination)Set which control signal masts must be in a given state before our source mast can be set.voidsetSensors(java.util.Hashtable<NamedBeanHandle<Sensor>,java.lang.Integer> sensors, SignalMast destination)Set which sensors must be in a given state before our source signal mast can be set.(package private) voidsetSignalAppearance()Before going active or checking that we can go active, wait 500ms for things to settle down to help prevent a race condition.voidsetState(int i)Provide generic access to internal state.voidsetStore(int store, SignalMast destination)Determine if the signal mast logic is stored in the panel file and if all the information is stored.voidsetTurnouts(java.util.Hashtable<NamedBeanHandle<Turnout>,java.lang.Integer> turnouts, SignalMast destination)Set the states that each control turnout must be in for the source signal mast not to be set to a Stop aspect.intsetupDirectionSensors()Add direction sensors to SMLvoidsetupLayoutEditorDetails()Set up a Signal Mast Logic from the Layout Editor panel where its source Signal Mast is present, when useLayoutEditor is set to true.java.util.LinkedHashMap<Block,java.lang.Integer>setupLayoutEditorTurnoutDetails(java.util.List<LayoutBlock> blks, SignalMast destination)Set the auto turnouts based upon a given list of layout blocks for a specific destination mast.voiduseLayoutEditor(boolean boo, SignalMast destination)Set whether this logic should use the details stored in the Layout Editor to determine which blocks, turnouts will make up the logic between the source and destination signal mast.booleanuseLayoutEditor(SignalMast destination)Query if we are using the Layout Editor panels to build the signal mast logic, blocks, turnouts.booleanuseLayoutEditorBlocks(SignalMast destination)Query if we are using the Layout Editor block information in the signal mast logic.voiduseLayoutEditorDetails(boolean turnouts, boolean blocks, SignalMast destination)Set whether this logic should use the information from the Layout Editor for either blocks or turnouts.booleanuseLayoutEditorTurnouts(SignalMast destination)Query if we are using the Layout Editor turnout information in the signal mast logic.voidvetoableChange(java.beans.PropertyChangeEvent evt)-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
-
Methods inherited from interface jmri.SignalMastLogic
addPropertyChangeListener, getNumPropertyChangeListeners, removePropertyChangeListener
-
-
-
-
Field Detail
-
source
SignalMast source
-
destination
SignalMast destination
-
stopAspect
java.lang.String stopAspect
-
destList
java.util.Hashtable<SignalMast,jmri.implementation.DefaultSignalMastLogic.DestinationMast> destList
-
editor
LayoutEditor editor
-
facingBlock
LayoutBlock facingBlock
-
remoteProtectingBlock
LayoutBlock remoteProtectingBlock
-
disposing
boolean disposing
-
inWait
volatile boolean inWait
-
-
Constructor Detail
-
DefaultSignalMastLogic
public DefaultSignalMastLogic(@Nonnull SignalMast source)
Initialise a Signal Mast Logic for a given source Signal Mast.- Parameters:
source- The Signal Mast we are configuring an SML for
-
-
Method Detail
-
setFacingBlock
public void setFacingBlock(LayoutBlock facing)
Set the block facing our source signal mast.- Specified by:
setFacingBlockin interfaceSignalMastLogic- Parameters:
facing- The Layout Block facing the source Signal Mast
-
getFacingBlock
public LayoutBlock getFacingBlock()
Get the block defined as facing our source signal mast.- Specified by:
getFacingBlockin interfaceSignalMastLogic- Returns:
- The Layout Block facing the source Signal Mast
-
getProtectingBlock
public LayoutBlock getProtectingBlock(@Nonnull SignalMast dest)
Get the block that the source signal is protecting on the path to the destination signal mast.- Specified by:
getProtectingBlockin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast- Returns:
- the Layout Block
-
getSourceMast
public SignalMast getSourceMast()
Get the Source Mast.- Specified by:
getSourceMastin interfaceSignalMastLogic- Returns:
- Signal Mast object.
-
replaceSourceMast
public void replaceSourceMast(SignalMast oldMast, SignalMast newMast)
Replace the existing source Signal Mast with another signal mast. This is for use with such tools as the Layout Editor where a signal mast in a certain location can be replaced with another, while the remainder of the configuration stays the same.- Specified by:
replaceSourceMastin interfaceSignalMastLogic- Parameters:
oldMast- Signal Mast currently configured as the source mastnewMast- Signal Mast to act as the replacement source mast
-
replaceDestinationMast
public void replaceDestinationMast(SignalMast oldMast, SignalMast newMast)
Replace the existing destination Signal Mast with another signal mast. This is for use with such tools as the Layout Editor where a signalmast in a certain location can be replaced with another, while the remainder of the configuration stays the same.- Specified by:
replaceDestinationMastin interfaceSignalMastLogic- Parameters:
oldMast- Signal Mast currently configured as the destination mastnewMast- Signal Mast to act as the replacement destination mast
-
setDestinationMast
public void setDestinationMast(SignalMast dest)
Set the destination signal mast for this SML.- Specified by:
setDestinationMastin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast
-
isDestinationValid
public boolean isDestinationValid(SignalMast dest)
Check if signal mast is a destination signal mast in one of the logics- Specified by:
isDestinationValidin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast- Returns:
- true if destination is a destination mast in this object
-
getDestinationList
public java.util.List<SignalMast> getDestinationList()
Return a list of all Signal Masts that have been configured as Destination Masts on this SML.- Specified by:
getDestinationListin interfaceSignalMastLogic- Returns:
- A list of Signal Mast objects
-
getComment
public java.lang.String getComment(SignalMast dest)
Get the comment set on this SML.- Specified by:
getCommentin interfaceSignalMastLogic- Parameters:
dest- the mast to get the comment from- Returns:
- the comment or an empty string
-
setComment
public void setComment(java.lang.String comment, SignalMast dest)
Set the comment for this SML.- Specified by:
setCommentin interfaceSignalMastLogic- Parameters:
comment- text to add as commentdest- signal mast to add comment to
-
setStore
public void setStore(int store, SignalMast destination)
Determine if the signal mast logic is stored in the panel file and if all the information is stored.- Specified by:
setStorein interfaceSignalMastLogic- Parameters:
store- one ofSignalMastLogic.STOREALL,SignalMastLogic.STOREMASTSONLYorSignalMastLogic.STORENONEdestination- controlled signal mast
-
getStoreState
public int getStoreState(SignalMast destination)
Return where the signal mast logic should be stored, if so how much.- Specified by:
getStoreStatein interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- one of
SignalMastLogic.STOREALL,SignalMastLogic.STOREMASTSONLYorSignalMastLogic.STORENONE
-
setEnabled
public void setEnabled(SignalMast dest)
Set the logic to the destination signal mast to Enabled.- Specified by:
setEnabledin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast
-
setDisabled
public void setDisabled(SignalMast dest)
Set the logic to the destination signal mast to Disabled.- Specified by:
setDisabledin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast
-
isEnabled
public boolean isEnabled(SignalMast dest)
Query if the Signal Mast Logic from the current source signal mast to the specified destination signal mast is enabled.- Specified by:
isEnabledin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast- Returns:
- true if enabled
-
isActive
public boolean isActive(SignalMast dest)
Query if the Signal Mast Logic from the current source signal mast to the destination signal mast is active.- Specified by:
isActivein interfaceSignalMastLogic- Parameters:
dest- controlled signal mast- Returns:
- true if active; false otherwise
-
getActiveDestination
public SignalMast getActiveDestination()
Get the active destination Signal Mast for this Signal Mast Logic.- Specified by:
getActiveDestinationin interfaceSignalMastLogic- Returns:
- the active signal mast or null if none
-
removeDestination
public boolean removeDestination(SignalMast dest)
Remove the destination signal mast as a pair in this SML.- Specified by:
removeDestinationin interfaceSignalMastLogic- Parameters:
dest- controlled signal mast- Returns:
- true if there are no more destination signal masts
-
disableLayoutEditorUse
public void disableLayoutEditorUse()
- Specified by:
disableLayoutEditorUsein interfaceSignalMastLogic
-
useLayoutEditor
public void useLayoutEditor(boolean boo, SignalMast destination) throws JmriException
Set whether this logic should use the details stored in the Layout Editor to determine which blocks, turnouts will make up the logic between the source and destination signal mast.- Specified by:
useLayoutEditorin interfaceSignalMastLogic- Parameters:
boo- Use the Layout Editor details to determine logic detailsdestination- the Destination Signal Mast- Throws:
JmriException- if a path on the layout editor is not valid
-
setupDirectionSensors
public int setupDirectionSensors()
Add direction sensors to SML- Specified by:
setupDirectionSensorsin interfaceSignalMastLogic- Returns:
- number of errors
-
removeDirectionSensors
public void removeDirectionSensors()
remove direction sensors from SML need to autoActiveTrains.- Specified by:
removeDirectionSensorsin interfaceSignalMastLogic
-
useLayoutEditor
public boolean useLayoutEditor(SignalMast destination)
Query if we are using the Layout Editor panels to build the signal mast logic, blocks, turnouts.- Specified by:
useLayoutEditorin interfaceSignalMastLogic- Parameters:
destination- Destination Signal Mast- Returns:
- true if we are using the Layout Editor to build the signal mast logic.
-
useLayoutEditorDetails
public void useLayoutEditorDetails(boolean turnouts, boolean blocks, SignalMast destination) throws JmriException
Set whether this logic should use the information from the Layout Editor for either blocks or turnouts.- Specified by:
useLayoutEditorDetailsin interfaceSignalMastLogic- Parameters:
turnouts- set false if not to use the turnout information gathered from the layout editorblocks- set false if not to use the block information gathered from the layout editordestination- Destination Signal Mast- Throws:
JmriException- if a path on the layout editor is not valid
-
useLayoutEditorBlocks
public boolean useLayoutEditorBlocks(SignalMast destination)
Query if we are using the Layout Editor block information in the signal mast logic.- Specified by:
useLayoutEditorBlocksin interfaceSignalMastLogic- Parameters:
destination- Destination Signal Mast- Returns:
- true if we are using the block information from the Layout Editor.
-
useLayoutEditorTurnouts
public boolean useLayoutEditorTurnouts(SignalMast destination)
Query if we are using the Layout Editor turnout information in the signal mast logic.- Specified by:
useLayoutEditorTurnoutsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- true if we are using the turnout information from the Layout Editor.
-
getAssociatedSection
public Section getAssociatedSection(SignalMast destination)
Return the Section configured between the source and destination mast.- Specified by:
getAssociatedSectionin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- The section object
-
setAssociatedSection
public void setAssociatedSection(Section sec, SignalMast destination)
Define a Section between the source and destination mast.- Specified by:
setAssociatedSectionin interfaceSignalMastLogic- Parameters:
sec- The sectiondestination- controlled signal mast
-
allowAutoMaticSignalMastGeneration
public boolean allowAutoMaticSignalMastGeneration(SignalMast destination)
Query if we are allowing the system to automatically generate a list of conflicting Signal Mast that have a direct effect on our logic.- Specified by:
allowAutoMaticSignalMastGenerationin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- true if this is allowed.
-
allowAutoMaticSignalMastGeneration
public void allowAutoMaticSignalMastGeneration(boolean allow, SignalMast destination)
Sets whether we should allow the system to automatically generate a list of signal masts that could cause a conflicting route.- Specified by:
allowAutoMaticSignalMastGenerationin interfaceSignalMastLogic- Parameters:
allow- set true if we are to allow automatic generation.destination- controlled signal mast
-
allowTurnoutLock
public void allowTurnoutLock(boolean lock, SignalMast destination)
Sets whether we should lock all turnouts between the source and destination signal masts when the logic goes active, to prevent them from being changed. This is dependant upon the hardware allowing for this.- Specified by:
allowTurnoutLockin interfaceSignalMastLogic- Parameters:
lock- set true if the system should lock the turnout.destination- controlled signal mast
-
isTurnoutLockAllowed
public boolean isTurnoutLockAllowed(SignalMast destination)
Query if we are allowing the system to lock turnouts when the logic goes active.- Specified by:
isTurnoutLockAllowedin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- true if locking is allowed.
-
setTurnouts
public void setTurnouts(java.util.Hashtable<NamedBeanHandle<Turnout>,java.lang.Integer> turnouts, SignalMast destination)
Set the states that each control turnout must be in for the source signal mast not to be set to a Stop aspect.- Specified by:
setTurnoutsin interfaceSignalMastLogic- Parameters:
turnouts- A list of named turnouts and their respective set to state to checkdestination- controlled signal mast
-
setAutoTurnouts
public void setAutoTurnouts(java.util.Hashtable<Turnout,java.lang.Integer> turnouts, SignalMast destination)
Set which turnouts must be set to a given state for the signal mast not to be set to a Stop aspect. These Turnouts are not stored in the panel file.- Specified by:
setAutoTurnoutsin interfaceSignalMastLogic- Parameters:
turnouts- map of turnouts and their respective set to statedestination- controlled signal mast
-
setBlocks
public void setBlocks(java.util.Hashtable<Block,java.lang.Integer> blocks, SignalMast destination)
Set which blocks must be in a given state for the signal mast not to be set to a Stop aspect.- Specified by:
setBlocksin interfaceSignalMastLogic- Parameters:
blocks- map of Blocks and their respective set to statedestination- controlled signal mast
-
setAutoBlocks
public void setAutoBlocks(java.util.LinkedHashMap<Block,java.lang.Integer> blocks, SignalMast destination)
Set which blocks must be in a given state for the signal mast not to be set to a Stop aspect. These blocks are not stored in the panel file.- Specified by:
setAutoBlocksin interfaceSignalMastLogic- Parameters:
blocks- map ofBlocks and their respective set to state to be checkeddestination- controlled signal mast
-
setMasts
public void setMasts(java.util.Hashtable<SignalMast,java.lang.String> masts, SignalMast destination)
Set which control signal masts must be in a given state before our source mast can be set.- Specified by:
setMastsin interfaceSignalMastLogic- Parameters:
masts- map of control signal masts and respective set to states to be checkeddestination- controlled signal mast
-
setAutoMasts
public void setAutoMasts(java.util.Hashtable<SignalMast,java.lang.String> masts, SignalMast destination)
Set which control signal masts must be in a given state before our source mast can be set. These Signal Masts are not stored in the panel file.- Specified by:
setAutoMastsin interfaceSignalMastLogic- Parameters:
masts- list of control signal masts and their respective set to state to be checkeddestination- controlled signal mast
-
setSensors
public void setSensors(java.util.Hashtable<NamedBeanHandle<Sensor>,java.lang.Integer> sensors, SignalMast destination)
Set which sensors must be in a given state before our source signal mast can be set.- Specified by:
setSensorsin interfaceSignalMastLogic- Parameters:
sensors- TheSensors to be checkeddestination- controlled signal mast
-
addSensor
public void addSensor(java.lang.String sensorName, int state, SignalMast destination)
Add an individual control Sensor and its set to state to the Signal Mast Logic.- Specified by:
addSensorin interfaceSignalMastLogic- Parameters:
sensorName- The sensor to be removedstate- Integer representing the state the control Sensor should be indestination- controlled signal mast
-
removeSensor
public void removeSensor(java.lang.String sensorName, SignalMast destination)
Remove an individual control Sensor from the Signal Mast Logic.- Specified by:
removeSensorin interfaceSignalMastLogic- Parameters:
sensorName- The sensor to be removeddestination- controlled signal mast
-
removeSensor
public void removeSensor(Sensor sen, SignalMast destination)
-
getBlocks
public java.util.List<Block> getBlocks(SignalMast destination)
Return the Layout Blocks that have been defined by the user to control the SML to the destination mast.- Specified by:
getBlocksin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Block objects
-
getAutoBlocks
public java.util.List<Block> getAutoBlocks(SignalMast destination)
Return all the blocks that have been detected as being in use for this logic. This includes blocks on level xings that are not directly in the path but do have an effect on the logic.- Specified by:
getAutoBlocksin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Block objects
-
getAutoBlocksBetweenMasts
public java.util.List<Block> getAutoBlocksBetweenMasts(SignalMast destination)
Return a list of blocks just that have been detected as being directly between the source and destination mast. The order of the blocks in the list is the order in which they are connected.- Specified by:
getAutoBlocksBetweenMastsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of block objects
-
getTurnouts
public java.util.List<Turnout> getTurnouts(SignalMast destination)
Return the Turnouts that have been defined by the user to control the SML to the destination mast.- Specified by:
getTurnoutsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Turnout objects
-
getNamedTurnouts
public java.util.List<NamedBeanHandle<Turnout>> getNamedTurnouts(SignalMast destination)
Return the Turnouts that have been defined by the user to control the SML to the destination mast as NamedBeanHandles.- Specified by:
getNamedTurnoutsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Turnout NamedBeanHandles
-
removeTurnout
public void removeTurnout(Turnout turn, SignalMast destination)
-
getAutoTurnouts
public java.util.List<Turnout> getAutoTurnouts(SignalMast destination)
Return only the turnouts that have been detected as being directly between the source and destination mast. The order of the turnouts in the list is the order in which they are connected.- Specified by:
getAutoTurnoutsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of turnout objects
-
getSensors
public java.util.List<Sensor> getSensors(SignalMast destination)
Return the Sensors that have been defined by the user to control the SML to the destination mast.- Specified by:
getSensorsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Sensor objects
-
getNamedSensors
public java.util.List<NamedBeanHandle<Sensor>> getNamedSensors(SignalMast destination)
Return the Sensors that have been defined by the user to control the SML to the destination mast as NamedBeanHandles.- Specified by:
getNamedSensorsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Sensor NamedBeanHandles
-
getSignalMasts
public java.util.List<SignalMast> getSignalMasts(SignalMast destination)
Return the Signal Masts that have been defined by the user to control the SML to the destination mast.- Specified by:
getSignalMastsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of Signal Mast objects
-
getAutoMasts
public java.util.List<SignalMast> getAutoMasts(SignalMast destination)
Return a list of control masts that have been automatically detected as being directly between the source and destination mast. The order of the control masts in the list is the order in which they are connected.- Specified by:
getAutoMastsin interfaceSignalMastLogic- Parameters:
destination- controlled signal mast- Returns:
- A list of signal mast objects
-
initialise
public void initialise()
General method to initialise all SMLs on the source SIgnal Mast using destList- Specified by:
initialisein interfaceSignalMastLogic
-
initialise
public void initialise(SignalMast destination)
Initialise the signal mast after all the parameters have been set.- Specified by:
initialisein interfaceSignalMastLogic- Parameters:
destination- controlled signal mast
-
setupLayoutEditorTurnoutDetails
public java.util.LinkedHashMap<Block,java.lang.Integer> setupLayoutEditorTurnoutDetails(java.util.List<LayoutBlock> blks, SignalMast destination)
Set the auto turnouts based upon a given list of layout blocks for a specific destination mast.- Specified by:
setupLayoutEditorTurnoutDetailsin interfaceSignalMastLogic- Parameters:
blks- List of Layout Blocks.destination- Destination Signal Mast- Returns:
- A LinkedHashMap of the original blocks and their required state, plus any blocks found on double cross-overs that also need to be un-occupied.
-
setupLayoutEditorDetails
public void setupLayoutEditorDetails()
Set up a Signal Mast Logic from the Layout Editor panel where its source Signal Mast is present, when useLayoutEditor is set to true.- Specified by:
setupLayoutEditorDetailsin interfaceSignalMastLogic
-
checkStates
boolean checkStates()
Check if routes to the destination Signal Mast are clear.- Returns:
- true if the path to the next signal is clear
-
areBlocksIncluded
public boolean areBlocksIncluded(java.util.List<Block> blks)
Returns true if any of the blocks in the supplied list are included in any of the logics that set this signal.- Specified by:
areBlocksIncludedin interfaceSignalMastLogic- Parameters:
blks- A list of Layout Blocks to query against- Returns:
- whether all supplied blocks are in at least one of the logics
-
getBlockState
public int getBlockState(Block block, SignalMast destination)
Return the Set To State of a control block as it is configured between the source and destination mast.- Specified by:
getBlockStatein interfaceSignalMastLogic- Parameters:
block- The Control Layout Blockdestination- controlled signal mast- Returns:
- Integer representing the state the control block should be in
-
isBlockIncluded
public boolean isBlockIncluded(Block block, SignalMast destination)
Check whether the Block is part of at least one of the logics.- Specified by:
isBlockIncludedin interfaceSignalMastLogic- Parameters:
block- a layout blockdestination- controlled signal mast- Returns:
- true if block is included in any of the Signal Mast Logics that set destination
-
isTurnoutIncluded
public boolean isTurnoutIncluded(Turnout turnout, SignalMast destination)
Check if a turnout is part of at least one of the logics that set a signal mast.- Specified by:
isTurnoutIncludedin interfaceSignalMastLogic- Parameters:
turnout- the turnout to checkdestination- controlled signal mast- Returns:
- true if turnout is included in any of the Signal Mast Logics that set destination
-
isSensorIncluded
public boolean isSensorIncluded(Sensor sensor, SignalMast destination)
Check if a sensor is part of at least one of the logics that set a SignalMast.- Specified by:
isSensorIncludedin interfaceSignalMastLogic- Parameters:
sensor- the sensor to checkdestination- controlled signal- Returns:
- true if sensor is included in any of the Signal Mast Logics that set destination
-
isSignalMastIncluded
public boolean isSignalMastIncluded(SignalMast signal, SignalMast destination)
Check if a signal mast is part of at least one of the logics that set another signal mast.- Specified by:
isSignalMastIncludedin interfaceSignalMastLogic- Parameters:
signal- the signal mast to checkdestination- controlled signal mast- Returns:
- true if signal is included in any of the Signal Mast Logics that set destination
-
getAutoBlockState
public int getAutoBlockState(Block block, SignalMast destination)
Return the Set State of a control block as it is configured between the source and destination mast.- Specified by:
getAutoBlockStatein interfaceSignalMastLogic- Parameters:
block- The Control Layout Block.destination- controlled signal mast- Returns:
- The int value representing the occupancy state that the block should show
-
getSensorState
public int getSensorState(Sensor sensor, SignalMast destination)
Return the Set To State of a control Sensor as it is configured between the source and destination mast.- Specified by:
getSensorStatein interfaceSignalMastLogic- Parameters:
sensor- The Control Sensordestination- controlled signal mast- Returns:
- Integer representing the state the control Sensor should be in
-
getTurnoutState
public int getTurnoutState(Turnout turnout, SignalMast destination)
Return the Set State of a control Turnout as it is configured between the source and destination mast.- Specified by:
getTurnoutStatein interfaceSignalMastLogic- Parameters:
turnout- The Control Turnoutdestination- controlled signal mast- Returns:
- Integer representing the state the control Sensor should be in
-
getAutoTurnoutState
public int getAutoTurnoutState(Turnout turnout, SignalMast destination)
Return the Set State of a control turnout as it is configured between the source and destination mast.- Specified by:
getAutoTurnoutStatein interfaceSignalMastLogic- Parameters:
turnout- The Control Turnoutdestination- controlled signal mast- Returns:
- The name of the Aspect the Control Mast should display
-
getSignalMastState
public java.lang.String getSignalMastState(SignalMast mast, SignalMast destination)
Return the Set To State (Aspect) of a control Signal Mast as it is configured between the source and destination mast.- Specified by:
getSignalMastStatein interfaceSignalMastLogic- Parameters:
mast- The Control Signal Mastdestination- controlled signal mast- Returns:
- Integer representing the state the control Signal Mast should be in
-
getAutoSignalMastState
public java.lang.String getAutoSignalMastState(SignalMast mast, SignalMast destination)
Return the Set State (Aspect) of a control mast as it is configured between the source and destination mast.- Specified by:
getAutoSignalMastStatein interfaceSignalMastLogic- Parameters:
mast- The Control Signal Mastdestination- controlled signal mast- Returns:
- The name of the Aspect the Control Mast should display
-
getMaximumSpeed
public float getMaximumSpeed(SignalMast destination)
Get the Maximum Speed set for the destination Signal Mast in this SML.- Specified by:
getMaximumSpeedin interfaceSignalMastLogic- Parameters:
destination- the destination mast- Returns:
- A number representing the speed
-
setSignalAppearance
void setSignalAppearance()
Before going active or checking that we can go active, wait 500ms for things to settle down to help prevent a race condition.
-
setMastAppearance
void setMastAppearance()
Evaluate the destination signal mast Aspect and set ours accordingly.
-
setConflictingLogic
public void setConflictingLogic(SignalMast sm, LevelXing lx)
Add control elements for a SML pair containing a destination signal mast that itself is skipped as it is incompatible with an SML around a level crossing.- Specified by:
setConflictingLogicin interfaceSignalMastLogic- Parameters:
sm- The destination Signal Mastlx- The LevelXing Layout Editor element
-
removeConflictingLogic
public void removeConflictingLogic(SignalMast sm, LevelXing lx)
Remove control elements for a SML pair containing a destination signal mast that itself is incompatible with an SML around a level crossing.- Specified by:
removeConflictingLogicin interfaceSignalMastLogic- Parameters:
sm- The destination Signal Mastlx- The LevelXing Layout Editor element
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
Description copied from class:AbstractNamedBean- Specified by:
vetoableChangein interfaceNamedBean- Specified by:
vetoableChangein interfaceSignalMastLogic- Specified by:
vetoableChangein interfacejava.beans.VetoableChangeListener- Overrides:
vetoableChangein classAbstractNamedBean- Throws:
java.beans.PropertyVetoException
-
dispose
public void dispose()
Note: This does not stop any delayed operations that might be queued.- Specified by:
disposein interfaceNamedBean- Specified by:
disposein interfaceSignalMastLogic- Overrides:
disposein classAbstractNamedBean
-
getBeanType
public java.lang.String getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
getState
public int getState()
No valid integer state, always return a constant.
-
setState
public void setState(int i)
Description copied from interface:NamedBeanProvide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.
-
getUsageReport
public java.util.List<NamedBeanUsageReport> getUsageReport(NamedBean bean)
Get a list of references for the specified bean.- Specified by:
getUsageReportin interfaceNamedBean- Parameters:
bean- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
-