jmri.jmrix.lenz
Class XNetMessage

java.lang.Object
  extended by jmri.jmrix.AbstractMessage
      extended by jmri.jmrix.AbstractMRMessage
          extended by jmri.jmrix.lenz.XNetMessage
All Implemented Interfaces:
Serializable, Message

public class XNetMessage
extends AbstractMRMessage
implements Serializable

Represents a single command or response on the XpressNet.

Content is represented with ints to avoid the problems with sign-extension that bytes have, and because a Java char is actually a variable number of bytes in Unicode.

Author:
Bob Jacobsen Copyright (C) 2002, Paul Bender Copyright (C) 2003-2010
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
 
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
 
Constructor Summary
XNetMessage(int len)
          Create a new object, representing a specific-length message.
XNetMessage(String s)
          Create an XNetMessage from a String containing bytes.
XNetMessage(XNetMessage message)
          Create a new object, that is a copy of an existing message.
XNetMessage(XNetReply message)
          Create an XNetMessage from an XNetReply.
 
Method Summary
 boolean checkParity()
          check whether the message has a valid parity
static XNetMessage getAddLocoToConsistMsg(int consist, int address, boolean isNormalDir)
           
static XNetMessage getAddressedEmergencyStop(int address)
           
static XNetMessage getBitVerifyOpsModeCVMsg(int AH, int AL, int cv, int bit, boolean value)
           
static XNetMessage getBitWriteOpsModeCVMsg(int AH, int AL, int cv, int bit, boolean value)
           
static XNetMessage getBuildDoubleHeaderMsg(int address1, int address2)
           
static XNetMessage getCSAutoStartMessage(boolean autoMode)
          Generate the message to set the Command Station to Auto or Manual restart mode.
static XNetMessage getCSStatusRequestMessage()
          Generate the message to request the Command Station Status
static XNetMessage getCSVersionRequestMessage()
          Generate the message to request the Command Station Hardware/Software Version
static XNetMessage getDBSearchMsgConsistAddress(int address, boolean searchForward)
           
static XNetMessage getDBSearchMsgNextMULoco(int consist, int address, boolean searchForward)
           
static XNetMessage getDeleteAddressOnStackMsg(int address)
           
static XNetMessage getDisolveDoubleHeaderMsg(int address)
           
 Integer getElementBCD(int n)
          Get an integer representation of a BCD value
static XNetMessage getEmergencyOffMsg()
           
static XNetMessage getExitProgModeMsg()
           
static XNetMessage getFeedbackRequestMsg(int pNumber, boolean pLowerNibble)
          Generate a message to recieve the feedback information for an upper or lower nibble of the feedback address in question
static XNetMessage getFunctionGroup1OpsMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
           
static XNetMessage getFunctionGroup1SetMomMsg(int address, boolean f0, boolean f1, boolean f2, boolean f3, boolean f4)
           
static XNetMessage getFunctionGroup2OpsMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
           
static XNetMessage getFunctionGroup2SetMomMsg(int address, boolean f5, boolean f6, boolean f7, boolean f8)
           
static XNetMessage getFunctionGroup3OpsMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
           
static XNetMessage getFunctionGroup3SetMomMsg(int address, boolean f9, boolean f10, boolean f11, boolean f12)
           
static XNetMessage getFunctionGroup4OpsMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
           
static XNetMessage getFunctionGroup4SetMomMsg(int address, boolean f13, boolean f14, boolean f15, boolean f16, boolean f17, boolean f18, boolean f19, boolean f20)
           
static XNetMessage getFunctionGroup5OpsMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
           
static XNetMessage getFunctionGroup5SetMomMsg(int address, boolean f21, boolean f22, boolean f23, boolean f24, boolean f25, boolean f26, boolean f27, boolean f28)
           
static XNetMessage getLIAddressRequestMsg(int address)
          Generate the message to set or request the Computer Interface Address
static XNetMessage getLISpeedRequestMsg(int speed)
          Generate the message to set or request the Computer Interface speed
