Class LocoNetMessageInterpret


  • public class LocoNetMessageInterpret
    extends java.lang.Object
    A utility class for formatting LocoNet packets into human-readable text.

    Note that the formatted strings end in a \n, and may contain more than one line separated by \n. Someday this should be converted to proper Java line handling.

    Much of this file is a Java-recoding of the display.c file from the llnmon package of John Jabour. Some of the conversions involve explicit decoding of structs defined in loconet.h in that same package. Those parts are (C) Copyright 2001 Ron W. Auld. Use of these parts is by direct permission of the author.

    This class is derived from and replaces JMRI's jmri.jmrix.loconet.locomon.Llnmon.java .

    Many major comment blocks here are quotes from the Digitrax LocoNet(r) OPCODE SUMMARY: found in the LocoNet(r) Personal Edition 1.

    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.

    Reverse engineering of OPC_MULTI_SENSE was provided by Al Silverstein, used with permission.

    Reverse engineering of the Duplex Group/Password/Channel management was provided by Leo Bicknell with help from B. Milhaupt, used with permission.

    Reverse-engineering of device-specific OpSw messages, throttle text message, and throttle semaphore message was provided by B. Milhaupt, used with permission. Reverse-engineering of device-specific LNSV messages was provided by K. Drenth, used with permission.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String convertToMixed​(int addressLow, int addressHigh)
      Create a string representation of the loco address in addressLow and addressHigh in a form appropriate for the type of address (2 or 4 digit) using the Digitrax 'mixed mode' if necessary.
      protected static java.lang.String directionOfTravelString​(boolean isForward)  
      static java.lang.String dotme​(int val)
      Take the LocoIO version number and convert to human friendly format, like "1.4.8" or "9.1".
      static java.lang.String getDeviceNameFromIPLInfo​(int manuf, int type)  
      static java.lang.String getSlaveNameFromIPLInfo​(int manuf, int slaveNum)  
      static java.lang.String interpretAlm​(LocoNetMessage l)
      Interpret messages with Opcode of OPC_ALM_READ, OPC_ALM_WRITE.
      protected static java.lang.String interpretDIRF​(int dirf)  
      protected static java.lang.String[] interpretF0_F4toStrings​(int dirf)  
      protected static java.lang.String[] interpretF5_F8toStrings​(int snd)  
      static java.lang.String interpretMessage​(LocoNetMessage l, java.lang.String turnoutPrefix, java.lang.String sensorPrefix, java.lang.String reporterPrefix)
      Format the message into a text string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • interpretMessage

        public static java.lang.String interpretMessage​(LocoNetMessage l,
                                                        java.lang.String turnoutPrefix,
                                                        java.lang.String sensorPrefix,
                                                        java.lang.String reporterPrefix)
        Format the message into a text string.

        Where the code is unable to determine a correct interpretation, the returned string contains a message indicating that the message is not decoded followed by the individual bytes of the message (in hexadecimal).

        Parameters:
        l - Message to parse
        turnoutPrefix - "System Name+ prefix which designates the connection's Turnouts, such as "LT"
        sensorPrefix - "System Name+ prefix which designates the connection's Turnouts, such as "LS"
        reporterPrefix - "System Name+ prefix which designates the connection's Turnouts, such as "LR"
        Returns:
        String representation of the interpretation of the message
      • interpretDIRF

        protected static java.lang.String interpretDIRF​(int dirf)
      • dotme

        public static java.lang.String dotme​(int val)
        Take the LocoIO version number and convert to human friendly format, like "1.4.8" or "9.1".
        Parameters:
        val - The LocoIO version.
        Returns:
        String with human readable format
      • convertToMixed

        public static java.lang.String convertToMixed​(int addressLow,
                                                      int addressHigh)
        Create a string representation of the loco address in addressLow and addressHigh in a form appropriate for the type of address (2 or 4 digit) using the Digitrax 'mixed mode' if necessary.

        "Mixed mode" is used by DT100 and DT200 throttles to display loco addresses between 100 and 127 as a two-digit displayable value, where the left digit is either 'a', 'b', or 'c', (for addresses in the 10x, 11x, and 12x ranges, respectively), and the right digit is the "x" from the ranges above.

        Parameters:
        addressLow - the least-significant 7 bits of the loco address
        addressHigh - the most-significant 7 bits of the loco address
        Returns:
        a String containing the address, using Digitrax 'mixed mode' representation of the loco address, if appropriate
      • interpretAlm

        public static java.lang.String interpretAlm​(LocoNetMessage l)
        Interpret messages with Opcode of OPC_ALM_READ, OPC_ALM_WRITE.
        Parameters:
        l - LocoNet Message to interpret
        Returns:
        String containing interpreted message or empty string if message is not interpretable.