Class PduRecorder

java.lang.Object
edu.nps.moves.dis7.utilities.stream.PduRecorder
All Implemented Interfaces:
PduReceiver

public class PduRecorder extends Object implements PduReceiver
Utility to save PDUs received over the network to disk
Author:
Mike Bailey, jmbailey@nps.edu
  • Field Details

    • COMMENT_MARKER

      public static final String COMMENT_MARKER
      Character sentinel indicating remainder of line is a comment
      See Also:
      Constant Field Values
  • Constructor Details

    • PduRecorder

      public PduRecorder() throws IOException
      Default constructor that uses default values for output directory, multicast address and port.
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String directoryPath) throws IOException
      Constructor to let the use specify an output directory. Uses default values for multicast address and port.
      Parameters:
      directoryPath - the directory to write log files to
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String outputDirectory, String multicastAddress, int port)
      Constructor to let the user specify all required parameters
      Parameters:
      outputDirectory - local path for directory where the log files are written
      multicastAddress - multicast group address to receive data from (TODO allow unicast UDP)
      port - UDP port to listen for data
  • Method Details

    • getPduLogEncoding

      public static String getPduLogEncoding()
      TODO change this to enumeration type for strictness
      Returns:
      the pduLogEncoding
    • setPduLogEncoding

      public static void setPduLogEncoding(String newPduLogEncoding)
      Parameters:
      newPduLogEncoding - the pduLogEncoding to set
    • startResume

      public void startResume()
      Start or resume this instance
    • stopPause

      public void stopPause()
      Stop or pause this instance
    • end

      public File end()
      End operation of this instance
      Returns:
      recorder logFile
    • receivePdu

      public void receivePdu(byte[] newBuffer, int newLength)
      Description copied from interface: PduReceiver
      Receives a PDU and writes its raw contents to an output file for later playback and inspection.
      Specified by:
      receivePdu in interface PduReceiver
      Parameters:
      newBuffer - the array containing raw PDU data
      newLength - the length of the buffer
    • getLogFilePath

      public String getLogFilePath()
      Retrieve the path to the log file
      Returns:
      the path to the log file
    • getDisThreadedNetIF

      public DisThreadedNetworkInterface getDisThreadedNetIF()
      Returns:
      an instance of this DisThreadedNetworkInterface
    • isRunning

      public boolean isRunning()
      Returns:
      the pduRecorderRunning
    • main

      public static void main(String[] args)
      Entry point invocation. Saves a PDU output log to ./pduLog. Invoking the edu.nps.moves.dis7.examples.PduReaderPlayer will playback all logs written to the log directory
      Parameters:
      args - none supported, TODO offer path/filename