jmri.jmrix.lenz
Class XNetReply

java.lang.Object
  extended by jmri.jmrix.AbstractMessage
      extended by jmri.jmrix.AbstractMRReply
          extended by jmri.jmrix.lenz.XNetReply
All Implemented Interfaces:
Message

public class XNetReply
extends AbstractMRReply

Represents a single response from the XpressNet.

Author:
Paul Bender Copyright (C) 2004

Field Summary
 
Fields inherited from class jmri.jmrix.AbstractMRReply
DEFAULTMAXSIZE
 
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
 
Constructor Summary
XNetReply()
           
XNetReply(String message)
          Create a reply from a string of hex characters.
XNetReply(XNetMessage message)
          Create a reply from an XNetMessage.
XNetReply(XNetReply reply)
           
 
Method Summary
 boolean checkParity()
          check whether the message has a valid parity
 Integer getElementBCD(int n)
          Get an integer representation of a BCD value
 int getFeedbackEncoderMsgAddr()
          If this is a feedback response message for a feedback encoder, return the address.
 int getFeedbackEncoderMsgAddr(int startByte)
           If this is a feedback broadcast message and the specified startByte is the address byte of an address byte/data byte pair for a feedback encoder, return the address.
 int getFeedbackMessageType()
           Extract the feedback message type from a feedback message this is the middle two bits of the upper byte of the second data byte.
 int getFeedbackMessageType(int startByte)
           Extract the feedback message type from the data byte of associated with the specified address byte specified by startByte.
 String getOpCodeHex()
           
 int getThrottleMsgAddr()
          If this is a throttle-type message, return address.
 int getTurnoutMsgAddr()
           If this is a feedback response message for a turnout, return the address.
 int getTurnoutMsgAddr(int startByte)
           If this is a feedback broadcast message and the specified startbyte is the address byte of an addres byte data byte pair for a turnout, return the address.
 int getTurnoutStatus(int turnout)
           Parse the feedback message for a turnout, and return the status for the even or odd half of the nibble (upper or lower part)
 int getTurnoutStatus(int startByte, int turnout)
           Parse the specified address byte/data byte pair in a feedback broadcast message and see if it is for a turnout.
 boolean isCommErrorMessage()
           
 boolean isConsistMessage()
          Is this a consist message?
 boolean isCSBusyMessage()
           
 boolean isCSTransferError()
           
 boolean isFeedbackBroadcastMessage()
          Is this a feedback broadcast message?
 boolean isFeedbackMessage()
          Is this a feedback response message?
 boolean isOkMessage()
           
 boolean isRetransmittableErrorMsg()
           
 boolean isThrottleMessage()
          Is this a throttle message?
 boolean isThrottleTakenOverMessage()
          Does this message indicate the locomotive has been taken over by another device?
 boolean isUnsolicited()
           
 void resetUnsolicited()
           
 void setParity()
           
protected  int skipPrefix(int index)
           
 
Methods inherited from class jmri.jmrix.AbstractMRReply
flush, getOpCode, isBinary, match, maxSize, pollValue, setBinary, setElement, setOpCode, setUnsolicited, skipWhiteSpace, toString, value
 
Methods inherited from class jmri.jmrix.AbstractMessage
getElement, getNumDataElements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XNetReply

public XNetReply()

XNetReply

public XNetReply(XNetReply reply)

XNetReply

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


XNetReply

public XNetReply(String message)
Create a reply from a string of hex characters.

Method Detail

getOpCodeHex

public String getOpCodeHex()

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

Parameters:
n - byte in message to convert
Returns:
Integer value of BCD byte.

skipPrefix

protected int skipPrefix(int index)
Specified by:
skipPrefix in class AbstractMRReply

getTurnoutMsgAddr

public int getTurnoutMsgAddr()

If this is a feedback response message for a turnout, return the address. Otherwise return -1.

Returns:
the integer address or -1 if not a turnout message

getTurnoutMsgAddr

public int getTurnoutMsgAddr(int startByte)

