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
break;
case 1:
outDir = args[0];
sendToNet = Boolean.valueOf(args[1]);
break;
case 3:
outDir = args[0];
mcast = args[1];
port = Integer.parseInt(args[2]);
sendToNet = true;
sendToNet = Boolean.valueOf(args[3]);
break;
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.out.println("Beginning pdu playback from directory " + outDir);
try {
PduPlayer pduPlayer = new PduPlayer(mcast, port, Path.of(outDir));
pduPlayer.sendToNet(sendToNet);
PduPlayer pduPlayer = new PduPlayer(mcast, port, Path.of(outDir), sendToNet);
mystate state = mystate.RUNNING;
Scanner scan = new Scanner(System.in);
......
......@@ -54,12 +54,14 @@ public class PduPlayer {
* @param ip the multicast group address to utilize
* @param port the multicast port to utilize
* @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
*/
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.ip = ip;
this.port = port;
this.netSend = sendToNet;
thrd = new Thread(() -> begin());
thrd.setPriority(Thread.NORM_PRIORITY);
......@@ -84,10 +86,6 @@ public class PduPlayer {
private byte[] globalByteBufferForX3dInterPolators = null;
// -------------------- End Variables for X3D autogenerated code
public void sendToNet(boolean tf) {
netSend = tf;
}
public void addRawListener(RawListener lis) {
rawListener = lis;
}
......
......@@ -207,8 +207,7 @@ public class AllPduRoundTripTest
{
sem.acquire();
Path path = Path.of(recorder.getLogFile()).getParent();
PduPlayer player = new PduPlayer(disnetworking.getMcastGroup(), disnetworking.getDisPort(), path);
player.sendToNet(false);
PduPlayer player = new PduPlayer(disnetworking.getMcastGroup(), disnetworking.getDisPort(), path, false);
player.addRawListener(ba -> {
if (ba != null) {
Pdu pdu = pduFactory.createPdu(ba);
......
......@@ -133,8 +133,7 @@ public class SignalPdusTest {
Path path = Path.of(recorder.getLogFile()).getParent();
// Note: the player will playback all log files in the given path
PduPlayer player = new PduPlayer(netif.getMcastGroup(), netif.getDisPort(), path);
player.sendToNet(false);
PduPlayer player = new PduPlayer(netif.getMcastGroup(), netif.getDisPort(), path, false);
player.addRawListener(ba -> {
if (ba != null)
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