org.ka2ddo.yaac
Class YAAC

java.lang.Object
  extended by org.ka2ddo.yaac.YAAC
All Implemented Interfaces:
GpsDataListener, BeaconChangeListener

public class YAAC
extends java.lang.Object
implements BeaconChangeListener, GpsDataListener

This is the main program for the YAAC program, and is a singleton. It accepts the command line arguments to override any saved preferences, then starts up the backend and GUI (if GUI is requested).

Command-line parameters are of the form "-key value" or "-key" (no value) and correspond to the names used in the Preferences nodes used to persist the values. There are a few special values defined by the core code of the this application:

Note that the JRE property java.library.path must be set correctly so YAAC can find any native libraries needed (such as those that support the RXTX serial port library). The YAACBootstrap class exists to help set up the command-line environment for invoking YAAC.


Field Summary
static java.lang.String OPT_GUI
          Boolean TRUE or FALSE if GUI is going to be invoked.
static java.lang.String OPT_LAST_CHOSEN_PATH
          Symbolic ket name for the last chosen digipeat path used for text messaging.
static java.lang.String OPT_LOG_DIR
          Symbolic key name by which the path to the logging file directory is cached in the properties.
static java.lang.String OPT_MSG_LOG
          Symbolic key name by which the path to the message logging directory is cached in the properties.
static java.lang.String OPT_OSM_TILE_DIR
          Symbolic key name by which the path to the map rendering tile directory is cached in the properties.
static java.lang.String OSNAME
          The key value in the YAAC properties for the generic name of the host operating system (distilled from value in Java system properties).
static java.lang.String WINDOWS
          Symbolic name for Microsoft Windows operating systems, associated with OSNAME key in properties table.
 
Method Summary
static void addShutdownHandler(ShutdownHandler sh)
          Register a ShutdownHandler to be invoked when YAAC is shut down.
 void beaconChanged(BeaconData beaconData)
          This method is called for registered implementors when changed beacon data is stored to preferences.
static AbstractMenuAction findMenuAction(java.lang.String preLocalizedTagName)
          Find a menu entry with the specified tag name,
static java.io.File getBaseDir()
          Get the root directory of the YAAC installation.
static BeaconData getBeaconData()
          Get the BeaconData information for this station.
static java.lang.String getCallsign()
          Get the primary callsign set for this station running YAAC.
static CheckpointingLogger getCheckpointingLogger()
          Get the logger used to track YAAC's error messages.
static DistanceUnit getDistanceUnit()
          Get the currently set unit for distance display.
static CumulativeBooleanAndFilter getFilter()
          Get the top-level Filter for selectively choosing which Messages to see in the various YAAC display windows.
static GuiIfc getGui()
          Get the object representing the front-end user interface main window.
static java.lang.ClassLoader getLastClassLoader()
          Get the last of the daisy-chained list of ClassLoaders for YAAC and all its accepted plugins.
static ShutdownHandler getLastShutdownHandler()
          Pop the most recently remaining registered ShutdownHandler from the stack.
static StationState getLocalStation()
          Get the StationState object containing the status of the local station.
static java.util.ArrayList<AbstractMenuAction> getMenuBarActionList()
          Get a list of all currently defined potential menu items for inclusion in a popup menu in the map window.
static java.lang.String getMsg(java.lang.String tagName)
          Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.
static java.lang.String getMsg(java.lang.String bundleBaseName, java.lang.String tagName)
          Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.
static java.util.ResourceBundle getMsgBundle()
          Get the appropriate locale-specific message bundle for YAAC.
static java.util.ResourceBundle getMsgBundle(java.lang.String altBundleName)
          Get the appropriate locale-specific variant of some message bundle in one or more of the provided plugins.
static java.util.ArrayList<AbstractPopupMenuAction> getPopupMenuActionList()
          Get a list of all currently defined potential menu items for inclusion in a popup menu in the map window.
static java.util.prefs.Preferences getPreferences()
          Get a handle to the Java Preferences node at the root of the subtree used to store YAAC preferences.
static PressureUnit getPressureUnit()
          Get the currently set unit for pressure display.
static java.lang.String getProfileName()
          Get the name of the profile being used to store configuration data.
static java.util.Properties getProps()
          Get the Properties object used to efficiently cache preferences that are used frequently by YAAC.
static java.util.List<Provider> getProviderList()
          Get a List of all the Provider objects loaded into YAAC.
static SnifferDataModel getSnifferDataModel()
          Get the data structure used to cache all received raw AX.25 packets.
