Package jmri.jmrix
Class AbstractMRMessage
java.lang.Object
jmri.jmrix.AbstractMessage
jmri.jmrix.AbstractMRMessage
- All Implemented Interfaces:
Message
- Direct Known Subclasses:
AcelaMessage
,CanMessage
,Dcc4PcMessage
,DCCppMessage
,EasyDccMessage
,EcosMessage
,GridConnectMessage
,IEEE802154Message
,JMRIClientMessage
,MarklinMessage
,Message
,Message
,NceMessage
,RfidMessage
,SerialMessage
,SerialMessage
,SerialMessage
,SerialMessage
,SerialMessage
,SerialMessage
,SerialMessage
,SprogMessage
,SRCPMessage
,TamsMessage
,XNetMessage
,Z21Message
public abstract class AbstractMRMessage extends AbstractMessage
Abstract base class for messages in a message/reply protocol.
Carries a sequence of characters, with accessors.
-
Field Summary
Fields Modifier and Type Field Description protected static int
LONG_TIMEOUT
protected static int
SHORT_TIMEOUT
Minimum timeout that's acceptable. -
Constructor Summary
Constructors Constructor Description AbstractMRMessage()
Create a new AbstractMRMessage instance.AbstractMRMessage(int i)
Create a new AbstractMRMessage instance of a given byte size.AbstractMRMessage(String s)
Create a new Message instance from a string.AbstractMRMessage(AbstractMRMessage m)
Copy an AbstractMRMessage to a new instance. -
Method Summary
Modifier and Type Method Description void
addIntAsFourHex(int val, int offset)
Put an int value into the message as four ASCII upper-case hex characters.void
addIntAsThree(int val, int offset)
void
addIntAsThreeHex(int val, int offset)
Put an int value into the message as three ASCII upper-case hex characters.void
addIntAsTwoHex(int val, int offset)
Put an int value into the message as two ASCII upper-case hex characters.int
getNeededMode()
Get needed mode.int
getOpCode()
String
getOpCodeHex()
int
getRetries()
Get number of retries.int
getTimeout()
Get Timeout.boolean
isBinary()
Get if is binary.boolean
replyExpected()
Is a reply expected to this message?void
setBinary(boolean b)
Set if Binary.void
setNeededMode(int pMode)
Set a needed mode.void
setOpCode(int i)
void
setRetries(int i)
Set number of retries.void
setTimeout(int t)
Set Timeout.String
toString()
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
Field Details
-
SHORT_TIMEOUT
Minimum timeout that's acceptable.Also used as default for normal operations. Don't shorten this "to make recovery faster", as sometimes internal delays can slow processing down.
Units are milliseconds.
- See Also:
- Constant Field Values
-
LONG_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Details
-
AbstractMRMessage
public AbstractMRMessage()Create a new AbstractMRMessage instance. -
AbstractMRMessage
Create a new AbstractMRMessage instance of a given byte size.- Parameters:
i
- number of elements in message
-
AbstractMRMessage
Copy an AbstractMRMessage to a new instance.- Parameters:
m
- the message to copy
-
AbstractMRMessage
Create a new Message instance from a string.- Parameters:
s
- String to use as message content
-
-
Method Details
-
setOpCode
-
getOpCode
-
getOpCodeHex
-
setNeededMode
Set a needed mode. Final so that it can be called in constructors.- Parameters:
pMode
- required mode value.
-
getNeededMode
Get needed mode. Final so that it can be called in constructors.- Returns:
- mNeededMode required mode value.
-
replyExpected
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).
- Returns:
- true by default in Abstract MR message.
-
isBinary
Get if is binary. Final so that it can be called in constructors.- Returns:
- true if binary, else false.
-
setBinary
Set if Binary. final so that it can be called in constructors.- Parameters:
b
- true if binary, else false.
-
setTimeout
Set Timeout. Final so that it can be called in constructors.- Parameters:
t
- timeout value.
-
getTimeout
Get Timeout. Final so that it can be called in constructors.- Returns:
- timeout value.
-
setRetries
Set number of retries. Final so that it can be called in constructors- Parameters:
i
- number of retries, actual value to set, not an increment.
-
getRetries
Get number of retries. final so that it can be called in constructors- Returns:
- number of retries count.
-
addIntAsThree
-
addIntAsTwoHex
Put an int value into the message as two ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
addIntAsThreeHex
Put an int value into the message as three ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
addIntAsFourHex
Put an int value into the message as four ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
toString
Description copied from interface:Message
-