static XNetMessage getLIVersionRequestMessage()
          Generate the message to request the Computer Interface Hardware/Software Version
static XNetMessage getLocomotiveFunctionHighMomStatusMsg(int address)
           
static XNetMessage getLocomotiveFunctionHighOnStatusMsg(int address)
           
static XNetMessage getLocomotiveFunctionStatusMsg(int address)
           
static XNetMessage getLocomotiveInfoRequestMsg(int address)
           
static XNetMessage getNextAddressOnStackMsg(int address, boolean searchForward)
           
static XNetMessage getNMRAXNetMsg(byte[] packet)
           
 int getOpCode()
           
 String getOpCodeHex()
          Get a String representation of the op code in hex
static XNetMessage getReadDirectCVMsg(int cv)
           
static XNetMessage getReadPagedCVMsg(int cv)
           
static XNetMessage getReadRegisterMsg(int reg)
           
static XNetMessage getRemoveLocoFromConsistMsg(int consist, int address)
           
static XNetMessage getResumeOperationsMsg()
           
static XNetMessage getServiceModeResultsMsg()
           
static XNetMessage getSpeedAndDirectionMsg(int address, int speedStepMode, float speed, boolean isForward)
           
static XNetMessage getTurnoutCommandMsg(int pNumber, boolean pClose, boolean pThrow, boolean pOn)
          Generate a message to change turnout state
static XNetMessage getVerifyOpsModeCVMsg(int AH, int AL, int cv, int val)
           
static XNetMessage getWriteDirectCVMsg(int cv, int val)
           
static XNetMessage getWriteOpsModeCVMsg(int AH, int AL, int cv, int val)
           
static XNetMessage getWritePagedCVMsg(int cv, int val)
           
static XNetMessage getWriteRegisterMsg(int reg, int val)
           
 int length()
          return the message length
 void setOpCode(int i)
           
 void setParity()
           
static void setXNetMessageRetries(int t)
          changing the default number of retries for an XPressNet message
static void setXNetMessageTimeout(int t)
          changing the default timeout for an XPressNet message
 
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getRetries, getTimeout, isBinary, replyExpected, setBinary, setNeededMode, setRetries, setTimeout, toString
 
Methods inherited from class jmri.jmrix.AbstractMessage
getElement, getNumDataElements, setElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XNetMessage

public XNetMessage(int len)
Create a new object, representing a specific-length message.

Parameters:
len - Total bytes in message, including opcode and error-detection byte.

XNetMessage

public XNetMessage(XNetMessage message)
Create a new object, that is a copy of an existing message.

Parameters:
message - existing message.

XNetMessage

public XNetMessage(XNetReply message)
Create an XNetMessage from an XNetReply.


XNetMessage

public XNetMessage(String s)
Create an XNetMessage from a String containing bytes.

Method Detail

setOpCode

public void setOpCode(int i)
Overrides:
setOpCode in class AbstractMRMessage

getOpCode

public int getOpCode()
Overrides:
getOpCode in class AbstractMRMessage

getOpCodeHex

public String getOpCodeHex()
Get a String representation of the op code in hex

Overrides:
getOpCodeHex in class AbstractMRMessage

checkParity

public boolean checkParity()
check whether the message has a valid parity


setParity

public void setParity()

getElementBCD

public Integer getElementBCD(int n)
Get an integer representation of a BCD value


length

public int length()
return the message length


setXNetMessageRetries

public static void setXNetMessageRetries(int t)
changing the default number of retries for an XPressNet message

Parameters:
t - number of retries to attempt.

setXNetMessageTimeout

public static void setXNetMessageTimeout(int t)
changing the default timeout for an XPressNet message

Parameters:
t - Timeout in milliseconds

getNMRAXNetMsg

public static XNetMessage getNMRAXNetMsg(byte[] packet)

getTurnoutCommandMsg

