Skip to content
Snippets Groups Projects
Commit 8d109880 authored by J. M. Bailey's avatar J. M. Bailey
Browse files

Fix for most recent release

parent afee964b
No related branches found
No related tags found
No related merge requests found
...@@ -35,15 +35,15 @@ endorsed.classpath= ...@@ -35,15 +35,15 @@ endorsed.classpath=
excludes= excludes=
file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar file.reference.dis-enums-1.3.jar=../lib/dis-enums-1.3.jar
file.reference.open-dis7-entities-all.jar=../lib/open-dis7-entities-all.jar file.reference.open-dis7-entities-all.jar=../lib/open-dis7-entities-all.jar
file.reference.open-dis7.jar=../lib/open-dis7.jar file.reference.open-dis7-java.jar=../lib/open-dis7-java.jar
file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar file.reference.open-dis_4.16.jar=../lib/open-dis_4.16.jar
includes=** includes=**
jar.compress=false jar.compress=false
javac.classpath=\ javac.classpath=\
${file.reference.open-dis7.jar}:\ ${file.reference.open-dis7-java.jar}:\
${file.reference.open-dis7-entities-all.jar}:\ ${file.reference.open-dis7-entities-all.jar}:\
${file.reference.dis-enums-1.3.jar}:\ ${file.reference.open-dis_4.16.jar}:\
${file.reference.open-dis_4.16.jar} ${file.reference.dis-enums-1.3.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
...@@ -69,6 +69,7 @@ javadoc.noindex=false ...@@ -69,6 +69,7 @@ javadoc.noindex=false
javadoc.nonavbar=false javadoc.nonavbar=false
javadoc.notree=false javadoc.notree=false
javadoc.private=false javadoc.private=false
javadoc.reference.open-dis7-java.jar=../lib/open-dis7-javadoc.jar
javadoc.splitindex=true javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
...@@ -95,4 +96,5 @@ run.test.classpath=\ ...@@ -95,4 +96,5 @@ run.test.classpath=\
run.test.modulepath=\ run.test.modulepath=\
${javac.test.modulepath} ${javac.test.modulepath}
source.encoding=UTF-8 source.encoding=UTF-8
source.reference.open-dis7-java.jar=../lib/open-dis7-source.jar
src.dir=src src.dir=src
package OpenDis7Examples; package OpenDis7Examples;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*; import java.util.*;
import edu.nps.moves.dis7.*; import edu.nps.moves.dis7.*;
import edu.nps.moves.dis7.util.*; import edu.nps.moves.dis7.util.*;
import edu.nps.moves.disenum.PduType;
/**
/** * Receives PDUs from the network in IEEE DIS format.
* Receives PDUs from the network in IEEE DIS format. * Adapted from OpenDIS library example package edu.nps.moves.examples
* Adapted from OpenDIS library example package edu.nps.moves.examples *
* * @author DMcG
* @author DMcG * @version $Id:$
* @version $Id:$ */
*/ public class EspduReceiver
public class EspduReceiver {
{ /** Max size of a PDU in binary format that we can receive. This is actually
/** Max size of a PDU in binary format that we can receive. This is actually * somewhat outdated--PDUs can be larger--but this is a reasonable starting point.
* somewhat outdated--PDUs can be larger--but this is a reasonable starting point. */
*/ public static final int MAX_PDU_SIZE = 8192;
public static final int MAX_PDU_SIZE = 8192;
/** Default multicast group address we send on. */
/** Default multicast group address we send on. */ public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
public static final String DEFAULT_MULTICAST_ADDRESS = "239.1.2.3";
/** 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 = 3000;
public static final int DEFAULT_MULTICAST_PORT = 3000;
public static void main(String args[])
public static void main(String args[]) {
{ System.out.println("DisExamplesOpenDis7.EspduReceiver started...");
System.out.println("DisExamplesOpenDis7.EspduReceiver started...");
MulticastSocket socket;
MulticastSocket socket; DatagramPacket packet;
DatagramPacket packet; InetAddress address;
InetAddress address; PduFactory pduFactory = new PduFactory();
PduFactory pduFactory = new PduFactory();
try {
try { // Specify the socket to receive data
// Specify the socket to receive data socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); socket.setBroadcast(true);
socket.setBroadcast(true);
// address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP);
// address = InetAddress.getByName(EspduSender.DEFAULT_MULTICAST_GROUP); // socket.joinGroup(address);
// socket.joinGroup(address);
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]; packet = new DatagramPacket(buffer, buffer.length);
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
socket.receive(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(),packet.getLength());
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData()); if (pduBundle.size() > 1)
if (pduBundle.size() > 1) System.out.println("Bundle size is " + pduBundle.size());
System.out.println("Bundle size is " + pduBundle.size()); Iterator iterator = pduBundle.iterator();
Iterator iterator = pduBundle.iterator();
while(iterator.hasNext())
while(iterator.hasNext()) {
{ Pdu aPdu = (Pdu)iterator.next();
Pdu aPdu = (Pdu)iterator.next();
System.out.println("received PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType().name() + " of type " + aPdu.getClass().getName());
System.out.println("received PDU " + aPdu.getPduType().getValue() + " " + aPdu.getPduType().name() + " of type " + aPdu.getClass().getName()); if(aPdu instanceof EntityStatePdu)
if(aPdu instanceof EntityStatePdu) {
{ EntityID eid = ((EntityStatePdu)aPdu).getEntityID();
EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation();
Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.println(" ID triplet: [" + eid.getSiteID()+ ", " + eid.getApplicationID()+ ", " + eid.getEntityID()+ "] ");
System.out.println(" ID triplet: [" + eid.getSiteID()+ ", " + eid.getApplicationID()+ ", " + eid.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() + "]"); }
// TODO fix library! } // end iterator loop through PDU bundle
System.out.println("** TODO error, 'PDU not implemented' is a library bug"); } // end while
} } // End try
} // end iterator loop through PDU bundle catch (IOException e)
} // end while {
} // End try System.out.println("Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:");
catch (IOException e) System.out.println(e);
{ }
System.out.println("Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:"); System.out.println("DisExamplesOpenDis7.EspduReceiver complete.");
System.out.println(e); } // end main
} } // end class
System.out.println("DisExamplesOpenDis7.EspduReceiver complete.");
} // end main
} // end class
This diff is collapsed.
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