Package jmri.jmrix.lenz
Class FeedbackItem
- java.lang.Object
-
- jmri.jmrix.lenz.FeedbackItem
-
public class FeedbackItem extends java.lang.Object
Represents a single response from the XpressNet.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FeedbackItem(XNetReply reply, int number, int data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getAccessoryStatus()
Gives status value as specified in XPressNet.int
getAddress()
Returns the (base) address of the item.java.lang.Boolean
getEncoderStatus(int sensorNumber)
Returns encoder feedback for the given sensor.int
getTurnoutStatus()
Translates raw value ingetAccessoryStatus()
into Turnout's CLOSED/THROWN valuesint
getType()
Returns the feedback type.boolean
isAccessory()
Returns true, if the feedback is from turnout (accessory).boolean
isEncoder()
Returns true, if the feedback is from feedback encoder.boolean
isMotionComplete()
Determines if the turnout motion has completed.boolean
isUnsolicited()
Determines if the feedback was solicited.boolean
matchesAddress(int address)
Determines if the feedback is for the given Turnout addressFeedbackItem
pairedAccessoryItem()
Returns a FeedbackItem instance for the other accessory address reported in the item.
-
-
-
Constructor Detail
-
FeedbackItem
protected FeedbackItem(XNetReply reply, int number, int data)
-
-
Method Detail
-
isUnsolicited
public boolean isUnsolicited()
Determines if the feedback was solicited.- Returns:
true
, if feedback was solicited.
-
getAddress
public int getAddress()
Returns the (base) address of the item. For turnouts, return the reported address. For encoders, return the address of the first contained sensor- Returns:
- the address.
-
matchesAddress
public boolean matchesAddress(int address)
Determines if the feedback is for the given Turnout address- Parameters:
address
- address to check- Returns:
true
, if the item applies to the address.
-
isMotionComplete
public boolean isMotionComplete()
Determines if the turnout motion has completed. Requires decoder/switch feedback to be processed by the command station; alwaysfalse
if not connected.- Returns:
true
if the motion is complete.
-
getType
public int getType()
Returns the feedback type.- 0: Turnout without feedback
- 1: Turnout with feedback
- 2: Feedback encoder
- 3: reserved, invalid
- Returns:
- feedback type.
-
getTurnoutStatus
public int getTurnoutStatus()
Translates raw value ingetAccessoryStatus()
into Turnout's CLOSED/THROWN values- Returns:
Turnout.CLOSED
,Turnout.THROWN
or -1 for inconsistent.s
-
isEncoder
public boolean isEncoder()
Returns true, if the feedback is from feedback encoder.- Returns:
true
for encoder feedback.
-
isAccessory
public boolean isAccessory()
Returns true, if the feedback is from turnout (accessory).- Returns:
true
for turnout feedback.
-
getAccessoryStatus
public int getAccessoryStatus()
Gives status value as specified in XPressNet.- 0x00: turnout was not operated
- 0x01: last command was "0", turnout left, CLOSED.
- 0x02: last command was "1", turnout right, THROWN.
- 0x03: reserved, invalid
- Returns:
- accessory state.
-
getEncoderStatus
@CheckForNull public java.lang.Boolean getEncoderStatus(int sensorNumber)
Returns encoder feedback for the given sensor. The function returnnull
if the sensor number is not within this FeedbackItem range, or the item does not represent an encoder feedback.- Parameters:
sensorNumber
- sensor number, starting with 1.- Returns:
- The sensor's reported bit value (true/false) or
null
, if no encoder feedback for the sensor is found.
-
pairedAccessoryItem
public FeedbackItem pairedAccessoryItem()
Returns a FeedbackItem instance for the other accessory address reported in the item. Returnsnull
for non-accessory feedbacks.- Returns:
- instance for the paired accessory, or
null
.
-
-