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
Abstract base class for messages in a message/reply protocol.
Carries a sequence of characters, with accessors.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intMinimum timeout that's acceptable.Fields inherited from class jmri.jmrix.AbstractMessage
_dataChars, _nDataChars -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new AbstractMRMessage instance.AbstractMRMessage(int i) Create a new AbstractMRMessage instance of a given byte size.Create a new Message instance from a string.Copy an AbstractMRMessage to a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIntAsFourHex(int val, int offset) Put an int value into the message as four ASCII upper-case hex characters.voidaddIntAsThree(int val, int offset) voidaddIntAsThreeHex(int val, int offset) Put an int value into the message as three ASCII upper-case hex characters.voidaddIntAsTwoHex(int val, int offset) Put an int value into the message as two ASCII upper-case hex characters.final intGet needed mode.intfinal intGet number of retries.final intGet Timeout.final booleanisBinary()Get if is binary.booleanIs a reply expected to this message?final voidsetBinary(boolean b) Set if Binary.final voidsetNeededMode(int pMode) Set a needed mode.voidsetOpCode(int i) final voidsetRetries(int i) Set number of retries.final voidsetTimeout(int t) Set Timeout.toString()Methods inherited from class jmri.jmrix.AbstractMessage
equals, getElement, getNumDataElements, hashCode, setElementMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.jmrix.Message
toMonitorString
-
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:
-
LONG_TIMEOUT
- See Also:
-
-
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
-