static SoundMaker getSoundMaker()
          Get the object used to produce sound effects.
static long getStartupTime()
          Report the Unix time in milliseconds when YAAC was started.
static StatusData getStatusData()
          Get the StatusData information for this station.
static TemperatureUnit getTemperatureUnit()
          Get the currently set unit for temperature display.
static int getTimeBeforeInactive()
          Set the time interval after which no user action indicates the station is unattended.
static RelativeTimeFilter getTimeFilter()
          Get the Filter controlling the maximum age of displayed message traffic.
static java.lang.Enum<? extends UnitEnum> getUnit(java.lang.Class<? extends UnitEnum> cls)
          Get the current preferred value of the unit-specifying Enum class.
static WeightUnit getWeightUnit()
          Get the currently set unit for weight display.
 void gpsDataUpdated(GPSDistributor distributor, GpsFix currentFix, boolean isLocal, java.lang.String source)
          Called by the GPSDistributor when the GPS data has been updated.
static boolean isCallsignSet()
          Indicate if the local station's callsign has been set.
static boolean isDebug()
          Indicate if debug messages should be printed out.
static boolean isLogAPRS()
          Efficiently test if APRS packets should be logged to disk.
static boolean isLogGPS()
          Efficiently test if GPS NMEA sentences should be logged to disk.
static boolean isOperatorPresent(long now)
          Test if human user has been active within the tolerance for inactivity.
static boolean isShowOperatorPresent()
          Indicate if beacons should use the 'O' overlay to indicate an operator is present at the station.
static boolean isUseExtendedSymbols()
          Report whether APRS 1.2 extended symbols are available and will be used if needed.
static void loadOnePlugin(java.io.File pluginJar)
          Attempt to load one JAR file as a plugin
static void main(java.lang.String[] args)
          Main program entry point.
static void moveNewUpgraderToLib()
          Upon startup of a freshly upgraded installation of YAAC, move the installed upgrade.jar file to the directory location it will be executed from for upgrades, so that the new upgrade.jar and the old executing one will not collide (an operation prohibited by Microsoft Windows).
static void operatorActed()
          Update last time human user did something on the UI.
static void removeShutdownHandler(ShutdownHandler sh)
          Unregister a ShutdownHandler that is no longer needed.
 void satDataUpdated(GPSDistributor distributor, SatelliteCatalog satCatalog, boolean isLocal, java.lang.String source)
          Called when the satellite constellation in use changes.
static void setDistanceUnit(DistanceUnit distanceUnit)
          Change the current unit for scaling distance display, and store the change in the YAAC preferences.
static void setLogAPRS(boolean logAPRS)
          Remember if APRS packets should be logged to disk.
static void setLogGPS(boolean logGPS)
          Remember if GPS NMEA sentences should be logged to disk.
static void setPressureUnit(PressureUnit pressureUnit)
          Change the current unit for scaling pressure display, and store the change in the YAAC preferences.
static void setShowOperatorPresent(boolean showOperatorPresent)
          Indicate if beacons should use the 'O' overlay to indicate an operator is present at the station.
static void setSoundMaker(SoundMaker soundMaker)
          Specify the object used to produce sound effects.
static void setTemperatureUnit(TemperatureUnit temperatureUnit)
          Change the current unit for scaling temperature display, and store the change in the YAAC preferences.
static void setTimeBeforeInactive(int minutesBeforeInactive)
          Set the time interval after which no user action indicates the station is unattended.
static void setUseExtendedSymbols(boolean useExtendedSymbols)
          Specify whether APRS 1.2 extended symbols should be used to render stations reporting known overlays of alternate table symbols.
static void setWeightUnit(WeightUnit weightUnit)
          Change the current unit for scaling weight display, and store the change in the YAAC preferences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPT_GUI

public static final java.lang.String OPT_GUI
Boolean TRUE or FALSE if GUI is going to be invoked.

See Also:
Constant Field Values

OSNAME

public static final java.lang.String OSNAME
The key value in the YAAC properties for the generic name of the host operating system (distilled from value in Java system properties).

See Also:
getProps(), Constant Field Values

OPT_OSM_TILE_DIR

public static final java.lang.String OPT_OSM_TILE_DIR
Symbolic key name by which the path to the map rendering tile directory is cached in the properties.

See Also:
getProps(), Constant Field Values

OPT_LOG_DIR

public static final java.lang.String OPT_LOG_DIR
Symbolic key name by which the path to the logging file directory is cached in the properties.