If this is a feedback broadcast message and the specified startbyte is the address byte of an addres byte data byte pair for a turnout, return the address. Otherwise return -1.

Parameters:
startByte - address byte of the address byte/data byte pair.
Returns:
the integer address or -1 if not a turnout message

getTurnoutStatus

public int getTurnoutStatus(int turnout)

Parse the feedback message for a turnout, and return the status for the even or odd half of the nibble (upper or lower part)

Parameters:
turnout -
  • 0 for the even turnout associated with the pair. This is the upper half of the data nibble asociated with the pair
  • 1 for the odd turnout associated with the pair. This is the lower half of the data nibble asociated with the pair
Returns:
THROWN/CLOSED as defined in Turnout

getTurnoutStatus

public int getTurnoutStatus(int startByte,
                            int turnout)

Parse the specified address byte/data byte pair in a feedback broadcast message and see if it is for a turnout. If it is, return the status for the even or odd half of the nibble (upper or lower part)

Parameters:
startByte - address byte of the address byte/data byte pair.
turnout -
  • 0 for the even turnout associated with the pair. This is the upper half of the data nibble asociated with the pair
  • 1 for the odd turnout associated with the pair. This is the lower half of the data nibble asociated with the pair
Returns:
THROWN/CLOSED as defined in Turnout

getFeedbackEncoderMsgAddr

public int getFeedbackEncoderMsgAddr()
If this is a feedback response message for a feedback encoder, return the address. Otherwise return -1.

Returns:
the integer address or -1 if not a feedback message

getFeedbackEncoderMsgAddr

public int getFeedbackEncoderMsgAddr(int startByte)

If this is a feedback broadcast message and the specified startByte is the address byte of an address byte/data byte pair for a feedback encoder, return the address. Otherwise return -1.

Parameters:
startByte - address byte of the address byte data byte pair.
Returns:
the integer address or -1 if not a feedback message

isFeedbackMessage

public boolean isFeedbackMessage()
Is this a feedback response message?


isFeedbackBroadcastMessage

public boolean isFeedbackBroadcastMessage()
Is this a feedback broadcast message?


getFeedbackMessageType

public int getFeedbackMessageType()

Extract the feedback message type from a feedback message this is the middle two bits of the upper byte of the second data byte.

Returns:
message type, values are:
  • 0 for a turnout with no feedback
  • 1 for a turnout with feedback
  • 2 for a feedback encoder
  • 3 is reserved by Lenz for future use.

getFeedbackMessageType

public int getFeedbackMessageType(int startByte)

Extract the feedback message type from the data byte of associated with the specified address byte specified by startByte.

The return value is the middle two bits of the upper byte of the data byte of an address byte/data byte pair.

Parameters:
startByte - The address byte for this addres byte data byte pair.
Returns:
message type, values are:
  • 0 for a turnout with no feedback
  • 1 for a turnout with feedback
  • 2 for a feedback encoder
  • 3 is reserved by Lenz for future use.

getThrottleMsgAddr

public int getThrottleMsgAddr()
If this is a throttle-type message, return address. Otherwise return -1. Note we only identify the command now; the reponse to a request for status is not yet seen here.


isThrottleMessage

public boolean isThrottleMessage()
Is this a throttle message?


isThrottleTakenOverMessage

public boolean isThrottleTakenOverMessage()
Does this message indicate the locomotive has been taken over by another device?


isConsistMessage

public boolean isConsistMessage()
Is this a consist message?


isOkMessage

public boolean isOkMessage()

isCSBusyMessage

public boolean isCSBusyMessage()

isCSTransferError

public boolean isCSTransferError()

isCommErrorMessage

public boolean isCommErrorMessage()

isRetransmittableErrorMsg

public boolean isRetransmittableErrorMsg()
Overrides:
isRetransmittableErrorMsg in class AbstractMRReply

isUnsolicited

public boolean isUnsolicited()
Overrides:
isUnsolicited in class AbstractMRReply

resetUnsolicited

public final void resetUnsolicited()


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