|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.implementation.AbstractNamedBean
jmri.Block
public class Block
Represents a particular piece of track, more informally a "Block". As trains move around the layout, a set of Block objects interact to keep track of which train is where, going in which direction. As a result of this, the set of Block objects pass around "token" (value) Objects representing the trains. This could be e.g. a Throttle to control the train, or something else.
A Block (at least in this implementation) corresponds exactly to the track covered by a single sensor. That should be generalized in the future.
Optionally, a Block can be associated with a Reporter. In this case, the Reporter will provide the Block with the "token" (value). This could be e.g an RFID reader reading an ID tag attached to a locomotive. Depending on the specific Reporter implementation, either the current reported value or the last reported value will be relevant - this can be configured
Objects of this class are Named Beans, so can be manipulated through tables, have listeners, etc.
There is no functional requirement for a type letter in the System Name, but by convention we use 'B' for 'Block'. The default implementation is not system-specific, so a system letter of 'I' is appropriate. This leads to system names like "IB201".
The direction of a Block is set from the direction of the incoming train. When a train is found to be coming in on a particular Path, that Path's getFromBlockDirection becomes the direction of the train in this Block.
Issues:
Do not assume that a Block object uniquely represents a piece of track. To allow independent development, it must be possible for multiple Block objects to take care of a particular section of track.
Possible state values:
Possible Curvature attributes (optional) User can set the curvature if desired. For use in automatic running of trains, to indicate where slow down is required.
The length of the block may also optionally be entered if desired. This attribute is for use in automatic running of trains. Length should be the actual length of model railroad track in the block. It is always stored here in millimeter units. A length of 0.0 indicates no entry of length by the user.
| Field Summary | |
|---|---|
static int |
GRADUAL
|
static int |
NONE
|
static int |
OCCUPIED
|
static int |
SEVERE
|
static int |
TIGHT
|
static int |
UNOCCUPIED
|
| Fields inherited from class jmri.implementation.AbstractNamedBean |
|---|
mSystemName, mUserName |
| Fields inherited from interface jmri.NamedBean |
|---|
INCONSISTENT, UNKNOWN |
| Constructor Summary | |
|---|---|
Block(String systemName)
|
|
Block(String systemName,
String userName)
|
|
| Method Summary | |
|---|---|
void |
addPath(Path p)
|
String |
getBlockSpeed()
|
int |
getCurvature()
|
int |
getDirection()
|
float |
getLengthCm()
|
float |
getLengthIn()
|
float |
getLengthMm()
|
NamedBeanHandle<Sensor> |
getNamedSensor()
|
List<Path> |
getPaths()
Get a copy of the list of Paths |
boolean |
getPermissiveWorking()
|
Reporter |
getReporter()
Retrieve the Reporter that is linked to this Block |
Sensor |
getSensor()
|
float |
getSpeedLimit()
|
int |
getState()
Provide generic access to internal state. |
Object |
getValue()
|
int |
getWorkingDirection()
|
void |
goingActive()
Handles Block sensor going ACTIVE: this block is now occupied, figure out from who and copy their value. |
void |
goingInactive()
Handles Block sensor going INACTIVE: this block is empty |
boolean |
isReportingCurrent()
Determine if the Block's value is being populated from the current report
or from the last report. |
void |
removePath(Path p)
|
void |
setBlockSpeed(String s)
|
void |
setCurvature(int c)
|
void |
setDirection(int direction)
|
void |
setLength(float l)
|
void |
setNamedSensor(NamedBeanHandle<Sensor> s)
|
void |
setPermissiveWorking(boolean w)
|
void |
setReporter(Reporter reporter)
Set the Reporter that should provide the data value for this block. |
void |
setReportingCurrent(boolean reportingCurrent)
Define if the Block's value should be populated from the current report
or from the last report. |
void |
setSensor(String pName)
|
void |
setState(int v)
Provide a general method for updating the report. |
void |
setValue(Object value)
Set the value retained by this Block. |
void |
setWorkingDirection(int w)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int OCCUPIED
public static final int UNOCCUPIED
public static final int NONE
public static final int GRADUAL
public static final int TIGHT
public static final int SEVERE
| Constructor Detail |
|---|
public Block(String systemName)
public Block(String systemName,
String userName)
| Method Detail |
|---|
public void setSensor(String pName)
public void setNamedSensor(NamedBeanHandle<Sensor> s)
public Sensor getSensor()
public NamedBeanHandle<Sensor> getNamedSensor()
public void setReporter(Reporter reporter)
reporter - Reporter object to link, or null to clearReporterpublic Reporter getReporter()
Reporterpublic void setReportingCurrent(boolean reportingCurrent)
current report
or from the last report.
reportingCurrent - Reporterpublic boolean isReportingCurrent()
current report
or from the last report.
current report;
false if from last report.Reporterpublic int getState()
NamedBeanThis generally shouldn't be used by Java code; use the class-specific form instead. (E.g. getCommandedState in Turnout) This provided to make Jython script access easier to read.
public void addPath(Path p)
public void removePath(Path p)
public List<Path> getPaths()
public void setState(int v)
public void setValue(Object value)
value - The new Object resident in this block, or null if none.public Object getValue()
public void setDirection(int direction)
public int getDirection()
public int getWorkingDirection()
public void setWorkingDirection(int w)
public boolean getPermissiveWorking()
public void setPermissiveWorking(boolean w)
public float getSpeedLimit()
public String getBlockSpeed()
public void setBlockSpeed(String s)
throws JmriException
JmriExceptionpublic void setCurvature(int c)
public int getCurvature()
public void setLength(float l)
public float getLengthMm()
public float getLengthCm()
public float getLengthIn()
public void goingInactive()
public void goingActive()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||