Package jmri.jmrix.lenz
Class XNetReply
java.lang.Object
jmri.jmrix.AbstractMessage
jmri.jmrix.AbstractMRReply
jmri.jmrix.lenz.XNetReply
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
Z21XNetReply
Represents a single response from the XpressNet.
-
Field Summary
Fields inherited from class jmri.jmrix.AbstractMRReply
DEFAULTMAXSIZEFields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck whether the message has a valid parity.protected final FeedbackItemcreateFeedbackItem(int n, int d) getElementBCD(int n) Get an integer representation of a BCD value.intIf this is a feedback response message for a feedback encoder, return the address.intgetFeedbackEncoderMsgAddr(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.final intReturns the number of feedback items in the messages.intExtract the feedback message type from a feedback message this is the middle two bits of the upper byte of the second data byte.intgetFeedbackMessageType(int startByte) Extract the feedback message type from the data byte of associated with the specified address byte specified by startByte.Get the opcode as a string in hex format.(package private) int(package private) intintintintIf this is a throttle-type message, return address.intIf this is a feedback response message for a turnout, return the address.intgetTurnoutMsgAddr(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.intgetTurnoutStatus(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).intgetTurnoutStatus(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.booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is a communications error message.booleanIs this a consist message?booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station Busy message (61 81 e3).booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station Transfer Error message (61 80 e1).booleanIs this message a direct CV mode programming response?booleanIs this a feedback broadcast message?booleanIs this a feedback response message?booleanisFeedbackMotionComplete(int startByte) booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the OK message (01 04 05).(package private) booleanXPressNet Ops Mode Reply message handling routinesbooleanIs this message a register or paged mode programming response?booleanbooleanIs this message a service mode response?booleanIs this a throttle message?booleanDoes this message indicate the locomotive has been taken over by another device?booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is a communications error message.booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the timeslot restored message (01 07 06).booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station no longer providing a timeslot message (01 05 04).booleanGet flag for Unsolicited.booleanIn the interest of code reuse, the following function checks to see if an XpressNet Message is the not supported Error message (61 82 e3).booleanonTurnoutFeedback(int accessoryNumber, Function<FeedbackItem, Boolean> proc) Calls processor for turnout's feedback, returns the processor's outcome.selectModuleFeedback(int sensorNumber) Returns value of the given feedback module bit.selectTurnoutFeedback(int accessoryNumber) Selects a matching turnout feedback.voidprotected intskipPrefix(int index) skipPrefix is not used at this point in time, but is defined as abstract in AbstractMRReplyMethods inherited from class jmri.jmrix.AbstractMRReply
flush, getOpCode, isBinary, match, maxSize, pollValue, setBinary, setElement, setOpCode, setUnsolicited, skipWhiteSpace, toString, valueMethods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode
-
Constructor Details
-
XNetReply
public XNetReply() -
XNetReply
-
XNetReply
Create a reply from an XNetMessage.- Parameters:
message- existing message.
-
XNetReply
Create a reply from a string of hex characters.- Parameters:
message- hex string of message.
-
-
Method Details
-
getOpCodeHex
Get the opcode as a string in hex format.- Returns:
- 0x hex string of OpCode.
-
checkParity
Check whether the message has a valid parity.- Returns:
- true if parity valid, else false.
-
setParity
-
getElementBCD
Get an integer representation of a BCD value.- Parameters:
n- byte in message to convert- Returns:
- Integer value of BCD byte.
-
skipPrefix
skipPrefix is not used at this point in time, but is defined as abstract in AbstractMRReply- Specified by:
skipPrefixin classAbstractMRReply
-
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
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
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
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
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
-
getFeedbackMessageItems
Returns the number of feedback items in the messages. For accessory info replies, always returns 1. For broadcast, it returns the number of feedback pairs. Returns 0 for non-feedback messages.- Returns:
- number of feedback pair items.
-
getFeedbackEncoderMsgAddr
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
Is this a feedback response message?- Returns:
- true if a feedback response, else false.
-
isFeedbackBroadcastMessage
Is this a feedback broadcast message?- Returns:
- true if a feedback broadcast message, else false.
-
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
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.
-
isFeedbackMotionComplete
-
getThrottleMsgAddr
If this is a throttle-type message, return address. Otherwise return -1.Note we only identify the command now; the response to a request for status is not yet seen here.
- Returns:
- address if throttle-type message, else -1.
-
isThrottleMessage
Is this a throttle message?- Returns:
- true if throttle message. else false.
-
isThrottleTakenOverMessage
Does this message indicate the locomotive has been taken over by another device?- Returns:
- true if take over message, else false.
-
isConsistMessage
Is this a consist message?- Returns:
- true if consist message, else false.
-
isOkMessage
In the interest of code reuse, the following function checks to see if an XpressNet Message is the OK message (01 04 05).- Returns:
- true if an OK message, else false.
-
isTimeSlotRestored
In the interest of code reuse, the following function checks to see if an XpressNet Message is the timeslot restored message (01 07 06).- Returns:
- true if a time-slot restored message.
-
isTimeSlotRevoked
In the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station no longer providing a timeslot message (01 05 04).- Returns:
- true if a time-slot revoked message, else false.
-
isCSBusyMessage
In the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station Busy message (61 81 e3).- Returns:
- true if is a CS Busy message, else false.
-
isCSTransferError
In the interest of code reuse, the following function checks to see if an XpressNet Message is the Command Station Transfer Error message (61 80 e1).- Returns:
- if CS Transfer error, else false.
-
isUnsupportedError
In the interest of code reuse, the following function checks to see if an XpressNet Message is the not supported Error message (61 82 e3).- Returns:
- true if unsupported error, else false.
-
isCommErrorMessage
In the interest of code reuse, the following function checks to see if an XpressNet Message is a communications error message.The errors handled are: 01 01 00 -- Error between interface and the PC 01 02 03 -- Error between interface and the Command Station 01 03 02 -- Unknown Communications Error 01 06 07 -- LI10x Buffer Overflow 01 0A 0B -- LIUSB only. Request resend of data.
- Returns:
- true if comm error message, else false.
-
isTimeSlotErrorMessage
In the interest of code reuse, the following function checks to see if an XpressNet Message is a communications error message.The errors handled are: 01 05 04 -- Timeslot Error 01 07 06 -- Timeslot Restored 01 08 09 -- Data sent while there is no Timeslot
- Returns:
- true if time slot error, else false.
-
isServiceModeResponse
Is this message a service mode response?- Returns:
- true if a service mode response, else false.
-
isPagedModeResponse
Is this message a register or paged mode programming response?- Returns:
- true if register or paged mode programming response, else false.
-
isDirectModeResponse
Is this message a direct CV mode programming response?- Returns:
- true if direct CV mode programming response, else false.
-
getServiceModeCVNumber
- Returns:
- the CV value associated with a service mode reply return -1 if not a service mode message.
-
getServiceModeCVValue
- Returns:
- the value returned by the DCC system associated with a service mode reply. return -1 if not a service mode message.
-
isRetransmittableErrorMsg
- Overrides:
isRetransmittableErrorMsgin classAbstractMRReply- Returns:
- true if the message is an error message indicating we should retransmit.
-
isUnsolicited
Description copied from class:AbstractMRReplyGet flag for Unsolicited.- Overrides:
isUnsolicitedin classAbstractMRReply- Returns:
- true if the message is an unsolicited message
-
selectModuleFeedback
Returns value of the given feedback module bit. ReturnsOptionalthat is non-empty, if the feedback was present. The Optional's value indicates the feedback state.- Parameters:
sensorNumber- the sensor bit ID- Returns:
- optional sensor state.
-
onTurnoutFeedback
Calls processor for turnout's feedback, returns the processor's outcome. Searches for the turnout feedback for the given accessory. If found, runs a processor on the feedback item, and returns its Boolean result.Returns
false, if matching feedback is not found.- Parameters:
accessoryNumber- the turnout numberproc- the processor- Returns:
falseif feedback was not found, or a result ofproc().
-
selectTurnoutFeedback
Selects a matching turnout feedback. Finds turnout feedback for the givenaccessoryNumber. Returns an encapsulated feedback, that can be inspected. If no matching feedback is present, returns emptyOptional.- Parameters:
accessoryNumber- the turnout number- Returns:
- optional feedback item.
-
createFeedbackItem
-
isOpsModeResultMessage
boolean isOpsModeResultMessage()XPressNet Ops Mode Reply message handling routines -
getOpsModeResultAddress
int getOpsModeResultAddress() -
getOpsModeResultValue
int getOpsModeResultValue() -
toMonitorString
- Returns:
- a string representation of the reply suitable for display in the XpressNet monitor.
-