jmri.jmrix.lenz
Class XNetPacketizer

java.lang.Object
  extended by jmri.jmrix.AbstractMRTrafficController
      extended by jmri.jmrix.lenz.XNetTrafficController
          extended by jmri.jmrix.lenz.XNetPacketizer
All Implemented Interfaces:
XNetInterface
Direct Known Subclasses:
LI100XNetPacketizer, LIUSBServerXNetPacketizer, LIUSBXNetPacketizer, XnTcpXNetPacketizer, ZTC640XNetPacketizer

public class XNetPacketizer
extends XNetTrafficController

Converts Stream-based I/O to/from XNet messages. The "XNetInterface" side sends/receives XNetMessage objects. The connection to a XNetPortController is via a pair of *Streams, which then carry sequences of characters for transmission.

Messages come to this via the main GUI thread, and are forwarded back to listeners in that same thread. Reception and transmission are handled in dedicated threads by RcvHandler and XmtHandler objects. Those are internal classes defined here. The thread priorities are:

Author:
Bob Jacobsen Copyright (C) 2001

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
 
Field Summary
 
Fields inherited from class jmri.jmrix.lenz.XNetTrafficController
mListenerMasks
 
Fields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, AUTORETRYSTATE, cmdListeners, controller, flushReceiveChars, IDLESTATE, istream, mCurrentMode, mCurrentState, mLastSender, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, POLLSTATE, PROGRAMINGMODE, rcvException, replyInDispatch, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable
 
Fields inherited from interface jmri.jmrix.lenz.XNetInterface
ALL, COMMINFO, CONSIST, CS_INFO, FEEDBACK, INTERFACE, PROGRAMMING, THROTTLE
 
Constructor Summary
XNetPacketizer(LenzCommandStation pCommandStation)
           
 
Method Summary
protected  void addTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)
          Add trailer to the outgoing byte stream.
 boolean portReadyToSend(AbstractPortController p)
          Check to see if PortController object can be sent to.
 void sendXNetMessage(XNetMessage m, XNetListener reply)
          Forward a preformatted XNetMessage to the actual interface.
 boolean status()
           
 
Methods inherited from class jmri.jmrix.lenz.XNetTrafficController
addXNetListener, endOfMessage, enterNormalMode, enterProgMode, forwardMessage, forwardReply, getCommandStation, getSystemConnectionMemo, handleTimeout, instance, loadChars, newReply, pollMessage, pollReplyHandler, programmerIdle, removeXNetListener, sendHighPriorityXNetMessage, setInstance, setSystemConnectionMemo
 
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addHeaderToOutput, addListener, canReceive, connectionWarn, connectPort, disconnectPort, enterProgModeDelayTime, finalize, forwardToPort, getLastSender, getPortName, getSelfLock, handleOneIncomingReply, hasTimeouts, lengthOfByteStream, newRcvNotifier, notifyMessage, notifyReply, portWarn, portWarnTCP, readByteProtected, receiveLoop, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, terminate, transmitWait, waitForStartOfReply
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XNetPacketizer

public XNetPacketizer(LenzCommandStation pCommandStation)
Method Detail

status

public boolean status()
Specified by:
status in interface XNetInterface
Specified by:
status in class XNetTrafficController

sendXNetMessage

public void sendXNetMessage(XNetMessage m,
                            XNetListener reply)
Forward a preformatted XNetMessage to the actual interface. Checksum is computed and overwritten here, then the message is converted to a byte array and queue for transmission

Specified by:
sendXNetMessage in interface XNetInterface
Specified by:
sendXNetMessage in class XNetTrafficController
Parameters:
m - Message to send; will be updated with CRC

addTrailerToOutput

protected void addTrailerToOutput(byte[] msg,
                                  int offset,
                                  AbstractMRMessage m)
Add trailer to the outgoing byte stream. This version adds the checksum to the last byte.

Overrides:
addTrailerToOutput in class AbstractMRTrafficController
Parameters:
msg - The output byte stream
offset - the first byte not yet used

portReadyToSend

public boolean portReadyToSend(AbstractPortController p)
                        throws Exception
Check to see if PortController object can be sent to. returns true if ready, false otherwise May throw an Exception.

Overrides:
portReadyToSend in class AbstractMRTrafficController
Throws:
Exception


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads