Class IEEE802154TrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.AbstractMRNodeTrafficController
-
- jmri.jmrix.ieee802154.IEEE802154TrafficController
-
- All Implemented Interfaces:
IEEE802154Interface
- Direct Known Subclasses:
SerialTrafficController,XBeeTrafficController
public abstract class IEEE802154TrafficController extends AbstractMRNodeTrafficController implements IEEE802154Interface
Converts Stream-based I/O to/from messages. The "IEEE802154Interface" side sends/receives message objects.The connection to a IEEE802154PortController is via a pair of *Streams, which then carry sequences of characters for transmission. Note that this processing is handled in an independent thread.
This maintains a list of nodes, but doesn't currently do anything with it. This implementation is complete and can be instantiated, but is not functional. It will be created e.g. when a default object is needed for configuring nodes, etc, during the initial configuration. A subclass must be instantiated to actually communicate with an adapter.
-
-
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 booleanlogDebug-
Fields inherited from class jmri.jmrix.AbstractMRNodeTrafficController
curSerialNodeIndex, maxNode, minNode, nodeArray, numNodes
-
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 IEEE802154TrafficController()Create a new IEEE802154TrafficController instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddIEEE802154Listener(IEEE802154Listener l)protected voidaddTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)Add trailer to the outgoing byte stream.voiddeleteNode(java.lang.String nodeAddress)Delete a node by the string representation of its address.protected booleanendOfMessage(AbstractMRReply msg)The length is the first byte of the message payload, The end of the message occurs when the length of the message is equal to the payload length.protected AbstractMRMessageenterNormalMode()Sets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageenterProgMode()Set the system to programming mode.protected intenterProgModeDelayTime()Get the delay (wait time) after enabling the programming track.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m)Forward a IEEE802154Message to all registered IEEE802154Interface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply r)Forward a reply to all registered IEEE802154Interface listeners.protected voidforwardToPort(AbstractMRMessage m, AbstractMRListener reply)Actually transmit the next message to the port.IEEE802154SystemConnectionMemogetAdapterMemo()IEEE802154MessagegetIEEE802154Message(int length)Get a message of a specific length for filling in.AbstractNodegetNodeFromAddress(byte[] ba)Identify a SerialNode from its node address.AbstractNodegetNodeFromAddress(int[] ia)Identify a SerialNode from its node address Note: 'addr' is the node address.AbstractNodegetNodeFromAddress(java.lang.String addr)Identify a SerialNode from its node address.abstract IEEE802154NodenewNode()Build a new IEEE802154 Node.protected AbstractMRMessagepollMessage()Eventually, do initialization if neededprotected AbstractMRListenerpollReplyHandler()voidremoveIEEE802154Listener(IEEE802154Listener l)voidsendIEEE802154Message(IEEE802154Message m, IEEE802154Listener reply)Forward a preformatted message to the actual interface.voidsetAdapterMemo(IEEE802154SystemConnectionMemo adaptermemo)protected voidwaitForStartOfReply(java.io.DataInputStream istream)IEEE 802.15.4 messages start with a 0x7E delimiter byte.-
Methods inherited from class jmri.jmrix.AbstractMRNodeTrafficController
deleteNode, getMustInit, getNode, getNodeFromAddress, getNumNodes, init, registerNode, setMustInit, setMustInit
-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, newReply, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, warnOnTimeout
-
-
-
-
Field Detail
-
logDebug
protected boolean logDebug
-
-
Constructor Detail
-
IEEE802154TrafficController
public IEEE802154TrafficController()
Create a new IEEE802154TrafficController instance.
-
-
Method Detail
-
getIEEE802154Message
public IEEE802154Message getIEEE802154Message(int length)
Get a message of a specific length for filling in.This is a default, null implementation, which must be overridden in an adapter-specific subclass.
- Parameters:
length- length for new message- Returns:
- null since this method should be over-ridden
-
addIEEE802154Listener
public void addIEEE802154Listener(IEEE802154Listener l)
- Specified by:
addIEEE802154Listenerin interfaceIEEE802154Interface
-
removeIEEE802154Listener
public void removeIEEE802154Listener(IEEE802154Listener l)
- Specified by:
removeIEEE802154Listenerin interfaceIEEE802154Interface
-
enterProgModeDelayTime
protected int enterProgModeDelayTime()
Description copied from class:AbstractMRTrafficControllerGet the delay (wait time) after enabling the programming track. Override in subclass to add a longer delay.- Overrides:
enterProgModeDelayTimein classAbstractMRTrafficController- Returns:
- 0 as default delay
-
forwardMessage
protected void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a IEEE802154Message to all registered IEEE802154Interface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
protected void forwardReply(AbstractMRListener client, AbstractMRReply r)
Forward a reply to all registered IEEE802154Interface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
pollMessage
protected AbstractMRMessage pollMessage()
Eventually, do initialization if needed- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
protected AbstractMRListener pollReplyHandler()
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendIEEE802154Message
public void sendIEEE802154Message(IEEE802154Message m, IEEE802154Listener reply)
Forward a preformatted message to the actual interface.- Specified by:
sendIEEE802154Messagein interfaceIEEE802154Interface
-
forwardToPort
protected void forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
Description copied from class:AbstractMRTrafficControllerActually transmit the next message to the port.- Overrides:
forwardToPortin classAbstractMRTrafficController- Parameters:
m- the message to sendreply- the Listener sending the message, often provided as 'this'- See Also:
AbstractMRTrafficController.sendMessage(AbstractMRMessage, AbstractMRListener)
-
enterProgMode
protected AbstractMRMessage enterProgMode()
Description copied from class:AbstractMRTrafficControllerSet the system to programming mode.- Specified by:
enterProgModein classAbstractMRTrafficController- Returns:
- any message that needs to be returned to the Command Station to change modes. If no message is needed, returns null.
- See Also:
AbstractMRTrafficController.enterNormalMode()
-
enterNormalMode
protected AbstractMRMessage enterNormalMode()
Description copied from class:AbstractMRTrafficControllerSets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()returns true, enterNormalMode() is called after a timeout.- Specified by:
enterNormalModein classAbstractMRTrafficController- Returns:
- any message that needs to be returned to the Command Station to change modes. If no message is needed, returns null.
- See Also:
AbstractMRTrafficController.enterProgMode()
-
setAdapterMemo
public void setAdapterMemo(IEEE802154SystemConnectionMemo adaptermemo)
-
getAdapterMemo
public IEEE802154SystemConnectionMemo getAdapterMemo()
-
waitForStartOfReply
protected void waitForStartOfReply(java.io.DataInputStream istream) throws java.io.IOException
IEEE 802.15.4 messages start with a 0x7E delimiter byte.- Overrides:
waitForStartOfReplyin classAbstractMRTrafficController- Parameters:
istream- input source- Throws:
java.io.IOException- from underlying operations
-
endOfMessage
protected boolean endOfMessage(AbstractMRReply msg)
The length is the first byte of the message payload, The end of the message occurs when the length of the message is equal to the payload length.
NOTE: This function does not work with XBee nodes, which provide a modified version of the packets sent via the radio.
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
addTrailerToOutput
protected void addTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)
Add trailer to the outgoing byte stream. This version adds the checksum to the end of the message.- Overrides:
addTrailerToOutputin classAbstractMRTrafficController- Parameters:
msg- The output byte streamoffset- the first byte not yet usedm- output message to extend
-
newNode
public abstract IEEE802154Node newNode()
Build a new IEEE802154 Node. Must be implemented by derived classes- Returns:
- new IEEE802154Node.
-
getNodeFromAddress
public AbstractNode getNodeFromAddress(java.lang.String addr)
Identify a SerialNode from its node address.- Parameters:
addr- hex string for address, numbered from 0- Returns:
- serial node id, or 'niull' if a SerialNode with the specified address was not found
-
getNodeFromAddress
public AbstractNode getNodeFromAddress(int[] ia)
Identify a SerialNode from its node address Note: 'addr' is the node address.- Parameters:
ia- int array of node address, numbered from 0- Returns:
- serial address, or 'null' if a SerialNode with the specified address was not found
-
getNodeFromAddress
public AbstractNode getNodeFromAddress(byte[] ba)
Identify a SerialNode from its node address.- Parameters:
ba- array of bytes in hex address- Returns:
- serial node id, or 'null' if a SerialNode with the specified address was not found
-
deleteNode
public void deleteNode(java.lang.String nodeAddress)
Delete a node by the string representation of its address.- Parameters:
nodeAddress- text of hex node address
-
-