Class OBlock
- All Implemented Interfaces:
PropertyChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,NamedBean,PhysicalLocationReporter
Additional states are defined to indicate status of the track and trains to control panels. A jmri.Block has a PropertyChangeListener on the occupancy sensor and the OBlock will pass state changes of the occ.sensor on to its Warrant.
Entrances (exits when train moves in opposite direction) to OBlocks have Portals. A Portal object is a pair of OBlocks. Each OBlock has a list of its Portals.
When an OBlock (Detection Circuit) has a Portal whose entrance to the OBlock has a signal, then the OBlock and its chains of adjacent OBlocks up to the next OBlock having an entrance Portal with a signal, can be considered a "Block" in the sense of a prototypical railroad. Preferably all entrances to the "Block" should have entrance Portals with a signal.
A Portal has a list of paths (OPath objects) for each OBlock it separates. The paths are determined by the turnout settings of the turnouts contained in the block. Paths are contained within the Block boundaries. Names of OPath objects only need be unique within an OBlock.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameExceptionNested classes/interfaces inherited from interface jmri.PhysicalLocationReporter
PhysicalLocationReporter.Direction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longstatic final intstatic final intstatic final StringString constant to represent deleted.static final StringString constant to represent path Count.static final StringString constant to represent path State.static final StringString constant to represent portal Count.static final intstatic final intFields inherited from class jmri.Block
BLOCK_CURVATURE_CHANGE, BLOCK_LENGTH_CHANGE, BLOCK_PERMISSIVE_CHANGE, BLOCK_REPORTER_CHANGE, BLOCK_REPORTING_CURRENT, BLOCK_SPEED_CHANGE, GHOST_CHANGE, GRADUAL, NONE, OCC_SENSOR_CHANGE, OCCUPIED, PROPERTY_ALLOCATED, PROPERTY_DIRECTION, PROPERTY_VALUE, SEVERE, TIGHT, UNDETECTED, UNOCCUPIEDFields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanEnforce unique path names within OBlock, but allow a duplicate name of an OPath from another OBlock to be checked if it is in one of the OBlock's Portals.voidEnforce unique portal names.Allocate (reserves) the block for the Warrant Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.allocatePath(String pathName) Note path name may be set if block is not allocated to a warrant.booleandeAllocate(Warrant warrant) Remove allocation state // maybe restore this?voiddispose()Deactivate this object, so that it releases as many resources as possible and no longer effects others.booleanNote: this has to make choices about identity values (always the same) and operation values (can change as the block works).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.static StringgetLocalStatusName(String str) protected OPathgetPath()getPathByName(String name) getPortalByName(String name) static StringgetUsageReport(NamedBean bean) Get a list of references for the specified bean.void(Override) Handles Block sensor going ACTIVE: this block is now occupied, figure out from who and copy their value.void(Override) Handles Block sensor going INACTIVE: this block is empty.voidvoidinthashCode()booleanisAllocatedTo(Warrant warrant) booleanisDark()booleanisFree()Test that block is not occupied and not allocatedbooleanisMetric()booleanprotected StringAnother block sharing a turnout with this block queries whether turnout is in use.voidvoidpseudoPropertyChange(String propName, Object old, Object n) booleanremoveOPath(OPath path) protected voidremovePortal(Portal portal) Remove portal from OBlock and stub all paths using this portal to be dead end spurs.voidsetError(boolean set) booleansetErrorSensor(String pName) voidsetLength(float len) Set length in millimeters.voidvoidvoidvoidsetMetricUnits(boolean type) voidsetNamedSensor(NamedBeanHandle<Sensor> namedSensor) Set Block Occupancy Sensor.voidsetOutOfService(boolean set) protected StringSet Turnouts for the path.voidsetPortals(ArrayList<Portal> portals) booleanSet the sensor by name.voidsetState(int v) Update the OBlock status.voidSet the value retained by this Block.protected voidshowAllocated(Warrant warrant, String pathName) booleanMethods inherited from class jmri.Block
addBlockDenyList, addBlockDenyList, addPath, describeState, findFromPath, getBlockSpeed, getCurvature, getDeniedBlocks, getDirection, getDirection, getIsGhost, getLengthCm, getLengthIn, getLengthMm, getLocoAddress, getNamedSensor, getPaths, getPermissiveWorking, getPhysicalLocation, getPhysicalLocation, getReporter, getSensor, getSpeedLimit, getState, getValue, hasPath, isBlockDenied, isBlockDenied, isReportingCurrent, removeBlockDenyList, removeBlockDenyList, removePath, setAllocated, setBlockSpeed, setBlockSpeedName, setCurvature, setDirection, setIsGhost, setPermissiveWorking, setReporter, setReportingCurrent, toDebugString, vetoableChangeMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
compareTo, getRecommendedToolTip
-
Field Details
-
ALLOCATED
- See Also:
-
RUNNING
- See Also:
-
OUT_OF_SERVICE
- See Also:
-
TRACK_ERROR
- See Also:
-
PROPERTY_PATH_STATE
String constant to represent path State.- See Also:
-
PROPERTY_PATH_COUNT
String constant to represent path Count.- See Also:
-
PROPERTY_PORTAL_COUNT
String constant to represent portal Count.- See Also:
-
PROPERTY_DELETED
String constant to represent deleted.- See Also:
-
_entryTime
-
-
Constructor Details
-
OBlock
-
OBlock
-
-
Method Details
-
getLocalStatusName
-
getSystemStatusName
-
equals
Description copied from class:BlockNote: this has to make choices about identity values (always the same) and operation values (can change as the block works). Might be missing some identity values. -
hashCode
Description copied from class:AbstractNamedBean -
setSensor
Set the sensor by name. Fires propertyChange "OccupancySensorChange" when changed.Override to only set an existing sensor and to amend state with not UNDETECTED return true if an existing Sensor is set or sensor is to be removed from block.
-
setNamedSensor
Description copied from class:BlockSet Block Occupancy Sensor. If Sensor set, Adds PCL, sets Block Occupancy Status to Sensor. Block State PropertyChange Event will fire. Does NOT route initial Sensor Status via goingUnknown() / goingActive() etc.If Sensor null, removes PCL on previous Sensor, sets Block status to UNDETECTED.
- Overrides:
setNamedSensorin classBlock- Parameters:
namedSensor- Handle for Sensor.
-
setErrorSensor
- Parameters:
pName- name of error sensor- Returns:
- true if successful
-
getErrorSensor
-
getNamedErrorSensor
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
isPathSet
Another block sharing a turnout with this block queries whether turnout is in use.- Parameters:
path- that uses a common shared turnout- Returns:
- If warrant exists and path==pathname, return warrant display name, else null.
-
getWarrant
-
isAllocatedTo
-
getAllocatedPathName
-
setMetricUnits
-
isMetric
-
setMarkerForeground
-
getMarkerForeground
-
setMarkerBackground
-
getMarkerBackground
-
setMarkerFont
-
getMarkerFont
-
setState
Update the OBlock status. Override Block because change must come from an OBlock for Web Server to receive it -
setValue
Set the value retained by this Block. Also used when the Block itself gathers a value from an adjacent Block. This can be overridden in a subclass if e.g. you want to keep track of Blocks elsewhere, but make sure you also eventually invoke the super.setValue() here. Fires propertyChange "value" when changed. -
statusIs
-
isDark
-
isOccupied
-
occupiedBy
-
isFree
Test that block is not occupied and not allocated- Returns:
- true if not occupied and not allocated
-
allocate
Allocate (reserves) the block for the Warrant Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.- Parameters:
warrant- the Warrant- Returns:
- message with if block is already allocated to another warrant or block is OUT_OF_SERVICE
-
showAllocated
-
allocatePath
Note path name may be set if block is not allocated to a warrant. For use by CircuitBuilder Only. (test paths for editCircuitPaths)- Parameters:
pathName- name of a path- Returns:
- error message, otherwise null
-
getAllocatingWarrantName
-
deAllocate
Remove allocation state // maybe restore this? Remove listener regardless of ownership- Parameters:
warrant- warrant that has reserved this block. null is allowed for Conditionals and CircuitBuilder to reset the block. Otherwise, null should not be used.- Returns:
- true if warrant deallocated.
-
setOutOfService
-
setError
-
addPortal
Enforce unique portal names. Portals are now managed beans since 2014. This enforces unique names.- Parameters:
portal- the Portal to add
-
removePortal
Remove portal from OBlock and stub all paths using this portal to be dead end spurs.- Parameters:
portal- the Portal to remove
-
getPortalByName
-
getPortals
-
setPortals
-
getPathByName
-
setLength
Description copied from class:BlockSet length in millimeters. Paths will inherit this length, if their length is not specifically set. This length is the maximum length of any Path in the block. Path lengths exceeding this will be set to the default length.Fires propertyChange "BlockLengthChange" when changed, float values in mm.
-
addPath
Enforce unique path names within OBlock, but allow a duplicate name of an OPath from another OBlock to be checked if it is in one of the OBlock's Portals.- Parameters:
path- the OPath to add- Returns:
- true if path was added to OBlock
-
removeOPath
-
setPath
Set Turnouts for the path.Called by warrants to set turnouts for a train it is able to run. The warrant parameter verifies that the block is indeed allocated to the warrant. If the block is unwarranted then the block is allocated to the calling warrant. A logix conditional may also call this method with a null warrant parameter for manual logix control. If the block is under a different warrant the call will be rejected.
- Parameters:
pathName- name of the pathwarrant- warrant the block is allocated to- Returns:
- error message if the call fails. null if the call succeeds
-
getPath
-
pseudoPropertyChange
-
goingInactive
(Override) Handles Block sensor going INACTIVE: this block is empty. Called by handleSensorChange- Overrides:
goingInactivein classBlock
-
goingActive
(Override) Handles Block sensor going ACTIVE: this block is now occupied, figure out from who and copy their value. Called by handleSensorChange- Overrides:
goingActivein classBlock
-
goingUnknown
- Overrides:
goingUnknownin classBlock
-
goingInconsistent
- Overrides:
goingInconsistentin classBlock
-
dispose
Description copied from class:AbstractNamedBeanDeactivate this object, so that it releases as many resources as possible and no longer effects others.For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.
It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.
Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.
- Specified by:
disposein interfaceNamedBean- Overrides:
disposein classAbstractNamedBean
-
getDescription
-
getUsageReport
Description copied from interface:NamedBeanGet a list of references for the specified bean.- Specified by:
getUsageReportin interfaceNamedBean- Overrides:
getUsageReportin classBlock- Parameters:
bean- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
getBeanType
Description copied from interface:NamedBeanFor 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- Overrides:
getBeanTypein classBlock- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-