Class Lnsv1MessageContents

    • Constructor Detail

      • Lnsv1MessageContents

        public Lnsv1MessageContents​(LocoNetMessage m)
                             throws java.lang.IllegalArgumentException
        Create a new Lnsv1MessageContents object from a LocoNet message.
        Parameters:
        m - LocoNet message containing an SV Programming Format 1 message
        Throws:
        java.lang.IllegalArgumentException - if the LocoNet message is not a valid, supported SV Programming Format 1 message
    • Method Detail

      • isSupportedSv1Message

        public static boolean isSupportedSv1Message​(LocoNetMessage m)
        Check a LocoNet message to determine if it is a valid SV Programming Format 1 message.
        Parameters:
        m - LocoNet message to check
        Returns:
        true if LocoNet message m is a supported SV Programming Format 1 message, else false.
      • isLnMessageASpecificSv1Command

        public static boolean isLnMessageASpecificSv1Command​(LocoNetMessage m,
                                                             Lnsv1MessageContents.Sv1Command svCmd)
        Compare reply message against a specific SV Programming Format 1 message type.
        Parameters:
        m - LocoNet message to be verified as an SV Programming Format 1 message with the specified <SV_CMD> value
        svCmd - SV Programming Format 1 command to expect
        Returns:
        true if message is an SV Programming Format 1 message of the specified <SV_CMD>, else false.
      • extractMessageType

        public static Lnsv1MessageContents.Sv1Command extractMessageType​(LocoNetMessage m)
        Interpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>. If the message is not an SV Programming Format 1 message, returns null.
        Parameters:
        m - LocoNet message containing SV Programming Format 1 message
        Returns:
        Sv1Command found in the SV Programming Format 1 message or null if not found
      • extractMessageVersion

        public static int extractMessageVersion​(LocoNetMessage m)
        Interpret a LocoNet message to extract its SV Programming Format 1 <SV_CMD>. If the message is not an SV Programming Format 1 message, return null.
        Parameters:
        m - LocoNet message containing SV Programming Format 1 version field
        Returns:
        Version found in the SV Programming Format 1 message or -1 if not found
      • toString

        public java.lang.String toString()
        Interpret the SV Programming Format 1 message into a human-readable string.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String containing a human-readable version of the SV Programming Format 1 message
      • toString

        public java.lang.String toString​(java.util.Locale locale)
        Interpret the SV Programming Format 1 message into a human-readable string.
        Parameters:
        locale - locale to use for the human-readable string
        Returns:
        String containing a human-readable version of the SV Programming Format 1 message, in the language specified by the Locale if the properties have been translated to that Locale, else in the default English language.
      • toHexStr

        public static java.lang.String toHexStr​(int value)
        Format byte for decimal + (optional) hex display
      • toHexComposite

        public static java.lang.String toHexComposite​(int low,
                                                      int high)
        Format byte for hex display
      • isSupportedSv1Command

        public static boolean isSupportedSv1Command​(int possibleCmd)
        Parameters:
        possibleCmd - integer to be compared to the command list
        Returns:
        true if the possibleCmd value is one of the supported SV Programming Format 1 commands
      • isSupportedSv1Command

        public boolean isSupportedSv1Command()
        Confirm a message specifies a valid (known) SV Programming Format 1 command.
        Returns:
        true if the SV1 message specifies a valid (known) SV Programming Format 1 command.
      • isSupportedSv1ReadOneReply

        public boolean isSupportedSv1ReadOneReply()
        Returns:
        true if the SV1 message is a SV1 Read One Reply message
      • getSingleReadReportData

        public int getSingleReadReportData()
        Get the data from a SVs READ_ONE Reply message. May also be used to return the effective SV value reported in an SV1 WRITE_ONE Reply message (or is that returned in d8?).
        Returns:
        the <D6> value from the SV1 message
      • getDstH

        public int getDstH()
        Used to check message. LNSV1 messages do not use the DST_H field for high address
      • getDestAddr

        public int getDestAddr()
        Not returning a valid address because LNSV1 messages do not use the DST_H field for high address. and a composite address is not used. - LocoBuffer subaddress is always 1. - LocoIO subaddress is stored and fetched from PEER_XFER element SV1_SV_SUBADR_ELEMENT_INDEX (11). - JMRI LocoIO decoder address as stored in the Roster is calculated as a 14-bit number in jmri.jmrix.loconet.swing.lnsv1prog.Lnsv1ProgPane
      • getCmd

        public int getCmd()
      • getSv1D4

        public int getSv1D4()
        Get the d4 value
        Returns:
        d4 element contents
      • getSv1D6

        public int getSv1D6()
        Get the d6 value
        Returns:
        d6 element contents
      • getSv1D7

        public int getSv1D7()
        Get the d7 value
        Returns:
        d7 element contents
      • getSv1D8

        public int getSv1D8()
        Get the d8 value
        Returns:
        d8 element contents
      • createSv0Message

        public static LocoNetMessage createSv0Message​(int source,
                                                      int destination,
                                                      int subAddress,
                                                      int command,
                                                      int svNum,
                                                      int version,
                                                      int newVal,
                                                      int d6,
                                                      int d7,
                                                      int d8)
                                               throws java.lang.IllegalArgumentException
        Create a LocoNet message containing an SV Programming Format 0 message. Used only to simulate replies from LocoIO. Uses LNSV1_PEER_CODE_SV_VER0.

        See Programmer message code in LnOpsModeProgrammer loadSV1MessageFormat

        Parameters:
        source - source device address (for <SRC_L>)
        destination - = SV format 1 7-bit destination address (for <DST_L>)
        subAddress - = SV format 1 7-bit destination subaddress (for <DST_H>)
        command - SV Programming Format 1 command number (for <SV_CMD>)
        svNum - SV Programming Format 1 8-bit SV number
        newVal - (d4) SV first 8-bit data value to write (for <D4>)
        version - Programming Format 1 8-bit firmware version number; 0 in request,>0 in replies
        d6 - second 8-bit data value (for <D6>)
        d7 - third 8-bit data value (for <D7>)
        d8 - fourth 8-bit data value (for <D8>)
        Returns:
        LocoNet message for the requested message
        Throws:
        java.lang.IllegalArgumentException - if command is not a valid SV Programming Format 1 <SV_CMD> value
      • createSv1Message

        public static LocoNetMessage createSv1Message​(int source,
                                                      int destination,
                                                      int subAddress,
                                                      int command,
                                                      int svNum,
                                                      int version,
                                                      int newVal,
                                                      int d6,
                                                      int d7,
                                                      int d8)
                                               throws java.lang.IllegalArgumentException
        Create a LocoNet message containing an SV Programming Format 1 message.

        See Programmer message code in LnOpsModeProgrammer loadSV1MessageFormat

        Parameters:
        source - source device address (for <SRC_L>)
        destination - = SV format 1 7-bit destination address (for <DST_L>)
        subAddress - = SV format 1 7-bit destination subaddress (for <DST_H>)
        command - SV Programming Format 1 command number (for <SV_CMD>)
        svNum - SV Programming Format 1 8-bit SV number
        newVal - (d4) SV first 8-bit data value to write (for <D4>)
        version - Programming Format 1 8-bit firmware version number; 0 in request,>0 in replies
        d6 - second 8-bit data value (for <D6>)
        d7 - third 8-bit data value (for <D7>)
        d8 - fourth 8-bit data value (for <D8>)
        Returns:
        LocoNet message for the requested message
        Throws:
        java.lang.IllegalArgumentException - if command is not a valid SV Programming Format 1 <SV_CMD> value
      • createSv1ReadRequest

        public static LocoNetMessage createSv1ReadRequest​(int dst,
                                                          int subAddress,
                                                          int svNum)
        Create LocoNet message for a query of an SV of this object.
        Parameters:
        dst - address of the device to read from
        subAddress - subaddress of the device to read from
        svNum - SV number to read
        Returns:
        LocoNet message
      • createSv1ReadReply

        public static LocoNetMessage createSv1ReadReply​(int src,
                                                        int dst,
                                                        int subAddress,
                                                        int version,
                                                        int svNum,
                                                        int returnValue)
        Simulate a read/probe reply for testing/developing.
        Parameters:
        src - board low address
        dst - dest high address, usually 0x50 for LocoBuffer/PC
        subAddress - board high address
        version - fictional firmware version number to add
        svNum - SV read
        Returns:
        LocoNet message containing the reply
      • createSv1WriteReply

        public static LocoNetMessage createSv1WriteReply​(int src,
                                                         int dst,
                                                         int subAddress,
                                                         int version,
                                                         int svNum,
                                                         int returnValue)
        Simulate a read/probe reply for testing/developing.
        Parameters:
        src - board low address
        subAddress - board high address
        dst - dest high address, usually 0x1050 for LocoBuffer/PC
        version - fictional firmware version number to add
        svNum - SV read
        Returns:
        LocoNet message containing the reply
      • createBroadcastSetAddress

        public static LocoNetMessage[] createBroadcastSetAddress​(int address,
                                                                 int subAddress)
        Compose a message that changes the hardware board address of ALL connected LNSV1 (LocoIO) boards.
        Parameters:
        address - the new base address of the LocoIO board to change
        subAddress - the new subAddress of the board
        Returns:
        an array containing one or two LocoNet messages
      • createBroadcastProbeAll

        public static LocoNetMessage createBroadcastProbeAll()
        Create a message to probe all connected LocoIO (LNSV1) units on a given LocoNet connection.
        Returns:
        the complete LocoNet message