See Also:
getProps(), Constant Field Values

OPT_MSG_LOG

public static final java.lang.String OPT_MSG_LOG
Symbolic key name by which the path to the message logging directory is cached in the properties.

See Also:
getProps(), Constant Field Values

OPT_LAST_CHOSEN_PATH

public static final java.lang.String OPT_LAST_CHOSEN_PATH
Symbolic ket name for the last chosen digipeat path used for text messaging.

See Also:
getProps(), Constant Field Values

WINDOWS

public static final java.lang.String WINDOWS
Symbolic name for Microsoft Windows operating systems, associated with OSNAME key in properties table.

See Also:
OSNAME, Constant Field Values
Method Detail

main

public static void main(java.lang.String[] args)
Main program entry point.

Parameters:
args - command line arguments

moveNewUpgraderToLib

public static void moveNewUpgraderToLib()
                                 throws java.io.IOException
Upon startup of a freshly upgraded installation of YAAC, move the installed upgrade.jar file to the directory location it will be executed from for upgrades, so that the new upgrade.jar and the old executing one will not collide (an operation prohibited by Microsoft Windows).

Throws:
java.io.IOException - if upgrade.jar could not successfully be moved for some reason

beaconChanged

public void beaconChanged(BeaconData beaconData)
This method is called for registered implementors when changed beacon data is stored to preferences.

Specified by:
beaconChanged in interface BeaconChangeListener
Parameters:
beaconData - BeaconData record that has been changed

gpsDataUpdated

public void gpsDataUpdated(GPSDistributor distributor,
                           GpsFix currentFix,
                           boolean isLocal,
                           java.lang.String source)
Called by the GPSDistributor when the GPS data has been updated.

Specified by:
gpsDataUpdated in interface GpsDataListener
Parameters:
distributor - instance of the GPSDistributor
currentFix - current GpsFix
isLocal - boolean true if this is GPS data for the local station, false if for a remote GPS receiver
source - String name assigned to remote GPS receiver, or null if for the local receiver

satDataUpdated

public void satDataUpdated(GPSDistributor distributor,
                           SatelliteCatalog satCatalog,
                           boolean isLocal,
                           java.lang.String source)
Called when the satellite constellation in use changes.

Specified by:
satDataUpdated in interface GpsDataListener
Parameters:
distributor - instance of the GPSDistributor
satCatalog - updated SatelliteCatalog instance
isLocal - boolean true if this is GPS data for the local station, false if for a remote GPS receiver
source - String name assigned to remote GPS receiver, or null if for the local receiver

loadOnePlugin

public static void loadOnePlugin(java.io.File pluginJar)
Attempt to load one JAR file as a plugin

Parameters:
pluginJar - File identifying the JAR file assumed to be the root of a plugin

findMenuAction

public static AbstractMenuAction findMenuAction(java.lang.String preLocalizedTagName)
Find a menu entry with the specified tag name,

Parameters:
preLocalizedTagName - pre-localized tag name String to search for
Returns:
first AbstractMenuAction with the specified name, or null if no match found

getMsgBundle

public static java.util.ResourceBundle getMsgBundle()
Get the appropriate locale-specific message bundle for YAAC.

Returns:
a ResourceBundle that is the most locale-specific possible for the runtime environment

getMsgBundle

public static java.util.ResourceBundle getMsgBundle(java.lang.String altBundleName)
Get the appropriate locale-specific variant of some message bundle in one or more of the provided plugins.

Parameters:
altBundleName - String base name of the ResourceBundle to search for
Returns:
a ResourceBundle that is the most locale-specific possible for the runtime environment

getMsg

public static java.lang.String getMsg(java.lang.String tagName)
                               throws java.util.MissingResourceException
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle. If the tagName String contains a colon ':', this is the delimiter between the ResourceBundle name and the name of the resource within the bundle; otherwise, the entire tagName string is considered to be the name of the resource within the default bundle.

Parameters:
tagName - String name to look up
Returns:
localized String corresponding to the tag, or NoSuchResourceException if the if the tag cannot be found
Throws:
java.util.MissingResourceException - if the tag cannot be found

getMsg

public static java.lang.String getMsg(java.lang.String bundleBaseName,
                                      java.lang.String tagName)
                               throws java.util.MissingResourceException
Get the appropriate localized String corresponding to a ResourceBundle tag name in a specific ResourceBundle.

Parameters:
bundleBaseName - String name of bundle containing the tag
tagName - String name to look up
Returns:
localized String corresponding to the tag, or NoSuchResourceException if the if the tag cannot be found
Throws:
java.util.MissingResourceException - if the bundle or tag cannot be found

