Skip to content
Snippets Groups Projects
Commit 0b66dbe2 authored by brutzman's avatar brutzman
Browse files

report number of PDUs sent when exiting

parent 3dbffdcc
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ public class AllPduSender ...@@ -41,7 +41,7 @@ public class AllPduSender
} }
} }
public void run() public int run()
{ {
System.out.println("DisExamplesOpenDis7.AllPduSender started..."); System.out.println("DisExamplesOpenDis7.AllPduSender started...");
try try
...@@ -60,10 +60,10 @@ public class AllPduSender ...@@ -60,10 +60,10 @@ public class AllPduSender
try { try {
switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType
{ {
// each case value is DISPDUType
case OTHER: // 0 case OTHER: // 0
System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO why was this received? System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO why was this received?
// nothing to send break; // nothing to send
break;
case ENTITY_STATE: // 1 case ENTITY_STATE: // 1
aPdu = new EntityStatePdu(); aPdu = new EntityStatePdu();
...@@ -443,7 +443,7 @@ public class AllPduSender ...@@ -443,7 +443,7 @@ public class AllPduSender
packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT); packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
multicastSocket.send(packet); multicastSocket.send(packet);
try { try {
Thread.sleep(250L); // TODO shouldn't this kind of delay timing be in a DIS sender class? Thread.sleep(100L); // TODO shouldn't this kind of delay timing be in a DIS sender class?
} }
catch (InterruptedException ex) { catch (InterruptedException ex) {
} }
...@@ -460,27 +460,32 @@ public class AllPduSender ...@@ -460,27 +460,32 @@ public class AllPduSender
//PduContainer container = new PduContainer(); //PduContainer container = new PduContainer();
//container.setPdus(generatedPdus); //container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml"); //container.marshallToXml("examplePdus.xml");
return generatedPdusList.size();
} }
catch (IOException e) catch (IOException e)
{ {
System.out.println(e); System.out.println(e);
return -1;
} }
} }
public static void main(String args[]) public static void main(String args[])
{ {
AllPduSender allPduSender;
int totalSentPdus = 0;
if (args.length == 2) if (args.length == 2)
{ {
AllPduSender sender = new AllPduSender(Integer.parseInt(args[0]), args[1]); allPduSender = new AllPduSender(Integer.parseInt(args[0]), args[1]);
sender.run(); totalSentPdus = allPduSender.run();
} }
else else
{ {
System.out.println("Usage: AllPduSender <port> <multicast group>"); System.out.println("Usage: AllPduSender <port> <multicast group>");
System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
AllPduSender allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
allPduSender.run(); totalSentPdus = allPduSender.run();
} }
System.out.println("DisExamplesOpenDis7.AllPduSender complete."); System.out.println("DisExamplesOpenDis7.AllPduSender complete, sent " + totalSentPdus + " PDUs total.");
} }
} }
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