Skip to content
Snippets Groups Projects
Commit d08403b5 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

modify default invocation to permit debug, confirm filenames work under windows

parent 51845dc6
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ import edu.nps.moves.cot.dis.CoTMsgParserDisRunner; ...@@ -37,6 +37,7 @@ import edu.nps.moves.cot.dis.CoTMsgParserDisRunner;
import java.io.IOException; import java.io.IOException;
import java.io.PipedInputStream; import java.io.PipedInputStream;
import java.io.PipedOutputStream; import java.io.PipedOutputStream;
import java.util.Arrays;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -64,11 +65,14 @@ public class CoTMsgReceiver { ...@@ -64,11 +65,14 @@ public class CoTMsgReceiver {
Logger.getLogger(CoTMsgReceiver.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(CoTMsgReceiver.class.getName()).log(Level.SEVERE, null, ex);
} }
}//sleep }//sleep
static final String[] ARGS_DEFAULT = {"--performanceTestSendCoT", "udp", "localhost", "9999", "1", "1"};
/** /**
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String[] args) { public static void main(String[] args)
{
System.out.print ("CoTMsgReceiver"); System.out.print ("CoTMsgReceiver");
for (String arg:args) for (String arg:args)
...@@ -77,7 +81,15 @@ public class CoTMsgReceiver { ...@@ -77,7 +81,15 @@ public class CoTMsgReceiver {
} }
System.out.println(); System.out.println();
boolean isTcp = args[1].equalsIgnoreCase("tcp"); boolean isTcp = false;
if (args.length > 0)
{
isTcp = args[1].equalsIgnoreCase("tcp");
}
else
{
System.out.println ("CoTMsgReceiver invoked without parameter args, using default args " + Arrays.toString(ARGS_DEFAULT));
}
// - Create a custom CoTparser class. See CustomCoTparser.java. // - Create a custom CoTparser class. See CustomCoTparser.java.
// - Override the coTeventHandler() to add your custom CoT data handling. // - Override the coTeventHandler() to add your custom CoT data handling.
...@@ -95,28 +107,40 @@ public class CoTMsgReceiver { ...@@ -95,28 +107,40 @@ public class CoTMsgReceiver {
connectors.addCoTparser(disr); connectors.addCoTparser(disr);
// - Common usage example: // - Common usage example:
System.out.println("\n\nStarting listener pool\n"); System.out.println("\nStarting listener pool\n");
if (isTcp) { if (isTcp)
{
connectors.addTcpListener(CoTtcpListener.DEFAULT_COT_TCP_PORT); connectors.addTcpListener(CoTtcpListener.DEFAULT_COT_TCP_PORT);
connectors.startListener(CoTtcpListener.DEFAULT_COT_TCP_PORT); connectors.startListener (CoTtcpListener.DEFAULT_COT_TCP_PORT);
} else { }
else
{
connectors.addUdpListener(CoTudpListener.DEFAULT_COT_UDP_PORT); // default packet size 1024 connectors.addUdpListener(CoTudpListener.DEFAULT_COT_UDP_PORT); // default packet size 1024
connectors.startListener(CoTudpListener.DEFAULT_COT_UDP_PORT); connectors.startListener (CoTudpListener.DEFAULT_COT_UDP_PORT);
} }
PipedOutputStream out = null; PipedOutputStream pipedOutputStream = null;
// Redirect an output stream to be read by an input stream in order to // Redirect an output stream to be read by an input stream in order to
// stop the TCP listener // stop the TCP listener
try { try {
out = new PipedOutputStream(); pipedOutputStream = new PipedOutputStream();
System.setIn(new PipedInputStream(out)); System.setIn(new PipedInputStream(pipedOutputStream));
} catch (IOException ex) {} }
catch (IOException ioe)
{
System.out.println("*** pipedOutputStream ioe " + ioe.getMessage());
}
// Start the CoT message generator/server // Start the CoT message generator/server
Runnable r = () -> { Runnable r = () -> {
com.aciedge.cotplitool.Main.main(args); // odd invocation avoids resetting empty args array, which can provoke following obscure Java error
// error: local variables referenced from a lambda expression must be final or effectively final
// com.aciedge.cotplitool.Main.main(args);
if (args.length > 0)
com.aciedge.cotplitool.Main.main(args);
else com.aciedge.cotplitool.Main.main(ARGS_DEFAULT);
}; };
Thread t = new Thread(r); Thread t = new Thread(r);
t.setDaemon(true); t.setDaemon(true);
...@@ -125,7 +149,7 @@ public class CoTMsgReceiver { ...@@ -125,7 +149,7 @@ public class CoTMsgReceiver {
// TODO: can make this another input argument // TODO: can make this another input argument
sleep(5L); // default to 5 seconds of operation sleep(5L); // default to 5 seconds of operation
System.out.println("\n\nStopping listener pool\n"); System.out.println("\nStopping listener pool\n");
if (isTcp) if (isTcp)
connectors.stopListener(CoTtcpListener.DEFAULT_COT_TCP_PORT); connectors.stopListener(CoTtcpListener.DEFAULT_COT_TCP_PORT);
...@@ -134,8 +158,8 @@ public class CoTMsgReceiver { ...@@ -134,8 +158,8 @@ public class CoTMsgReceiver {
// Issue the CoT message generator/server quit/exit command // Issue the CoT message generator/server quit/exit command
try { try {
if (out != null) if (pipedOutputStream != null)
out.write("quit\n".getBytes("utf-8")); pipedOutputStream.write("quit\n".getBytes("utf-8"));
} catch (IOException ex) {} } catch (IOException ex) {}
// Shutdown the DIS listerner // Shutdown the DIS listerner
......
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