Class Z21XNetMessage

  • All Implemented Interfaces:
    java.io.Serializable, Message

    public class Z21XNetMessage
    extends XNetMessage
    Represents a single command or response on the XpressNet.

    Content is represented with ints to avoid the problems with sign-extension that bytes have, and because a Java char is actually a variable number of bytes in Unicode.

    See Also:
    Serialized Form
    • Constructor Detail

      • Z21XNetMessage

        public Z21XNetMessage​(int len)
        Constructor, just pass on to the superclass.
        Parameters:
        len - message length.
      • Z21XNetMessage

        public Z21XNetMessage​(Z21Message m)
        Constructor from a Z21Message.
        Parameters:
        m - the Z21Message.
      • Z21XNetMessage

        public Z21XNetMessage​(Z21XNetMessage message)
        Create a new object, that is a copy of an existing message.
        Parameters:
        message - an existing Z21XpressNet message
      • Z21XNetMessage

        public Z21XNetMessage​(Z21XNetReply message)
        Create an Z21XNetMessage from an Z21XNetReply.
        Parameters:
        message - the existing Z21XNetReply.
      • Z21XNetMessage

        public Z21XNetMessage​(java.lang.String s)
        Create an XNetMessage from a String containing bytes.
        Parameters:
        s - byte string.
    • Method Detail

      • getZ21ReadDirectCVMsg

        public static Z21XNetMessage getZ21ReadDirectCVMsg​(int cv)
        Create messages of a particular form.
        Parameters:
        cv - CV index
        Returns:
        message to send.
      • getZ21LocomotiveInfoRequestMsg

        public static Z21XNetMessage getZ21LocomotiveInfoRequestMsg​(int address)
        Given a locomotive address, request its status.
        Parameters:
        address - is the locomotive address
        Returns:
        message to send.
      • getZ21LocomotiveFunctionOperationMsg

        public static Z21XNetMessage getZ21LocomotiveFunctionOperationMsg​(int address,
                                                                          int functionno,
                                                                          boolean state)
        Given a locomotive address, a function number, and its value, generate a message to change the state.
        Parameters:
        address - is the locomotive address
        functionno - is the function to change
        state - is boolean representing whether the function is to be on or off
        Returns:
        message to send.
      • getZ21LanXSetLocoDriveMsg

        public static XNetMessage getZ21LanXSetLocoDriveMsg​(int address,
                                                            SpeedStepMode speedMode,
                                                            float speed,
                                                            boolean isForward)
        Generate a Z21 message to change the speed/direction of a locomotive.
        Parameters:
        address - the locomotive address
        speedMode - the speedstep mode see @jmri.DccThrottle for possible values.
        speed - a normalized speed value (a floating point number between 0 and 1). A negative value indicates emergency stop.
        isForward - true for forward, false for reverse.
        Returns:
        message to send.
      • getZ21TurnoutInfoRequestMessage

        public static Z21XNetMessage getZ21TurnoutInfoRequestMessage​(int address)
        Given a turnout address, generate a message to request the state.
        Parameters:
        address - the turnout address
        Returns:
        message to send.
      • getZ21SetTurnoutRequestMessage

        public static Z21XNetMessage getZ21SetTurnoutRequestMessage​(int address,
                                                                    boolean thrown,
                                                                    boolean active,
                                                                    boolean queue)
        Given a turnout address and whether or not it is thrown, generate a message to operate the turnout.
        Parameters:
        address - is the turnout address
        thrown - boolean value representing whether the turnout is thrown.
        active - boolean value representing whether the output is being set to active.
        queue - boolean value representing whehter or not the message is added to the queue.
        Returns:
        message to send.