Class AcelaNode
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- jmri.jmrix.acela.AcelaNode
-
public class AcelaNode extends AbstractNode
Models an Acela node.Nodes are numbered from 0. The first watchman node carries the first 8 sensors 0 to 7, etc.
The array of sensor states is used to update sensor known state only when there's a change on the serial bus. This allows for the sensor state to be updated within the program, keeping this updated state until the next change on the serial bus. E.g. you can manually change a state via an icon, and not have it change back the next time that node is polled.
Same applies to the outputs (Dash-8s and Signalmen)
-
-
Field Summary
Fields Modifier and Type Field Description static byte
AC
static int
BLINK
static int
BPOLAR
static byte
D8
static int
DOUBLE
protected int
endingOutputAddress
protected int
endingSensorAddress
protected boolean
hasActiveSensors
protected int
lastUsedSensor
(package private) static int
MAXNODE
(package private) static int
MAXOUTPUTBITS
(package private) static int
MAXSENSORBITS
Maximum number of sensors/outputs any node of any type can carry.(package private) static java.lang.String[]
moduleNames
(package private) static java.lang.String[]
moduleTips
static java.lang.String
moduleTypes
protected boolean
needInit
(package private) static java.lang.String[]
nodeNames
protected int
nodeType
static int
ONOFF
protected byte[]
outputArray
protected int
outputbitsPerCard
protected int[]
outputInit
static java.lang.String
outputInits
static java.lang.String
outputLEN0
protected int[]
outputLength
protected boolean[]
outputNeedToSend
static java.lang.String
outputNO
static java.lang.String
outputONOFF
protected int[]
outputSignalHeadType
static java.lang.String
outputSignalHeadTypes
protected int[]
outputSpecial
protected int[]
outputType
static java.lang.String
outputTypes
protected int[]
outputWired
static java.lang.String
outputWireds
static int
PULSE
static byte
SC
protected Sensor[]
sensorArray
protected int
sensorbitsPerCard
protected byte[]
sensorConfigArray
protected boolean[]
sensorHasBeenInit
protected int[]
sensorLastSetting
protected boolean[]
sensorNeedInit
static java.lang.String
sensorPolarities
protected int[]
sensorPolarity
protected int[]
sensorThreshold
protected int[]
sensorType
static java.lang.String
sensorTypes
static byte
SM
protected int
startingOutputAddress
protected int
startingSensorAddress
static byte
SW
static byte
SY
static byte
TB
(package private) int
timeout
protected int
transmissionDelay
static int
TRIPLE
static int
UKNOWN
static byte
UN
(package private) boolean
warned
static int
WIGWAG
static byte
WM
static byte
YM
-
Fields inherited from class jmri.jmrix.AbstractNode
nodeAddress
-
-
Constructor Summary
Constructors Constructor Description AcelaNode()
Create a new AcelaNode instance on the TrafficController associated with the default AcelaSystemConnectionMemo.AcelaNode(int address, int type, AcelaTrafficController tc)
Create a new AcelaNode instance and initialize default instance variables.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
checkNodeAddress(int address)
Check for valid address with respect to range, etc.AbstractMRMessage
createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.AbstractMRMessage
createOutPacket()
Create a Transmit packet (SerialMessage) to send current state.int
getEndingOutputAddress()
Get ending output address for range.int
getEndingSensorAddress()
Get ending sensor addresses for range.static java.lang.String[]
getModuleNames()
static java.lang.String[]
getNodeNames()
int
getNodeType()
Public method to return node type.java.lang.String
getNodeTypeString()
int
getNumOutputBitsPerCard()
Public method to return number of bits per card.int
getNumSensorBitsPerCard()
boolean
getOutputBit(int bitNumber)
Get the current state of an output bit.int
getOutputInit(int circuitnum)
java.lang.String
getOutputInitString(int circuitnum)
int
getOutputLength(int circuitnum)
int
getOutputSignalHeadType(int circuitnum)
java.lang.String
getOutputSignalHeadTypeString(int circuitnum)
int
getOutputSpecial(int circuitnum)
int
getOutputType(int circuitnum)
java.lang.String
getOutputTypeString(int circuitnum)
int
getOutputWired(int circuitnum)
Get Output configuration values.java.lang.String
getOutputWiredString(int circuitnum)
int
getSensorBitsPerCard()
Get the number of sensor bits per node.int
getSensorPolarity(int circuitnum)
java.lang.String
getSensorPolarityString(int circuitnum)
boolean
getSensorsActive()
Are any sensors present, and hence will this node need to be polled?int
getSensorThreshold(int circuitnum)
int
getSensorType(int circuitnum)
Public method to set and return Sensor configuration values.java.lang.String
getSensorTypeString(int circuitnum)
int
getStartingOutputAddress()
Get starting output address for range.int
getStartingSensorAddress()
Get starting sensor addresses for range.int
getTransmissionDelay()
Get the transmission delay on this node.boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.void
initNode()
void
markChanges(AcelaReply l)
Use the contents of the poll reply to mark changes.void
registerSensor(Sensor s, int rawaddr)
Register a sensor on an Acela node.void
resetTimeout(AbstractMRMessage m)
A reply was received, so there was no timeout, do any needed processing.void
setEndingOutputAddress(int endingAddress)
Set ending output address for range.void
setEndingSensorAddress(int endingAddress)
Set ending sensor addresses for range.void
setNodeType(int type)
void
setNodeTypeString(java.lang.String stringtype)
Public method to set node type.void
setOutputBit(int bitNumber, boolean state)
Set an output bit on this node.void
setOutputInit(int circuitnum, int type)
void
setOutputInitString(int circuitnum, java.lang.String stringtype)
void
setOutputLength(int circuitnum, int newlength)
void
setOutputSignalHeadType(int circuitnum, int type)
void
setOutputSignalHeadTypeString(int circuitnum, java.lang.String stringtype)
void
setOutputSpecial(int circuitnum, int type)
void
setOutputType(int circuitnum, int type)
void
setOutputTypeString(int circuitnum, java.lang.String stringtype)
void
setOutputWired(int circuitnum, int type)
Set Output configuration values.void
setOutputWiredString(int circuitnum, java.lang.String stringtype)
void
setSensorPolarity(int circuitnum, int polarity)
void
setSensorPolarityString(int circuitnum, java.lang.String stringpolarity)
void
setSensorThreshold(int circuitnum, int threshold)
void
setSensorType(int circuitnum, int type)
void
setSensorTypeString(int circuitnum, java.lang.String stringtype)
void
setStartingOutputAddress(int startingAddress)
Set starting output address for range.void
setStartingSensorAddress(int startingAddress)
Set starting sensor address for range.void
setTransmissionDelay(int delay)
Set transmission delay.-
Methods inherited from class jmri.jmrix.AbstractNode
getNodeAddress, mustSend, resetMustSend, setMustSend, setNodeAddress
-
-
-
-
Field Detail
-
MAXSENSORBITS
static final int MAXSENSORBITS
Maximum number of sensors/outputs any node of any type can carry.- See Also:
- Constant Field Values
-
MAXOUTPUTBITS
static final int MAXOUTPUTBITS
- See Also:
- Constant Field Values
-
MAXNODE
static final int MAXNODE
- See Also:
- Constant Field Values
-
AC
public static final byte AC
- See Also:
- Constant Field Values
-
TB
public static final byte TB
- See Also:
- Constant Field Values
-
D8
public static final byte D8
- See Also:
- Constant Field Values
-
WM
public static final byte WM
- See Also:
- Constant Field Values
-
SM
public static final byte SM
- See Also:
- Constant Field Values
-
SC
public static final byte SC
- See Also:
- Constant Field Values
-
SW
public static final byte SW
- See Also:
- Constant Field Values
-
YM
public static final byte YM
- See Also:
- Constant Field Values
-
SY
public static final byte SY
- See Also:
- Constant Field Values
-
UN
public static final byte UN
- See Also:
- Constant Field Values
-
moduleTypes
public static final java.lang.String moduleTypes
- See Also:
- Constant Field Values
-
nodeNames
static final java.lang.String[] nodeNames
-
moduleNames
static final java.lang.String[] moduleNames
-
moduleTips
static final java.lang.String[] moduleTips
-
nodeType
protected int nodeType
-
outputbitsPerCard
protected int outputbitsPerCard
-
sensorbitsPerCard
protected int sensorbitsPerCard
-
transmissionDelay
protected int transmissionDelay
-
needInit
protected boolean needInit
-
outputArray
protected byte[] outputArray
-
outputSpecial
protected int[] outputSpecial
-
outputSignalHeadType
protected int[] outputSignalHeadType
-
hasActiveSensors
protected boolean hasActiveSensors
-
lastUsedSensor
protected int lastUsedSensor
-
sensorArray
protected Sensor[] sensorArray
-
sensorNeedInit
protected boolean[] sensorNeedInit
-
sensorHasBeenInit
protected boolean[] sensorHasBeenInit
-
sensorLastSetting
protected int[] sensorLastSetting
-
sensorType
protected int[] sensorType
-
sensorPolarity
protected int[] sensorPolarity
-
sensorThreshold
protected int[] sensorThreshold
-
sensorConfigArray
protected byte[] sensorConfigArray
-
outputWired
protected int[] outputWired
-
outputInit
protected int[] outputInit
-
outputType
protected int[] outputType
-
outputLength
protected int[] outputLength
-
outputNeedToSend
protected boolean[] outputNeedToSend
-
sensorTypes
public static final java.lang.String sensorTypes
- See Also:
- Constant Field Values
-
sensorPolarities
public static final java.lang.String sensorPolarities
- See Also:
- Constant Field Values
-
outputWireds
public static final java.lang.String outputWireds
- See Also:
- Constant Field Values
-
outputInits
public static final java.lang.String outputInits
- See Also:
- Constant Field Values
-
outputTypes
public static final java.lang.String outputTypes
- See Also:
- Constant Field Values
-
ONOFF
public static final int ONOFF
- See Also:
- Constant Field Values
-
PULSE
public static final int PULSE
- See Also:
- Constant Field Values
-
BLINK
public static final int BLINK
- See Also:
- Constant Field Values
-
outputSignalHeadTypes
public static final java.lang.String outputSignalHeadTypes
- See Also:
- Constant Field Values
-
UKNOWN
public static final int UKNOWN
- See Also:
- Constant Field Values
-
DOUBLE
public static final int DOUBLE
- See Also:
- Constant Field Values
-
TRIPLE
public static final int TRIPLE
- See Also:
- Constant Field Values
-
BPOLAR
public static final int BPOLAR
- See Also:
- Constant Field Values
-
WIGWAG
public static final int WIGWAG
- See Also:
- Constant Field Values
-
outputONOFF
public static final java.lang.String outputONOFF
- See Also:
- Constant Field Values
-
outputLEN0
public static final java.lang.String outputLEN0
- See Also:
- Constant Field Values
-
outputNO
public static final java.lang.String outputNO
- See Also:
- Constant Field Values
-
startingOutputAddress
protected int startingOutputAddress
-
endingOutputAddress
protected int endingOutputAddress
-
startingSensorAddress
protected int startingSensorAddress
-
endingSensorAddress
protected int endingSensorAddress
-
warned
boolean warned
-
timeout
int timeout
-
-
Constructor Detail
-
AcelaNode
public AcelaNode()
Create a new AcelaNode instance on the TrafficController associated with the default AcelaSystemConnectionMemo.Assumes a node address of 0, and a node type of NO_CARD. If this constructor is used, actual node address must be set using
AbstractNode.setNodeAddress(int)
and actual node type usingsetNodeType(int)
-
AcelaNode
public AcelaNode(int address, int type, AcelaTrafficController tc)
Create a new AcelaNode instance and initialize default instance variables.- Parameters:
address
- the address of first bit on Acela bus (0-1023) type - D8, SM, WMtype
- a type constant from the classtc
- the TrafficControllerfor this connection
-
-
Method Detail
-
getNodeNames
public static java.lang.String[] getNodeNames()
-
getModuleNames
public static java.lang.String[] getModuleNames()
-
initNode
public void initNode()
-
setStartingOutputAddress
public void setStartingOutputAddress(int startingAddress)
Set starting output address for range. Used to help linear address search.- Parameters:
startingAddress
- starting output address for range.
-
getStartingOutputAddress
public int getStartingOutputAddress()
Get starting output address for range. Used to help linear address search.- Returns:
- starting output address.
-
setEndingOutputAddress
public void setEndingOutputAddress(int endingAddress)
Set ending output address for range. Used to help linear address search.- Parameters:
endingAddress
- end output address for range.
-
getEndingOutputAddress
public int getEndingOutputAddress()
Get ending output address for range. Used to help linear address search.- Returns:
- end output address for range.
-
setStartingSensorAddress
public void setStartingSensorAddress(int startingAddress)
Set starting sensor address for range. Used to help linear address search.- Parameters:
startingAddress
- start sensor address for range.
-
getStartingSensorAddress
public int getStartingSensorAddress()
Get starting sensor addresses for range. Used to help linear address search.- Returns:
- starting sensor address for range.
-
setEndingSensorAddress
public void setEndingSensorAddress(int endingAddress)
Set ending sensor addresses for range. Used to help linear address search.- Parameters:
endingAddress
- end sensor address.
-
getEndingSensorAddress
public int getEndingSensorAddress()
Get ending sensor addresses for range. Used to help linear address search.- Returns:
- end of range sensor address.
-
setOutputBit
public void setOutputBit(int bitNumber, boolean state)
Set an output bit on this node.- Parameters:
bitNumber
- the bit to setstate
- bit state to set: 'true' for 0, 'false' for 1
-
getOutputBit
public boolean getOutputBit(int bitNumber)
Get the current state of an output bit.- Parameters:
bitNumber
- the bit. Bits are numbered from 0 for Acela- Returns:
- 'true' for 0, 'false' for 1
-
getSensorsActive
public boolean getSensorsActive()
Are any sensors present, and hence will this node need to be polled?- Specified by:
getSensorsActive
in classAbstractNode
- Returns:
- 'true' if at least one sensor is active for this node
-
getOutputWired
public int getOutputWired(int circuitnum)
Get Output configuration values.- Parameters:
circuitnum
- wired output index number.- Returns:
- configuration value.
-
getOutputWiredString
public java.lang.String getOutputWiredString(int circuitnum)
-
setOutputWired
public void setOutputWired(int circuitnum, int type)
Set Output configuration values.- Parameters:
circuitnum
- output index number.type
- output type.
-
setOutputWiredString
public void setOutputWiredString(int circuitnum, java.lang.String stringtype)
-
getOutputInit
public int getOutputInit(int circuitnum)
-
getOutputInitString
public java.lang.String getOutputInitString(int circuitnum)
-
setOutputInit
public void setOutputInit(int circuitnum, int type)
-
setOutputInitString
public void setOutputInitString(int circuitnum, java.lang.String stringtype)
-
getOutputType
public int getOutputType(int circuitnum)
-
getOutputTypeString
public java.lang.String getOutputTypeString(int circuitnum)
-
setOutputType
public void setOutputType(int circuitnum, int type)
-
setOutputTypeString
public void setOutputTypeString(int circuitnum, java.lang.String stringtype)
-
getOutputLength
public int getOutputLength(int circuitnum)
-
setOutputLength
public void setOutputLength(int circuitnum, int newlength)
-
getOutputSpecial
public int getOutputSpecial(int circuitnum)
-
setOutputSpecial
public void setOutputSpecial(int circuitnum, int type)
-
getOutputSignalHeadType
public int getOutputSignalHeadType(int circuitnum)
-
getOutputSignalHeadTypeString
public java.lang.String getOutputSignalHeadTypeString(int circuitnum)
-
setOutputSignalHeadType
public void setOutputSignalHeadType(int circuitnum, int type)
-
setOutputSignalHeadTypeString
public void setOutputSignalHeadTypeString(int circuitnum, java.lang.String stringtype)
-
getSensorType
public int getSensorType(int circuitnum)
Public method to set and return Sensor configuration values.- Parameters:
circuitnum
- sensor type array index number.- Returns:
- sensor index value.
-
getSensorTypeString
public java.lang.String getSensorTypeString(int circuitnum)
-
setSensorType
public void setSensorType(int circuitnum, int type)
-
setSensorTypeString
public void setSensorTypeString(int circuitnum, java.lang.String stringtype)
-
getSensorPolarity
public int getSensorPolarity(int circuitnum)
-
getSensorPolarityString
public java.lang.String getSensorPolarityString(int circuitnum)
-
setSensorPolarity
public void setSensorPolarity(int circuitnum, int polarity)
-
setSensorPolarityString
public void setSensorPolarityString(int circuitnum, java.lang.String stringpolarity)
-
getSensorThreshold
public int getSensorThreshold(int circuitnum)
-
setSensorThreshold
public void setSensorThreshold(int circuitnum, int threshold)
-
getNodeType
public int getNodeType()
Public method to return node type.- Returns:
- node type number.
-
getNodeTypeString
public java.lang.String getNodeTypeString()
-
setNodeTypeString
public void setNodeTypeString(java.lang.String stringtype)
Public method to set node type.- Parameters:
stringtype
- string form of node type.
-
setNodeType
public void setNodeType(int type)
-
getNumOutputBitsPerCard
public int getNumOutputBitsPerCard()
Public method to return number of bits per card.- Returns:
- number of output bits per card.
-
getNumSensorBitsPerCard
public int getNumSensorBitsPerCard()
-
checkNodeAddress
public boolean checkNodeAddress(int address)
Check for valid address with respect to range, etc.- Specified by:
checkNodeAddress
in classAbstractNode
- Parameters:
address
- node number to check.- Returns:
- true if valid
-
getSensorBitsPerCard
public int getSensorBitsPerCard()
Get the number of sensor bits per node.- Returns:
- sensorbitsPerCard
-
getTransmissionDelay
public int getTransmissionDelay()
Get the transmission delay on this node.- Returns:
- delay in 10s of microseconds.
-
setTransmissionDelay
public void setTransmissionDelay(int delay)
Set transmission delay.Note: two bytes are used, so range is 0-65,535. If delay is out of range, it is restricted to the allowable range.
- Parameters:
delay
- a delay between bytes on receive (units of 10 microsec.)
-
createInitPacket
public AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.- Specified by:
createInitPacket
in classAbstractNode
- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
public AbstractMRMessage createOutPacket()
Create a Transmit packet (SerialMessage) to send current state.- Specified by:
createOutPacket
in classAbstractNode
- Returns:
- packet to send current node state.
-
markChanges
public void markChanges(AcelaReply l)
Use the contents of the poll reply to mark changes.- Parameters:
l
- Reply to a poll operation
-
registerSensor
public void registerSensor(Sensor s, int rawaddr)
Register a sensor on an Acela node. The numbers here are 0 to MAXSENSORBITS, not 1 to MAXSENSORBITS.- Parameters:
s
- Sensor objectrawaddr
- index number of sensor's input bit on this node, valid range from 0 to MAXSENSORBITS
-
handleTimeout
public boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.- Specified by:
handleTimeout
in classAbstractNode
- Parameters:
m
- message that didn't receive a replyl
- listener that sent the message- Returns:
- true if initialization is required
-
resetTimeout
public void resetTimeout(AbstractMRMessage m)
A reply was received, so there was no timeout, do any needed processing.- Specified by:
resetTimeout
in classAbstractNode
- Parameters:
m
- message received that has reset the timeout and is waiting to be handled
-
-