Skip to content
Snippets Groups Projects
Commit ce88bb38 authored by John Furr's avatar John Furr
Browse files

Draft files edited.

parent e5372327
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,8 @@ import java.io.*;
import java.util.*;
import edu.nps.moves.dis.*;
import java.io.IOException;
import edu.nps.moves.disenum.*;
import edu.nps.moves.disutil.PduFactory;
import java.sql.Timestamp;
public class FDCSendRecieve {
......@@ -26,7 +26,8 @@ public class FDCSendRecieve {
public static final int MULTICAST_PORT = 3000;
public static final String MULTICAST_GROUP = "239.1.2.3";
public static final boolean USE_FAST_ESPDU = false;
public long [] sentBuffer = new long[100];
// public List<long> sentBufferList;
public FDCSendRecieve(int port, String multicast) {
......@@ -42,18 +43,20 @@ public class FDCSendRecieve {
}
public void run(Pdu pdu) {
System.out.println("DisExamples.PduSender started...");
if(sentBuffer.)
System.out.println("FDC Sender started...");
short currentPduType = pdu.getPduType();
String currentPduTypeName = pdu.getClass().getName();
short currentProtocolFamilyID = pdu.getProtocolFamily();
String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
System.out.println("in sender, recived PDU type: "+currentPduType);
// String currentPduTypeName = pdu.getClass().getName();
// short currentProtocolFamilyID = pdu.getProtocolFamily();
// String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
try {
List<Pdu> generatedPdus = new ArrayList<>();
// Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list.
for (PduType pdu2 : PduType.values()) {
Pdu aPdu = null;
System.out.println(pdu);
......@@ -73,6 +76,7 @@ public class FDCSendRecieve {
espduLocation.setX(1.0);
espduLocation.setY(2.0);
espduLocation.setZ(3.0);
espdu.setTimestamp(System.currentTimeMillis());
break;
// case COMMENT:
......@@ -104,7 +108,7 @@ public class FDCSendRecieve {
generatedPdus.add(aPdu);
System.out.println("APDU container count " + generatedPdus.size());
}
}
// Send the PDUs we created
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
......@@ -116,12 +120,13 @@ public class FDCSendRecieve {
DataOutputStream dos = new DataOutputStream(baos);
byte[] buffer;
Pdu aPdu = generatedPdus.get(idx);
aPdu = generatedPdus.get(idx);
aPdu.marshal(dos);
buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet);
sentBuffer[sentBuffer.length] = aPdu.getTimestamp();
System.out.println("Sent PDU of type " + aPdu.getClass().getName());
}
} catch (IOException e) {
......@@ -173,8 +178,8 @@ public class FDCSendRecieve {
location.setY(0.0); //TGT = 150 OBS = 75
location.setZ(10.0); //TGT = 20 OBS = 50
FDCespdu.setEntityLocation(location);
sender.run(FDCespdu); //sends inital here I am and who I am
FDCespdu.setTimestamp(System.currentTimeMillis());
//sender.run(FDCespdu); //sends inital here I am and who I am
/* BELOW IS THE RECIEVE CODE //
// //
......@@ -209,9 +214,7 @@ public class FDCSendRecieve {
Pdu pdu = factory.createPdu(packet.getData());
if (pdu != null) {
currentPduType = pdu.getPduType();
String currentPduTypeName = pdu.getClass().getName();
short currentProtocolFamilyID = pdu.getProtocolFamily();
String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
......@@ -222,7 +225,9 @@ public class FDCSendRecieve {
if(currentPduType == 1) //EntityState
{
EntityStatePdu entityPDU = (EntityStatePdu) pdu;
if(entityPDU.getForceId()==222){
EntityType PduEntityType = entityPDU.getEntityType();
PduEntityType.setCountry(225);
if(PduEntityType.getCountry()==222){
//do something for the OBS as this is a russian asshat. Most likely send the pdu with sender.run(pdu);
System.out.println("got a russian SOB!");
}
......
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