jmri.jmrit.logix
Class OBlock

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.Block
          extended by jmri.jmrit.logix.OBlock
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, NamedBean

public class OBlock
extends Block
implements PropertyChangeListener

OBlock extends jmri.Block to be used in Logix Conditionals and Warrants. It is the smallest piece of track that can have occupancy detection. A better name would be Detection Circuit. However, an OBlock can be defined without an occupancy sensor and used to calculate routes. Additional states are defined to indicate status of the track and trains to control panels.

Entrances (exits when train moves in opposute 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. Preferrably 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.


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author:
Pete Cressman (C) 2009
See Also:
Serialized Form

Field Summary
static int ALLOCATED
           
static int DARK
           
static int OUT_OF_SERVICE
           
static int RUNNING
           
static int TRACK_ERROR
           
 
Fields inherited from class jmri.Block
GRADUAL, NONE, OCCUPIED, SEVERE, TIGHT, UNOCCUPIED
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
OBlock(String systemName)
           
OBlock(String systemName, String userName)
           
 
Method Summary
 boolean addPath(OPath path)
          Enforce unique path names within block
 void addPortal(Portal portal)
          Enforce unique portal names.
 String allocate(String pathName)
          Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.
protected  String allocate(Warrant warrant)
          Allocate (reserves) the block for the Warrant that is the 'value' object Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.
 String deAllocate(Warrant warrant)
          Remove allocation state Remove listener regardless of ownership
 void dispose()
          Deactivate this object, so that it releases as many resources as possible and no longer effects others.
 String getAllocatedPathName()
           
 String getDescription()
           
 Sensor getErrorSensor()
           
 float getLengthMeters()
           
 float getLengthScaleFeet()
           
static String getLocalStatusName(String str)
           
static Enumeration<String> getLocalStatusNames()
           
 NamedBeanHandle getNamedErrorSensor()
           
 OPath getPathByName(String name)
           
 Portal getPortalByName(String name)
           
 List<Portal> getPortals()
           
 float getScaleRatio()
           
static String getSystemStatusName(String str)
           
protected  Warrant getWarrant()
           
 void goingActive()
          (Override) Handles Block sensor going ACTIVE: this block is now occupied, figure out from who and copy their value.
 void goingInactive()
          (Override) Handles Block sensor going INACTIVE: this block is empty.
 boolean isFree()
          Test that block is not occupied and and not allocated
 boolean isMetric()
           
 void propertyChange(PropertyChangeEvent evt)
           
 void pseudoPropertyChange(String propName, Object old, Object n)
          Call for Circuit Builder to make icon color changes for its GUI
 void removePath(Path path)
           
 void removePortal(Portal portal)
          Remove portal from block and stub all paths using this portal to be dead end spurs.
 void setErrorSensor(String pName)
           
 void setMetricUnits(boolean type)
           
 void setNamedSensor(NamedBeanHandle<Sensor> namedSensor)
           
 void setOutOfService(boolean set)
           
 String setPath(String pathName, Warrant warrant)
          Set Turnouts for the path Called by warrants to set turnouts for a train it is able to run.
 void setScaleRatio(float sr)
           
 void setSensor(String pName)
           
 boolean statusIs(String statusName)
           
 
Methods inherited from class jmri.Block
addPath, getBlockSpeed, getCurvature, getDirection, getLengthCm, getLengthIn, getLengthMm, getNamedSensor, getPaths, getPermissiveWorking, getReporter, getSensor, getSpeedLimit, getState, getValue, getWorkingDirection, isReportingCurrent, setBlockSpeed, setCurvature, setDirection, setLength, setPermissiveWorking, setReporter, setReportingCurrent, setState, setValue, setWorkingDirection
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName, updateListenerRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALLOCATED

public static final int ALLOCATED
See Also:
Constant Field Values

RUNNING

public static final int RUNNING
See Also:
Constant Field Values

OUT_OF_SERVICE

public static final int OUT_OF_SERVICE
See Also:
Constant Field Values

DARK

public static final int DARK
See Also:
Constant Field Values

TRACK_ERROR

public static final int TRACK_ERROR
See Also:
Constant Field Values
Constructor Detail

OBlock

public OBlock(String systemName)

OBlock

public OBlock(String systemName,
              String userName)
Method Detail

getLocalStatusNames

public static Enumeration<String> getLocalStatusNames()

getLocalStatusName

public static String getLocalStatusName(String str)

getSystemStatusName

public static String getSystemStatusName(String str)

setSensor

public void setSensor(String pName)
Overrides:
setSensor in class Block

setNamedSensor

public void setNamedSensor(NamedBeanHandle<Sensor> namedSensor)
Overrides:
setNamedSensor in class Block

setErrorSensor

public void setErrorSensor(String pName)

getErrorSensor

public Sensor getErrorSensor()

getNamedErrorSensor

public NamedBeanHandle getNamedErrorSensor()

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

getWarrant

protected Warrant getWarrant()

getAllocatedPathName

public String getAllocatedPathName()

getLengthScaleFeet

public float getLengthScaleFeet()

getLengthMeters

public float getLengthMeters()

setMetricUnits

public void setMetricUnits(boolean type)

isMetric

public boolean isMetric()

setScaleRatio

public void setScaleRatio(float sr)

getScaleRatio

public float getScaleRatio()

statusIs

public boolean statusIs(String statusName)

isFree

public boolean isFree()
Test that block is not occupied and and not allocated


allocate

protected String allocate(Warrant warrant)
Allocate (reserves) the block for the Warrant that is the 'value' object Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.

Parameters:
warrant -
Returns:
name of block if block is already allocated to another warrant

allocate

public String allocate(String pathName)
Note the block may be OCCUPIED by a non-warranted train, but the allocation is permitted.

Returns:
name of block if block is already allocated to another warrant

deAllocate

public String deAllocate(Warrant warrant)
Remove allocation state Remove listener regardless of ownership


setOutOfService

public void setOutOfService(boolean set)

addPortal

public void addPortal(Portal portal)
Enforce unique portal names. Portals are not managed beans and multiple config loads will create multiple Portal Objects that are "duplicates".


removePortal

public void removePortal(Portal portal)
Remove portal from block and stub all paths using this portal to be dead end spurs.


getPortalByName

public Portal getPortalByName(String name)

getPortals

public List<Portal> getPortals()

getPathByName

public OPath getPathByName(String name)

addPath

public boolean addPath(OPath path)
Enforce unique path names within block


removePath

public void removePath(Path path)
Overrides:
removePath in class Block

setPath

public String setPath(String pathName,
                      Warrant warrant)
Set Turnouts for the path Called by warrants to set turnouts for a train it is able to run. The warrant parameter is 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. However, if the block is under a warrant the call will be rejected.

Parameters:
pathName - name of the path
warrant - warrant the block is allocated to
Returns:
error message if the call fails. null if the call succeeds

pseudoPropertyChange

public void pseudoPropertyChange(String propName,
                                 Object old,
                                 Object n)
Call for Circuit Builder to make icon color changes for its GUI


goingInactive

public void goingInactive()
(Override) Handles Block sensor going INACTIVE: this block is empty. Called by handleSensorChange

Overrides:
goingInactive in class Block

goingActive

public void goingActive()
(Override) Handles Block sensor going ACTIVE: this block is now occupied, figure out from who and copy their value. Called by handleSensorChange

Overrides:
goingActive in class Block

dispose

public void dispose()
Description copied from interface: NamedBean
Deactivate 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:
dispose in interface NamedBean
Overrides:
dispose in class AbstractNamedBean

getDescription

public String getDescription()


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads