Class Lnsv1MessageContents

java.lang.Object
jmri.jmrix.loconet.lnsvf1.Lnsv1MessageContents

public class Lnsv1MessageContents extends Object
Supporting class for LocoNet SV Programming Format 1 (LocoIO) messaging.

Some of the message formats used in this class are Copyright Digitrax, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Digitrax Inc for separate permission.

Uses the LOCONETSV1MODE programming mode.

Uses LnProgrammer LOCOIO_PEER_CODE_SV_VER1 message format, comparable to DecoderPro LOCONETSV1MODE The DecoderPro decoder definition is recommended for all LocoIO versions. Requires JMRI 4.12 or later.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • 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

      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

      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 String toString()
      Interpret the SV Programming Format 1 message into a human-readable string.
      Overrides:
      toString in class Object
      Returns:
      String containing a human-readable version of the SV Programming Format 1 message
    • toString

      public String toString(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 String toHexStr(int value)
      Format byte for decimal + (optional) hex display
    • toHexComposite

      public static 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

      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
    • getSrcL

      public int getSrcL()
    • getDstL

      public int getDstL()
    • 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
    • getSubAddress

      public int getSubAddress()
    • getCmd

      public int getCmd()
    • getSvNum

      public int getSvNum()
    • getSvValue

      public int getSvValue()
    • getVersionNum

      public int getVersionNum()
    • 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 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:
      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 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:
      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
    • createSv1WriteRequest

      public static LocoNetMessage createSv1WriteRequest(int dst, int subAddress, int svNum, int newValue)
    • 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

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