Package jmri.jmrix
Class AbstractMRNodeTrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.AbstractMRNodeTrafficController
-
- Direct Known Subclasses:
AcelaTrafficController
,IEEE802154TrafficController
,SerialTrafficController
,SerialTrafficController
,SerialTrafficController
,SerialTrafficController
,SerialTrafficController
public abstract class AbstractMRNodeTrafficController extends AbstractMRTrafficController
Abstract Traffic Controller base class for those implementations that track a set of nodes.The nodes are descendents of
AbstractNode
. Provides node management services, but no additional protocol.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
-
-
Field Summary
Fields Modifier and Type Field Description protected int
curSerialNodeIndex
Working variable for keeping track of the active node, if any.protected int
maxNode
protected int
minNode
protected AbstractNode[]
nodeArray
protected int
numNodes
Total number of SerialNodes registered with this TrafficController.-
Fields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, AUTORETRYSTATE, cmdListeners, connectionError, controller, flushReceiveChars, IDLESTATE, istream, listenerQueue, maxRcvExceptionCount, mCurrentMode, mCurrentState, mLastSender, msgQueue, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, POLLSTATE, PROGRAMINGMODE, rcvException, rcvThread, replyInDispatch, threadStopRequest, timeoutFlag, timeouts, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable, xmtThread
-
-
Constructor Summary
Constructors Constructor Description AbstractMRNodeTrafficController()
Create a new unnamed MRNodeTrafficController instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteNode(int nodeAddress)
Delete a SerialNode by node address.protected boolean
getMustInit(int i)
Does a given node need to have initialization data sent?AbstractNode
getNode(int index)
Get the Serial node for a given index as registered with this TrafficController.AbstractNode
getNodeFromAddress(int addr)
Identify a SerialNode from its node address.int
getNumNodes()
Get the total number of currently registered nodes.protected void
init(int minNode, int maxNode)
Initialize based on number of first and last nodes.void
registerNode(AbstractNode node)
Register a Serial node on this TrafficController.protected void
setMustInit(int i, boolean v)
Mark whether a given node needs to have initialization data sent.protected void
setMustInit(AbstractNode node, boolean v)
-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, endOfMessage, enterNormalMode, enterProgMode, enterProgModeDelayTime, forwardMessage, forwardReply, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, newReply, notifyMessage, notifyReply, pollMessage, pollReplyHandler, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeout
-
-
-
-
Field Detail
-
minNode
protected int minNode
-
maxNode
protected int maxNode
-
numNodes
protected volatile int numNodes
Total number of SerialNodes registered with this TrafficController. Incremented as Serial Nodes are created and registered. Corresponds to the next available address innodeArray
.
-
nodeArray
protected AbstractNode[] nodeArray
-
curSerialNodeIndex
protected int curSerialNodeIndex
Working variable for keeping track of the active node, if any.
-
-
Constructor Detail
-
AbstractMRNodeTrafficController
public AbstractMRNodeTrafficController()
Create a new unnamed MRNodeTrafficController instance.
-
-
Method Detail
-
init
protected void init(int minNode, int maxNode)
Initialize based on number of first and last nodes.- Parameters:
minNode
- lowest node number, usually 0maxNode
- highest node number
-
getMustInit
protected boolean getMustInit(int i)
Does a given node need to have initialization data sent?- Parameters:
i
- the node address (number)- Returns:
- true if initialization data is required
-
setMustInit
protected void setMustInit(int i, boolean v)
Mark whether a given node needs to have initialization data sent.- Parameters:
i
- the node indexv
- true if set to require sending initialization data
-
setMustInit
protected void setMustInit(AbstractNode node, boolean v)
-
getNumNodes
public int getNumNodes()
Get the total number of currently registered nodes.- Returns:
- the number of registerd nodes on this connection
-
registerNode
public void registerNode(AbstractNode node)
Register a Serial node on this TrafficController.- Parameters:
node
- the node object to register
-
getNode
public AbstractNode getNode(int index)
Get the Serial node for a given index as registered with this TrafficController.- Parameters:
index
- the index number of the node. To cycle through all nodes, begin with index=0, and increment your index at each call.- Returns:
- the node at index, 'null' when index exceeds the number of defined nodes
-
getNodeFromAddress
public AbstractNode getNodeFromAddress(int addr)
Identify a SerialNode from its node address.- Parameters:
addr
- the node address, numbered from 0- Returns:
- the node at node address, 'null' if a SerialNode with the specified address was not found
-
deleteNode
public void deleteNode(int nodeAddress)
Delete a SerialNode by node address.- Parameters:
nodeAddress
- address number for the node to be deleted
-
-