Package jmri.jmrit.logix
Class Portal
java.lang.Object
jmri.jmrit.logix.Portal
A Portal is a boundary between two Blocks.
A Portal has Lists of the OPaths 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 a
PortalIcon 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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final StringString constant for property block changed.static final StringString constant for property direction.static final StringString constant for property name change.static final StringString constant for property portal delete.static final StringString constant for property signal change.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine which list the Path belongs to and add it to that list.voidvoiddeleteSignal(NamedBean signal) booleandispose()floatgetEntranceSpaceForBlock(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.floatgetName()getOpposingBlock(OBlock block) Get the OBlock on the other side of the Portal from the given OBlock.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.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.getPermissibleSpeed(OBlock block, boolean entrance) Check signals, if any, for speed into/out of a given block.getProtectedBlock(NamedBean signal) Get the OBlock protected by a signal.static NamedBeangetSignalProtectingBlock(OBlock block) Get the signal (either a SignalMast or a SignalHead) protecting an OBlock.intgetState()floatbooleanisValid()Check portal has both blocks and they are different blocks.booleanisValidPath(OPath path) Check if path connects to Portal.voidremovePath(OPath path) Remove an OPath from this Portal.voidvoidsetEntranceSpaceForBlock(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 voidsetEntryState(OBlock block) Call is from BlockOrder when setting the path.booleansetFromBlock(OBlock block, boolean changePaths) Set this portal's fromBlock.Set userName of this Portal.booleansetProtectSignal(NamedBean signal, float length, OBlock protectedBlock) Set a signal to protect an OBlock.voidsetState(int s) booleansetToBlock(OBlock block, boolean changePaths) Set this portal's toBlock.toString()
-
Field Details
-
PROPERTY_NAME_CHANGE
String constant for property name change.- See Also:
-
PROPERTY_SIGNAL_CHANGE
String constant for property signal change.- See Also:
-
PROPERTY_DIRECTION
String constant for property direction.- See Also:
-
PROPERTY_BLOCK_CHANGED
String constant for property block changed.- See Also:
-
PROPERTY_PORTAL_DELETE
String constant for property portal delete.- See Also:
-
UNKNOWN
- See Also:
-
ENTER_TO_BLOCK
- See Also:
-
ENTER_FROM_BLOCK
- See Also:
-
-
Constructor Details
-
Portal
-
-
Method Details
-
addPath
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
Remove an OPath from this Portal. Checks both the _fromBlock list as the _toBlock list.- Parameters:
path- the OPath to remove
-
setName
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
-
setToBlock
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
-
getToBlockName
-
getToPaths
-
setFromBlock
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
-
getFromBlockName
-
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
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
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
-
getFromSignalName
-
getFromSignalOffset
-
getToSignal
-
getToSignalName
-
getToSignalOffset
-
deleteSignal
-
getSignal
-
getPathsWithinBlock
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
Get the OBlock on the other side of the Portal from the given OBlock.- Parameters:
block- starting OBlock- Returns:
- the opposite block
-
getPathsFromOpposingBlock
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
Call is from BlockOrder when setting the path.- Parameters:
block- OBlock
-
setState
-
getState
-
addPropertyChangeListener
@OverridingMethodsMustInvokeSuper public void addPropertyChangeListener(PropertyChangeListener listener) -
removePropertyChangeListener
@OverridingMethodsMustInvokeSuper public void removePropertyChangeListener(PropertyChangeListener listener) -
setEntranceSpaceForBlock
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
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
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
Check if path connects to Portal.- Parameters:
path- OPath to test- Returns:
- true if valid
-
isValid
Check portal has both blocks and they are different blocks.- Returns:
- true if valid
-
dispose
-
getDescription
-
toString
-