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
}
}
public void run()
public int run()
{
System.out.println("DisExamplesOpenDis7.AllPduSender started...");
try
......@@ -60,10 +60,10 @@ public class AllPduSender
try {
switch (pdu) // using enumeration values from edu.​nps.​moves.​dis7.​enumerations.​DISPDUType
{
// each case value is DISPDUType
case OTHER: // 0
System.out.println ("*** Note: DISPDUType." + pdu.name() + " not supported"); // TODO why was this received?
// nothing to send
break;
break; // nothing to send
case ENTITY_STATE: // 1
aPdu = new EntityStatePdu();
......@@ -443,7 +443,7 @@ public class AllPduSender
packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
multicastSocket.send(packet);
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) {
}
......@@ -460,27 +460,32 @@ public class AllPduSender
//PduContainer container = new PduContainer();
//container.setPdus(generatedPdus);
//container.marshallToXml("examplePdus.xml");
return generatedPdusList.size();
}
catch (IOException e)
{
System.out.println(e);
return -1;
}
}
public static void main(String args[])
{
AllPduSender allPduSender;
int totalSentPdus = 0;
if (args.length == 2)
{
AllPduSender sender = new AllPduSender(Integer.parseInt(args[0]), args[1]);
sender.run();
allPduSender = new AllPduSender(Integer.parseInt(args[0]), args[1]);
totalSentPdus = allPduSender.run();
}
else
{
System.out.println("Usage: AllPduSender <port> <multicast group>");
System.out.println("Default: AllPduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
AllPduSender allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
allPduSender.run();
allPduSender = new AllPduSender(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
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