Class 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 in getAccessoryStatus() into Turnout's CLOSED/THROWN values
      int 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 address
      FeedbackItem pairedAccessoryItem()
      Returns a FeedbackItem instance for the other accessory address reported in the item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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; always false 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.
      • 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
        The method returns 0x03, if the feedback is not for accessory.
        Returns:
        accessory state.
      • getEncoderStatus

        @CheckForNull
        public java.lang.Boolean getEncoderStatus​(int sensorNumber)
        Returns encoder feedback for the given sensor. The function return null 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. Returns null for non-accessory feedbacks.
        Returns:
        instance for the paired accessory, or null.