Please review any and all PUBLIC repositories, groups and associate files. These allow anyone on the Internet to access without authentication. Repository and group owners are responsible for their content and permission settings. Go to your project(s), click on Settings > General and expand the "Visibility, project features, permissions" to change this setting.

Renamed the folder to BrennenstuhlTobias

parent b4c6f2d6
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DISTools;
package PduStreamTools;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
......
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DISTools;
package PduStreamTools;
/**
*
......
package PduStreamTools;
import java.io.*;
import java.net.*;
import java.util.*;
import edu.nps.moves.dis7.*;
import edu.nps.moves.dis7.util.*;
/**
* Receives PDUs from the network in IEEE DIS format.
* Adapted from OpenDIS library example package edu.nps.moves.examples
*
* @author DMcG
* @version $Id:$
*/
public class EspduReceiver
{
/** 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.
*/
public static final int MAX_PDU_SIZE = 8192;
/** Default multicast group address we send on. */
public String DEFAULT_MULTICAST_ADDRESS;
/** Default multicast port used, matches Wireshark DIS capture default */
public int DEFAULT_MULTICAST_PORT;
public String receive(String localBroadCastAddress, int localPort)
{
System.out.println("DisExamplesOpenDis7.EspduReceiver started...");
String returnString;
returnString = new String("Test Return Receiver \n");
this.DEFAULT_MULTICAST_ADDRESS = localBroadCastAddress;
this.DEFAULT_MULTICAST_PORT = localPort;
MulticastSocket socket;
DatagramPacket packet;
InetAddress address;
PduFactory pduFactory = new PduFactory();
try {
// Specify the socket to receive data
socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
// socket.setBroadcast(true);
address = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
socket.joinGroup(address);
byte buffer[] = new byte[MAX_PDU_SIZE];
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(packet.getData(),packet.getLength());
if (pduBundle.size() > 1)
System.out.println("Bundle size is " + pduBundle.size());
returnString += "Bundle size is "+ pduBundle.size();
Iterator iterator = pduBundle.iterator();
while (iterator.hasNext())
{
Pdu aPdu = (Pdu)iterator.next();
String receiptMessage = "received PDU type " + aPdu.getPduType().getValue() + "=" + aPdu.getPduType().name() + " " + aPdu.getClass().getName();
if (aPdu instanceof EntityStatePdu)
{
System.out.println("===============");
returnString += "===============\n";
System.out.println(receiptMessage);
returnString += receiptMessage + "\n";
EntityID entityID = ((EntityStatePdu)aPdu).getEntityID();
Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation();
System.out.println(" entityID triplet: [" + entityID.getSiteID()+ ", " + entityID.getApplicationID()+ ", " + entityID.getEntityID()+ "] ");
returnString += " entityID triplet: [" + entityID.getSiteID()+ ", " + entityID.getApplicationID()+ ", " + entityID.getEntityID()+ "] ";
System.out.println(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]\n");
returnString += " Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]\n";
}
else if (aPdu instanceof FirePdu)
{
System.out.println(receiptMessage);
returnString += receiptMessage + "\n";
Vector3Double position = ((FirePdu)aPdu).getLocationInWorldCoordinates();
System.out.println(" FirePdu locationInWorldCoordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]");
returnString += " FirePdu locationInWorldCoordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]\n";
}
else
{
System.out.println(receiptMessage);
returnString += receiptMessage + "\n";
}
} // end iterator loop through PDU bundle
} // end try block
catch (IOException e)
{
System.out.println("Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:");
returnString += "Problem with DisExamplesOpenDis7.EspduReceiver, see exception trace:\n";
System.out.println(e);
returnString += e + "\n";
}
System.out.println("DisExamplesOpenDis7.EspduReceiver complete.");
return returnString;
} // end main
} // end class
This diff is collapsed.
......@@ -10,6 +10,7 @@ package PduStreamTools;
* rights reserved. This work is licensed under the BSD open source license,
* available at https://www.movesinstitute.org/licenses/bsd.html
*/
import static PduStreamTools.RecorderBase64.COMMENT_MARKER;
import static PduStreamTools.RecorderBase64.START_COMMENT_MARKER;
import static PduStreamTools.RecorderBase64.STOP_COMMENT_MARKER;
......
......@@ -12,6 +12,7 @@ import edu.nps.moves.dis7.enumerations.DISPDUType;
import edu.nps.moves.dis7.util.DisNetworking;
import edu.nps.moves.dis7.util.DisNetworking.BuffAndLength;
import edu.nps.moves.dis7.util.PduFactory;
import edu.nps.moves.dis7.util.playerrecorder.PduReceiver;
import org.apache.commons.io.FilenameUtils;
import java.io.BufferedWriter;
......
......@@ -12,6 +12,7 @@ import edu.nps.moves.dis7.enumerations.DISPDUType;
import edu.nps.moves.dis7.util.DisNetworking;
import edu.nps.moves.dis7.util.DisNetworking.BuffAndLength;
import edu.nps.moves.dis7.util.PduFactory;
import edu.nps.moves.dis7.util.playerrecorder.PduReceiver;
import org.apache.commons.io.FilenameUtils;
import java.io.BufferedWriter;
......
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DISTools;
package PduStreamTools;
import java.awt.BorderLayout;
import java.awt.GridLayout;
......
......@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DISTools;
package PduStreamTools;
import javax.swing.SwingUtilities;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment