Package jmri.jmrix.roco.z21
Class Z21Message
- java.lang.Object
-
- jmri.jmrix.AbstractMessage
-
- jmri.jmrix.AbstractMRMessage
-
- jmri.jmrix.roco.z21.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 Summary
Fields Modifier and Type Field Description (package private) boolean
mReplyExpected
-
Fields inherited from class jmri.jmrix.AbstractMRMessage
LONG_TIMEOUT, SHORT_TIMEOUT
-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
Constructor Summary
Constructors Constructor Description Z21Message()
Z21Message(byte[] a, int l)
This ctor interprets the byte array as a sequence of characters to send.Z21Message(int i)
Z21Message(java.lang.String m)
This ctor interprets the String as the exact sequence to send, byte-for-byte.Z21Message(XNetMessage m)
Z21Message(LocoNetMessage m)
-
Method Summary
-
Methods inherited from class jmri.jmrix.AbstractMRMessage
addIntAsFourHex, addIntAsThree, addIntAsThreeHex, addIntAsTwoHex, getNeededMode, getOpCodeHex, getRetries, getTimeout, isBinary, setBinary, setNeededMode, setRetries, setTimeout, toString
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
-
-
-
Field Detail
-
mReplyExpected
boolean mReplyExpected
-
-
Constructor Detail
-
Z21Message
public Z21Message()
-
Z21Message
public Z21Message(int i)
-
Z21Message
public Z21Message(XNetMessage m)
-
Z21Message
public Z21Message(LocoNetMessage m)
-
Z21Message
public Z21Message(java.lang.String m)
This ctor interprets the String as the exact sequence to send, byte-for-byte.- Parameters:
m
- message string.
-
Z21Message
public Z21Message(byte[] a, int l)
This ctor interprets the byte array as a sequence of characters to send.- Parameters:
a
- Array of bytes to sendl
- unused.
-
-
Method Detail
-
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 classAbstractMRMessage
- Returns:
- true by default in Abstract MR message.
-
setOpCode
public void setOpCode(int i)
- Overrides:
setOpCode
in classAbstractMRMessage
-
getOpCode
public int getOpCode()
- Overrides:
getOpCode
in classAbstractMRMessage
-
setLength
public void setLength(int i)
-
getLength
public int getLength()
-
getBuffer
byte[] getBuffer()
-
getSerialNumberRequestMessage
public static Z21Message getSerialNumberRequestMessage()
-
getLanGetHardwareInfoRequestMessage
public static Z21Message getLanGetHardwareInfoRequestMessage()
-
getLanLogoffRequestMessage
public static Z21Message getLanLogoffRequestMessage()
-
getLanGetBroadcastFlagsRequestMessage
public static Z21Message getLanGetBroadcastFlagsRequestMessage()
- Returns:
- z21 message for LAN_GET_BROADCAST_FLAGS request.
-
getLanSetBroadcastFlagsRequestMessage
public static Z21Message getLanSetBroadcastFlagsRequestMessage(int flags)
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
public static Z21Message getLanRailComGetDataRequestMessage()
- Returns:
- z21 message for LAN_RAILCOM_GETDATA request.
-
getLanSystemStateDataChangedRequestMessage
public static Z21Message getLanSystemStateDataChangedRequestMessage()
- Returns:
- z21 message for LAN_SYSTEMSTATE_GETDATA
-
toMonitorString
public java.lang.String toMonitorString()
- Returns:
- a human-readable representation of the message.
-
isLocoNetTunnelMessage
boolean isLocoNetTunnelMessage()
-
isLocoNetDispatchMessage
boolean isLocoNetDispatchMessage()
-
isLocoNetDetectorMessage
boolean isLocoNetDetectorMessage()
-
getLocoNetMessage
LocoNetMessage 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
boolean 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
-
-