Class Z21Message

All Implemented Interfaces:
Message

public class Z21Message extends AbstractMRMessage
Class for messages in the z21/Z21 protocol. Messages have the following format: 2 bytes data length. 2 bytes op code. n bytes data. All numeric values are stored in little endian format. Carries a sequence of characters, with accessors.
  • Field Details

  • Constructor Details

    • Z21Message

      public Z21Message()
    • Z21Message

      public Z21Message(int i)
    • Z21Message

    • Z21Message

    • Z21Message

      public Z21Message(String m)
      This ctor interprets the String as the exact sequence to send, byte-for-byte.
      Parameters:
      m - message string.
    • Z21Message

      @Deprecated(since="5.13.5", forRemoval=true) public Z21Message(byte[] a, int l)
      Deprecated, for removal: This API element is subject to removal in a future version.
      5.13.5, unused, requires further development.
      This ctor interprets the byte array as a sequence of characters to send.
      Parameters:
      a - Array of bytes to send
      l - unused.
  • Method Details

    • replyExpected

      public boolean replyExpected()
      Description copied from class: AbstractMRMessage
      Is a reply expected to this message?

      By default, a reply is expected to every message; either a reply or a timeout is needed before the next message can be sent.

      If this returns false, the transmit queue will immediately go on to transmit the next message (if any).

      Overrides:
      replyExpected in class AbstractMRMessage
      Returns:
      true by default in Abstract MR message.
    • setOpCode

      public void setOpCode(int i)
      Overrides:
      setOpCode in class AbstractMRMessage
    • getOpCode

      public int getOpCode()
      Overrides:
      getOpCode in class AbstractMRMessage
    • setLength

      public void setLength(int i)
    • getLength

      public int getLength()
    • getBuffer

      byte[] getBuffer()
    • getSerialNumberRequestMessage

    • getLanGetHardwareInfoRequestMessage

    • getLanLogoffRequestMessage

    • getLanGetBroadcastFlagsRequestMessage

      Returns:
      z21 message for LAN_GET_BROADCAST_FLAGS request.
    • getLanSetBroadcastFlagsRequestMessage

      Set the broadcast flags as described in section 2.16 of the Roco Z21 Protocol Manual.

      Brief descriptions of the flags are as follows (losely translated from German with the aid of google translate).

      • 0x00000001 send XpressNet related information (track power on/off, programming mode, short circuit, broadcast stop, locomotive information, turnout information).
      • 0x00000002 send data changes that occur on the RMBUS.
      • 0x00000004 (deprecated by Roco) send Railcom Data
      • 0x00000100 send changes in system state (such as track voltage)
      • 0x00010000 send changes to locomotives on XpressNet (must also have 0x00000001 set.
      • 0x01000000 forward LocoNet data to the client. Does not send Locomotive or turnout data.
      • 0x02000000 send Locomotive specific LocoNet data to the client.
      • 0x04000000 send Turnout specific LocoNet data to the client.
      • 0x08000000 send Occupancy information from LocoNet to the client
      • 0x00040000 Automatically send updates for Railcom data to the client
      • 0x00080000 send can detector messages to the client
      Parameters:
      flags - integer representing the flags (32 bits).
      Returns:
      z21 message for LAN_SET_BROADCAST_FLAGS request.
    • getLanRailComGetDataRequestMessage

      Returns:
      z21 message for LAN_RAILCOM_GETDATA request.
    • getLanSystemStateDataChangedRequestMessage

      Returns:
      z21 message for LAN_SYSTEMSTATE_GETDATA
    • toMonitorString

      Returns:
      a human-readable representation of the message.
    • isLocoNetTunnelMessage

    • isLocoNetDispatchMessage

    • isLocoNetDetectorMessage

    • getLocoNetMessage

    • getLanRMBusGetDataRequestMessage

      public static Z21Message getLanRMBusGetDataRequestMessage(int group)
      Parameters:
      group - the RM Bus group number to request.
      Returns:
      z21 message for LAN_RMBUS_GETDATA
    • getLanRMBusProgramModuleMessage

      public static Z21Message getLanRMBusProgramModuleMessage(int address)
      Parameters:
      address - the RM Bus address to write.
      Returns:
      z21 message for LAN_RMBUS_PROGRAMMODULE
    • isCanDetectorMessage

    • getLanCanDetector

      public static Z21Message getLanCanDetector(int address)
      Parameters:
      address - CAN NetworkID of the module to request data from.
      Returns:
      z21 message for LAN_CAN_DETECTOR request message