Package jmri.jmrit.logix
Class Portal
- java.lang.Object
-
- jmri.jmrit.logix.Portal
-
public class Portal extends java.lang.Object
A Portal is a boundary between two Blocks.A Portal has Lists of the
OPath
s that connect through it. The direction of trains passing through the portal is managed from the BlockOrders of the Warrant the train is running under. The Portal fires a PropertyChangeEvent that aPortalIcon
can listen for to set direction arrows for a given route. The Portal also supplies speed information from any signals set at its location that the Warrant passes on the Engineer.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ENTER_FROM_BLOCK
static int
ENTER_TO_BLOCK
static int
UNKNOWN
-
Constructor Summary
Constructors Constructor Description Portal(java.lang.String uName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addPath(OPath path)
Determine which list the Path belongs to and add it to that list.void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
void
deleteSignal(NamedBean signal)
boolean
dispose()
java.lang.String
getDescription()
float
getEntranceSpaceForBlock(OBlock block)
Get the distance (plus or minus) in millimeters from the portal gap where the speed change indicated by the signal should be completed.OBlock
getFromBlock()
java.lang.String
getFromBlockName()
java.util.List<OPath>
getFromPaths()
NamedBean
getFromSignal()
java.lang.String
getFromSignalName()
float
getFromSignalOffset()
java.lang.String
getName()
OBlock
getOpposingBlock(OBlock block)
Get the OBlock on the other side of the Portal from the given OBlock.java.util.List<OPath>
getPathsFromOpposingBlock(OBlock block)
Get the paths from the portal in the next connected OBlock i.e. paths in the block on the other side of the portal from this (the param) block.java.util.List<OPath>
getPathsWithinBlock(OBlock block)
Get the paths to the portal within the connected OBlock i.e. the paths in this (the param) block through the Portal.java.lang.String
getPermissibleSpeed(OBlock block, boolean entrance)
Check signals, if any, for speed into/out of a given block.OBlock
getProtectedBlock(NamedBean signal)
Get the OBlock protected by a signal.static NamedBean
getSignal(java.lang.String name)
NamedBean
getSignalProtectingBlock(OBlock block)
Get the signal (either a SignalMast or a SignalHead) protecting an OBlock.int
getState()
OBlock
getToBlock()
java.lang.String
getToBlockName()
java.util.List<OPath>
getToPaths()
NamedBean
getToSignal()
java.lang.String
getToSignalName()
float
getToSignalOffset()
boolean
isValid()
Check portal has both blocks and they are different blocks.boolean
isValidPath(OPath path)
Check if path connects to Portal.void
removePath(OPath path)
Remove an OPath from this Portal.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
void
setEntranceSpaceForBlock(OBlock block, float distance)
Set the distance (plus or minus) in millimeters from the portal gap where the speed change indicated by the signal should be completed.protected void
setEntryState(OBlock block)
Call is from BlockOrder when setting the path.boolean
setFromBlock(OBlock block, boolean changePaths)
Set this portal's fromBlock.java.lang.String
setName(java.lang.String newName)
Set userName of this Portal.boolean
setProtectSignal(NamedBean signal, float length, OBlock protectedBlock)
Set a signal to protect an OBlock.void
setState(int s)
boolean
setToBlock(OBlock block, boolean changePaths)
Set this portal's toBlock.java.lang.String
toString()
-
-
-
Field Detail
-
UNKNOWN
public static final int UNKNOWN
- See Also:
- Constant Field Values
-
ENTER_TO_BLOCK
public static final int ENTER_TO_BLOCK
- See Also:
- Constant Field Values
-
ENTER_FROM_BLOCK
public static final int ENTER_FROM_BLOCK
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Portal
public Portal(java.lang.String uName)
-
-
Method Detail
-
addPath
public boolean addPath(@Nonnull OPath path)
Determine which list the Path belongs to and add it to that list.- Parameters:
path
- OPath to add- Returns:
- false if Path does not have a matching block for this Portal
-
removePath
public void removePath(@Nonnull OPath path)
Remove an OPath from this Portal. Checks both the _fromBlock list as the _toBlock list.- Parameters:
path
- the OPath to remove
-
setName
@CheckForNull public java.lang.String setName(@CheckForNull java.lang.String newName)
Set userName of this Portal. Checks if name is available.- Parameters:
newName
- name for path- Returns:
- return error message, null if name change is OK
-
getName
public java.lang.String getName()
-
setToBlock
public boolean setToBlock(@CheckForNull OBlock block, boolean changePaths)
Set this portal's toBlock. Remove this portal from old toBlock, if any. Add this portal in the new toBlock's list of portals.- Parameters:
block
- to be the new toBlockchangePaths
- if true, set block in paths. If false, verify that all toPaths are contained in the block.- Returns:
- false if paths are not in the block
-
getToBlock
public OBlock getToBlock()
-
getToBlockName
public java.lang.String getToBlockName()
-
getToPaths
public java.util.List<OPath> getToPaths()
-
setFromBlock
public boolean setFromBlock(@CheckForNull OBlock block, boolean changePaths)
Set this portal's fromBlock. Remove this portal from old fromBlock, if any. Add this portal in the new toBlock's list of portals.- Parameters:
block
- to be the new fromBlockchangePaths
- if true, set block in paths. If false, verify that all toPaths are contained in the block.- Returns:
- false if paths are not in the block
-
getFromBlock
public OBlock getFromBlock()
-
getFromBlockName
public java.lang.String getFromBlockName()
-
getFromPaths
public java.util.List<OPath> getFromPaths()
-
setProtectSignal
public boolean setProtectSignal(@CheckForNull NamedBean signal, float length, @CheckForNull OBlock protectedBlock)
Set a signal to protect an OBlock. Warrants look ahead for speed changes and change the train speed accordingly.- Parameters:
signal
- either a SignalMast or a SignalHead. Set to null to remove (previous) signal from Portallength
- offset length in millimeters. This is additional entrance space for the block. This distance added to or subtracted from the calculation of the ramp distance when a warrant must slow the train in response to the aspect or appearance of the signal.protectedBlock
- OBlock the signal protects- Returns:
- true if signal is set
-
getSignalProtectingBlock
@CheckForNull public NamedBean getSignalProtectingBlock(@Nonnull OBlock block)
Get the signal (either a SignalMast or a SignalHead) protecting an OBlock.- Parameters:
block
- is the direction of entry, i.e. the protected block- Returns:
- signal protecting block, if block is protected, otherwise null.
-
getProtectedBlock
@CheckForNull public OBlock getProtectedBlock(@CheckForNull NamedBean signal)
Get the OBlock protected by a signal.- Parameters:
signal
- is the signal, either a SignalMast or a SignalHead- Returns:
- Protected OBlock, if it is protected, otherwise null.
-
getFromSignal
public NamedBean getFromSignal()
-
getFromSignalName
public java.lang.String getFromSignalName()
-
getFromSignalOffset
public float getFromSignalOffset()
-
getToSignal
public NamedBean getToSignal()
-
getToSignalName
@CheckForNull public java.lang.String getToSignalName()
-
getToSignalOffset
public float getToSignalOffset()
-
deleteSignal
public void deleteSignal(@Nonnull NamedBean signal)
-
getSignal
@CheckForNull public static NamedBean getSignal(java.lang.String name)
-
getPathsWithinBlock
public java.util.List<OPath> getPathsWithinBlock(@CheckForNull OBlock block)
Get the paths to the portal within the connected OBlock i.e. the paths in this (the param) block through the Portal.- Parameters:
block
- OBlock- Returns:
- null if portal does not connect to block
-
getOpposingBlock
public OBlock getOpposingBlock(@Nonnull OBlock block)
Get the OBlock on the other side of the Portal from the given OBlock.- Parameters:
block
- starting OBlock- Returns:
- the opposite block
-
getPathsFromOpposingBlock
public java.util.List<OPath> getPathsFromOpposingBlock(@Nonnull OBlock block)
Get the paths from the portal in the next connected OBlock i.e. paths in the block on the other side of the portal from this (the param) block.- Parameters:
block
- OBlock- Returns:
- null if portal does not connect to block
-
setEntryState
protected void setEntryState(@CheckForNull OBlock block)
Call is from BlockOrder when setting the path.- Parameters:
block
- OBlock
-
setState
public void setState(int s)
-
getState
public int getState()
-
addPropertyChangeListener
@OverridingMethodsMustInvokeSuper public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
-
removePropertyChangeListener
@OverridingMethodsMustInvokeSuper public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
-
setEntranceSpaceForBlock
public void setEntranceSpaceForBlock(@Nonnull OBlock block, float distance)
Set the distance (plus or minus) in millimeters from the portal gap where the speed change indicated by the signal should be completed.- Parameters:
block
- a protected OBlockdistance
- length in millimeters, called Offset in the OBlock Signal Table
-
getEntranceSpaceForBlock
public float getEntranceSpaceForBlock(@Nonnull OBlock block)
Get the distance (plus or minus) in millimeters from the portal gap where the speed change indicated by the signal should be completed. Property is called Offset in the OBlock Signal Table.- Parameters:
block
- a protected OBlock- Returns:
- distance
-
getPermissibleSpeed
public java.lang.String getPermissibleSpeed(@Nonnull OBlock block, boolean entrance)
Check signals, if any, for speed into/out of a given block. The signal that protects the "to" block is the signal facing the "from" Block, i.e. the "from" signal. (and vice-versa)- Parameters:
block
- is the direction of entry, "from" blockentrance
- true for EntranceSpeed, false for ExitSpeed- Returns:
- permissible speed, null if no signal
-
isValidPath
public boolean isValidPath(@Nonnull OPath path)
Check if path connects to Portal.- Parameters:
path
- OPath to test- Returns:
- true if valid
-
isValid
public boolean isValid()
Check portal has both blocks and they are different blocks.- Returns:
- true if valid
-
dispose
@OverridingMethodsMustInvokeSuper public boolean dispose()
-
getDescription
public java.lang.String getDescription()
-
-