Class IEEE802154TrafficController
- All Implemented Interfaces:
IEEE802154Interface
- Direct Known Subclasses:
SerialTrafficController,XBeeTrafficController
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
FieldsFields inherited from class jmri.jmrix.AbstractMRNodeTrafficController
curSerialNodeIndex, maxNode, minNode, nodeArray, numNodesFields 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
ConstructorsConstructorDescriptionCreate a new IEEE802154TrafficController instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidaddTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m) Add trailer to the outgoing byte stream.voiddeleteNode(String nodeAddress) Delete a node by the string representation of its address.protected booleanThe 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 AbstractMRMessageSets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageSet the system to programming mode.protected intGet 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.getIEEE802154Message(int length) Get a message of a specific length for filling in.getNodeFromAddress(byte[] ba) Identify a SerialNode from its node address.getNodeFromAddress(int[] ia) Identify a SerialNode from its node address Note: 'addr' is the node address.getNodeFromAddress(String addr) Identify a SerialNode from its node address.abstract IEEE802154NodenewNode()Build a new IEEE802154 Node.protected AbstractMRMessageEventually, do initialization if neededprotected AbstractMRListenervoidvoidForward a preformatted message to the actual interface.voidsetAdapterMemo(IEEE802154SystemConnectionMemo adaptermemo) protected voidwaitForStartOfReply(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, setMustInitMethods 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 Details
-
logDebug
-
-
Constructor Details
-
IEEE802154TrafficController
public IEEE802154TrafficController()Create a new IEEE802154TrafficController instance.
-
-
Method Details
-
getIEEE802154Message
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
- Specified by:
addIEEE802154Listenerin interfaceIEEE802154Interface
-
removeIEEE802154Listener
- Specified by:
removeIEEE802154Listenerin interfaceIEEE802154Interface
-
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
Forward a IEEE802154Message to all registered IEEE802154Interface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
Forward a reply to all registered IEEE802154Interface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
pollMessage
Eventually, do initialization if needed- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendIEEE802154Message
Forward a preformatted message to the actual interface.- Specified by:
sendIEEE802154Messagein interfaceIEEE802154Interface
-
forwardToPort
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:
-
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:
-
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:
-
setAdapterMemo
-
getAdapterMemo
-
waitForStartOfReply
IEEE 802.15.4 messages start with a 0x7E delimiter byte.- Overrides:
waitForStartOfReplyin classAbstractMRTrafficController- Parameters:
istream- input source- Throws:
IOException- from underlying operations
-
endOfMessage
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
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
Build a new IEEE802154 Node. Must be implemented by derived classes- Returns:
- new IEEE802154Node.
-
getNodeFromAddress
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
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
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
Delete a node by the string representation of its address.- Parameters:
nodeAddress- text of hex node address
-