public static XNetMessage getTurnoutCommandMsg(int pNumber,
                                               boolean pClose,
                                               boolean pThrow,
                                               boolean pOn)
Generate a message to change turnout state


getFeedbackRequestMsg

public static XNetMessage getFeedbackRequestMsg(int pNumber,
                                                boolean pLowerNibble)
Generate a message to recieve the feedback information for an upper or lower nibble of the feedback address in question


getServiceModeResultsMsg

public static XNetMessage getServiceModeResultsMsg()

getExitProgModeMsg

public static XNetMessage getExitProgModeMsg()

getReadPagedCVMsg

public static XNetMessage getReadPagedCVMsg(int cv)

getReadDirectCVMsg

public static XNetMessage getReadDirectCVMsg(int cv)

getWritePagedCVMsg

public static XNetMessage getWritePagedCVMsg(int cv,
                                             int val)

getWriteDirectCVMsg

public static XNetMessage getWriteDirectCVMsg(int cv,
                                              int val)

getReadRegisterMsg

public static XNetMessage getReadRegisterMsg(int reg)

getWriteRegisterMsg

public static XNetMessage getWriteRegisterMsg(int reg,
                                              int val)

getWriteOpsModeCVMsg

public static XNetMessage getWriteOpsModeCVMsg(int AH,
                                               int AL,
                                               int cv,
                                               int val)

getVerifyOpsModeCVMsg

public static XNetMessage getVerifyOpsModeCVMsg(int AH,
                                                int AL,
                                                int cv,
                                                int val)

getBitWriteOpsModeCVMsg

public static XNetMessage getBitWriteOpsModeCVMsg(int AH,
                                                  int AL,
                                                  int cv,
                                                  int bit,
                                                  boolean value)

getBitVerifyOpsModeCVMsg

public static XNetMessage getBitVerifyOpsModeCVMsg(int AH,
                                                   int AL,
                                                   int cv,
                                                   int bit,
                                                   boolean value)

getBuildDoubleHeaderMsg

public static XNetMessage getBuildDoubleHeaderMsg(int address1,
                                                  int address2)

getDisolveDoubleHeaderMsg

public static XNetMessage getDisolveDoubleHeaderMsg(int address)

getAddLocoToConsistMsg

public static XNetMessage getAddLocoToConsistMsg(int consist,
                                                 int address,
                                                 boolean isNormalDir)

getRemoveLocoFromConsistMsg

public static XNetMessage getRemoveLocoFromConsistMsg(int consist,
                                                      int address)

getNextAddressOnStackMsg

public static XNetMessage getNextAddressOnStackMsg(int address,
                                                   boolean searchForward)

getDBSearchMsgConsistAddress

public static XNetMessage getDBSearchMsgConsistAddress(int address,
                                                       boolean searchForward)

getDBSearchMsgNextMULoco

public static XNetMessage getDBSearchMsgNextMULoco(int consist,
                                                   int address,
                                                   boolean searchForward)

getDeleteAddressOnStackMsg

public static XNetMessage getDeleteAddressOnStackMsg(int address)

getLocomotiveInfoRequestMsg

public static XNetMessage getLocomotiveInfoRequestMsg(int address)

getLocomotiveFunctionStatusMsg

public static XNetMessage getLocomotiveFunctionStatusMsg(int address)

getLocomotiveFunctionHighOnStatusMsg

public static XNetMessage getLocomotiveFunctionHighOnStatusMsg(int address)

getLocomotiveFunctionHighMomStatusMsg

public static XNetMessage getLocomotiveFunctionHighMomStatusMsg(int address)

getAddressedEmergencyStop

public static XNetMessage getAddressedEmergencyStop(int address)

getSpeedAndDirectionMsg

public static XNetMessage getSpeedAndDirectionMsg(int address,
                                                  int speedStepMode,
                                                  float speed,
                                                  boolean isForward)

getFunctionGroup1OpsMsg

