Package jmri.jmrix
Class AbstractNode
- java.lang.Object
-
- jmri.jmrix.AbstractNode
-
- Direct Known Subclasses:
AcelaNode
,IEEE802154Node
,SerialNode
,SerialNode
,SerialNode
,SerialNode
,SerialNode
public abstract class AbstractNode extends java.lang.Object
Basic implementation of a node for JMRI protocol support.Integrated with
AbstractMRNodeTrafficController
.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
needSend
int
nodeAddress
-
Constructor Summary
Constructors Constructor Description AbstractNode()
Create a new instance of AbstractNode.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
checkNodeAddress(int address)
Check for valid address with respect to range, etc.abstract AbstractMRMessage
createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.abstract AbstractMRMessage
createOutPacket()
Create a Transmit packet (AbstractMRMessage) to send current state.int
getNodeAddress()
Public method to return the node address.abstract boolean
getSensorsActive()
Are any sensors present, and hence will this node need to be polled?abstract boolean
handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.boolean
mustSend()
Get Must Send state.void
resetMustSend()
Public to reset state of needSend flag.abstract void
resetTimeout(AbstractMRMessage m)
A reply was received, so there was no timeout, do any needed processing.void
setMustSend()
Public to set state of needSend flag.void
setNodeAddress(int address)
Public method to set the node address.
-
-
-
Field Detail
-
nodeAddress
public int nodeAddress
-
needSend
boolean needSend
-
-
Constructor Detail
-
AbstractNode
public AbstractNode()
Create a new instance of AbstractNode.
-
-
Method Detail
-
getNodeAddress
public int getNodeAddress()
Public method to return the node address.- Returns:
- node address number
-
setNodeAddress
public void setNodeAddress(int address)
Public method to set the node address. Address range is checked in subclasses.- Parameters:
address
- address index to set in node- Throws:
java.lang.IllegalArgumentException
- if out of range
-
checkNodeAddress
protected abstract boolean checkNodeAddress(int address)
Check for valid address with respect to range, etc.- Parameters:
address
- node number to check.- Returns:
- true if valid
-
createInitPacket
public abstract AbstractMRMessage createInitPacket()
Create the needed Initialization packet (AbstractMRMessage) for this node.- Returns:
- the packet, or 'null' if not needed
-
createOutPacket
public abstract AbstractMRMessage createOutPacket()
Create a Transmit packet (AbstractMRMessage) to send current state.- Returns:
- packet to send current node state.
-
getSensorsActive
public abstract boolean getSensorsActive()
Are any sensors present, and hence will this node need to be polled?- Returns:
- 'true' if at least one sensor is active for this node
-
handleTimeout
public abstract boolean handleTimeout(AbstractMRMessage m, AbstractMRListener l)
Deal with a timeout in the transmission controller.- Parameters:
m
- message that didn't receive a replyl
- listener that sent the message- Returns:
- true if initialization is required
-
resetTimeout
public abstract void resetTimeout(AbstractMRMessage m)
A reply was received, so there was no timeout, do any needed processing.- Parameters:
m
- message received that has reset the timeout and is waiting to be handled
-
mustSend
public boolean mustSend()
Get Must Send state.- Returns:
- state of needSend flag.
-
resetMustSend
public void resetMustSend()
Public to reset state of needSend flag. Subclasses may override to enforce conditions.
-
setMustSend
public void setMustSend()
Public to set state of needSend flag.
-
-