org.ka2ddo.opentrac
Class OpenTracMessage

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

public class OpenTracMessage
extends AX25Message
implements AX25FrameSource, SendableMessage, java.lang.Iterable<OpenTracEntity>

Outer layer of a generic OpenTRAC protocol message, containing entities and attributes of each entity.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ka2ddo.ax25.AX25Message
AX25Message.Precedence
 
Field Summary
 java.util.ArrayList<OpenTracEntity> entities
          List of OpenTracEntity objects wrapped in this OpenTracMessage.
 
Fields inherited from class org.ka2ddo.ax25.AX25Message
ax25Frame, invalid, ISO_8859_1, originatingCallsign, PERMANENT, rcptTime, thirdParty, timestamp, UTC, UTF8
 
Constructor Summary
OpenTracMessage()
           
 
Method Summary
 void appendEntity(OpenTracEntity entity)
          Add another entity of data to this message.
protected  boolean bodyEquals(AX25Message other)
          Compare the contents of the body of the message, reporting if they match.
 int computeBody(byte[] buf, int offset)
          Convert an OpenTRAC message into a properly encoded byte array..
 byte[] getBody(boolean countTransmission, byte protocolId, AX25Frame frame)
          Get an instance of this message, suitable for transmitting.
 Connector getConnector()
          Specify the Connector this message should be transmitted through.
 OpenTracEntity getEntity(java.lang.String callsign, int ssid, short extensionId)
          Find the OpenTracEntity within this OpenTracMessage matching the specified identification.
 AX25Frame[] getFrames(boolean incrementXmtCount, byte protocolId, java.lang.String senderCallsign)
          Get an AX25Frame of the data to transmit.
 OpenTracElement getMatchingElement(int type)
          Get the first element of the specified OpenTrac element ID on any entity in this message.
 int getNumTransmitsBeforeDecay()
          Get the number of cycles for a complete iteration over the proportional pathing digipeat path set.
 AX25Message.Precedence getPrecedence()
          Report the traffic-handling precedence for this message instance.
 boolean hasPosition()
          Report if this AX25Message contains position data.
 boolean hasWeather()
          Report if this OpenTracMessage contains weather information.
 boolean isEnabled()
          Test if message should still be transmitted.
 boolean isEveryEntityAddressed()
          Test if every entity in this message has been properly addressed.
 java.util.Iterator<OpenTracEntity> iterator()
          Returns an iterator over a set of elements of type OpenTracEntity.
 java.lang.String paramString()
          Descriptive text about this message, to be included in the toString() method's response.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class org.ka2ddo.ax25.AX25Message
compareTo, dup, equals, extractSource, getAx25Frame, getFirstDigipeat, getLastDigipeat, getOriginalDestination, getOriginalSource, getOriginatingCallsign, getRcptTime, getTimestamp, hashCode, hasThisFirstDigi, indexOf, indexOf, isInvalid, onlyDigits, onlyDigits, onlyDigitsOrPeriod, onlyDigitsOrSpace, onlyDigitsPlus, onlyPeriods, setAx25Frame, setInvalid, setOriginatingCallsign, setRcptTime, setTimestamp, split
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ka2ddo.ax25.SendableMessage
dup
 

Field Detail

entities

public java.util.ArrayList<OpenTracEntity> entities
List of OpenTracEntity objects wrapped in this OpenTracMessage.

Constructor Detail

OpenTracMessage

public OpenTracMessage()
Method Detail

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 java.lang.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()

toString

public java.lang.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,
                             byte protocolId,
                             java.lang.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,
                      byte 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 - AX.25 protocol ID to generate the message in, or 0 for default protocol; currently, only OpenTRAC are supported.
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:
AX25Frame.parsedAX25Msg

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

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:
Connector.CAP_XMT_PACKET_DATA

iterator

public java.util.Iterator<OpenTracEntity> iterator()
Returns an iterator over a set of elements of type OpenTracEntity.

Specified by:
iterator in interface java.lang.Iterable<OpenTracEntity>
Returns:
an Iterator.

getEntity

public OpenTracEntity getEntity(java.lang.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