Skip to content
Snippets Groups Projects
Commit b5522624 authored by cs2017's avatar cs2017
Browse files

Cleanup

parent 079824cd
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,6 @@ import edu.nps.moves.disutil.*; ...@@ -6,8 +6,6 @@ import edu.nps.moves.disutil.*;
import edu.nps.moves.dis.*; import edu.nps.moves.dis.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/** /**
* Receives PDUs from the network creates a TCP connection, then * Receives PDUs from the network creates a TCP connection, then
...@@ -74,21 +72,8 @@ public class AngelBlankEspduReceiverAtoTCP { ...@@ -74,21 +72,8 @@ public class AngelBlankEspduReceiverAtoTCP {
DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT); DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT);
dataGram.send(DpSend); dataGram.send(DpSend);
//Socket clientConnection = new Socket(TCP_DESTINATION_IP, TCP_DESTINATION_PORT);
//OutputStream os = clientConnection.getOutputStream();
//PrintStream ps = new PrintStream(os);
System.out.println("Alpha Bridging Complete to: " + TCP_DESTINATION_IP); System.out.println("Alpha Bridging Complete to: " + TCP_DESTINATION_IP);
//EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); //EntityType entityType = ((EntityStatePdu)aPdu).getEntityType();
/**ps.println(eid.getSite());
ps.println(eid.getApplication());
ps.println(eid.getEntity());
ps.println(entityType.getEntityKind()); // Platform (vs lifeform, munition, sensor, etc.)
ps.println(entityType.getCountry()); // USA
ps.println(entityType.getDomain()); // Land (vs air, surface, subsurface, space)
ps.println(entityType.getCategory()); // Tank
ps.println(entityType.getSubcategory()); // M1 Abrams
ps.println(entityType.getSpec()); // M1A2 Abrams**/
} }
Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation(); Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation();
System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] ");
......
...@@ -6,8 +6,7 @@ import edu.nps.moves.disutil.*; ...@@ -6,8 +6,7 @@ import edu.nps.moves.disutil.*;
import edu.nps.moves.dis.*; import edu.nps.moves.dis.*;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/** /**
* Receives PDUs from the network in IEEE format and creates a TCP connection, * Receives PDUs from the network in IEEE format and creates a TCP connection,
...@@ -63,23 +62,8 @@ public class AngelBlankEspduReceiverBtoTCP { ...@@ -63,23 +62,8 @@ public class AngelBlankEspduReceiverBtoTCP {
DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT); DatagramPacket DpSend = new DatagramPacket(data, data.length, InetAddress.getByName(TCP_DESTINATION_IP), TCP_DESTINATION_PORT);
dataGram.send(DpSend); // Create TCP Bridge dataGram.send(DpSend); // Create TCP Bridge
//Socket clientConnection = new Socket(TCP_DESTINATION_IP, TCP_DESTINATION_PORT);
// OutputStream os = clientConnection.getOutputStream();
//PrintStream ps = new PrintStream(os);
System.out.println("Bravo briding complete to: "+ TCP_DESTINATION_IP); System.out.println("Bravo briding complete to: "+ TCP_DESTINATION_IP);
//EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); //EntityType entityType = ((EntityStatePdu)aPdu).getEntityType();
/** ps.println(eid.getSite());
ps.println(eid.getApplication());
ps.println(eid.getEntity());
ps.println(entityType.getEntityKind()); // Platform (vs lifeform, munition, sensor, etc.)
ps.println(entityType.getCountry()); // USA
ps.println(entityType.getDomain()); // Land (vs air, surface, subsurface, space)
ps.println(entityType.getCategory()); // Tank
ps.println(entityType.getSubcategory()); // M1 Abrams
ps.println(entityType.getSpec()); // M1A2 Abrams**/
} }
Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation(); Vector3Double location = ((EntityStatePdu)aPdu).getEntityLocation();
System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] ");
......
...@@ -104,7 +104,6 @@ public static void main(String args[]) ...@@ -104,7 +104,6 @@ public static void main(String args[])
{ {
int connectionCount = 0; int connectionCount = 0;
DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT); DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT);
//ServerSocket serverSocket = new ServerSocket(TCP_DESTINATION_PORT);
while(true){ while(true){
try try
...@@ -112,7 +111,6 @@ public static void main(String args[]) ...@@ -112,7 +111,6 @@ public static void main(String args[])
byte buffer[] = new byte[MAX_PDU_SIZE]; byte buffer[] = new byte[MAX_PDU_SIZE];
DatagramPacket tcpPacket = new DatagramPacket(buffer, buffer.length); DatagramPacket tcpPacket = new DatagramPacket(buffer, buffer.length);
ds.receive(tcpPacket); ds.receive(tcpPacket);
//Socket clientConnection = serverSocket.accept();
connectionCount++; connectionCount++;
System.out.println("Current PDUs transferred over TCP: "+ connectionCount); System.out.println("Current PDUs transferred over TCP: "+ connectionCount);
List<Pdu> pduBundle = pduFactory.getPdusFromBundle(tcpPacket.getData()); List<Pdu> pduBundle = pduFactory.getPdusFromBundle(tcpPacket.getData());
...@@ -126,50 +124,14 @@ public static void main(String args[]) ...@@ -126,50 +124,14 @@ public static void main(String args[])
if(aPdu instanceof EntityStatePdu){ if(aPdu instanceof EntityStatePdu){
EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); EntityID eid = ((EntityStatePdu)aPdu).getEntityID();
System.out.println("Entity ID transferred: "+eid.getEntity()); System.out.println("Entity ID transferred: "+eid.getEntity());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//System.out.println(); DataOutputStream dos = new DataOutputStream(baos);
// end trop through PDU bundle aPdu.marshal(dos);
//System.out.println("RA SB received TCP connection."); byte[] data = baos.toByteArray();
/**InputStream is = clientConnection.getInputStream(); DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT);
InputStreamReader isr = new InputStreamReader(is); socket.send(udpPacket);
BufferedReader br = new BufferedReader(isr);
//System.out.println("RA SB waiting to readline.");
int entitySite = Integer.parseInt(br.readLine());
int entityApplication = Integer.parseInt(br.readLine());
int entityEntity = Integer.parseInt(br.readLine());
short entityEntityKind = Short.parseShort(br.readLine());
int entityCountry = Integer.parseInt(br.readLine());
short entityDomain = Short.parseShort(br.readLine());
short entityCategory = Short.parseShort(br.readLine());
short entitySubcategory = Short.parseShort(br.readLine());
short entitySpec = Short.parseShort(br.readLine());
//System.out.println("RA SB reading complete.");
espdu.setExerciseID((short)1);
EntityID eid = espdu.getEntityID();
eid.setSite(entitySite); // 0 is apparently not a valid site number, per the spec
eid.setApplication(entityApplication);
eid.setEntity(entityEntity);
EntityType entityType = espdu.getEntityType();
entityType.setEntityKind(entityEntityKind); // Platform (vs lifeform, munition, sensor, etc.)
entityType.setCountry(entityCountry); // USA
entityType.setDomain(entityDomain); // AIR (vs air, surface, subsurface, space)
entityType.setCategory(entityCategory); // Tank
entityType.setSubcategory(entitySubcategory); // M1 Abrams
entityType.setSpec(entitySpec); // M1A2 Abrams **/
//int ts = disTime.getDisAbsoluteTimestamp();
//espdu.setTimestamp(ts);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
aPdu.marshal(dos);
// The byte array here is the packet in DIS format. We put that into a
// datagram and send it.
byte[] data = baos.toByteArray();
DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT);
socket.send(udpPacket);
} }
//System.out.println(" EID=[" + eid.getSite() + "," + eid.getApplication() + "," + eid.getEntity() + "]"); }
//clientConnection.close();
}
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -184,7 +146,7 @@ public static void main(String args[]) ...@@ -184,7 +146,7 @@ public static void main(String args[])
} }
/**
public static Set<InetAddress> getBroadcastAddresses() public static Set<InetAddress> getBroadcastAddresses()
{ {
Set<InetAddress> bcastAddresses = new HashSet<InetAddress>(); Set<InetAddress> bcastAddresses = new HashSet<InetAddress>();
...@@ -224,5 +186,5 @@ public static void main(String args[]) ...@@ -224,5 +186,5 @@ public static void main(String args[])
return bcastAddresses; return bcastAddresses;
} }
**/
} }
...@@ -106,7 +106,6 @@ public static void main(String args[]) ...@@ -106,7 +106,6 @@ public static void main(String args[])
{ {
int connectionCount = 0; int connectionCount = 0;
DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT); DatagramSocket ds = new DatagramSocket(TCP_DESTINATION_PORT);
//ServerSocket serverSocket = new ServerSocket(TCP_DESTINATION_PORT);
while(true){ while(true){
try try
...@@ -128,48 +127,13 @@ public static void main(String args[]) ...@@ -128,48 +127,13 @@ public static void main(String args[])
if(aPdu instanceof EntityStatePdu){ if(aPdu instanceof EntityStatePdu){
EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); EntityID eid = ((EntityStatePdu)aPdu).getEntityID();
System.out.println("Entity ID transferred: "+eid.getEntity()); System.out.println("Entity ID transferred: "+eid.getEntity());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
/** DataOutputStream dos = new DataOutputStream(baos);
//System.out.println("RB SA received TCP connection."); aPdu.marshal(dos);
InputStream is = clientConnection.getInputStream(); byte[] data = baos.toByteArray();
InputStreamReader isr = new InputStreamReader(is); DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT);
BufferedReader br = new BufferedReader(isr); socket.send(udpPacket);
//System.out.println("RB SA waiting to readline.");
int entitySite = Integer.parseInt(br.readLine());
int entityApplication = Integer.parseInt(br.readLine());
int entityEntity = Integer.parseInt(br.readLine());
short entityEntityKind = Short.parseShort(br.readLine());
int entityCountry = Integer.parseInt(br.readLine());
short entityDomain = Short.parseShort(br.readLine());
short entityCategory = Short.parseShort(br.readLine());
short entitySubcategory = Short.parseShort(br.readLine());
short entitySpec = Short.parseShort(br.readLine());
//System.out.println("RB SA reading complete.");
espdu.setExerciseID((short)1);
EntityID eid = espdu.getEntityID();
eid.setSite(entitySite); // 0 is apparently not a valid site number, per the spec
eid.setApplication(entityApplication);
eid.setEntity(entityEntity);
EntityType entityType = espdu.getEntityType();
entityType.setEntityKind(entityEntityKind); // Platform (vs lifeform, munition, sensor, etc.)
entityType.setCountry(entityCountry); // USA
entityType.setDomain(entityDomain); // AIR (vs air, surface, subsurface, space)
entityType.setCategory(entityCategory); // Tank
entityType.setSubcategory(entitySubcategory); // M1 Abrams
entityType.setSpec(entitySpec); // M1A2 Abrams
int ts = disTime.getDisAbsoluteTimestamp();
espdu.setTimestamp(ts);**/
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
aPdu.marshal(dos);
// The byte array here is the packet in DIS format. We put that into a
// datagram and send it.
byte[] data = baos.toByteArray();
DatagramPacket udpPacket = new DatagramPacket(data, data.length, InetAddress.getByName(DEFAULT_MULTICAST_GROUP), DIS_DESTINATION_PORT);
socket.send(udpPacket);
} }
//System.out.println(" EID=[" + eid.getSite() + "," + eid.getApplication() + "," + eid.getEntity() + "]");
} }
} }
catch(Exception e) catch(Exception e)
......
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