Package org.ka2ddo.yaac.io
Class SendableMessageWrapper
java.lang.Object
org.ka2ddo.yaac.io.SendableMessageWrapper
- All Implemented Interfaces:
Serializable
,SetBeaconRatesIfc
,AX25FrameSource
- Direct Known Subclasses:
ObjectReportSender
public class SendableMessageWrapper
extends Object
implements AX25FrameSource, Serializable, SetBeaconRatesIfc
This class wraps a SendableMessage in a AX25Frame suitable for transmission.
- Author:
- Andrew Pavlin KA2DDO
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The characters (in order) for sequencing a multi-line bulletin.Fields inherited from interface org.ka2ddo.ax25.AX25FrameSource
NO_FRAMES
-
Constructor Summary
ConstructorDescriptionWrap a SendableMessage for one transmission cycle with the default proportional pathing path set.SendableMessageWrapper
(SendableMessage msg, int maxRetries) Wrap a SendableMessage for the specified number of transmission cycles with the default proportional pathing path set.SendableMessageWrapper
(SendableMessage msg, String[] relays) Wrap a SendableMessage for one transmission cycle with the specified proportional pathing path set.SendableMessageWrapper
(SendableMessage msg, String[] relays, int maxRetries) Wrap a SendableMessage for the specified number of transmission cycles with the specified proportional pathing path set. -
Method Summary
Modifier and TypeMethodDescriptionstatic AX25Frame
buildAX25FrameForMessage
(String[] relays, SendableMessage msg, int numTransmissions, ProtocolFamily protocolId, String senderCallsign) Convert a SendableMessage object into a transmittable AX.25 frame, ready to send via KISS protocol to a TNC/radio.void
cancelPermanently
(boolean isGuiDispatchThread) Delete this SendableMessageWrapper from the transmission queue.void
cancelTransmission
(boolean isGuiDispatchThread) Stop trying to transmit this message, but still keep track of it in the model.protected void
cleanup()
Do any cleanup work involved in removing this wrapped message from the transmission queue.void
Set the first time for this SendableMessage to transmit, so all the ones being started at YAAC startup time don't pile out at one time.static SendableMessageWrapper
Find any wrapper outstanding for an equivalent SendableMessage.static SendableMessageWrapper
Find any wrapper outstanding for the specified SendableMessage.Get the port to which this message should be sent.int
Get the scaling factor by which the message repeat interval is enlarged (until the default slow send rate is reached).String[]
Get the proportional pathing ordered set of digipeat paths.getFrames
(boolean incrementXmtCount, ProtocolFamily protocolId, String senderCallsign) Get one or more AX25Frames of the data to transmit.int
getId()
Get the internal sequence ID assigned to this wrapperint
Get the fast retransmission rate for this message.long
Get the last time this message was transmitted.int
Get the maximum number of transmissions allowed for this message.getMsg()
Get the SendableMessage wrapped in this objectGet the next message in a chain of linked outgoing messages.int
Get the number of times this message has been transmitted.int
Get the number of times the message will be transmitted before the transmission rate is slowed.static ArrayList<SendableMessageWrapper>
getObjectsInGroup
(String groupName) Search the list of outgoing messages for local Objects tagged with the specified QRU group.static Vector<SendableMessageWrapper>
Get a reference to the vector of outstanding locally originated messages.Get a map of all the QRU groups known to have locally originated objects on this station, and return the count of objects per group.int
Get the number of transmissions remaining until the message has been sent.int
Get the slow retransmission rate for this message.boolean
isAcked()
Report whether this message was acknowledged by its recipient.boolean
isActive()
Report whether this SendableMessageWrapper is still queued for upcoming transmissions.boolean
Report whether this message was rejected by its recipient.boolean
Indicate whether beacon data source can dynamically change its position (latitude/longitude), such as for a mobile station with a GPS.void
Put this SendableMessageWrapper on the list of messages to be transmitted and start transmitting it according to its transmit parameters.static void
removeObsoleteMessage
(Message msg, boolean isGuiDispatchThread) Find and cancel any queued messages matching the passed message.static void
removeObsoleteMessage
(SendableMessageWrapper smw, boolean isGuiDispatchThread) Find and cancel any queued messages matching the passed message.void
requeue()
Reschedule the beacon based on its last transmission time and any changes in retransmit interval.void
resetTransmitCount
(boolean isGuiDispatchThread) Reset the retransmission counters as if this was a brand-new message using the initial fast transmission rate.void
setAcked
(boolean acknowledged) Indicate that this message has been acknowledged.void
setConnector
(Connector targetConnector) Set the port to which this message should be sent.void
setDecayRatio
(int decayRatio) Set the scaling factor by which the message repeat interval is enlarged (until the default slow send rate is reached).void
setDigipeatPaths
(String[] relays) Set the proportional pathing ordered set of digipeat paths.void
setInitialSendRate
(int fastSendRate) Set the fast retransmission rate for this message.void
setMaxTransmits
(int maxTransmits) Get the maximum number of transmissions allowed for this message.void
setNextMessage
(SendableMessageWrapper nextMessage) Set the message after this message in a chain of sequenced messages.void
setRejected
(boolean rejected) Indicate that this message has been rejected.static void
Set the global handler for changes in the list of SendableMessages.void
setSlowSendRate
(int slowSendRate) Set the slow retransmission rate for this message.toString()
Returns a string representation of the object.
-
Field Details
-
BULLETIN_SEQUENCE_CHARS
The characters (in order) for sequencing a multi-line bulletin. Maximum of 36 lines in a bulletin.- See Also:
-
-
Constructor Details
-
SendableMessageWrapper
Wrap a SendableMessage for one transmission cycle with the default proportional pathing path set.- Parameters:
msg
- SendableMessage to transmit
-
SendableMessageWrapper
Wrap a SendableMessage for one transmission cycle with the specified proportional pathing path set.- Parameters:
msg
- SendableMessage to transmitrelays
- ordered array of digipeat paths for proportional pathing (1-element array to not use proportional pathing)
-
SendableMessageWrapper
Wrap a SendableMessage for the specified number of transmission cycles with the default proportional pathing path set.- Parameters:
msg
- SendableMessage to transmitmaxRetries
- number of times (times 2^N length of proportional path set) the message should be transmitted
-
SendableMessageWrapper
Wrap a SendableMessage for the specified number of transmission cycles with the specified proportional pathing path set.- Parameters:
msg
- SendableMessage to transmitrelays
- ordered array of digipeat paths for proportional pathing (1-element array to not use proportional pathing)maxRetries
- number of times (times 2^N length of proportional path set) the message should be transmitted
-
-
Method Details
-
setSendableMessageListener
Set the global handler for changes in the list of SendableMessages.- Parameters:
l
- SendableMessageListener to handle list change events
-
getMsg
Get the SendableMessage wrapped in this object- Returns:
- wrapped SendableMessage
-
getFrames
public AX25Frame[] getFrames(boolean incrementXmtCount, ProtocolFamily protocolId, String senderCallsign) Get one or more AX25Frames of the data to transmit.- Specified by:
getFrames
in interfaceAX25FrameSource
- Parameters:
incrementXmtCount
- indicate whether the transmit counter (used to cycle through proportional pathing) should be incrementedprotocolId
- indicate the protocol to generate this frame for (not relevant for digipeated frames)senderCallsign
- String of local callsign sending this message (may be ignored if digipeating a message from another station)- Returns:
- array of AX25Frame objects to transmit, or null indicating nothing to transmit in the specified protocol
-
buildAX25FrameForMessage
public static AX25Frame buildAX25FrameForMessage(String[] relays, SendableMessage msg, int numTransmissions, ProtocolFamily protocolId, String senderCallsign) Convert a SendableMessage object into a transmittable AX.25 frame, ready to send via KISS protocol to a TNC/radio.- Parameters:
relays
- digipeater to specify in the AX.25 framemsg
- the SendableMessage to encapsulate in an AX.25 framenumTransmissions
- number of times the message has been transmitted.protocolId
- AX.25 protocol ID to generate the message in; currently, only APRS and OPENTRAC are supported.senderCallsign
- String of local callsign sending this message (may be ignored if digipeating a message from another station)- Returns:
- an AX25Frame object ready to transmit, or null if the conversion and encapsulation could not be done.
-
getNumTransmitsBeforeDecay
public int getNumTransmitsBeforeDecay()Get the number of times the message will be transmitted before the transmission rate is slowed. This is a function of the number of proportional paths defined, as the transmit interval will not be slowed until the entire proportional path cycle has been gone through.- Specified by:
getNumTransmitsBeforeDecay
in interfaceAX25FrameSource
- Returns:
- number of transmits for one cycle of the proportional paths of this message
-
getLastTransmitTime
public long getLastTransmitTime()Get the last time this message was transmitted.- Returns:
- transmission time as Unix time in milliseconds since midnight Jan 1 1970 UTC, or zero if never transmitted
-
getNumTransmissions
public int getNumTransmissions()Get the number of times this message has been transmitted.- Returns:
- transmit count
-
resetTransmitCount
public void resetTransmitCount(boolean isGuiDispatchThread) Reset the retransmission counters as if this was a brand-new message using the initial fast transmission rate.- Parameters:
isGuiDispatchThread
- boolean true if caller is the GUI dispatch thread
-
getInitialSendRate
public int getInitialSendRate()Get the fast retransmission rate for this message.- Specified by:
getInitialSendRate
in interfaceSetBeaconRatesIfc
- Returns:
- fast retransmit rate in seconds
-
setInitialSendRate
public void setInitialSendRate(int fastSendRate) Set the fast retransmission rate for this message.- Specified by:
setInitialSendRate
in interfaceSetBeaconRatesIfc
- Parameters:
fastSendRate
- fast retransmit rate in seconds
-
setDecayRatio
public void setDecayRatio(int decayRatio) Set the scaling factor by which the message repeat interval is enlarged (until the default slow send rate is reached).- Specified by:
setDecayRatio
in interfaceSetBeaconRatesIfc
- Parameters:
decayRatio
- int decay ratio (should be 2 or 3)
-
getDecayRatio
public int getDecayRatio()Get the scaling factor by which the message repeat interval is enlarged (until the default slow send rate is reached).- Specified by:
getDecayRatio
in interfaceSetBeaconRatesIfc
- Returns:
- int decay ratio
-
getSlowSendRate
public int getSlowSendRate()Get the slow retransmission rate for this message.- Specified by:
getSlowSendRate
in interfaceSetBeaconRatesIfc
- Returns:
- slow retransmission rate in seconds
-
setSlowSendRate
public void setSlowSendRate(int slowSendRate) Set the slow retransmission rate for this message.- Specified by:
setSlowSendRate
in interfaceSetBeaconRatesIfc
- Parameters:
slowSendRate
- slow retransmission rate in seconds
-
isUseGpsForPosition
public boolean isUseGpsForPosition()Indicate whether beacon data source can dynamically change its position (latitude/longitude), such as for a mobile station with a GPS.- Specified by:
isUseGpsForPosition
in interfaceSetBeaconRatesIfc
- Returns:
- boolean true if latitude or longitude of beacon can change dynamically (not just through UI)
-
getNextMessage
Get the next message in a chain of linked outgoing messages.- Returns:
- SendableMessageWrapper of next message, or null if this message is alone or the end of a chain
-
setNextMessage
Set the message after this message in a chain of sequenced messages.- Parameters:
nextMessage
- SendableMessageWrapper around the next message after this one, or null for no next message
-
getConnector
Get the port to which this message should be sent. By default, returns null (i.e., send to all available ports), but can be sent to a specific port if a non-null value is specified tosetConnector(Connector)
.- Specified by:
getConnector
in interfaceAX25FrameSource
- Returns:
- null for all PortConnectors
- See Also:
-
setConnector
Set the port to which this message should be sent. Specifying null means send to all available ports, but can be sent to a specific port if parameter is non-null.- Parameters:
targetConnector
- null for all PortConnectors
-
getOutstandingMessages
Get a reference to the vector of outstanding locally originated messages.- Returns:
- Vector of SendableMessageWrappers that are still outstanding
-
findWrapperOf
Find any wrapper outstanding for the specified SendableMessage.- Parameters:
sm
- SendableMessage to look for in queue- Returns:
- SendableMessageWrapper containing the specified SendableMessage, or null if not found
-
findDuplicateWrapperOf
Find any wrapper outstanding for an equivalent SendableMessage.- Parameters:
sm
- SendableMessage to look for in queue- Returns:
- SendableMessageWrapper containing the specified SendableMessage, or null if not found
-
getQruGroupCounts
Get a map of all the QRU groups known to have locally originated objects on this station, and return the count of objects per group.- Returns:
- HashMap of group names to counts
-
getObjectsInGroup
Search the list of outgoing messages for local Objects tagged with the specified QRU group.- Parameters:
groupName
- QRU category name- Returns:
- ArrayList of SendableMessageWrappers containing ObjectReports in the specified QRU group
-
isAcked
public boolean isAcked()Report whether this message was acknowledged by its recipient.- Returns:
- boolean true if this message received a "ack" response.
-
setAcked
public void setAcked(boolean acknowledged) Indicate that this message has been acknowledged.- Parameters:
acknowledged
- the new setting of the acknowledged boolean flag
-
isRejected
public boolean isRejected()Report whether this message was rejected by its recipient.- Returns:
- boolean true if this message received a "rej" response.
-
setRejected
public void setRejected(boolean rejected) Indicate that this message has been rejected.- Parameters:
rejected
- the new setting of the rejected boolean flag
-
queueForTransmission
public void queueForTransmission()Put this SendableMessageWrapper on the list of messages to be transmitted and start transmitting it according to its transmit parameters. -
cancelTransmission
public void cancelTransmission(boolean isGuiDispatchThread) Stop trying to transmit this message, but still keep track of it in the model.- Parameters:
isGuiDispatchThread
- boolean true if caller is the GUI dispatch thread
-
cleanup
protected void cleanup()Do any cleanup work involved in removing this wrapped message from the transmission queue. -
cancelPermanently
public void cancelPermanently(boolean isGuiDispatchThread) Delete this SendableMessageWrapper from the transmission queue. Note this doesn't call cancelTransmission() because that would send an update event to any listeners, and this message might be deleted entirely before the event was processed.- Parameters:
isGuiDispatchThread
- boolean true if caller is the GUI dispatch thread
-
removeObsoleteMessage
Find and cancel any queued messages matching the passed message.- Parameters:
msg
- Message to compare against queued messagesisGuiDispatchThread
- boolean true if caller is the GUI dispatch thread
-
removeObsoleteMessage
Find and cancel any queued messages matching the passed message.- Parameters:
smw
- SendableMessageWrapper to compare against queued messagesisGuiDispatchThread
- boolean true if caller is the GUI dispatch thread
-
requeue
public void requeue()Reschedule the beacon based on its last transmission time and any changes in retransmit interval. -
computeRandomizedTransmitTime
public void computeRandomizedTransmitTime()Set the first time for this SendableMessage to transmit, so all the ones being started at YAAC startup time don't pile out at one time. -
isActive
public boolean isActive()Report whether this SendableMessageWrapper is still queued for upcoming transmissions.- Returns:
- boolean true if message is still waiting for (re)transmission
-
getRemainingTransmits
public int getRemainingTransmits()Get the number of transmissions remaining until the message has been sent.- Returns:
- int number of remaining transmissions
-
getMaxTransmits
public int getMaxTransmits()Get the maximum number of transmissions allowed for this message.- Returns:
- int maximum number of transmissions
-
setMaxTransmits
public void setMaxTransmits(int maxTransmits) Get the maximum number of transmissions allowed for this message.- Parameters:
maxTransmits
- maximum number of transmissions
-
getDigipeatPaths
Get the proportional pathing ordered set of digipeat paths.- Returns:
- ordered String array of digipeat paths
-
setDigipeatPaths
Set the proportional pathing ordered set of digipeat paths.- Parameters:
relays
- ordered String array of digipeat paths
-
toString
Returns a string representation of the object. In general, thetoString
method returns a string that "textually represents" this object. -
getId
public int getId()Get the internal sequence ID assigned to this wrapper- Returns:
- ID number
-