diff --git a/examples/src/OpenDis7Examples/PduListenerSaver.java b/examples/src/OpenDis7Examples/PduListenerSaver.java index 1f9da30146db83e5a6e8fbcf0bfdf8ae667fba96..c8753d29cdbd71e30c8f91e5a8b7c199b51b2d9b 100644 --- a/examples/src/OpenDis7Examples/PduListenerSaver.java +++ b/examples/src/OpenDis7Examples/PduListenerSaver.java @@ -11,6 +11,7 @@ import java.util.Scanner; /** * PduSaver.java created on Aug 21, 2019 + * Renamed PduListenerSaver * MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu * * @author Mike Bailey, jmbailey@nps.edu @@ -18,11 +19,9 @@ import java.util.Scanner; */ public class PduListenerSaver // TODO promote to open-dis7 library? { - private final static String DEFAULT_OUTPUTDIR = "pduLog"; - private final static String MCAST_ADDR = "239.1.2.3"; - private final static int DIS_PORT = 3000; -// public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; -// public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; + private final static String DEFAULT_OUTPUT_DIRECTORY = "pduLog"; + public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS; + public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT; private enum mystate { @@ -32,9 +31,9 @@ public class PduListenerSaver // TODO promote to open-dis7 library? public static void main(String[] args) { - String outDir = DEFAULT_OUTPUTDIR; - String mcast = MCAST_ADDR; - int port = DIS_PORT; + String outputDirectory = DEFAULT_OUTPUT_DIRECTORY; + String multicastAddress = DEFAULT_MULTICAST_ADDRESS; + int multicastPort = DEFAULT_MULTICAST_PORT; System.out.println("DisExamplesOpenDis7.PduListenerSaver started..."); @@ -42,21 +41,22 @@ public class PduListenerSaver // TODO promote to open-dis7 library? case 0: break; case 1: - outDir = args[0]; + outputDirectory = args[0]; break; case 3: - outDir = args[0]; - mcast = args[1]; - port = Integer.parseInt(args[2]); + outputDirectory = args[0]; + multicastAddress = args[1]; + multicastPort = Integer.parseInt(args[2]); break; default: - System.err.println("Usage: PduListener() or PduListener(\"outputdir\") or PduListener(\"outputdir\",\"multicast address\", ipPort"); + // Common-sense practice is to print help message if invocation is problematic + System.err.println("Usage: PduListenerSaver() or PduListenerSaver(\"outputdir\") or PduListenerSaver(\"outputDirectory\",\"multicastAddress\", multicastPort"); System.exit(1); } - System.out.println("Beginning pdu save to directory " + outDir); + System.out.println("Beginning PduListenerSaver (" + multicastAddress + ":" + multicastPort + ") to directory " + outputDirectory); try { - PduRecorder recorder = new PduRecorder(outDir, mcast, port); + PduRecorder recorder = new PduRecorder(outputDirectory, multicastAddress, multicastPort); recorder.startResume(); mystate state = mystate.RUNNING; @@ -83,7 +83,8 @@ public class PduListenerSaver // TODO promote to open-dis7 library? break; } } - System.out.println("Ending pdu save to "+recorder.getLogFile()); + System.out.println("Ending PduListenerSaver pdu recording, saved to file:"); + System.out.println(recorder.getLogFile()); } catch (IOException ex) { System.err.println("*** Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());