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.-
Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars
-
-
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(java.lang.String s)
Create a new Message instance from a string.AbstractMRMessage(AbstractMRMessage m)
Copy an AbstractMRMessage to a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods 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()
java.lang.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.java.lang.String
toString()
-
Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElement
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.Message
toMonitorString
-
-
-
-
Field Detail
-
SHORT_TIMEOUT
protected static final int 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
protected static final int LONG_TIMEOUT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractMRMessage
public AbstractMRMessage()
Create a new AbstractMRMessage instance.
-
AbstractMRMessage
public AbstractMRMessage(int i)
Create a new AbstractMRMessage instance of a given byte size.- Parameters:
i
- number of elements in message
-
AbstractMRMessage
public AbstractMRMessage(@Nonnull AbstractMRMessage m)
Copy an AbstractMRMessage to a new instance.- Parameters:
m
- the message to copy
-
AbstractMRMessage
public AbstractMRMessage(java.lang.String s)
Create a new Message instance from a string.- Parameters:
s
- String to use as message content
-
-
Method Detail
-
setOpCode
public void setOpCode(int i)
-
getOpCode
public int getOpCode()
-
getOpCodeHex
public java.lang.String getOpCodeHex()
-
setNeededMode
public final void setNeededMode(int pMode)
Set a needed mode. Final so that it can be called in constructors.- Parameters:
pMode
- required mode value.
-
getNeededMode
public final int getNeededMode()
Get needed mode. Final so that it can be called in constructors.- Returns:
- mNeededMode required mode value.
-
replyExpected
public boolean 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
public final boolean isBinary()
Get if is binary. Final so that it can be called in constructors.- Returns:
- true if binary, else false.
-
setBinary
public final void setBinary(boolean b)
Set if Binary. final so that it can be called in constructors.- Parameters:
b
- true if binary, else false.
-
setTimeout
public final void setTimeout(int t)
Set Timeout. Final so that it can be called in constructors.- Parameters:
t
- timeout value.
-
getTimeout
public final int getTimeout()
Get Timeout. Final so that it can be called in constructors.- Returns:
- timeout value.
-
setRetries
public final void setRetries(int i)
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
public final int getRetries()
Get number of retries. final so that it can be called in constructors- Returns:
- number of retries count.
-
addIntAsThree
public void addIntAsThree(int val, int offset)
-
addIntAsTwoHex
public void addIntAsTwoHex(int val, int offset)
Put an int value into the message as two ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
addIntAsThreeHex
public void addIntAsThreeHex(int val, int offset)
Put an int value into the message as three ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
addIntAsFourHex
public void addIntAsFourHex(int val, int offset)
Put an int value into the message as four ASCII upper-case hex characters.- Parameters:
val
- value to convert.offset
- offset in message.
-
-