Package org.ka2ddo.yaac.ax25
Class StationState
java.lang.Object
org.ka2ddo.yaac.ax25.StationState
- All Implemented Interfaces:
Serializable
,Comparable<StationState>
,Iterable<AX25Message>
,SupportsExtraData
public class StationState
extends Object
implements Comparable<StationState>, Serializable, SupportsExtraData, Iterable<AX25Message>
This class maintains a record of the current state of a monitored station,
and a reverse-chronologically-ordered history of all messages heard from
the station. The accumulated state can be updated or recomputed from history
at any time.
- Author:
- Andrew Pavlin, KA2DDO
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
This enumeration identifies special conditions of a monitored station or object that color a background circle behind the icon for the station. -
Field Summary
Modifier and TypeFieldDescriptionprotected char
The local alias symbol code within the specified symbol table for representing this station or object on the map.protected char
The local alias symbol table ID (or overlay character for alternate symbols).The String identifying this particular station or object.boolean
Whether or not this station or object should be displayed on the map.The String identifying a local alias for this Station or Object.static final long
Constant defining 80 minutes (the period commonly considered to be out-of-date in APRS) in Java milliseconds.Place to attach miscellaneous attachments to a station or object.float
Scratch range variable used for aloha circle calculation.static final Comparator<StationState>
Comparator to order StationState objects by case-insensitive comparison of their identifier strings.protected char
The symbol code within the specified symbol table for representing this station or object on the map.protected char
The symbol table ID (or overlay character for alternate symbols). -
Constructor Summary
ConstructorDescriptionStationState
(String callsign) Create a new StationState object with the specified identifying String and the specified parent node for tree-style display of the information. -
Method Summary
Modifier and TypeMethodDescriptionint
addMessage
(AX25Message msg) Add a message to the accumulated history for this station.Append the tactical alias for this station (or the undefinition if this station doesn't have an alias).void
Clear all accumulated inferred information about the station or object.int
Compares this object with the specified object for order.boolean
Indicates whether some other object is "equal to" this one.get
(int childIndex) Get the Nth oldest message received from this station or object.final long
getAge
(long now) Report the time since this station's information was updated.int
Return the length in characters of the tactical callsign exchange phrase for this station/object.final char
Return the currently defined local alias symbolCode reported for this station or object.final char
Return the currently defined local alias identifier of the table containing the symbol reported for this station or object.float
getAmsl()
Get the last known altitude of the specified station or object.getAttachment
(Object key) Get a named attachment for this station.Object[]
Get all the keys for attachments on this station or object.float
Get the last known course bearing for this station.static int
Get the current default value for how long a station or object can be inactive before an inactive event is reported.Get the identifying name of the station or object described by this StationState.long
Get the last time this station appeared as a digipeater.long
Get the timestamp when the position was last updated.double
Get the most recently reported or inferred latitude for this station or object.Get the current locally defined alias for this Station or Object.double
Get the most recently reported or inferred longitude for this station or object.int
Get how long this station or object can be inactive before an inactive event is reported for it.long
Get the last time a Message was received on behalf of this station or object or anything this station digipeated.Get the last APRS position message reported for this station or object.long
Get the last time a Message was received on behalf of this station or object.Get the current Precedence state of this station or object.static long
Get the time in seconds that messages will be kept before purging.float
Return the last reported position ambiguity,Return the hashable and comparable identifier for the record.getSpecialState
(long now, long age) Derive the background color for a given object.float
getSpeed()
Return the last known speed of travel of this station or object.final char
Return the last symbolCode reported for this station or object.final char
Return the identifier of the table containing the symbol reported for this station or object.Get the map containing extracted weather and hurricane information.int
hashCode()
Returns a hash code value for the object.boolean
Report if this station is providing hurricane information.boolean
Report if this station or object has any messages from played-back log files.boolean
Report if this station has received any messages in real-time.boolean
Report if this station is providing weather information.boolean
Indicates if this "station" is actually an Object or Item that is currently active (not killed).static boolean
Report whether newly created stations and object records are visible by default.boolean
isDirect
(long oldestAllowed) Report if the station has been directly heard by the local YAAC instance (without being digipeated) recently.static boolean
Efficiently test if vicinity plotting should be done for stations not reporting position.boolean
Indicate if the station has only been heard via a IGate connection to the APRS-IS backbone.boolean
isLocalRf
(long oldestAllowed, int maxDigis) Indicate if the station is accessible over local RF.boolean
isObject()
Reports if this station was last reported as a non-transmitting object or item, as defined by the APRS specifications.boolean
Reports if this station is actually a non-transmitting object or item, as defined by the APRS specifications.boolean
If entire history of this station is GpsRawMessages at too fast a rate for APRS messaging, than it must be either a moron or a remote GPS (as defined in the SerialGpsConnector and SerialGpsPortEditor).isStationMoving
(long now) Test if the station monitored by this StationState appears to be moving or remaining in a fixed location.boolean
isTimeInRange
(long timestamp) Test if this station has any messages meeting the specified time range.boolean
Indicate if this station is a transmit-only tracker.iterator()
Obtain an iterator to cycle through the messages accumulated for this station or object.void
persistLocalAlias
(Preferences rootNode) Checkpoint the current tactical name setting to Java Preferencesint
pruneOldMessages
(long then) Delete all messages from this StationState object whose receive times are older than the specified old age.putAttachment
(Object key, Object attachment) Add an attachment to this station or object.removeAttachment
(Object key) Remove an attachment from this station or object.final void
setAltSymbolCode
(char altSymbolCode) Set the currently defined local alias symbolCode reported for this station or object.final void
setAltSymTableId
(char altSymTableId) Set the currently defined local alias identifier of the table containing the symbol reported for this station or object.void
setAmsl
(float amsl) Overwrite the altitude for this station/object.static void
setDefaultIsViewableForNewStation
(boolean defaultIsViewableForNewStation) Specify whether newly created stations and object records are visible by default.static void
setDefaultMaxInactivityBeforeAlarm
(int defaultMaxInactivityBeforeAlarm) Set the default for how long a station or object can be inactive before an inactive event is reported for it.static void
setDoVicinityPlot
(boolean doVicinityPlot) Remember if vicinity plotting should be done for stations not reporting position.void
setLocalAlias
(String localAlias) Set the current locally defined alias for this Station or Object.void
setLocation
(double latitude, double longitude, long timestampMsec) Set the location for this station or object.void
setMaxInactivityBeforeAlarm
(int maxInactivityInMinutes) Set how long this station or object can be inactive before an inactive event is reported for it.static void
setPurgeThresholdSecs
(long purgeThresholdSecs) Set the time in seconds before messages will be purged.void
setRadiusOfConfidence
(float radiusOfConfidence) Specify the radius of confidence (position ambiguity).void
setSymbol
(char symTableId, char symbolCode) Change the symbol code associated with this station.void
setVelocity
(float bearing, float speedKts) Set the speed and direction of motion for this station or object.int
size()
Get the number of messages associated with this station or object.toString()
Return a string describing this object.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
MINUTES_80
public static final long MINUTES_80Constant defining 80 minutes (the period commonly considered to be out-of-date in APRS) in Java milliseconds.- See Also:
-
identifier
The String identifying this particular station or object. -
localAlias
The String identifying a local alias for this Station or Object. -
symTableId
protected char symTableIdThe symbol table ID (or overlay character for alternate symbols). '/' indicates a primary table symbol, anything else is an alternate table symbol. Default value until changed is the table for the "Unknown Position" symbol. -
symbolCode
protected char symbolCodeThe symbol code within the specified symbol table for representing this station or object on the map. Derived from symbol information embedded or inferred from the most recently received Messages. Default value until changed is the code for the "Unknown Position" symbol.- See Also:
-
altSymTableId
protected char altSymTableIdThe local alias symbol table ID (or overlay character for alternate symbols). '/' indicates a primary table symbol, anything else is an alternate table symbol. -
altSymbolCode
protected char altSymbolCodeThe local alias symbol code within the specified symbol table for representing this station or object on the map.- See Also:
-
isViewable
public boolean isViewableWhether or not this station or object should be displayed on the map.- See Also:
-
rangeM
public transient float rangeMScratch range variable used for aloha circle calculation.- See Also:
-
miscAttachments
Place to attach miscellaneous attachments to a station or object. -
SORT_BY_IDENTIFIER
Comparator to order StationState objects by case-insensitive comparison of their identifier strings.
-
-
Constructor Details
-
StationState
Create a new StationState object with the specified identifying String and the specified parent node for tree-style display of the information.- Parameters:
callsign
- String callsign or name of the station or object
-
-
Method Details
-
isDoVicinityPlot
public static boolean isDoVicinityPlot()Efficiently test if vicinity plotting should be done for stations not reporting position.- Returns:
- boolean true if stations should be vicinity plotted relative to the original digipeating station
-
setDoVicinityPlot
public static void setDoVicinityPlot(boolean doVicinityPlot) Remember if vicinity plotting should be done for stations not reporting position.- Parameters:
doVicinityPlot
- boolean true if stations should be vicinity plotted relative to the original digipeating station
-
getPurgeThresholdSecs
public static long getPurgeThresholdSecs()Get the time in seconds that messages will be kept before purging.- Returns:
- time in seconds before purging (non-positive means no purging)
-
setPurgeThresholdSecs
public static void setPurgeThresholdSecs(long purgeThresholdSecs) Set the time in seconds before messages will be purged.- Parameters:
purgeThresholdSecs
- time in seconds before messages are purged (non-positive time specifies no purging)
-
getMaxInactivityBeforeAlarm
public int getMaxInactivityBeforeAlarm()Get how long this station or object can be inactive before an inactive event is reported for it.- Returns:
- maximum inactivity time in minutes, or 0 if no time limit, -1 if need to use default
-
setMaxInactivityBeforeAlarm
public void setMaxInactivityBeforeAlarm(int maxInactivityInMinutes) Set how long this station or object can be inactive before an inactive event is reported for it. Note that zero overrides the default by specifying no timeout, negative takes away the override so the default applies.- Parameters:
maxInactivityInMinutes
- maximum inactivity time in minutes, or <= 0 if no time limit
-
getDefaultMaxInactivityBeforeAlarm
public static int getDefaultMaxInactivityBeforeAlarm()Get the current default value for how long a station or object can be inactive before an inactive event is reported. Individual stations can override this value.- Returns:
- maximum inactivity time in minutes, or <= 0 if no time limit
-
setDefaultMaxInactivityBeforeAlarm
public static void setDefaultMaxInactivityBeforeAlarm(int defaultMaxInactivityBeforeAlarm) Set the default for how long a station or object can be inactive before an inactive event is reported for it.- Parameters:
defaultMaxInactivityBeforeAlarm
- maximum inactivity time in minutes, or <= 0 if no time limit
-
isDefaultIsViewableForNewStation
public static boolean isDefaultIsViewableForNewStation()Report whether newly created stations and object records are visible by default. Unless changed by the filter UI, this is always true.- Returns:
- boolean true if newly created StationState objects are marked viewable
-
setDefaultIsViewableForNewStation
public static void setDefaultIsViewableForNewStation(boolean defaultIsViewableForNewStation) Specify whether newly created stations and object records are visible by default. Unless changed by the filter UI, this is always true.- Parameters:
defaultIsViewableForNewStation
- boolean true if newly created StationState objects should be marked viewable
-
clearState
public void clearState()Clear all accumulated inferred information about the station or object. -
addMessage
Add a message to the accumulated history for this station.- Parameters:
msg
- AX25Message to add to the history of this station state- Returns:
- zero-based index within the time-ordered history where the message was inserted
-
pruneOldMessages
public int pruneOldMessages(long then) Delete all messages from this StationState object whose receive times are older than the specified old age.- Parameters:
then
- long time in milliseconds since Unix epoch that is the oldest time of messages not to be deleted- Returns:
- number of deleted messages
-
isOnlyOverrapidGpsFixes
public boolean isOnlyOverrapidGpsFixes()If entire history of this station is GpsRawMessages at too fast a rate for APRS messaging, than it must be either a moron or a remote GPS (as defined in the SerialGpsConnector and SerialGpsPortEditor).- Returns:
- boolean true if entire message history is excessively frequent raw GPS messages
-
hasRealtimeMessages
public boolean hasRealtimeMessages()Report if this station has received any messages in real-time.- Returns:
- boolean true if real time messages have been received from this station or about this object
-
hasPlaybackMessages
public boolean hasPlaybackMessages()Report if this station or object has any messages from played-back log files.- Returns:
- boolean true if real time messages have been received from this station or about this object
-
isTimeInRange
public boolean isTimeInRange(long timestamp) Test if this station has any messages meeting the specified time range.- Parameters:
timestamp
- border time in Java standard milliseconds since 1970 UTC- Returns:
- boolean true if this station meets the specified constraint
-
getAge
public final long getAge(long now) Report the time since this station's information was updated.- Parameters:
now
- the current time in Java standard milliseconds since 1970 UTC- Returns:
- the number of milliseconds since the most recent message from this station, or Long.MAX_VALUE if no messages pass the filter and have timestamps
-
getAmsl
public float getAmsl()Get the last known altitude of the specified station or object.- Returns:
- altitude in meters, or Float.NaN if altitude unknown
-
setAmsl
public void setAmsl(float amsl) Overwrite the altitude for this station/object.- Parameters:
amsl
- new altitude in meters above mean sea level relative to WGS84 geoid
-
getIdentifier
Get the identifying name of the station or object described by this StationState.- Returns:
- String name of the station or object
-
getRecordIdentifier
Return the hashable and comparable identifier for the record.- Specified by:
getRecordIdentifier
in interfaceSupportsExtraData
- Returns:
- Object that uniquely identifies the record within its GuiContentType domain
-
getLatitude
public double getLatitude()Get the most recently reported or inferred latitude for this station or object.- Returns:
- latitude in decimal degrees North, or 0.0 if unknown
-
getLongitude
public double getLongitude()Get the most recently reported or inferred longitude for this station or object.- Returns:
- longitude in decimal degrees East, or 0.0 if unknown
-
getLastPosTime
public long getLastPosTime()Get the timestamp when the position was last updated.- Returns:
- milliseconds since Jan 1 1970 UTC, or -1 if no position data is available
-
getLastDigiTime
public long getLastDigiTime()Get the last time this station appeared as a digipeater.- Returns:
- milliseconds since Jan 1 1970 UTC of last digipeat, or -1 if no digipeat data is available
-
getBearing
public float getBearing()Get the last known course bearing for this station. Meaningless if speed returns zero.- Returns:
- bearing of travel in clockwise degrees from True North
-
getSpeed
public float getSpeed()Return the last known speed of travel of this station or object.- Returns:
- speed of travel in decimal knots (nautical miles per hour)
- See Also:
-
isDirect
public boolean isDirect(long oldestAllowed) Report if the station has been directly heard by the local YAAC instance (without being digipeated) recently.- Parameters:
oldestAllowed
- the time in milliseconds after which this station must have been locally heard to report true- Returns:
- boolean true if station has been locally heard
-
isLocalRf
public boolean isLocalRf(long oldestAllowed, int maxDigis) Indicate if the station is accessible over local RF.- Parameters:
oldestAllowed
- oldest message time to check for local vs. non-localmaxDigis
- maximum number of digipeats to consider- Returns:
- true if station is local to current YAAC instance and heard over RF
-
isIGateOnly
public boolean isIGateOnly()Indicate if the station has only been heard via a IGate connection to the APRS-IS backbone.- Returns:
- true if station messages have only arrived from the Internet
-
getRadiusOfConfidence
public float getRadiusOfConfidence()Return the last reported position ambiguity,- Returns:
- position ambiguity in meters around the actual reported latitude/longitude, or a negative value if the ambiguity has not been reported yet
-
setRadiusOfConfidence
public void setRadiusOfConfidence(float radiusOfConfidence) Specify the radius of confidence (position ambiguity). This should only be called from code that does not call theaddMessage(AX25Message)
method.- Parameters:
radiusOfConfidence
- position ambiguity in meters around the actual reported latitude/longitude, or a negative value if the ambiguity has not been reported yet
-
getSymbolCode
public final char getSymbolCode()Return the last symbolCode reported for this station or object.- Returns:
- symbol character
-
getSymTableId
public final char getSymTableId()Return the identifier of the table containing the symbol reported for this station or object.- Returns:
- symbol table ID character or overlay character if overlay used
-
getAltSymbolCode
public final char getAltSymbolCode()Return the currently defined local alias symbolCode reported for this station or object.- Returns:
- symbol character, or '\0' if no alias used
-
getAltSymTableId
public final char getAltSymTableId()Return the currently defined local alias identifier of the table containing the symbol reported for this station or object.- Returns:
- symbol table ID character or overlay character if overlay used, or '\0' if no alias used
-
setAltSymbolCode
public final void setAltSymbolCode(char altSymbolCode) Set the currently defined local alias symbolCode reported for this station or object.- Parameters:
altSymbolCode
- symbol character, or '\0' if no alias used
-
setAltSymTableId
public final void setAltSymTableId(char altSymTableId) Set the currently defined local alias identifier of the table containing the symbol reported for this station or object.- Parameters:
altSymTableId
- symbol table ID character or overlay character if overlay used, or '\0' if no alias used
-
hasWeather
public boolean hasWeather()Report if this station is providing weather information.- Returns:
- boolean true if the station has accumulated weather data.
-
hasHurricane
public boolean hasHurricane()Report if this station is providing hurricane information.- Returns:
- boolean true if the station has accumulated hurricane data.
-
isObjectOnly
public boolean isObjectOnly()Reports if this station is actually a non-transmitting object or item, as defined by the APRS specifications.- Returns:
- boolean true if this object has only been described by ObjectReport messages.
- See Also:
-
isObject
public boolean isObject()Reports if this station was last reported as a non-transmitting object or item, as defined by the APRS specifications.- Returns:
- boolean true if this object was last described by an ObjectReport message.
- See Also:
-
isTxOnlyTracker
public boolean isTxOnlyTracker()Indicate if this station is a transmit-only tracker.- Returns:
- boolean true if all collected evidence implies that station is a transmit-only tracker device (ex. Byonics TinyTrak3, etc.)
-
iterator
Obtain an iterator to cycle through the messages accumulated for this station or object.- Specified by:
iterator
in interfaceIterable<AX25Message>
- Returns:
- Iterator
-
getWeatherStateMap
Get the map containing extracted weather and hurricane information.- Returns:
- Map of Enums (either WeatherEnum or HurricanceEnum) to corresponding values, or null if no weather data
-
toString
Return a string describing this object. -
get
Get the Nth oldest message received from this station or object.- Parameters:
childIndex
- int index into accumulated message history- Returns:
- AX25Message
- Throws:
IndexOutOfBoundsException
- if childIndex not in range- See Also:
-
size
public int size()Get the number of messages associated with this station or object.- Returns:
- number of messages
-
getMostRecentRcptTimeOfSelf
public long getMostRecentRcptTimeOfSelf()Get the last time a Message was received on behalf of this station or object.- Returns:
- timestamp in Unix milliseconds since Jan 1, 1970 UTC.
-
getMostRecentPacketTime
public long getMostRecentPacketTime()Get the last time a Message was received on behalf of this station or object or anything this station digipeated.- Returns:
- timestamp in Unix milliseconds since Jan 1, 1970 UTC.
-
compareTo
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The default ordering for this class is by case-insensitive lexical order of the identifier name of the station or object.- Specified by:
compareTo
in interfaceComparable<StationState>
- Parameters:
ss
- the StationState to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
NullPointerException
- if the specified object is nullClassCastException
- if the specified object's type prevents it from being compared to this object.
-
getSpecialState
Derive the background color for a given object.- Parameters:
now
- time reference (in milliseconds since Jan 1 1970 UTC) to use to calculate ageage
- delta time since last received transmission from this station in milliseconds- Returns:
- SpecialState enum for this object, or null if no special state known for this object
-
isStationMoving
Test if the station monitored by this StationState appears to be moving or remaining in a fixed location.- Parameters:
now
- current time in Java milliseconds since Jan 1 1970 UTC- Returns:
- one of states MOVING, FIXED, or DEADRECKONED, or null if the movement of the station could not be derived
-
getPrecedence
Get the current Precedence state of this station or object.- Returns:
- the highest Precedence reported by this station or object in the last 10 minutes
-
getMostRecentPosition
Get the last APRS position message reported for this station or object. Does not currently work with OpenTRAC position reports.- Returns:
- most recent APRS PositionMessage, or null if no APRS positions
-
isActiveObject
public boolean isActiveObject()Indicates if this "station" is actually an Object or Item that is currently active (not killed). "Stations" with messages other than Object/Item reports and Status reports are not active Objects.- Returns:
- boolean true if this is an active Object/Item, false otherwise
-
getLocalAlias
Get the current locally defined alias for this Station or Object.- Returns:
- local alias, or null if no alias defined
-
setLocalAlias
Set the current locally defined alias for this Station or Object.- Parameters:
localAlias
- the String local alias for this Station or Object, or null to clear the alias
-
persistLocalAlias
Checkpoint the current tactical name setting to Java Preferences- Parameters:
rootNode
- root Preferences node where Aliases subnode exists is persisting is to be done
-
setSymbol
public void setSymbol(char symTableId, char symbolCode) Change the symbol code associated with this station.- Parameters:
symTableId
- character for the symbol table and/or overlay for this station/objectsymbolCode
- character for the symbol within the specified table for this station/object
-
setLocation
public void setLocation(double latitude, double longitude, long timestampMsec) Set the location for this station or object.- Parameters:
latitude
- latitude in degrees Northlongitude
- longitude in degrees EasttimestampMsec
- time in milliseconds since Jan 1 1970 UTC (epoch)
-
setVelocity
public void setVelocity(float bearing, float speedKts) Set the speed and direction of motion for this station or object.- Parameters:
bearing
- direction of travel in degrees from True NorthspeedKts
- sped of motion in knots (nautical miles per hour)
-
equals
Indicates whether some other object is "equal to" this one. -
hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided byjava.util.Hashtable
. -
getAttachment
Get a named attachment for this station.- Specified by:
getAttachment
in interfaceSupportsExtraData
- Parameters:
key
- Object identifying the particular attachment- Returns:
- the attached data, or null if no attachment with the specified key
-
putAttachment
Add an attachment to this station or object.- Specified by:
putAttachment
in interfaceSupportsExtraData
- Parameters:
key
- Object that will identify this particular attachmentattachment
- data to be attached- Returns:
- previous attachment under this key, or null if no previous attachment
- Throws:
NullPointerException
- if a null attachment is specified
-
removeAttachment
Remove an attachment from this station or object.- Specified by:
removeAttachment
in interfaceSupportsExtraData
- Parameters:
key
- Object identifying the attachment to be removed- Returns:
- whatever attachment was formerly associated with this key, or null if no previous attachment
-
getAttachmentKeys
Get all the keys for attachments on this station or object.- Returns:
- array of key objects (may be zero length if no attachments)
-
getAliasKVLength
public int getAliasKVLength()Return the length in characters of the tactical callsign exchange phrase for this station/object.- Returns:
- number of characters to encode the local alias and/or alternate symbol translation of the identifier, or zero if no alternate defined for this station/object
-
appendAliasKV
Append the tactical alias for this station (or the undefinition if this station doesn't have an alias).- Parameters:
b
- StringBuilder to append to- Returns:
- the updated StringBuilder
-