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