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 { ...@@ -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. //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"); System.out.println("Case: Enitity_State " + pdu + "\n");
aPdu = new EntityStatePdu(); aPdu = new EntityStatePdu();
EntityStatePdu espdu = (EntityStatePdu) aPdu; EntityStatePdu espdu = (EntityStatePdu) aPdu;
...@@ -75,71 +75,28 @@ public class FDCSendRecieve { ...@@ -75,71 +75,28 @@ public class FDCSendRecieve {
espduLocation.setZ(3.0); espduLocation.setZ(3.0);
break; break;
case COMMENT: // case COMMENT:
aPdu = new CommentPdu(); // aPdu = new CommentPdu();
break; // break;
//
case FIRE: // case FIRE:
aPdu = new FirePdu(); // aPdu = new FirePdu();
break; // break;
//
case DETONATION: // case DETONATION:
aPdu = new DetonationPdu(); // aPdu = new DetonationPdu();
break; // break;
//
case COLLISION: // case ACKNOWLEDGE:
aPdu = new CollisionPdu(); // aPdu = new AcknowledgePdu();
break; // break;
//
case SERVICE_REQUEST: case 16: //ACTION_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:
aPdu = new ActionRequestPdu(); aPdu = new ActionRequestPdu();
break; break;
default: default:
//add some shit that makes sense here.
System.out.print("PDU of type " + pdu + " not supported, created or sent "); System.out.print("PDU of type " + pdu + " not supported, created or sent ");
System.out.println(); System.out.println();
} }
...@@ -149,8 +106,6 @@ public class FDCSendRecieve { ...@@ -149,8 +106,6 @@ public class FDCSendRecieve {
} }
} }
// Send the PDUs we created // Send the PDUs we created
InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS); InetAddress localMulticastAddress = InetAddress.getByName(DEFAULT_MULTICAST_ADDRESS);
MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT); MulticastSocket socket = new MulticastSocket(DEFAULT_MULTICAST_PORT);
...@@ -177,21 +132,25 @@ public class FDCSendRecieve { ...@@ -177,21 +132,25 @@ public class FDCSendRecieve {
public static void main(String[] args) { public static void main(String[] args) {
//turns on the sender code - might need to move around down into the recieve with the if statements... //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]); // ORIGINAL SENDING CODE MAIN CLASS:
// sender.run(); //needs to be sender.run(pdu) //
} else { //
System.out.println("Usage: PduSender <port> <multicast group>"); // if (args.length == 2) {
System.out.println("Default: PduSender " + DEFAULT_MULTICAST_PORT + " " + DEFAULT_MULTICAST_ADDRESS); // FDCSendRecieve sender = new FDCSendRecieve(Integer.parseInt(args[0]), args[1]);
FDCSendRecieve sender = new FDCSendRecieve(DEFAULT_MULTICAST_PORT, DEFAULT_MULTICAST_ADDRESS); // // 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(); // sender.run();
} // }
// //
// Inital Hello world from entity: // 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(); EntityStatePdu FDCespdu = new EntityStatePdu();
FDCespdu.setExerciseID((short)1); FDCespdu.setExerciseID((short)1);
EntityID entityID = FDCespdu.getEntityID(); EntityID entityID = FDCespdu.getEntityID();
...@@ -200,16 +159,22 @@ public class FDCSendRecieve { ...@@ -200,16 +159,22 @@ public class FDCSendRecieve {
entityID.setEntity(1); //change for each person I think??? - JMF entityID.setEntity(1); //change for each person I think??? - JMF
EntityType entityType = FDCespdu.getEntityType(); 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.setEntityKind((short) 1); // Platform (vs lifeform, munition, sensor, etc.) TGT=1, OBS = 1
entityType.setCountry(224); // UK entityType.setCountry(225); // USA TGT = 222 (Russia), OBS = 225
entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space) entityType.setDomain((short) 1); // Land (vs air, surface, subsurface, space) both TGT and OBS are 1
entityType.setCategory((short) 1); // Tank entityType.setCategory((short) 3); // FDC TGT = 1, Tank OBS=40 OP
entityType.setSubcategory((short) 1); // M1 Abrams entityType.setSubcategory((short) 12); // M1068 TGT = 2, T72 tank NONE FOR OP
entityType.setSpec((short) 4); // M1A1 w/ mine roller 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 // /* BELOW IS THE RECIEVE CODE //
// // // //
...@@ -223,7 +188,8 @@ public class FDCSendRecieve { ...@@ -223,7 +188,8 @@ public class FDCSendRecieve {
try { 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); socket = new MulticastSocket(MULTICAST_PORT);
address = InetAddress.getByName(MULTICAST_GROUP); address = InetAddress.getByName(MULTICAST_GROUP);
socket.joinGroup(address); socket.joinGroup(address);
...@@ -237,23 +203,44 @@ public class FDCSendRecieve { ...@@ -237,23 +203,44 @@ public class FDCSendRecieve {
packet = new DatagramPacket(buffer, buffer.length); // reset packet = new DatagramPacket(buffer, buffer.length); // reset
socket.receive(packet); socket.receive(packet);
//
//TODO: NEED IF STATEMENT IF THE SENDER IS THIS CLASS TO DELETE.
//
Pdu pdu = factory.createPdu(packet.getData()); Pdu pdu = factory.createPdu(packet.getData());
if (pdu != null) { if (pdu != null) {
currentPduType = pdu.getPduType(); 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(); String currentPduTypeName = pdu.getClass().getName();
short currentProtocolFamilyID = pdu.getProtocolFamily(); short currentProtocolFamilyID = pdu.getProtocolFamily();
String currentPduFamilyName = pdu.getClass().getSuperclass().getSimpleName(); 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(); StringBuilder message = new StringBuilder();
message.append("received DIS PDU: "); message.append("received DIS PDU: ");
message.append("pduType "); message.append("pduType ");
...@@ -270,10 +257,10 @@ public class FDCSendRecieve { ...@@ -270,10 +257,10 @@ public class FDCSendRecieve {
} }
} }
} catch (IOException e) { } 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); System.out.println(e);
} finally { } finally {
System.out.println("DisExamples.PduReceiver complete."); System.out.println("FDC.PduReceiver complete. - OUT!");
} }
} }
......
...@@ -68,6 +68,8 @@ public class FriscoFurrPduSender ...@@ -68,6 +68,8 @@ public class FriscoFurrPduSender
espduLocation.setX(1.0); espduLocation.setX(1.0);
espduLocation.setY(2.0); espduLocation.setY(2.0);
espduLocation.setZ(3.0); espduLocation.setZ(3.0);
EntityType entityType = espdu.getEntityType();
entityType.setCountry(222);
break; break;
// //
// case COMMENT: // 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