getProps

public static java.util.Properties getProps()
Get the Properties object used to efficiently cache preferences that are used frequently by YAAC.

Returns:
java.util.Properties object containing the property values

getGui

public static GuiIfc getGui()
Get the object representing the front-end user interface main window.

Returns:
GuiIfc implementing object

getPreferences

public static java.util.prefs.Preferences getPreferences()
Get a handle to the Java Preferences node at the root of the subtree used to store YAAC preferences.

Returns:
java.util.prefs.Preferences

getFilter

public static CumulativeBooleanAndFilter getFilter()
Get the top-level Filter for selectively choosing which Messages to see in the various YAAC display windows.

Returns:
CumulativeBooleanAndFilter containing all other Filter instances in use.

getTimeFilter

public static RelativeTimeFilter getTimeFilter()
Get the Filter controlling the maximum age of displayed message traffic.

Returns:
RelativeTimeFilter

getProviderList

public static java.util.List<Provider> getProviderList()
Get a List of all the Provider objects loaded into YAAC.

Returns:
read-only List of Provider subclasses

getBeaconData

public static BeaconData getBeaconData()
Get the BeaconData information for this station.

Returns:
the corresponding BeaconData record

isCallsignSet

public static boolean isCallsignSet()
Indicate if the local station's callsign has been set.

Returns:
boolean true if default beacon callsign is filled in

getStatusData

public static StatusData getStatusData()
Get the StatusData information for this station.

Returns:
the corresponding StatusData record

getCallsign

public static java.lang.String getCallsign()
Get the primary callsign set for this station running YAAC.

Returns:
String of the callsign (usually the callsign used in the primary beacon definition)
See Also:
getBeaconData()

getSnifferDataModel

public static SnifferDataModel getSnifferDataModel()
Get the data structure used to cache all received raw AX.25 packets.

Returns:
the SnifferTableModel

getMenuBarActionList

public static java.util.ArrayList<AbstractMenuAction> getMenuBarActionList()
Get a list of all currently defined potential menu items for inclusion in a popup menu in the map window.

Returns:
ArrayList of AbstractPopupMenuActions

getPopupMenuActionList

public static java.util.ArrayList<AbstractPopupMenuAction> getPopupMenuActionList()
Get a list of all currently defined potential menu items for inclusion in a popup menu in the map window.

Returns:
ArrayList of AbstractPopupMenuActions

getDistanceUnit

public static DistanceUnit getDistanceUnit()
Get the currently set unit for distance display.

Returns:
DistanceUnit for scaling displayed distances.

setDistanceUnit

public static void setDistanceUnit(DistanceUnit distanceUnit)
Change the current unit for scaling distance display, and store the change in the YAAC preferences.

Parameters:
distanceUnit - DistanceUnit to use for all future distance displays

getTemperatureUnit

public static TemperatureUnit getTemperatureUnit()
Get the currently set unit for temperature display.

Returns:
TemperatureUnit for scaling displayed temperatures.

setTemperatureUnit

public static void setTemperatureUnit(TemperatureUnit temperatureUnit)
Change the current unit for scaling temperature display, and store the change in the YAAC preferences.

Parameters:
temperatureUnit - TemperatureUnit to use for all future temperature displays

getPressureUnit

public static PressureUnit getPressureUnit()
Get the currently set unit for pressure display.

Returns:
PressureUnit for scaling displayed pressures.

setPressureUnit

public static void setPressureUnit(PressureUnit pressureUnit)
Change the current unit for scaling pressure display, and store the change in the YAAC preferences.

Parameters:
pressureUnit - PressureUnit to use for all future pressure displays

getWeightUnit

public static WeightUnit getWeightUnit()
Get the currently set unit for weight display.

Returns:
WeightUnit for scaling displayed weights.

setWeightUnit

public static void setWeightUnit(WeightUnit weightUnit)
Change the current unit for scaling weight display, and store the change in the YAAC preferences.

Parameters:
weightUnit - WeightUnit to use for all future weight displays

getUnit

public static java.lang.Enum<? extends UnitEnum> getUnit(java.lang.Class<? extends UnitEnum> cls)
Get the current preferred value of the unit-specifying Enum class.

Parameters:
cls - subclass of Enum that implements the UnitEnum tag interface
Returns:
preferred value of the specified Enum class

isLogAPRS

public static boolean isLogAPRS()
Efficiently test if APRS packets should be logged to disk.

