Skip to content
Snippets Groups Projects
Commit 53278c9c authored by brutzman's avatar brutzman
Browse files

better formatting of output, include packet count to facilitate testing

parent 07278287
No related branches found
No related tags found
No related merge requests found
...@@ -35,6 +35,7 @@ public class EspduReceiver ...@@ -35,6 +35,7 @@ public class EspduReceiver
DatagramPacket packet; DatagramPacket packet;
InetAddress address; InetAddress address;
PduFactory pduFactory = new PduFactory(); PduFactory pduFactory = new PduFactory();
int pduCount = 0;
try { try {
// Specify the socket to receive data // Specify the socket to receive data
...@@ -56,22 +57,25 @@ public class EspduReceiver ...@@ -56,22 +57,25 @@ public class EspduReceiver
System.out.println("Bundle size is " + pduBundle.size()); System.out.println("Bundle size is " + pduBundle.size());
// end iterator loop through PDU bundle // end iterator loop through PDU bundle
for (Pdu aPdu : pduBundle) { for (Pdu aPdu : pduBundle)
String receiptMessage = "received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName(); {
pduCount++;
String receiptMessage = String.format("%3s", pduCount) // right justify, 3 characters
+ ". 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("===============");
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();
System.out.println(" entityID triplet: [" + entityID.getSiteID()+ ", " + entityID.getApplicationID()+ ", " + entityID.getEntityID()+ "] "); System.out.println(" entityID triplet: [" + entityID.getSiteID()+ ", " + entityID.getApplicationID()+ ", " + entityID.getEntityID()+ "] ");
System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
} }
else if (aPdu instanceof FirePdu) else if (aPdu instanceof FirePdu)
{ {
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() + "]");
} }
else else
......
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