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

Draft files edited.

parent 5832b38b
No related branches found
No related tags found
No related merge requests found
......@@ -59,10 +59,10 @@ public class FDCSendRecieve {
//Change the switch statement to the currentPduType from the recieve portion, then when a packet we want comes in, send the CASE file.
switch (pdu2) // using enumeration values from edu.nps.moves.disenum.*
switch (currentPduType) // using enumeration values from edu.nps.moves.disenum.*
{
case ENTITY_STATE:
case 1: //ENTITY_STATE:
System.out.println("Case: Enitity_State " + pdu + "\n");
aPdu = new EntityStatePdu();
EntityStatePdu espdu = (EntityStatePdu) aPdu;
......@@ -75,71 +75,28 @@ public class FDCSendRecieve {
espduLocation.setZ(3.0);
break;
case COMMENT:
aPdu = new CommentPdu();
break;
case FIRE:
aPdu = new FirePdu();
break;
case DETONATION:
aPdu = new DetonationPdu();
break;
case COLLISION:
aPdu = new CollisionPdu();
break;
case SERVICE_REQUEST:
aPdu = new ServiceRequestPdu();
break;
case RESUPPLY_OFFER:
aPdu = new ResupplyOfferPdu();
break;
case RESUPPLY_RECEIVED:
aPdu = new ResupplyReceivedPdu();
break;
case RESUPPLY_CANCEL:
aPdu = new ResupplyCancelPdu();
break;
case REPAIR_COMPLETE:
aPdu = new RepairCompletePdu();
break;
case REPAIR_RESPONSE:
aPdu = new RepairResponsePdu();
break;
case CREATE_ENTITY:
aPdu = new CreateEntityPdu();
break;
case REMOVE_ENTITY:
aPdu = new RemoveEntityPdu();
break;
case START_RESUME:
aPdu = new StartResumePdu();
break;
case STOP_FREEZE:
aPdu = new StopFreezePdu();
break;
case ACKNOWLEDGE:
aPdu = new AcknowledgePdu();
break;
case ACTION_REQUEST:
// case COMMENT:
// aPdu = new CommentPdu();
// break;
//
// case FIRE:
// aPdu = new FirePdu();
// break;
//
// case DETONATION:
// aPdu = new DetonationPdu();
// break;
//
// case ACKNOWLEDGE:
// aPdu = new AcknowledgePdu();
// break;
//
case 16: //ACTION_REQUEST:
aPdu = new ActionRequestPdu();
break;
default:
//add some shit that makes sense here.
System.out.print("PDU of type " + pdu + " not supported, created or sent ");
System.out.println();
}
......@@ -149,8 +106,6 @@ public class FDCSendRecieve {
}
}
// Send the PDUs we created
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
......@@ -177,21 +132,25 @@ public class FDCSendRecieve {
public static void main(String[] args) {
//turns on the sender code - might need to move around down into the recieve with the if statements...
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);
//
// 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);
FDCSendRecieve sender = new FDCSendRecieve(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); //initalize the sender
EntityStatePdu FDCespdu = new EntityStatePdu();
FDCespdu.setExerciseID((short)1);
EntityID entityID = FDCespdu.getEntityID();
......@@ -200,16 +159,22 @@ public class FDCSendRecieve {
entityID.setEntity(1); //change for each person I think??? - JMF
EntityType entityType = FDCespdu.getEntityType();
//
//Need to update the info below to match the unit type
//Need to update the info below to match the unit type IAW SISO-REF-010-2015 V.21
// https://www.sisostds.org/DesktopModules/Bring2mind/DMX/Download.aspx?Command=Core_Download&EntryId=42916&PortalId=0&TabId=105
//
entityType.setEntityKind((short) 1); // Platform (vs lifeform, munition, sensor, etc.)
entityType.setCountry(224); // UK
entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space)
entityType.setCategory((short) 1); // Tank
entityType.setSubcategory((short) 1); // M1 Abrams
entityType.setSpec((short) 4); // M1A1 w/ mine roller
entityType.setEntityKind((short) 1); // Platform (vs lifeform, munition, sensor, etc.) TGT=1, OBS = 1
entityType.setCountry(225); // USA TGT = 222 (Russia), OBS = 225
entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space) both TGT and OBS are 1
entityType.setCategory((short) 3); // FDC TGT = 1, Tank OBS=40 OP
entityType.setSubcategory((short) 12); // M1068 TGT = 2, T72 tank NONE FOR OP
entityType.setSpec((short) 1); // M1068 w/ SICUP Tent NONE FOR TGT OR OP
Vector3Double location = new Vector3Double();
location.setX(0.0); //TGT = 150 OBS = 75
location.setY(0.0); //TGT = 150 OBS = 75
location.setZ(10.0); //TGT = 20 OBS = 50
FDCespdu.setEntityLocation(location);
sender.run(FDCespdu);
sender.run(FDCespdu); //sends inital here I am and who I am
/* BELOW IS THE RECIEVE CODE //
// //
......@@ -223,7 +188,8 @@ public class FDCSendRecieve {
try {
System.out.println("DisExamples.PduReceiver started...");
// TODO: Change the line below to make sense for each class
System.out.println("FDC is alive and ready to recieve fire missions...");
socket = new MulticastSocket(MULTICAST_PORT);
address = InetAddress.getByName(MULTICAST_GROUP);
socket.joinGroup(address);
......@@ -237,23 +203,44 @@ 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.
//
Pdu pdu = factory.createPdu(packet.getData());
if (pdu != null) {
currentPduType = pdu.getPduType();
// if statement might need to go here fix thread shit...
// if(currentPduType == 5 ||currentPduType == 4 )
// {Thread thread;
// thread = new Thread(sender.run(pdu));
// thread.start();
// }
sender.run(pdu);
String currentPduTypeName = pdu.getClass().getName();
short currentProtocolFamilyID = pdu.getProtocolFamily();
String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName();
//Reference for PDU Types:
// http://faculty.nps.edu/brutzman/vrtp/mil/navy/nps/disEnumerations/JdbeHtmlFiles/pdu/8.htm
if(currentPduType == 1) //EntityState
{
EntityStatePdu entityPDU = (EntityStatePdu) pdu;
if(entityPDU.getForceId()==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!");
}
}
EntityID OBSEntityID = new EntityID(); // need to figure out what this is....and then just put into if statement below
if(currentPduType == 16) //Action request
{
ActionRequestPdu actionPdu = (ActionRequestPdu) pdu;
if(actionPdu.getOriginatingEntityID() == OBSEntityID)
{
sender.run(pdu);
}
}
//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 ");
......@@ -270,10 +257,10 @@ public class FDCSendRecieve {
}
}
} catch (IOException e) {
System.out.println("Problem with DisExamples.PduReceiver, see exception trace:");
System.out.println("Problem with FDC.PduReceiver, see exception trace:");
System.out.println(e);
} finally {
System.out.println("DisExamples.PduReceiver complete.");
System.out.println("FDC.PduReceiver complete. - OUT!");
}
}
......
......@@ -68,6 +68,8 @@ public class FriscoFurrPduSender
espduLocation.setX(1.0);
espduLocation.setY(2.0);
espduLocation.setZ(3.0);
EntityType entityType = espdu.getEntityType();
entityType.setCountry(222);
break;
//
// case COMMENT:
......
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