Returns:
boolean true if logging should occur

isLogGPS

public static boolean isLogGPS()
Efficiently test if GPS NMEA sentences should be logged to disk.

Returns:
boolean true if logging should occur

setLogAPRS

public static void setLogAPRS(boolean logAPRS)
Remember if APRS packets should be logged to disk.

Parameters:
logAPRS - boolean true if logging should occur in the future

setLogGPS

public static void setLogGPS(boolean logGPS)
Remember if GPS NMEA sentences should be logged to disk.

Parameters:
logGPS - boolean true if logging should occur in the future

isDebug

public static boolean isDebug()
Indicate if debug messages should be printed out.

Returns:
boolean true if debug messages should be printed

isShowOperatorPresent

public static boolean isShowOperatorPresent()
Indicate if beacons should use the 'O' overlay to indicate an operator is present at the station.

Returns:
boolean true if operator-present overlay should be used for alternate set symbols

setShowOperatorPresent

public static void setShowOperatorPresent(boolean showOperatorPresent)
Indicate if beacons should use the 'O' overlay to indicate an operator is present at the station.

Parameters:
showOperatorPresent - boolean true if operator-present overlay should be used for alternate set symbols

isUseExtendedSymbols

public static boolean isUseExtendedSymbols()
Report whether APRS 1.2 extended symbols are available and will be used if needed.

Returns:
boolean true if known APRS 1.2 extended symbols are loaded

setUseExtendedSymbols

public static void setUseExtendedSymbols(boolean useExtendedSymbols)
Specify whether APRS 1.2 extended symbols should be used to render stations reporting known overlays of alternate table symbols.

Parameters:
useExtendedSymbols - boolean true if APRS 1.2 extended symbols should be used if needed

getTimeBeforeInactive

public static int getTimeBeforeInactive()
Set the time interval after which no user action indicates the station is unattended.

Returns:
time in minutes before inactivity

setTimeBeforeInactive

public static void setTimeBeforeInactive(int minutesBeforeInactive)
Set the time interval after which no user action indicates the station is unattended.

Parameters:
minutesBeforeInactive - time in minutes before inactivity

operatorActed

public static void operatorActed()
Update last time human user did something on the UI.


isOperatorPresent

public static boolean isOperatorPresent(long now)
Test if human user has been active within the tolerance for inactivity.

Parameters:
now - current time in milliseconds since Jan 1 1970 UTC
Returns:
boolean true if user have been active recently

getStartupTime

public static long getStartupTime()
Report the Unix time in milliseconds when YAAC was started.

Returns:
milliseconds since Jan 1, 1970 UTC when this invocation of YAAC was started

getLocalStation

public static StationState getLocalStation()
Get the StationState object containing the status of the local station.

Returns:
the StationState object corresponding to the local station

addShutdownHandler

public static void addShutdownHandler(ShutdownHandler sh)
Register a ShutdownHandler to be invoked when YAAC is shut down.

Parameters:
sh - ShutdownHandler to register

removeShutdownHandler

public static void removeShutdownHandler(ShutdownHandler sh)
Unregister a ShutdownHandler that is no longer needed.

Parameters:
sh - ShutdownHandler to remove

getLastShutdownHandler

public static ShutdownHandler getLastShutdownHandler()
Pop the most recently remaining registered ShutdownHandler from the stack.

Returns:
last ShutdownHandler, or null if no handlers left

getCheckpointingLogger

public static CheckpointingLogger getCheckpointingLogger()
Get the logger used to track YAAC's error messages.

Returns:
the CheckpointingLogger copying standard output and standard error

getProfileName

public static java.lang.String getProfileName()
Get the name of the profile being used to store configuration data.

Returns:
String profile name, or null if using the default profile

getBaseDir

public static java.io.File getBaseDir()
Get the root directory of the YAAC installation.

Returns:
File of the YAAC installation directory (where YAAC.jar lives)

getLastClassLoader

public static java.lang.ClassLoader getLastClassLoader()
Get the last of the daisy-chained list of ClassLoaders for YAAC and all its accepted plugins.

Returns:
ClassLoader to use for all dynamic class lookups

getSoundMaker

public static SoundMaker getSoundMaker()
Get the object used to produce sound effects.

Returns:
current SoundMaker implementation

setSoundMaker

public static void setSoundMaker(SoundMaker soundMaker)
Specify the object used to produce sound effects.

Parameters:
soundMaker - new SoundMaker implementation to provide audio outputs