Skip to content
Snippets Groups Projects
Commit 8116110e authored by terry-norbraten's avatar terry-norbraten
Browse files

must specify sentToNet in the constructor, else, the listener thread

starts before a "false" can be interpreted
parent 2377f668
No related branches found
No related tags found
No related merge requests found
...@@ -41,22 +41,24 @@ public class PduReaderPlayer ...@@ -41,22 +41,24 @@ public class PduReaderPlayer
break; break;
case 1: case 1:
outDir = args[0]; outDir = args[0];
sendToNet = Boolean.valueOf(args[1]);
break; break;
case 3: case 3:
outDir = args[0]; outDir = args[0];
mcast = args[1]; mcast = args[1];
port = Integer.parseInt(args[2]); port = Integer.parseInt(args[2]);
sendToNet = true; sendToNet = Boolean.valueOf(args[3]);
break; break;
default: default:
System.err.println("Usage: PduReaderPlayer() or PduReaderPlayer(\"outputdir\") or PduReaderPlayer(\"outputdir\",\"multicast address\", ipPort"); System.err.println("Usage: PduReaderPlayer() or "
+ "PduReaderPlayer(\"outputdir\", \"sendToNet true/false\") or "
+ "PduReaderPlayer(\"outputdir\", \"multicast address\", \"ipPort\", \"sendToNet true/false\"");
System.exit(1); System.exit(1);
} }
System.out.println("Beginning pdu playback from directory " + outDir); System.out.println("Beginning pdu playback from directory " + outDir);
try { try {
PduPlayer pduPlayer = new PduPlayer(mcast, port, Path.of(outDir)); PduPlayer pduPlayer = new PduPlayer(mcast, port, Path.of(outDir), sendToNet);
pduPlayer.sendToNet(sendToNet);
mystate state = mystate.RUNNING; mystate state = mystate.RUNNING;
Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in);
......
...@@ -54,12 +54,14 @@ public class PduPlayer { ...@@ -54,12 +54,14 @@ public class PduPlayer {
* @param ip the multicast group address to utilize * @param ip the multicast group address to utilize
* @param port the multicast port to utilize * @param port the multicast port to utilize
* @param disLogDirectory a path to the directory containing PDU log files * @param disLogDirectory a path to the directory containing PDU log files
* @param sendToNet to capture X3D interpolator values - if desired
* @throws IOException if something goes wrong processing files * @throws IOException if something goes wrong processing files
*/ */
public PduPlayer(String ip, int port, Path disLogDirectory) throws IOException { public PduPlayer(String ip, int port, Path disLogDirectory, boolean sendToNet) throws IOException {
this.disLogDirectory = disLogDirectory; this.disLogDirectory = disLogDirectory;
this.ip = ip; this.ip = ip;
this.port = port; this.port = port;
this.netSend = sendToNet;
thrd = new Thread(() -> begin()); thrd = new Thread(() -> begin());
thrd.setPriority(Thread.NORM_PRIORITY); thrd.setPriority(Thread.NORM_PRIORITY);
...@@ -84,10 +86,6 @@ public class PduPlayer { ...@@ -84,10 +86,6 @@ public class PduPlayer {
private byte[] globalByteBufferForX3dInterPolators = null; private byte[] globalByteBufferForX3dInterPolators = null;
// -------------------- End Variables for X3D autogenerated code // -------------------- End Variables for X3D autogenerated code
public void sendToNet(boolean tf) {
netSend = tf;
}
public void addRawListener(RawListener lis) { public void addRawListener(RawListener lis) {
rawListener = lis; rawListener = lis;
} }
......
...@@ -207,8 +207,7 @@ public class AllPduRoundTripTest ...@@ -207,8 +207,7 @@ public class AllPduRoundTripTest
{ {
sem.acquire(); sem.acquire();
Path path = Path.of(recorder.getLogFile()).getParent(); Path path = Path.of(recorder.getLogFile()).getParent();
PduPlayer player = new PduPlayer(disnetworking.getMcastGroup(), disnetworking.getDisPort(), path); PduPlayer player = new PduPlayer(disnetworking.getMcastGroup(), disnetworking.getDisPort(), path, false);
player.sendToNet(false);
player.addRawListener(ba -> { player.addRawListener(ba -> {
if (ba != null) { if (ba != null) {
Pdu pdu = pduFactory.createPdu(ba); Pdu pdu = pduFactory.createPdu(ba);
......
...@@ -133,8 +133,7 @@ public class SignalPdusTest { ...@@ -133,8 +133,7 @@ public class SignalPdusTest {
Path path = Path.of(recorder.getLogFile()).getParent(); Path path = Path.of(recorder.getLogFile()).getParent();
// Note: the player will playback all log files in the given path // Note: the player will playback all log files in the given path
PduPlayer player = new PduPlayer(netif.getMcastGroup(), netif.getDisPort(), path); PduPlayer player = new PduPlayer(netif.getMcastGroup(), netif.getDisPort(), path, false);
player.sendToNet(false);
player.addRawListener(ba -> { player.addRawListener(ba -> {
if (ba != null) if (ba != null)
assertNotNull(pduFac.createPdu(ba), "PDU creation failure"); assertNotNull(pduFac.createPdu(ba), "PDU creation failure");
......
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