public static XNetMessage getFunctionGroup1OpsMsg(int address,
                                                  boolean f0,
                                                  boolean f1,
                                                  boolean f2,
                                                  boolean f3,
                                                  boolean f4)

getFunctionGroup1SetMomMsg

public static XNetMessage getFunctionGroup1SetMomMsg(int address,
                                                     boolean f0,
                                                     boolean f1,
                                                     boolean f2,
                                                     boolean f3,
                                                     boolean f4)

getFunctionGroup2OpsMsg

public static XNetMessage getFunctionGroup2OpsMsg(int address,
                                                  boolean f5,
                                                  boolean f6,
                                                  boolean f7,
                                                  boolean f8)

getFunctionGroup2SetMomMsg

public static XNetMessage getFunctionGroup2SetMomMsg(int address,
                                                     boolean f5,
                                                     boolean f6,
                                                     boolean f7,
                                                     boolean f8)

getFunctionGroup3OpsMsg

public static XNetMessage getFunctionGroup3OpsMsg(int address,
                                                  boolean f9,
                                                  boolean f10,
                                                  boolean f11,
                                                  boolean f12)

getFunctionGroup3SetMomMsg

public static XNetMessage getFunctionGroup3SetMomMsg(int address,
                                                     boolean f9,
                                                     boolean f10,
                                                     boolean f11,
                                                     boolean f12)

getFunctionGroup4OpsMsg

public static XNetMessage getFunctionGroup4OpsMsg(int address,
                                                  boolean f13,
                                                  boolean f14,
                                                  boolean f15,
                                                  boolean f16,
                                                  boolean f17,
                                                  boolean f18,
                                                  boolean f19,
                                                  boolean f20)

getFunctionGroup4SetMomMsg

public static XNetMessage getFunctionGroup4SetMomMsg(int address,
                                                     boolean f13,
                                                     boolean f14,
                                                     boolean f15,
                                                     boolean f16,
                                                     boolean f17,
                                                     boolean f18,
                                                     boolean f19,
                                                     boolean f20)

getFunctionGroup5OpsMsg

public static XNetMessage getFunctionGroup5OpsMsg(int address,
                                                  boolean f21,
                                                  boolean f22,
                                                  boolean f23,
                                                  boolean f24,
                                                  boolean f25,
                                                  boolean f26,
                                                  boolean f27,
                                                  boolean f28)

getFunctionGroup5SetMomMsg

public static XNetMessage getFunctionGroup5SetMomMsg(int address,
                                                     boolean f21,
                                                     boolean f22,
                                                     boolean f23,
                                                     boolean f24,
                                                     boolean f25,
                                                     boolean f26,
                                                     boolean f27,
                                                     boolean f28)

getResumeOperationsMsg

public static XNetMessage getResumeOperationsMsg()

getEmergencyOffMsg

public static XNetMessage getEmergencyOffMsg()

getCSVersionRequestMessage

public static XNetMessage getCSVersionRequestMessage()
Generate the message to request the Command Station Hardware/Software Version


getCSStatusRequestMessage

public static XNetMessage getCSStatusRequestMessage()
Generate the message to request the Command Station Status


getCSAutoStartMessage

public static XNetMessage getCSAutoStartMessage(boolean autoMode)
Generate the message to set the Command Station to Auto or Manual restart mode.


getLIVersionRequestMessage

public static XNetMessage getLIVersionRequestMessage()
Generate the message to request the Computer Interface Hardware/Software Version


getLIAddressRequestMsg

public static XNetMessage getLIAddressRequestMsg(int address)
Generate the message to set or request the Computer Interface Address

Parameters:
address - Interface address (0-31). Send invalid address to request the address (32-255).

getLISpeedRequestMsg

public static XNetMessage getLISpeedRequestMsg(int speed)
Generate the message to set or request the Computer Interface speed

Parameters:
speed - 1 is 19,200bps, 2 is 38,400bps, 3 is 57,600bps, 4 is 115,200bps. Send invalid speed to request the current setting.


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