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 Details

  • Constructor Details

  • Method Details

    • setOpCode

      public void setOpCode​(int i)
    • getOpCode

      public int getOpCode()
    • getOpCodeHex

      public 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.
    • toString

      public String toString()
      Description copied from interface: Message
      Specified by:
      toString in interface Message
      Overrides:
      toString in class Object