Class SnifferDataModel

java.lang.Object
org.ka2ddo.yaac.core.SnifferDataModel
All Implemented Interfaces:
Runnable, AprsMessageListener, AX25FrameListener, ParsedAX25MessageListener, ClearableTableModel

public final class SnifferDataModel extends Object implements AX25FrameListener, AprsMessageListener, ParsedAX25MessageListener, Runnable, ClearableTableModel
This class maintains a list of all messages heard by the application.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

    • LOGFILE_PLAYBACK_CONNECTOR

      public static final Connector LOGFILE_PLAYBACK_CONNECTOR
      Bogus Connector instance used to identify historical packets loaded from a log file.
  • Constructor Details

    • SnifferDataModel

      public SnifferDataModel()
      Create the singleton SnifferDataModel that collects incoming packet traffic for tabular display.
  • Method Details

    • getRowCount

      public int getRowCount()
      Get the number of packets currently stored in the SnifferDataModel.
      Returns:
      packet count
    • addSnifferDataListener

      public void addSnifferDataListener(SnifferDataListener l)
      Register a SnifferDataListener.
      Parameters:
      l - SnifferDataListener to register
    • removeSnifferDataListener

      public void removeSnifferDataListener(SnifferDataListener l)
      Unregister a SnifferDataListener.
      Parameters:
      l - SnifferDataListener to unregister
    • consumeAX25Frame

      public void consumeAX25Frame(AX25Frame frame, Connector connector)
      Description copied from interface: AX25FrameListener
      Receive an incoming frame from the specified input Connector. Note that the frame will not have any decoded AX25Message associated with it yet.
      Specified by:
      consumeAX25Frame in interface AX25FrameListener
      Parameters:
      frame - AX25Frame that was received
      connector - Connector that was the source of the frame.
    • addSnifferLogFilter

      public static void addSnifferLogFilter(SnifferLogFilter filter)
      Register a SnifferLogFilter.
      Parameters:
      filter - SnifferLogFilter to register
    • removeSnifferLogFilter

      public static void removeSnifferLogFilter(SnifferLogFilter filter)
      Unregister a SnifferLogFilter.
      Parameters:
      filter - SnifferLogFilter to register
    • aprsMessageReceived

      public void aprsMessageReceived(Message msg)
      Delivers the next packet received by YAAC that is an APRS message.
      Specified by:
      aprsMessageReceived in interface AprsMessageListener
      Parameters:
      msg - some subclass of Message containing the message contents; the message should have an AX25Frame connected to it
      See Also:
    • parsedAX25MessageReceived

      public void parsedAX25MessageReceived(byte pid, AX25Message msg)
      Delivers the next message received by YAAC that is some sort of parsed AX.25 higher-level message.
      Specified by:
      parsedAX25MessageReceived in interface ParsedAX25MessageListener
      Parameters:
      pid - AX.25 protocol ID
      msg - some subclass of Message containing the message contents; the message should have an AX25Frame connected to it
      See Also:
    • run

      public void run()
      Do not call. Invoked by GUI dispatch thread to update the GUI with recently received packets.
      Specified by:
      run in interface Runnable
    • importMessages

      public void importMessages(InputStream in, PacketExportMode exportMode, int scaleFactor, StatusListener statusListener, long fileSize, Filter filter) throws IOException
      Import a file of AX.25 frames in any of three formats into YAAC.
      Parameters:
      in - InputStream to read the file data from
      exportMode - expected format of the data stream
      scaleFactor - the speed-up factor for simulated playback, or zero for as-fast-as-possible
      statusListener - StatusListener to receive file reading progress reports, or null if not desired
      fileSize - total length of file being read in
      filter - Filter to use to discard unwanted messages, or null to keep all messages
      Throws:
      IOException - if file reading fails for an unexpected reason
    • exportMessages

      public void exportMessages(OutputStream o, PacketExportMode exportMode, boolean saveAll) throws IOException
      Export packets passing the current filters in the SnifferDataModel to a file in the specified file format.
      Parameters:
      o - OutputStream to write the file data to
      exportMode - PacketExportMode specifying the format of the saved packet data
      saveAll - boolean true if filters should be ignored and all currently held packets should be saved
      Throws:
      IOException - if packets could not be written to the stream for any reason
    • getMessage

      public AX25Frame getMessage(int rowIndex)
      Get the Nth packet stored in the SnifferDataModel.
      Parameters:
      rowIndex - zero-based index of the AX25Frame to return
      Returns:
      AX25Frame
      Throws:
      IndexOutOfBoundsException - if rowIndex is not in range of the available frames
    • getLoggerFormat

      public PacketExportMode getLoggerFormat()
      Get the current format for AX.25 message logging.
      Returns:
      PacketExportMode in use
    • setLoggerFormat

      public void setLoggerFormat(PacketExportMode pem)
      Set the format for AX.25 message logging.
      Parameters:
      pem - PacketExportMode to use
    • deleteAllRows

      public int deleteAllRows(ClearableTableModel.ClearType clearType)
      Delete all rows from this table.
      Specified by:
      deleteAllRows in interface ClearableTableModel
      Parameters:
      clearType - type of rows to delete
      Returns:
      number of rows deleted
    • tableCanContainPlayback

      public boolean tableCanContainPlayback()
      Identifies whether this table can contain playback (historical) data.
      Specified by:
      tableCanContainPlayback in interface ClearableTableModel
      Returns:
      boolean true if table can contain playback data.
    • tableCanContainRealtime

      public boolean tableCanContainRealtime()
      Identifies whether this table can contain realtime data.
      Specified by:
      tableCanContainRealtime in interface ClearableTableModel
      Returns:
      boolean true if table can contain realtime data.