Class CbusOpCodes


  • public class CbusOpCodes
    extends java.lang.Object
    Methods to decode CBUS opcodes https://github.com/MERG-DEV/CBUSlib
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decode​(AbstractMessage msg)
      Return a string representation of a decoded CBUS Message
      static java.lang.String decodeExtended​(CanFrame msg)
      Return a string representation of a decoded Extended CBUS Message
      static java.lang.String decodeopc​(AbstractMessage msg)
      Return a string OPC of a CBUS Message
      static java.lang.String decodeopcNonExtended​(AbstractMessage msg)
      Return a string representation of a decoded CBUS OPC
      static java.lang.String fullDecode​(AbstractMessage msg)
      Return a string representation of a decoded CBUS Message Used in CBUS Console Log
      static java.lang.String getCbusErr​(AbstractMessage msg)
      Return CBUS ERR OPC String.
      static java.lang.String getDirectionFromByte​(int speed)
      Get localised direction from speed byte.
      static java.util.EnumSet<CbusFilterType> getOpcFilters​(int opc)
      Get the filters for a CBUS OpCode.
      static int getOpcMinPriority​(int opc)
      Get the Minimum Priority for a CBUS OpCode.
      static java.lang.String getOpcName​(int opc)
      Get the Name of a CBUS OpCode.
      static java.lang.String getSpeedFromByte​(int speed)
      Get loco speed from byte value.
      static boolean isDcc​(int opc)
      Test if CBUS opcode represents a DCC Command Station Message
      static boolean isEvent​(int opc)
      Test if CBUS OpCode represents a CBUS event.
      static boolean isEventNotRequest​(int opc)
      Test if CBUS opcode represents a JMRI event table event.
      static boolean isEventRequest​(int opc)
      Test if CBUS opcode represents an event request.
      static boolean isKnownOpc​(AbstractMessage msg)
      Test if CBUS OpCode is known to JMRI.
      static boolean isOnEvent​(int opc)
      Test if CBUS opcode represents an on event.
      static boolean isShortEvent​(int opc)
      Test if CBUS opcode represents a short event.
      static java.lang.String locoFromBytes​(int byteA, int byteB)
      Return Loco Address String
      static java.lang.String speedDirFromByte​(int byteA)
      Get text string of speed / direction.
      • Methods inherited from class java.lang.Object

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

      • fullDecode

        @Nonnull
        public static final java.lang.String fullDecode​(AbstractMessage msg)
        Return a string representation of a decoded CBUS Message Used in CBUS Console Log
        Parameters:
        msg - CbusMessage to be decoded Return String decoded message
        Returns:
        decoded CBUS message
      • getCbusErr

        @Nonnull
        public static final java.lang.String getCbusErr​(AbstractMessage msg)
        Return CBUS ERR OPC String.
        Parameters:
        msg - CanMessage or CanReply containing the CBUSERR OPC
        Returns:
        Error String
      • locoFromBytes

        @Nonnull
        public static final java.lang.String locoFromBytes​(int byteA,
                                                           int byteB)
        Return Loco Address String
        Parameters:
        byteA - 1st loco byte
        byteB - 2nd loco byte
        Returns:
        Loco Address String
      • speedDirFromByte

        @Nonnull
        public static final java.lang.String speedDirFromByte​(int byteA)
        Get text string of speed / direction.
        Parameters:
        byteA - the Speed / Direction byte value.
        Returns:
        translated String.
      • getSpeedFromByte

        public static java.lang.String getSpeedFromByte​(int speed)
        Get loco speed from byte value.
        Parameters:
        speed - byte value 0-255 of speed containing direction flag.
        Returns:
        interpreted String, maybe with EStop localised text.
      • getDirectionFromByte

        public static java.lang.String getDirectionFromByte​(int speed)
        Get localised direction from speed byte.
        Parameters:
        speed - 0-255, 0-127 Reverse, else Forwards.
        Returns:
        localised Forward or Reverse String.
      • decode

        @Nonnull
        public static final java.lang.String decode​(AbstractMessage msg)
        Return a string representation of a decoded CBUS Message
        Parameters:
        msg - CbusMessage to be decoded
        Returns:
        decoded message after extended frame check
      • decodeExtended

        @Nonnull
        public static final java.lang.String decodeExtended​(CanFrame msg)
        Return a string representation of a decoded Extended CBUS Message
        Parameters:
        msg - Extended CBUS CAN Frame to be decoded
        Returns:
        decoded message after extended frame check
      • decodeopcNonExtended

        @Nonnull
        public static final java.lang.String decodeopcNonExtended​(AbstractMessage msg)
        Return a string representation of a decoded CBUS OPC
        Parameters:
        msg - CbusMessage to be decoded Return String decoded OPC
        Returns:
        decoded CBUS OPC, eg. "RTON" or "ACON2", else Reserved string.
      • decodeopc

        @Nonnull
        public static final java.lang.String decodeopc​(AbstractMessage msg)
        Return a string OPC of a CBUS Message
        Parameters:
        msg - CbusMessage
        Returns:
        decoded CBUS OPC, eg. "RTON" or "ACON2", else Reserved string. Empty String for Extended Frames as no OPC concept.
      • isKnownOpc

        public static final boolean isKnownOpc​(AbstractMessage msg)
        Test if CBUS OpCode is known to JMRI. Performs Extended / RTR Frame check.
        Parameters:
        msg - CanReply or CanMessage
        Returns:
        True if opcode is known
      • isEvent

        public static final boolean isEvent​(int opc)
        Test if CBUS OpCode represents a CBUS event.

        Defined in the CBUS Developer Manual as accessory commands. Excludes fast clock.

        ACON, ACOF, AREQ, ARON, AROF, ASON, ASOF, ASRQ, ARSON, ARSOF, ACON1, ACOF1, ARON1, AROF1, ASON1, ASOF1, ARSON1, ARSOF1, ACON2, ACOF2, ARON2, AROF2, ASON2, ASOF2, ARSON2, ARSOF2

        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents an event
      • isEventNotRequest

        public static final boolean isEventNotRequest​(int opc)
        Test if CBUS opcode represents a JMRI event table event. Event codes excluding request codes + fastclock.

        ACON, ACOF, ARON, AROF, ASON, ASOF, ARSON, ARSOF, ACON1, ACOF1, ARON1, AROF1, ASON1, ASOF1, ARSON1, ARSOF1, ACON2, ACOF2, ARON2, AROF2, ASON2, ASOF2, ARSON2, ARSOF2, ACON3, ACOF3, ARON3, AROF3, ASON3, ASOF3, ARSON3, ARSOF3,

        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents an event
      • isDcc

        public static final boolean isDcc​(int opc)
        Test if CBUS opcode represents a DCC Command Station Message

        TOF, TON, ESTOP, RTOF, RTON, RESTP, KLOC, QLOC, DKEEP, RLOC, QCON, ALOC, STMOD, PCON, KCON, DSPD, DFLG, DFNON, DFNOF, SSTAT, DFUN, GLOC, ERR, RDCC3, WCVO, WCVB, QCVS, PCVS, RDCC4, WCVS, VCVS, RDCC5, WCVOA, RDCC6, PLOC, STAT, RSTAT

        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents a dcc command
      • isOnEvent

        public static final boolean isOnEvent​(int opc)
        Test if CBUS opcode represents an on event.

        ACON, ARON, ASON, ARSON ACON1, ARON1, ASON1, ARSON1 ACON2, ARON2, ASON2, ARSON2 ACON3, ARON3, ASON3, ARSON3

        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents an on event
      • isEventRequest

        public static final boolean isEventRequest​(int opc)
        Test if CBUS opcode represents an event request. Excludes node data requests RQDAT + RQDDS. AREQ, ASRQ
        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents a short event
      • isShortEvent

        public static final boolean isShortEvent​(int opc)
        Test if CBUS opcode represents a short event.

        ASON, ASOF, ASRQ, ARSON, ARSOF ASON1, ASOF1, ARSON1, ARSOF1 ASON2, ASOF2, ARSON2, ARSOF2 ASON3, ASOF3, ARSON3, ARSOF3

        Parameters:
        opc - CBUS op code
        Returns:
        True if opcode represents a short event
      • getOpcFilters

        @Nonnull
        public static final java.util.EnumSet<CbusFilterTypegetOpcFilters​(int opc)
        Get the filters for a CBUS OpCode.
        Parameters:
        opc - CBUS op code
        Returns:
        Filter EnumSet
      • getOpcName

        @Nonnull
        public static final java.lang.String getOpcName​(int opc)
        Get the Name of a CBUS OpCode.
        Parameters:
        opc - CBUS op code
        Returns:
        Name if known, else empty String.
      • getOpcMinPriority

        public static final int getOpcMinPriority​(int opc)
        Get the Minimum Priority for a CBUS OpCode.
        Parameters:
        opc - CBUS op code
        Returns:
        Minimum Priority