Class OpenTracMessage

java.lang.Object
org.ka2ddo.ax25.AX25Message
org.ka2ddo.opentrac.OpenTracMessage
All Implemented Interfaces:
Serializable, Cloneable, Comparable<AX25Message>, Iterable<OpenTracEntity>, AX25FrameSource, SendableMessage

public class OpenTracMessage extends AX25Message implements AX25FrameSource, SendableMessage, Iterable<OpenTracEntity>
Outer layer of a generic OpenTRAC protocol message, containing entities and attributes of each entity.
Author:
Andrew Pavlin, KA2DDO
See Also:
  • Field Details

    • entities

      public ArrayList<OpenTracEntity> entities
      List of OpenTracEntity objects wrapped in this OpenTracMessage.
  • Constructor Details

    • OpenTracMessage

      public OpenTracMessage()
  • Method Details

    • computeBody

      public int computeBody(byte[] buf, int offset)
      Convert an OpenTRAC message into a properly encoded byte array..
      Parameters:
      buf - byte array containing a transmission-format OpenTRAC message
      offset - starting position in array that the message begins at
      Returns:
      position in array after the decoded message
    • paramString

      public String paramString()
      Descriptive text about this message, to be included in the toString() method's response.
      Overrides:
      paramString in class AX25Message
      Returns:
      String describing the contents of this message
      See Also:
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class AX25Message
      Returns:
      a string representation of the object.
    • getMatchingElement

      public OpenTracElement getMatchingElement(int type)
      Get the first element of the specified OpenTrac element ID on any entity in this message.
      Parameters:
      type - OpenTRAC element ID
      Returns:
      OpenTracElement of the specified type ID, or null if no matching element on any entity in this message
    • appendEntity

      public void appendEntity(OpenTracEntity entity)
      Add another entity of data to this message.
      Parameters:
      entity - OpenTracEntity to append to this message
    • getFrames

      public AX25Frame[] getFrames(boolean incrementXmtCount, ProtocolFamily protocolId, String senderCallsign)
      Get an AX25Frame of the data to transmit.
      Specified by:
      getFrames in interface AX25FrameSource
      Parameters:
      incrementXmtCount - indicate whether the transmit counter (used to cycle through proportional pathing) should be incremented
      protocolId - AX.25 protocol to format message in
      senderCallsign - String of local callsign sending this message (may be ignored if digipeating a message from another station)
      Returns:
      AX25Frame to transmit, or null indicating nothing to transmit
    • getBody

      public byte[] getBody(boolean countTransmission, ProtocolFamily protocolId, AX25Frame frame)
      Get an instance of this message, suitable for transmitting.
      Specified by:
      getBody in interface SendableMessage
      Parameters:
      countTransmission - number of times the message has been transmitted
      protocolId - ProtocolFamily to generate the message in
      frame - AX25Frame into which the message will be placed, so any alternate AX25Message can be linked to it
      Returns:
      byte array of message
      See Also:
    • isEnabled

      public boolean isEnabled()
      Test if message should still be transmitted.
      Specified by:
      isEnabled in interface SendableMessage
      Returns:
      boolean true if message should still be transmitted
    • disableForTransmit

      public void disableForTransmit()
      Specify that message should no longer be transmitted.
      Specified by:
      disableForTransmit in interface SendableMessage
    • hasWeather

      public boolean hasWeather()
      Report if this OpenTracMessage contains weather information.
      Specified by:
      hasWeather in class AX25Message
      Returns:
      boolean true if weather information in this Message
    • isEveryEntityAddressed

      public boolean isEveryEntityAddressed()
      Test if every entity in this message has been properly addressed. Locally-generated entities can be left unaddressed until transmit time, so the correct originating callsign for the transmitting port can be filled in.
      Returns:
      boolean true if entity has an originator's address (callsign-SSID)
    • hasPosition

      public boolean hasPosition()
      Report if this AX25Message contains position data.
      Overrides:
      hasPosition in class AX25Message
      Returns:
      boolean true if message contains position information
    • getPrecedence

      public AX25Message.Precedence getPrecedence()
      Report the traffic-handling precedence for this message instance.
      Overrides:
      getPrecedence in class AX25Message
      Returns:
      Precedence level for this AX25Message
    • getNumTransmitsBeforeDecay

      public int getNumTransmitsBeforeDecay()
      Get the number of cycles for a complete iteration over the proportional pathing digipeat path set.
      Specified by:
      getNumTransmitsBeforeDecay in interface AX25FrameSource
      Returns:
      number of transmissions to do one cycle of proportional pathing (value is 2^(N-1) where N is number of path choices)
    • getConnector

      public Connector getConnector()
      Specify the Connector this message should be transmitted through.
      Specified by:
      getConnector in interface AX25FrameSource
      Returns:
      a specific Connector instance to transmit through, or null for all applicable ports (Connector.CAP_XMT_PACKET_DATA and not rejecting this specific packet [such as IGateConnectors shouldn't re-transmit something received from the IGate])
      See Also:
    • iterator

      public Iterator<OpenTracEntity> iterator()
      Returns an iterator over a set of elements of type OpenTracEntity.
      Specified by:
      iterator in interface Iterable<OpenTracEntity>
      Returns:
      an Iterator.
    • getEntity

      public OpenTracEntity getEntity(String callsign, int ssid, short extensionId)
      Find the OpenTracEntity within this OpenTracMessage matching the specified identification.
      Parameters:
      callsign - String callsign of entity
      ssid - int SSID of entity
      extensionId - short extension ID of entity
      Returns:
      matching OpenTracEntity or null if no match
    • bodyEquals

      protected boolean bodyEquals(AX25Message other)
      Compare the contents of the body of the message, reporting if they match.
      Specified by:
      bodyEquals in class AX25Message
      Parameters:
      other - another AX25Message to compare against
      Returns:
      boolean true if the body values are equivalent
    • getProtocols

      public Set<ProtocolFamily> getProtocols()
      Get the protocol family or families that this message corresponds to, so ports that don't support all protocols will not forward inappropriate packets.
      Overrides:
      getProtocols in class AX25Message
      Returns:
      array of supported ProtocolFamily enums