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

Edit comments

parent 9bba1164
No related branches found
No related tags found
No related merge requests found
......@@ -61,14 +61,7 @@ public class FDCSendRecieve {
short currentPduType = pdu.getPduType();
System.out.println("in sender, recived PDU type: " + currentPduType);
// String currentPduTypeName = pdu.getClass().getName();
// short currentProtocolFamilyID = pdu.getProtocolFamily();
// String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
// Loop through all the enumerated PDU types, create a PDU for each type,
// and add that PDU to a list.
//System.out.println(pdu);
//Change the switch statement to the currentPduType from the recieve portion, then when a packet we want comes in, send the CASE file.
switch (currentPduType) // using enumeration values from edu.nps.moves.disenum.*
{
......@@ -76,25 +69,13 @@ public class FDCSendRecieve {
aPdu = pdu;
break;
// case COMMENT:
// aPdu = new CommentPdu();
// break;
//
case 2: //FIRE
aPdu = pdu;
break;
//
// case DETONATION:
// aPdu = new DetonationPdu();
// break;
//
case 15: //AcknowledgePdu
aPdu = pdu;
break;
//
// case 16: //ACTION_REQUEST:
// aPdu = new ActionRequestPdu();
// break;
case 17:
aPdu = pdu;
......@@ -105,7 +86,6 @@ public class FDCSendRecieve {
break;
default:
//add some shit that makes sense here.
System.out.print("PDU of type " + pdu + " not supported, created or sent ");
System.out.println();
}
......@@ -126,7 +106,6 @@ public class FDCSendRecieve {
buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, localMulticastAddress, DEFAULT_MULTICAST_PORT);
socket.send(packet);
//sentBuffer[sentBuffer.length] = aPdu.getTimestamp();
sentBufferList.add(aPdu.getTimestamp());
System.out.println("Sent PDU of type " + aPdu.getClass().getName()+ "\n");
}
......@@ -134,24 +113,7 @@ public class FDCSendRecieve {
public static void main(String[] args) throws IOException, InterruptedException {
DisTime disTime = DisTime.getInstance();
//turns on the sender code - might need to move around down into the recieve with the if statements...
//
// ORIGINAL SENDING CODE MAIN CLASS:
//
//
// if (args.length == 2) {
// FDCSendRecieve sender = new FDCSendRecieve(Integer.parseInt(args[0]), args[1]);
// // sender.run(); //needs to be sender.run(pdu)
// } else {
// System.out.println("Usage: PduSender <port> <multicast group>");
// System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS);
// FDCSendRecieve sender = new FDCSendRecieve(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS);
// sender.run();
// }
//
// Inital Hello world from entity:
//
FDCSendRecieve sender = new FDCSendRecieve(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); //initalize the sender
EntityStatePdu FDCespdu = new EntityStatePdu();
......@@ -181,7 +143,7 @@ public class FDCSendRecieve {
FDCespdu.setEntityLocation(location);
int timestamp = disTime.getDisAbsoluteTimestamp();
FDCespdu.setTimestamp(timestamp);
//FDCespdu.setTimestamp(System.currentTimeMillis());
sender.run(FDCespdu); //sends inital here I am and who I am
//Set up other players to look for:
......@@ -206,7 +168,6 @@ public class FDCSendRecieve {
short currentPduType = 0; //will use the curentPduType as the check for sending other packets.
try {
// TODO: Change the line below to make sense for each class
System.out.println("FDC is alive and ready to recieve fire missions...\n\n");
socket = new MulticastSocket(MULTICAST_PORT);
address = InetAddress.getByName(MULTICAST_GROUP);
......@@ -221,9 +182,6 @@ public class FDCSendRecieve {
packet = new DatagramPacket(buffer, buffer.length); // reset
socket.receive(packet);
//
//TODO: NEED IF STATEMENT IF THE SENDER IS THIS CLASS TO DELETE.
//
String marking2 = new String();
Pdu pdu = factory.createPdu(packet.getData());
......@@ -246,7 +204,6 @@ public class FDCSendRecieve {
EntityStatePdu pdu2 = (EntityStatePdu) pdu;
marking2 = pdu2.getMarking().getCharactersString();
}
//Keep adding any if statements as needed for the class you are building.
StringBuilder message = new StringBuilder();
message.append("received DIS PDU: ");
message.append("pduType ");
......@@ -266,9 +223,6 @@ public class FDCSendRecieve {
EntityStatePdu entityPDU = (EntityStatePdu) pdu;
EntityType PduEntityType = entityPDU.getEntityType();
if (PduEntityType.getCountry() == 225) {
//do something for the OBS as this is a russian asshat. Most likely send the pdu with sender.run(pdu);
//create Action Request PDU
//sender.run(actionPDU);
Thread.sleep((long) 200);
timestamp = disTime.getDisAbsoluteTimestamp();
FDCespdu.setTimestamp(timestamp);
......@@ -284,14 +238,7 @@ public class FDCSendRecieve {
ack.setRequestID((long) 1);
timestamp = disTime.getDisAbsoluteTimestamp();
ack.setTimestamp(timestamp);
// ActionResponsePdu response = new ActionResponsePdu();
// response.setExerciseID((short) 1);
// response.setRequestID((long) 1);
// response.setOriginatingEntityID(FDCID);
// response.setReceivingEntityID(OBSEntityID);
// timestamp = disTime.getDisAbsoluteTimestamp();
// response.setTimestamp(timestamp);
//
FirePdu fire = new FirePdu();
fire.setExerciseID((short) 1);
fire.setFireMissionIndex(1000);
......@@ -301,7 +248,6 @@ public class FDCSendRecieve {
timestamp = disTime.getDisAbsoluteTimestamp();
fire.setTimestamp(timestamp);
sender.run(ack, fire);
// sender.run(fire,fire);
}
if (currentPduType == 22) //Comment PDU
......
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