Skip to content
Snippets Groups Projects
Commit e9dd9f1f authored by brutzman's avatar brutzman
Browse files

improved naming, comments, diagnostics

parent 12bc219d
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import java.util.Scanner; ...@@ -11,6 +11,7 @@ import java.util.Scanner;
/** /**
* PduSaver.java created on Aug 21, 2019 * PduSaver.java created on Aug 21, 2019
* Renamed PduListenerSaver
* MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu * MOVES Institute Naval Postgraduate School, Monterey, CA, USA www.nps.edu
* *
* @author Mike Bailey, jmbailey@nps.edu * @author Mike Bailey, jmbailey@nps.edu
...@@ -18,11 +19,9 @@ import java.util.Scanner; ...@@ -18,11 +19,9 @@ import java.util.Scanner;
*/ */
public class PduListenerSaver // TODO promote to open-dis7 library? public class PduListenerSaver // TODO promote to open-dis7 library?
{ {
private final static String DEFAULT_OUTPUTDIR = "pduLog"; private final static String DEFAULT_OUTPUT_DIRECTORY = "pduLog";
private final static String MCAST_ADDR = "239.1.2.3"; public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS;
private final static int DIS_PORT = 3000; public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT;
// public static final int DEFAULT_MULTICAST_PORT = AllPduSender.DEFAULT_MULTICAST_PORT;
// public static final String DEFAULT_MULTICAST_ADDRESS = AllPduSender.DEFAULT_MULTICAST_ADDRESS;
private enum mystate private enum mystate
{ {
...@@ -32,9 +31,9 @@ public class PduListenerSaver // TODO promote to open-dis7 library? ...@@ -32,9 +31,9 @@ public class PduListenerSaver // TODO promote to open-dis7 library?
public static void main(String[] args) public static void main(String[] args)
{ {
String outDir = DEFAULT_OUTPUTDIR; String outputDirectory = DEFAULT_OUTPUT_DIRECTORY;
String mcast = MCAST_ADDR; String multicastAddress = DEFAULT_MULTICAST_ADDRESS;
int port = DIS_PORT; int multicastPort = DEFAULT_MULTICAST_PORT;
System.out.println("DisExamplesOpenDis7.PduListenerSaver started..."); System.out.println("DisExamplesOpenDis7.PduListenerSaver started...");
...@@ -42,21 +41,22 @@ public class PduListenerSaver // TODO promote to open-dis7 library? ...@@ -42,21 +41,22 @@ public class PduListenerSaver // TODO promote to open-dis7 library?
case 0: case 0:
break; break;
case 1: case 1:
outDir = args[0]; outputDirectory = args[0];
break; break;
case 3: case 3:
outDir = args[0]; outputDirectory = args[0];
mcast = args[1]; multicastAddress = args[1];
port = Integer.parseInt(args[2]); multicastPort = Integer.parseInt(args[2]);
break; break;
default: 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.exit(1);
} }
System.out.println("Beginning pdu save to directory " + outDir); System.out.println("Beginning PduListenerSaver (" + multicastAddress + ":" + multicastPort + ") to directory " + outputDirectory);
try { try {
PduRecorder recorder = new PduRecorder(outDir, mcast, port); PduRecorder recorder = new PduRecorder(outputDirectory, multicastAddress, multicastPort);
recorder.startResume(); recorder.startResume();
mystate state = mystate.RUNNING; mystate state = mystate.RUNNING;
...@@ -83,7 +83,8 @@ public class PduListenerSaver // TODO promote to open-dis7 library? ...@@ -83,7 +83,8 @@ public class PduListenerSaver // TODO promote to open-dis7 library?
break; 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) { catch (IOException ex) {
System.err.println("*** Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage()); System.err.println("*** Exception: " + ex.getClass().getSimpleName() + ": " + ex.getLocalizedMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment