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

  • Constructor Details

    • PduRecorder

      public PduRecorder() throws IOException
      Default constructor that uses default values for output directory, DIS address and port. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations.
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String initialOutputDirectory) throws IOException
      Constructor to let the use specify an output directory. Uses default values for multicast address and port. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations.
      Parameters:
      initialOutputDirectory - the directory to write log files to
      Throws:
      IOException - if something goes wrong during instantiation
    • PduRecorder

      public PduRecorder(String initialOutputDirectory, String initialAddress, int initialPort)
      Constructor to let the user specify all required parameters. Each instance must invoke start() to begin operations, pause() to suspend operations, resume() to continue operations, and stop() to terminate operations..
      Parameters:
      initialOutputDirectory - local path for directory where the log files are written
      initialAddress - multicast group address to receive data from (TODO allow unicast UDP)
      initialPort - 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
    • resume

      public void resume()
      Resume instance operation
      See Also:
      start(), stop(), pause()
    • start

      public void start()
      Start instance operation
      See Also:
      stop(), pause(), resume()
    • pause

      public void pause()
      Pause operation of this instance
      See Also:
      start(), stop(), resume()
    • stop

      public File stop()
      End operation of this instance, removing interfaces
      Returns:
      recorder logFile
      See Also:
      start(), pause(), resume()
    • receivePdu

      public void receivePdu(byte[] newBuffer, int newLength)
      receivePdu from DIS data stream
      Specified by:
      receivePdu in interface PduReceiver
      Parameters:
      newBuffer - byte array for receiving data
      newLength - length of byte array
    • getLogFilePath

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

      @Deprecated public DisThreadedNetworkInterface getDisThreadedNetIF()
      Deprecated.
      Deprecated, use getDisThreadedNetworkInterface() instead
      Returns:
      an instance of this DisThreadedNetworkInterface
      See Also:
      getDisThreadedNetworkInterface()
    • getDisThreadedNetworkInterface

      public DisThreadedNetworkInterface getDisThreadedNetworkInterface()
      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
    • getAddress

      public String getAddress()
      Get current multicast (or unicast) network address for send and receive connections.
      Returns:
      current multicast address value
      See Also:
      https://en.wikipedia.org/wiki/Multicast_address
    • setAddress

      public void setAddress(String newAddress)
      Network address for send and receive connections.
      Parameters:
      newAddress - the new network address to set
      See Also:
      https://en.wikipedia.org/wiki/Multicast_address
    • getPort

      public int getPort()
      Get network port used, multicast or unicast.
      Returns:
      current port value
      See Also:
      https://en.wikipedia.org/wiki/Port_(computer_networking)
    • setPort

      public void setPort(int newPortValue)
      /** Set network port used, multicast or unicast.
      Parameters:
      newPortValue - the disPort value to set
      See Also:
      https://en.wikipedia.org/wiki/Port_(computer_networking)
    • getDescriptor

      public String getDescriptor()
      Get simple descriptor (such as parent class name) for this network interface, used in trace statements
      Returns:
      simple descriptor name
    • setDescriptor

      public void setDescriptor(String newDescriptor)
      Set new simple descriptor (such as parent class name) for this network interface, used in trace statements
      Parameters:
      newDescriptor - simple descriptor name
    • setVerbose

      public void setVerbose(boolean newValue)
      Set whether or not trace statements are provided when packets are sent or received.
      Parameters:
      newValue - the verbose status to set. Also resets verboseReceipt and verboseSending to match.
      See Also:
      verboseReceipt, verboseSending
    • hasVerboseOutput

      public boolean hasVerboseOutput()
      Whether or not trace statements are provided when packets are sent or received.
      Returns:
      the verbose status
      See Also:
      verboseReceipt, verboseSending
    • setVerboseReceipt

      public void setVerboseReceipt(boolean newValue)
      Set whether or not trace statements are provided when packets are received.
      Parameters:
      newValue - the verboseReceipt status to set
      See Also:
      verbose, verboseSending
    • hasVerboseReceipt

      public boolean hasVerboseReceipt()
      Whether or not trace statements are provided when packets are received.
      Returns:
      the verboseReceipt status
    • setVerboseSending

      public void setVerboseSending(boolean newValue)
      Set whether or not trace statements are provided when packets are sent.
      Parameters:
      newValue - the verboseSending status to set
      See Also:
      verbose, verboseReceipt
    • hasVerboseSending

      public boolean hasVerboseSending()
      Whether or not trace statements are provided when packets are sent.
      Returns:
      the verboseSending status
    • hasVerboseOutputIncludesTimestamp

      public boolean hasVerboseOutputIncludesTimestamp()
      Whether or not trace statements include timestamp values.
      Returns:
      the verboseIncludesTimestamp value
    • setVerboseIncludesTimestamp

      public void setVerboseIncludesTimestamp(boolean verboseIncludesTimestamp)
      Set whether or not trace statements include timestamp values.
      Parameters:
      verboseIncludesTimestamp - the value to set
    • getLogFileName

      public String getLogFileName()
      Returns:
      the logFileName
    • setLogFileName

      public void setLogFileName(String logFileName)
      Parameters:
      logFileName - the logFileName to set