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

various refinements

parent f41e1a9b
No related branches found
No related tags found
No related merge requests found
......@@ -26,15 +26,20 @@ public class EspduReceiver
/** Default multicast port used, matches Wireshark DIS capture default */
public static final int DEFAULT_MULTICAST_PORT = EspduSender.DEFAULT_MULTICAST_PORT;
/**
* Output prefix to identify this class
*/
private final static String TRACE_PREFIX = "[" + EspduReceiver.class.getName() + "] ";
public static void main(String args[])
{
System.out.println("OpenDis7Examples.EspduReceiver started...");
System.out.println(TRACE_PREFIX + "started...");
MulticastSocket socket;
DatagramPacket packet;
InetAddress address;
PduFactory pduFactory = new PduFactory();
DatagramPacket packet;
InetAddress address;
PduFactory pduFactory = new PduFactory();
int pduCount = 0;
try {
......@@ -43,10 +48,11 @@ public class EspduReceiver
// socket.setBroadcast(true);
address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
socket.joinGroup(address);
////// socket.joinGroup(address); // TODO not needed!
System.out.println("OpenDis7Examples.EspduReceiver: listening for PDU packets on " + address.getHostAddress() + " port " + DEFAULT_MULTICAST_PORT);
System.out.println(TRACE_PREFIX + "listening for PDU packets on " + address.getHostAddress() + " port " + DEFAULT_MULTICAST_PORT);
System.out.println("===============");
while (true) // Loop infinitely, receiving datagrams
{
byte buffer[] = new byte[MAX_PDU_SIZE];
......@@ -66,7 +72,6 @@ public class EspduReceiver
+ ". received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName();
if (aPdu instanceof EntityStatePdu)
{
System.out.println("===============");
System.out.println(receiptMessage);
EntityID entityID = ((EntityStatePdu)aPdu).getEntityID();
Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation();
......@@ -78,20 +83,20 @@ public class EspduReceiver
System.out.println(receiptMessage);
Vector3Double position = ((FirePdu)aPdu).getLocationInWorldCoordinates();
System.out.println(" FirePdu locationInWorldCoordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
System.out.println("===============");
}
else
{
System.out.println(receiptMessage);
}
}
} // end while
} // end of bundle loop
} // end of while loop
} // end try block
catch (IOException e)
catch (IOException ioe)
{
System.out.println("Problem with OpenDis7Examples.EspduReceiver, see exception trace:");
System.out.println(e);
System.out.println(TRACE_PREFIX + "Problem with input/output, see exception trace:");
System.out.println(ioe);
}
System.out.println("OpenDis7Examples.EspduReceiver complete.");
System.out.println(TRACE_PREFIX + "complete.");
} // end main
} // end class
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