diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverAtoTCP.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverAtoTCP.java index b634020ae144b7a9d8a1ae21ca4f25f25d27ec83..fb2bb36f69b87c3832c41ee1c685b8a69262ee61 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverAtoTCP.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverAtoTCP.java @@ -46,16 +46,6 @@ public class ABEspduReceiverAtoTCP { while (true) { try { - // Create TCP Bridge - System.out.println("Opening Bridge."); - - Socket clientConnection = new Socket("localhost", TCP_DESTINATION_PORT); - OutputStream os = clientConnection.getOutputStream(); - PrintStream ps = new PrintStream(os); - - //ByteArrayOutputStream baos = new ByteArrayOutputStream(); - //DataOutputStream dos = new DataOutputStream(baos); - System.out.println("Bridging Complete."); byte buffer[] = new byte[MAX_PDU_SIZE]; packet = new DatagramPacket(buffer, buffer.length); @@ -73,10 +63,23 @@ public class ABEspduReceiverAtoTCP { { Pdu aPdu = (Pdu)it.next(); - System.out.print("got PDU of type: " + aPdu.getClass().getName()); + // System.out.print("got PDU of type: " + aPdu.getClass().getName()); if(aPdu instanceof EntityStatePdu) { + EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); + if (eid.getSite() == 100){ + // Create TCP Bridge + System.out.println("Opening Bridge."); + + Socket clientConnection = new Socket("localhost", TCP_DESTINATION_PORT); + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + //ByteArrayOutputStream baos = new ByteArrayOutputStream(); + //DataOutputStream dos = new DataOutputStream(baos); + System.out.println("Bridging Complete."); + EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); ps.println(eid.getSite()); ps.println(eid.getApplication()); @@ -91,6 +94,7 @@ public class ABEspduReceiverAtoTCP { Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.print(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); + } } System.out.println(); } // end trop through PDU bundle diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverBtoTCP.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverBtoTCP.java index b5a4a7c45328313619eb795a013d9d082260dd24..60106c797ef50605ba3151fdce4f00be89f57221 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverBtoTCP.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/ABEspduReceiverBtoTCP.java @@ -46,16 +46,6 @@ public class ABEspduReceiverBtoTCP { while (true) { try { - // Create TCP Bridge - System.out.println("Opening Bridge."); - - Socket clientConnection = new Socket("localhost", TCP_DESTINATION_PORT); - OutputStream os = clientConnection.getOutputStream(); - PrintStream ps = new PrintStream(os); - - //ByteArrayOutputStream baos = new ByteArrayOutputStream(); - //DataOutputStream dos = new DataOutputStream(baos); - System.out.println("Bridging Complete."); byte buffer[] = new byte[MAX_PDU_SIZE]; packet = new DatagramPacket(buffer, buffer.length); @@ -73,10 +63,22 @@ public class ABEspduReceiverBtoTCP { { Pdu aPdu = (Pdu)it.next(); - System.out.print("got PDU of type: " + aPdu.getClass().getName()); + //System.out.print("got PDU of type: " + aPdu.getClass().getName()); if(aPdu instanceof EntityStatePdu) { EntityID eid = ((EntityStatePdu)aPdu).getEntityID(); + if (eid.getSite() == 200){ + // Create TCP Bridge + System.out.println("Opening Bridge."); + + Socket clientConnection = new Socket("localhost", TCP_DESTINATION_PORT); + OutputStream os = clientConnection.getOutputStream(); + PrintStream ps = new PrintStream(os); + + //ByteArrayOutputStream baos = new ByteArrayOutputStream(); + //DataOutputStream dos = new DataOutputStream(baos); + System.out.println("Bridging Complete."); + EntityType entityType = ((EntityStatePdu)aPdu).getEntityType(); ps.println(eid.getSite()); ps.println(eid.getApplication()); @@ -91,6 +93,7 @@ public class ABEspduReceiverBtoTCP { Vector3Double position = ((EntityStatePdu)aPdu).getEntityLocation(); System.out.print(" EID:[" + eid.getSite() + ", " + eid.getApplication() + ", " + eid.getEntity() + "] "); System.out.print(" Location in DIS coordinates: [" + position.getX() + ", " + position.getY() + ", " + position.getZ() + "]"); + } } System.out.println(); } // end trop through PDU bundle diff --git a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduSenderB.java b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduSenderB.java index df6423963194ffcfb634c22cb1ded48aeba5457d..d251d568b90fc114510844975b0391a61147d198 100644 --- a/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduSenderB.java +++ b/projects/Assignments/FinalProjects/2018March/AngelopoulosBlankenbeker/AngelBlankEspduSenderB.java @@ -237,8 +237,8 @@ public static void main(String args[]) DataOutputStream dos = new DataOutputStream(baos); espdu.marshal(dos); - FirePdu fire = new FirePdu(); - byte[] fireArray = fire.marshal(); + //FirePdu fire = new FirePdu(); + //byte[] fireArray = fire.marshal(); // The byte array here is the packet in DIS format. We put that into a