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 boolean
logDebug
-
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 void
addIEEE802154Listener(IEEE802154Listener l)
protected void
addTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)
Add trailer to the outgoing byte stream.void
deleteNode(java.lang.String nodeAddress)
Delete a node by the string representation of its address.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.protected AbstractMRMessage
enterNormalMode()
Sets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessage
enterProgMode()
Set the system to programming mode.protected int
enterProgModeDelayTime()
Get the delay (wait time) after enabling the programming track.protected void
forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a IEEE802154Message to all registered IEEE802154Interface listeners.protected void
forwardReply(AbstractMRListener client, AbstractMRReply r)
Forward a reply to all registered IEEE802154Interface listeners.protected void
forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
Actually transmit the next message to the port.IEEE802154SystemConnectionMemo
getAdapterMemo()
IEEE802154Message
getIEEE802154Message(int length)
Get a message of a specific length for filling in.AbstractNode
getNodeFromAddress(byte[] ba)
Identify a SerialNode from its node address.AbstractNode
getNodeFromAddress(int[] ia)
Identify a SerialNode from its node address Note: 'addr' is the node address.AbstractNode
getNodeFromAddress(java.lang.String addr)
Identify a SerialNode from its node address.abstract IEEE802154Node
newNode()
Build a new IEEE802154 Node.protected AbstractMRMessage
pollMessage()
Eventually, do initialization if neededprotected AbstractMRListener
pollReplyHandler()
void
removeIEEE802154Listener(IEEE802154Listener l)
void
sendIEEE802154Message(IEEE802154Message m, IEEE802154Listener reply)
Forward a preformatted message to the actual interface.void
setAdapterMemo(IEEE802154SystemConnectionMemo adaptermemo)
protected void
waitForStartOfReply(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:
addIEEE802154Listener
in interfaceIEEE802154Interface
-
removeIEEE802154Listener
public void removeIEEE802154Listener(IEEE802154Listener l)
- Specified by:
removeIEEE802154Listener
in interfaceIEEE802154Interface
-
enterProgModeDelayTime
protected int enterProgModeDelayTime()
Description copied from class:AbstractMRTrafficController
Get the delay (wait time) after enabling the programming track. Override in subclass to add a longer delay.- Overrides:
enterProgModeDelayTime
in classAbstractMRTrafficController
- Returns:
- 0 as default delay
-
forwardMessage
protected void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a IEEE802154Message to all registered IEEE802154Interface listeners.- Specified by:
forwardMessage
in 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:
forwardReply
in classAbstractMRTrafficController
-
pollMessage
protected AbstractMRMessage pollMessage()
Eventually, do initialization if needed- Specified by:
pollMessage
in classAbstractMRTrafficController
- Returns:
- Formatted poll message
-
pollReplyHandler
protected AbstractMRListener pollReplyHandler()
- Specified by:
pollReplyHandler
in classAbstractMRTrafficController
-
sendIEEE802154Message
public void sendIEEE802154Message(IEEE802154Message m, IEEE802154Listener reply)
Forward a preformatted message to the actual interface.- Specified by:
sendIEEE802154Message
in interfaceIEEE802154Interface
-
forwardToPort
protected void forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
Description copied from class:AbstractMRTrafficController
Actually transmit the next message to the port.- Overrides:
forwardToPort
in 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:AbstractMRTrafficController
Set the system to programming mode.- Specified by:
enterProgMode
in 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:AbstractMRTrafficController
Sets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()
returns true, enterNormalMode() is called after a timeout.- Specified by:
enterNormalMode
in 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:
waitForStartOfReply
in 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:
endOfMessage
in 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:
addTrailerToOutput
in 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
-
-